Skip to content

Commit

Permalink
Update cash_counter.py
Browse files Browse the repository at this point in the history
Added visualizations and total value text on the image.
  • Loading branch information
nathan-marraccini authored Aug 21, 2024
1 parent f0b3ab3 commit e573c31
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions cash_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import supervision as sv

# Load image and model
image = cv2.imread('IMG_8086.jpg')
model = YOLO('best.pt')
image = cv2.imread('PATH_TO_IMAGE')
model = YOLO('PATH_TO_BEST_PT_FILE')
results = model.predict(image)
# detections = sv.Detections.from_ultralytics(results)

names = model.names
print(names)

# Denominations and their values
denominations = {
'Penny': 0.01,
Expand Down Expand Up @@ -39,19 +40,13 @@

print(f"Total Dollar Amount: ${total_value:.2f}")

detections = sv.Detections.from_ultralytics(results)

# # bounding_box_annotator = sv.BoundingBoxAnnotator()
# annotated_frame = bounding_box_annotator.annotate(
# scene=image.copy(),
# detections=detections)

# annotated_frame_rgb = cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB)

# Convert the NumPy array (image) to a PIL Image
# from PIL import Image
# pil_image = Image.fromarray(annotated_frame_rgb)

# # Display the PIL image
# pil_image.show()
bounding_box_annotator = sv.BoundingBoxAnnotator()
annotated_frame = bounding_box_annotator.annotate(
scene=image.copy(),
detections=detections)
cv2.putText(annotated_frame, f"You have ${total_value}", (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
sv.plot(annotated_frame, (12,12))

# model.predict(source=0, show = True, conf = 0.8)
# model.predict(source=0, show = True, conf = 0.8)

0 comments on commit e573c31

Please sign in to comment.