def handle_cozmoImage(): '''Called very frequently from Javascript to request the latest camera image''' if remote_control_cozmo: image = remote_control_cozmo.cozmo.world.latest_image if image: return flask_helpers.serve_pil_image(image.raw_image) return flask_helpers.serve_pil_image(_default_camera_image)
def serve_single_image(): if flask_app.remote_control_vector: image = get_annotated_image() if image: return flask_helpers.serve_pil_image(image) return flask_helpers.serve_pil_image(_default_camera_image)
def handle_cozmoImage(): '''Called very frequently from Javascript to request the latest camera image''' if remote_control_cozmo: try: image = remote_control_cozmo.cozmo.world.latest_image if image: # by wmh # print (dir(image.raw_image)) # print (image.raw_image.height,image.raw_image.width) # - by wmh if _display_debug_annotations != DEBUG_ANNOTATIONS_DISABLED: image = image.annotate_image(scale=2) #wmh else: image = image.raw_image return flask_helpers.serve_pil_image(image) except cozmo.exceptions.SDKShutdown: # SDK is shutting down - Flask will block and spam errors here - force it to exit shutdown_func = request.environ.get('werkzeug.server.shutdown') if shutdown_func is not None: cozmo.logger.info("Shutting down Flask") shutdown_func() else: sys.exit("SDKShutdown") return flask_helpers.serve_pil_image(_default_camera_image)
def serve_single_image(): if remote_control_cozmo: try: image = get_annotated_image() if image: return flask_helpers.serve_pil_image(image) except cozmo.exceptions.SDKShutdown: requests.post('shutdown') return flask_helpers.serve_pil_image(_default_camera_image)
def handle_cozmoImage(): '''Called very frequently from Javascript to request the latest camera image''' if remote_control_cozmo: image = remote_control_cozmo.cozmo.world.latest_image if image: if _display_debug_annotations != DEBUG_ANNOTATIONS_DISABLED: image = image.annotate_image(scale=2) else: image = image.raw_image return flask_helpers.serve_pil_image(image) return flask_helpers.serve_pil_image(_default_camera_image)
def handle_cozmoImage(): '''Called very frequently from Javascript to request the latest camera image''' if remote_control_cozmo: image = remote_control_cozmo.cozmo.world.latest_image if image: #if _display_debug_annotations: # image = image.annotate_image(scale=2) #else # image = image.raw_image image = image.annotate_image(fit_size=(64, 48)) remote_control_cozmo.logImages.insert(remote_control_cozmo.fIdx, PIL2array(image).tolist()) remote_control_cozmo.logServos.insert( remote_control_cozmo.fIdx, remote_control_cozmo.cur_servo) remote_control_cozmo.logMotors.insert( remote_control_cozmo.fIdx, remote_control_cozmo.cur_motor) print('idx = ' + str(remote_control_cozmo.fIdx)) remote_control_cozmo.fIdx += 1 return flask_helpers.serve_pil_image(image) return flask_helpers.serve_pil_image(_default_camera_image)