def get_image_color() -> RespT: """Get the color image. --- get: description: Get the color image. tags: - Color camera responses: 200: description: Ok content: image/jpeg: schema: type: string 403: description: Not started """ if _mock: img = color_image() else: assert _kinect is not None img = _kinect.color_image() return send_file( image_to_bytes_io(img, target_format="JPEG", target_mode="RGB"), mimetype="image/jpeg", cache_timeout=0, )
def get_image_depth() -> RespT: """Get the depth image. --- get: description: Get the depth image. tags: - Depth camera parameters: - in: query name: averagedFrames schema: type: integer default: 1 required: false description: Package name responses: 200: description: Ok content: image/png: schema: type: string 403: description: Not started """ if _mock: img = depth_image() else: assert _kinect is not None img = _kinect.depth_image(averaged_frames=int(request.args.get("averagedFrames", default=1))) return send_file(image_to_bytes_io(img, target_format="PNG"), mimetype="image/png", cache_timeout=0)
def get_image_both() -> RespT: """Get the both color/depth image. --- get: description: Get the depth image. tags: - Synchronized responses: 200: description: Ok content: application/zip: schema: type: string format: binary 403: description: Not started """ if _mock: color = color_image() depth = depth_image() else: assert _kinect is not None both = _kinect.sync_images() color = both.color depth = both.depth mem_zip = io.BytesIO() with zipfile.ZipFile(mem_zip, mode="w", compression=zipfile.ZIP_STORED) as zf: zf.writestr("color.jpg", image_to_bytes_io(color).getvalue()) zf.writestr("depth.png", image_to_bytes_io(depth, target_format="PNG").getvalue()) mem_zip.seek(0) return send_file(mem_zip, mimetype="application/zip", cache_timeout=0, as_attachment=True, attachment_filename="synchronized.zip")