def get_latest_image(self): print("Called get latest image.") # Note: it is necessary to create new objects in this method instead of creating instance variables # in the constructor because of weird video threading issues. mambo_vision = DroneVision(self.mambo, is_bebop=False, buffer_size=30) user_vision = UserVision(mambo_vision) success = mambo_vision.open_video() # Open the video stream using ffmpeg for capturing and processing print("Success in opening vision is %s" % success) print("Vision successfully started!") # FIXME: investigate if these sleeps are needed. self.mambo.smart_sleep(5) frame = mambo_vision.get_latest_valid_picture() print("in save pictures on image %d " % self.index) if frame is not None: filename = "test_image_%06d.png" % self.index cv2.imwrite('./images/' + filename, frame) self.index += 1 # Save another copy of the same image to a hardcoded filename, which # we'll use as the latest image magic_filename = "latest_image.png" cv2.imwrite('./images/' + magic_filename, frame) #print(self.index) self.mambo.smart_sleep(5) print("Ending the sleep and vision") mambo_vision.close_video() return frame
# get the state information print("sleeping") mambo.smart_sleep(1) mambo.ask_for_state_update() mambo.smart_sleep(1) print("Preparing to open vision") mamboVision = DroneVision(mambo, is_bebop=False, buffer_size=30) userVision = UserVision(mamboVision) mamboVision.set_user_callback_function(userVision.save_pictures, user_callback_args=None) success = mamboVision.open_video() #Open the video stream using ffmpeg for capturing and processing print("Success in opening vision is %s" % success) print("Vision successfully started!") frame = mamboVision.get_latest_valid_picture() #here should be input to detect.py # run inference res = run_inference_for_single_image(frame, sess, tensor_dict, image_tensor) print("frame") # view the bounding boxes: cv2_visualize_results(frame, res, labels) cv2.imshow('frame', frame) # done doing vision demo print("Ending the sleep and vision") mamboVision.close_video() mambo.smart_sleep(5)