Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
yushulx committed Oct 15, 2024
1 parent cc76d01 commit 9fb44a1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions examples/official/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ def on_captured_result_received(self, captured_result):
captured_result = result_queue.get_nowait()
items = captured_result.get_items()
for item in items:
location = item.get_location()

if item.get_type() == EnumCapturedResultItemType.CRIT_BARCODE:
text = item.get_text()
location = item.get_location()
x1 = location.points[0].x
y1 = location.points[0].y
x2 = location.points[1].x
Expand All @@ -87,7 +89,14 @@ def on_captured_result_received(self, captured_result):
y4 = location.points[3].y
cv2.drawContours(
frame, [np.intp([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)

cv2.putText(frame, text, (x1, y1),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)

del location

elif item.get_type() == EnumCapturedResultItemType.CRIT_NORMALIZED_IMAGE:
location = item.get_location()
x1 = location.points[0].x
y1 = location.points[0].y
x2 = location.points[1].x
Expand All @@ -99,7 +108,10 @@ def on_captured_result_received(self, captured_result):
cv2.drawContours(
frame, [np.intp([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (255, 0, 0), 2)

del location
cv2.putText(frame, "Edge Detection", (x1, y1),
cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 2)

del location

if cv2.waitKey(1) & 0xFF == ord('q'):
break
Expand Down

0 comments on commit 9fb44a1

Please sign in to comment.