@@ -29,7 +29,7 @@ def draw_image(image, results, labels, size):
29
29
30
30
# Annotate image with label and confidence score
31
31
display_str = labels [obj ['class_id' ]] + ": " + str (round (obj ['score' ]* 100 , 2 )) + "%"
32
- draw .text ((box [ 0 ], box [ 1 ] ), display_str , font = ImageFont .truetype ("/usr/share/fonts/truetype/piboto/Piboto-Regular.ttf" , 20 ))
32
+ draw .text ((ymin , xmin ), display_str , font = ImageFont .truetype ("/usr/share/fonts/truetype/piboto/Piboto-Regular.ttf" , 20 ))
33
33
34
34
displayImage = np .asarray ( image )
35
35
cv2 .imshow ('Coral Live Object Detection' , displayImage )
@@ -115,7 +115,8 @@ def main():
115
115
_ , input_height , input_width , _ = interpreter .get_input_details ()[0 ]['shape' ]
116
116
117
117
# Initialize video stream
118
- vs = VideoStream (usePiCamera = args .picamera , resolution = (640 , 480 )).start ()
118
+ vs = VideoStream (usePiCamera = args .picamera , resolution = (640 , 480 ))
119
+ vs .start () # this would close/ release the camera object properly. For vs = VideoStream().start(), vs.stop() would not work
119
120
time .sleep (1 )
120
121
121
122
fps = FPS ().start ()
0 commit comments