cv2.setMouseCallback("MotionView", onMouse, "WINDOW_NORMAL"); cv2.imshow("MotionView", frame) if config["view"]["regions_threshold"]: cv2.imshow("ThresholdView", thresh) key = cv2.waitKey(1) & 0xFF # If the `q` key is pressed, break from the loop; if key == ord("q"): break # Clear the stream in preparation for the next frame or loop loaded file; frameCounter += 1 if config["debug"]["use_file"] == False: rawCapture.truncate(0) if config["debug"]["use_file"] and config["debug"]["file_loop"]: if frameCounter == (rawCapture.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT) / 2): frameCounter = 1 rawCapture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, 0) # Start filtering right framesets from cache (when not analysing) for persistency; if config["debug"]["print_messages"]: print "[MESSAGE] Done, recorded " + str(len(framesCache)) + " datasets!" print "[MESSAGE] Start filtering recorded information." if not config["debug"]["file_loop"]: if config["debug"]["print_frames_cache"]: print json.dumps(framesCache) if config["debug"]["print_messages"]: print "[MESSAGE] Filtering motion with persistency lower than " + str(config["capture"]["frames"]) + " frames..." if len(framesCache) > 0: tempFramesCache = {} for attribute, value in framesCache.iteritems():
GPIO.setup(Echo_sr04, GPIO.IN) #for rotation of turtlebot pub=rospy.Publisher('/cmd_vel', Twist, queue_size=10) rate= rospy.Rate(1) rot = Twist() vel_msg=() # setting the raspberry pi resolution and frame rate camera = PiCamera() camera.resolution = (640, 480) camera.framerate = 30 # PIRGBarray-reads the frames form RasPi camera as NumPy array(takes in camera object and size of resolution) rawCapture = PiRGBArray(camera, size=(640, 480)) width = rawCapture.get(cv2.CAP_PROP_FRAME_WIDTH) height = rawCapture.get(cv2.CAP_PROP_FRAME_HEIGHT) #centre of image centre = (int(width/2), int(height/2)) # allow the camera to warmup time.sleep(0.1) #rotation object rospy.Publisher("/cmd_vel", Twist, queue_size=1) rot = Twist() #to publish the percentage of the red colour detected to auto_nav target_pub = rospy.Publisher("auto_nav/seen_target", String, queue_size=1) percentage_1 = float(0)