def tracking_callback(tracker: color_tracker.ColorTracker): # Visualizing the original frame and the debugger frame cv2.imshow("original frame", tracker.frame) cv2.imshow("debug frame", tracker.debug_frame) # Stop the script when we press ESC key = cv2.waitKey(1) if key == 27: tracker.stop_tracking() for obj in tracker.tracked_objects: print("Object {0} center {1}".format(obj.id, obj.last_point))
greenLower = (29, 86, 6) greenUpper = (64, 255, 255) # set video resolution resWidth = 320 resLength = 240 if not args.get("video", False): #test vs = VideoStream(usePiCamera=True, awb_mode='sunlight', resolution=(resWidth, resLength)).start() # awb_mode=sunlight works well for tracking green object print("cam warming up") time.sleep(1) tracker1 = ColorTracker(vs.mainQueue).start() # tracker2 = ColorTracker(vs.mainQueue).start() # hud = Hud() # hud.start(tracker.cnts) # time.sleep(1) df1 = DisplayFrame(tracker1.xyDoneQueue).start() # df2 = DisplayFrame(tracker2.xyDoneQueue).start() vs.join() tracker1.join() df1.join() # vs.release() ## close all windows # cv2.destroyAllWindows()
# ball in the HSV color space, then initialize the list of tracked points greenLower = (29, 86, 6) greenUpper = (64, 255, 255) #set video resolution resWidth = 320 resLength = 240 if not args.get("video", False): vs = VideoStream(usePiCamera=True, awb_mode='sunlight', resolution=(resWidth, resLength)).start() # awb_mode=sunlight works well for tracking green object print("cam warming up") time.sleep(1) df = DisplayFrame(vs.mainQueue) df.start() tracker = ColorTracker(vs.mainQueue) tracker.start() hud = Hud() hud.start(tracker.cnts) time.sleep(1) while True: #vs.release() ## close all windows #cv2.destroyAllWindows()