capture_jpeg() does not return an image

Open
#32 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
40/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
fastapi, python
Domain
api, backend

Research direction

Start at the /camera/capture_jpeg endpoint and inspect how the FastAPI action result is exposed through the Swagger UI. Reproduce the request with the documented endpoint and compare the response with the expected JPEG image. Done means the endpoint returns an image that can be retrieved from Swagger UI or a requests-only client.

Written by the indexing model from the issue text.

Description

Hey! I was looking for something that uses the picamera2 and streams images. I found your beautiful codebase! Thanks for making this - and open-source! :-)
The scenario is the following: I let it run on a raspberry pi zero and stream images, once in a while I want to get (raw) images from the camera for hologram reconstruction. Students should do that through a statically hosted jupyter notebook (e.g. https://youseetoo.github.io/jupyter). Here, I cannot install the labthings fastapi due to some missing wheels it seems, hence I wanted to work with requests only. I wanted to retreive the image via the swagger ui, which produces a valid response, but no image:

Image
<span style="color: rgb(59, 65, 81); font-family: sans-serif; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="opblock opblock-get is-open" id="operations-default-list_invocations_camera_capture_jpeg_get" style="box-sizing: border-box; border: 1px solid rgb(97, 175, 254); border-radius: 4px; box-shadow: rgba(0, 0, 0, 0.19) 0px 0px 3px; margin: 0px 0px 15px; background: rgba(97, 175, 254, 0.1);"><div class="no-margin" style="box-sizing: border-box; border: none; height: auto; margin: 0px; padding: 0px;"><div class="opblock-body" style="box-sizing: border-box;"><div class="responses-wrapper" style="box-sizing: border-box;"><div class="responses-inner" style="box-sizing: border-box; padding: 20px;">
[   {     "status": "pending",     "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",     "action": "string",     "href": "string",     "timeStarted": "2025-06-02T06:33:33.877Z",     "timeRequested": "2025-06-02T06:33:33.877Z",     "timeCompleted": "2025-06-02T06:33:33.877Z",     "input": {       "resolution": "main",       "wait": 0.9     },     "output": {       "additionalProp1": "string",       "additionalProp2": "string",       "additionalProp3": "string"     },     "log": [       {         "message": "string",         "levelname": "string",         "levelno": 0,         "lineno": 0,         "filename": "string",         "created": "2025-06-02T06:33:33.877Z"       }     ],     "links": [       {         "href": "string",         "type": "string",         "rel": "string",         "anchor": "string",         "additionalProp1": {}       }     ]   } ] | No links
-- | --


</div></div></div></div></div></span><span style="color: rgb(59, 65, 81); font-family: sans-serif; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="opblock opblock-post" id="operations-default-start_action_camera_capture_jpeg_post" style="box-sizing: border-box; border: 1px solid rgb(73, 204, 144); border-radius: 4px; box-shadow: rgba(0, 0, 0, 0.19) 0px 0px 3px; margin: 0px 0px 15px; background: rgba(73, 204, 144, 0.1);"><div class="opblock-summary opblock-summary-post" style="box-sizing: border-box; align-items: center; cursor: pointer; display: flex; padding: 5px; border-color: rgb(73, 204, 144);"><button aria-expanded="false" class="opblock-summary-control" style="color-scheme: inherit; forced-color-adjust: inherit; mask: inherit; math-depth: inherit; position: inherit; position-anchor: inherit; text-size-adjust: inherit; appearance: inherit; color: inherit; font: inherit; font-palette: inherit; font-synthesis: inherit; position-area: inherit; text-orientation: inherit; text-rendering: inherit; text-spacing-trim: inherit; -webkit-font-smoothing: inherit; -webkit-locale: inherit; -webkit-text-orientation: inherit; -webkit-writing-mode: inherit; writing-mode: inherit; zoom: inherit; accent-color: inherit; place-content: inherit; place-items: inherit; place-self: inherit; alignment-baseline: inherit; anchor-name: inherit; anchor-scope: inherit; animation-composition: inherit; animation: inherit; app-region: inherit; aspect-ratio: inherit; backdrop-filter: inherit; backface-visibility: inherit; background: inherit; background-blend-mode: inherit; baseline-shift: inherit; baseline-source: inherit; block-size: inherit; border-block: inherit; border-bottom: 0px; border-radius: inherit; border-collapse: inherit; border-end-end-radius: inherit; border-end-start-radius: inherit; border-image: inherit; border-inline: inherit; border-left: inherit; border-right: inherit; border-start-end-radius: inherit; border-start-start-radius: inherit; border-top: inherit; inset: inherit; box-decoration-break: inherit; box-shadow: inherit; box-sizing: inherit; break-after: inherit; break-before: inherit; break-inside: inherit; buffered-rendering: inherit; caption-side: inherit; caret-color: inherit; clear: inherit; clip: inherit; clip-path: inherit; clip-rule: inherit; color-interpolation: inherit; color-interpolation-filters: inherit; color-rendering: inherit; columns: inherit; column-fill: inherit; gap: inherit; column-rule: inherit; column-span: inherit; contain: inherit; contain-intrinsic-block-size: inherit; contain-intrinsic-size: inherit; contain-intrinsic-inline-size: inherit; container: inherit; content: inherit; content-visibility: inherit; counter-increment: inherit; counter-reset: inherit; counter-set: inherit; cursor: inherit; cx: inherit; cy: inherit; d: inherit; display: inherit; dominant-baseline: inherit; dynamic-range-limit: inherit; empty-cells: inherit; field-sizing: inherit; fill: inherit; fill-opacity: inherit; fill-rule: inherit; filter: inherit; flex: 1 1 0%; flex-flow: inherit; float: inherit; flood-color: inherit; flood-opacity: inherit; grid: inherit; grid-area: inherit; height: inherit; hyphenate-character: inherit; hyphenate-limit-chars: inherit; hyphens: inherit; image-orientation: inherit; image-rendering: inherit; initial-letter: inherit; inline-size: inherit; inset-block: inherit; inset-inline: inherit; interpolate-size: inherit; isolation: inherit; letter-spacing: inherit; lighting-color: inherit; line-break: inherit; list-style: inherit; margin-block: inherit; margin: inherit; margin-inline: inherit; marker: inherit; mask-type: inherit; math-shift: inherit; math-style: inherit; max-block-size: inherit; max-height: inherit; max-inline-size: inherit; max-width: inherit; min-block-size: inherit; min-height: inherit; min-inline-size: inherit; min-width: inherit; mix-blend-mode: inherit; object-fit: inherit; object-position: inherit; object-view-box: inherit; offset: inherit; opacity: inherit; order: inherit; orphans: inherit; outline: inherit; outline-offset: inherit; overflow-anchor: inherit; overflow-block: inherit; overflow-clip-margin: inherit; overflow-inline: inherit; overflow-wrap: inherit; overflow: inherit; overlay: inherit; overscroll-behavior-block: inherit; overscroll-behavior-inline: inherit; overscroll-behavior: inherit; padding-block: inherit; padding: 0px; padding-inline: inherit; page: inherit; page-orientation: inherit; paint-order: inherit; perspective: inherit; perspective-origin: inherit; pointer-events: inherit; position-try: inherit; position-visibility: inherit; print-color-adjust: inherit; quotes: inherit; r: inherit; resize: inherit; rotate: inherit; ruby-align: inherit; ruby-position: inherit; rx: inherit; ry: inherit; scale: inherit; scroll-behavior: inherit; scroll-initial-target: inherit; scroll-margin-block: inherit; scroll-margin: inherit; scroll-margin-inline: inherit; scroll-marker-group: inherit; scroll-padding-block: inherit; scroll-padding: inherit; scroll-padding-inline: inherit; scroll-snap-align: inherit; scroll-snap-stop: inherit; scroll-snap-type: inherit; scroll-timeline: inherit; scrollbar-color: inherit; scrollbar-gutter: inherit; scrollbar-width: inherit; shape-image-threshold: inherit; shape-margin: inherit; shape-outside: inherit; shape-rendering: inherit; size: inherit; speak: inherit; stop-color: inherit; stop-opacity: inherit; stroke: inherit; stroke-dasharray: inherit; stroke-dashoffset: inherit; stroke-linecap: inherit; stroke-linejoin: inherit; stroke-miterlimit: inherit; stroke-opacity: inherit; stroke-width: inherit; tab-size: inherit; table-layout: inherit; text-align: inherit; text-align-last: inherit; text-anchor: inherit; text-box: inherit; text-combine-upright: inherit; text-decoration: inherit; text-decoration-skip-ink: inherit; text-emphasis: inherit; text-emphasis-position: inherit; text-indent: inherit; text-overflow: inherit; text-shadow: inherit; text-transform: inherit; text-underline-offset: inherit; text-underline-position: inherit; text-wrap: inherit; timeline-scope: inherit; touch-action: inherit; transform: inherit; transform-box: inherit; transform-origin: inherit; transform-style: inherit; transition: inherit; translate: inherit; user-select: inherit; vector-effect: inherit; vertical-align: inherit; view-timeline: inherit; view-transition-class: inherit; view-transition-name: inherit; visibility: inherit; border-spacing: inherit; -webkit-box-align: inherit; -webkit-box-decoration-break: inherit; -webkit-box-direction: inherit; -webkit-box-flex: inherit; -webkit-box-ordinal-group: inherit; -webkit-box-orient: inherit; -webkit-box-pack: inherit; -webkit-box-reflect: inherit; -webkit-line-break: inherit; -webkit-line-clamp: inherit; -webkit-mask-box-image: inherit; -webkit-rtl-ordering: inherit; -webkit-ruby-position: inherit; -webkit-tap-highlight-color: inherit; -webkit-text-combine: inherit; -webkit-text-decorations-in-effect: inherit; -webkit-text-fill-color: inherit; -webkit-text-security: inherit; -webkit-text-stroke: inherit; -webkit-user-drag: inherit; white-space-collapse: inherit; widows: inherit; width: inherit; will-change: inherit; word-break: inherit; word-spacing: inherit; x: inherit; y: inherit; z-index: inherit;"><span class="opblock-summary-method" style="background: rgb(73, 204, 144); border-radius: 3px; color: rgb(255, 255, 255); font-family: sans-serif; font-size: 14px; font-weight: 700; min-width: 80px; padding: 6px 0px; text-align: center; text-shadow: rgba(0, 0, 0, 0.1) 0px 1px 0px;">POST</span><div class="opblock-summary-path-description-wrapper" style="box-sizing: border-box; align-items: center; display: flex; flex-flow: wrap; flex-grow: 1; gap: 0px 10px; padding: 0px 10px;"><span class="opblock-summary-path" data-path="/camera/capture_jpeg" style="align-items: center; color: rgb(59, 65, 81); display: flex; font-family: monospace; font-size: 16px; font-weight: 600; word-break: break-word; flex-shrink: 1;"><a class="nostyle" href="http://100.88.140.127:5000/docs#/default/start_action_camera_capture_jpeg_post" style="background-color: transparent; box-sizing: border-box; display: inline; color: inherit; cursor: pointer; text-decoration: inherit;"><span>/camera<wbr>/capture_jpeg</span></a></span><div class="opblock-summary-description" style="box-sizing: border-box; color: rgb(59, 65, 81); font-family: sans-serif; font-size: 13px; word-break: break-word;">Acquire one image from the camera as a JPEG</div></div></button><div class="view-line-link copy-to-clipboard" title="Copy to clipboard" style="box-sizing: border-box; cursor: pointer; margin: 0px; position: static; top: 2px; transition: 0.5s; width: 0px; align-items: center; background: rgb(125, 130, 147); border: none; border-radius: 4px; bottom: 10px; display: flex; height: 26px; justify-content: center; right: 100px;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 16" width="15" height="16" aria-hidden="true" focusable="false"><g transform="translate(2, -1)"><path fill="#ffffff" fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"></path></g></svg></div><button aria-label="post ​/camera​/capture_jpeg" class="opblock-control-arrow" aria-expanded="false" tabindex="-1" style="font-family: sans-serif; font-size: 16px; line-height: 1.15; margin: 0px; overflow: visible; text-transform: none; appearance: button; cursor: pointer; background: none; border: none; text-align: center;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="arrow" width="20" height="20" aria-hidden="true" focusable="false"><path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"></path></svg></button></div></div></span><span style="color: rgb(59, 65, 81); font-family: sans-serif; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="opblock opblock-get" id="operations-default-get_property_camera_capture_metadata_get" style="box-sizing: border-box; border: 1px solid rgb(97, 175, 254); border-radius: 4px; box-shadow: rgba(0, 0, 0, 0.19) 0px 0px 3px; margin: 0px 0px 15px; background: rgba(97, 175, 254, 0.1);"><div class="opblock-summary opblock-summary-get" style="box-sizing: border-box; align-items: center; cursor: pointer; display: flex; padding: 5px; border-color: rgb(97, 175, 254);"><button aria-expanded="false" class="opblock-summary-control" style="color-scheme: inherit; forced-color-adjust: inherit; mask: inherit; math-depth: inherit; position: inherit; position-anchor: inherit; text-size-adjust: inherit; appearance: inherit; color: inherit; font: inherit; font-palette: inherit; font-synthesis: inherit; position-area: inherit; text-orientation: inherit; text-rendering: inherit; text-spacing-trim: inherit; -webkit-font-smoothing: inherit; -webkit-locale: inherit; -webkit-text-orientation: inherit; -webkit-writing-mode: inherit; writing-mode: inherit; zoom: inherit; accent-color: inherit; place-content: inherit; place-items: inherit; place-self: inherit; alignment-baseline: inherit; anchor-name: inherit; anchor-scope: inherit; animation-composition: inherit; animation: inherit; app-region: inherit; aspect-ratio: inherit; backdrop-filter: inherit; backface-visibility: inherit; background: inherit; background-blend-mode: inherit; baseline-shift: inherit; baseline-source: inherit; block-size: inherit; border-block: inherit; border-bottom: 0px; border-radius: inherit; border-collapse: inherit; border-end-end-radius: inherit; border-end-start-radius: inherit; border-image: inherit; border-inline: inherit; border-left: inherit; border-right: inherit; border-start-end-radius: inherit; border-start-start-radius: inherit; border-top: inherit; inset: inherit; box-decoration-break: inherit; box-shadow: inherit; box-sizing: inherit; break-after: inherit; break-before: inherit; break-inside: inherit; buffered-rendering: inherit; caption-side: inherit; caret-color: inherit; clear: inherit; clip: inherit; clip-path: inherit; clip-rule: inherit; color-interpolation: inherit; color-interpolation-filters: inherit; color-rendering: inherit; columns: inherit; column-fill: inherit; gap: inherit; column-rule: inherit; column-span: inherit; contain: inherit; contain-intrinsic-block-size: inherit; contain-intrinsic-size: inherit; contain-intrinsic-inline-size: inherit; container: inherit; content: inherit; content-visibility: inherit; counter-increment: inherit; counter-reset: inherit; counter-set: inherit; cursor: inherit; cx: inherit; cy: inherit; d: inherit; display: inherit; dominant-baseline: inherit; dynamic-range-limit: inherit; empty-cells: inherit; field-sizing: inherit; fill: inherit; fill-opacity: inherit; fill-rule: inherit; filter: inherit; flex: 1 1 0%; flex-flow: inherit; float: inherit; flood-color: inherit; flood-opacity: inherit; grid: inherit; grid-area: inherit; height: inherit; hyphenate-character: inherit; hyphenate-limit-chars: inherit; hyphens: inherit; image-orientation: inherit; image-rendering: inherit; initial-letter: inherit; inline-size: inherit; inset-block: inherit; inset-inline: inherit; interpolate-size: inherit; isolation: inherit; letter-spacing: inherit; lighting-color: inherit; line-break: inherit; list-style: inherit; margin-block: inherit; margin: inherit; margin-inline: inherit; marker: inherit; mask-type: inherit; math-shift: inherit; math-style: inherit; max-block-size: inherit; max-height: inherit; max-inline-size: inherit; max-width: inherit; min-block-size: inherit; min-height: inherit; min-inline-size: inherit; min-width: inherit; mix-blend-mode: inherit; object-fit: inherit; object-position: inherit; object-view-box: inherit; offset: inherit; opacity: inherit; order: inherit; orphans: inherit; outline: inherit; outline-offset: inherit; overflow-anchor: inherit; overflow-block: inherit; overflow-clip-margin: inherit; overflow-inline: inherit; overflow-wrap: inherit; overflow: inherit; overlay: inherit; overscroll-behavior-block: inherit; overscroll-behavior-inline: inherit; overscroll-behavior: inherit; padding-block: inherit; padding: 0px; padding-inline: inherit; page: inherit; page-orientation: inherit; paint-order: inherit; perspective: inherit; perspective-origin: inherit; pointer-events: inherit; position-try: inherit; position-visibility: inherit; print-color-adjust: inherit; quotes: inherit; r: inherit; resize: inherit; rotate: inherit; ruby-align: inherit; ruby-position: inherit; rx: inherit; ry: inherit; scale: inherit; scroll-behavior: inherit; scroll-initial-target: inherit; scroll-margin-block: inherit; scroll-margin: inherit; scroll-margin-inline: inherit; scroll-marker-group: inherit; scroll-padding-block: inherit; scroll-padding: inherit; scroll-padding-inline: inherit; scroll-snap-align: inherit; scroll-snap-stop: inherit; scroll-snap-type: inherit; scroll-timeline: inherit; scrollbar-color: inherit; scrollbar-gutter: inherit; scrollbar-width: inherit; shape-image-threshold: inherit; shape-margin: inherit; shape-outside: inherit; shape-rendering: inherit; size: inherit; speak: inherit; stop-color: inherit; stop-opacity: inherit; stroke: inherit; stroke-dasharray: inherit; stroke-dashoffset: inherit; stroke-linecap: inherit; stroke-linejoin: inherit; stroke-miterlimit: inherit; stroke-opacity: inherit; stroke-width: inherit; tab-size: inherit; table-layout: inherit; text-align: inherit; text-align-last: inherit; text-anchor: inherit; text-box: inherit; text-combine-upright: inherit; text-decoration: inherit; text-decoration-skip-ink: inherit; text-emphasis: inherit; text-emphasis-position: inherit; text-indent: inherit; text-overflow: inherit; text-shadow: inherit; text-transform: inherit; text-underline-offset: inherit; text-underline-position: inherit; text-wrap: inherit; timeline-scope: inherit; touch-action: inherit; transform: inherit; transform-box: inherit; transform-origin: inherit; transform-style: inherit; transition: inherit; translate: inherit; user-select: inherit; vector-effect: inherit; vertical-align: inherit; view-timeline: inherit; view-transition-class: inherit; view-transition-name: inherit; visibility: inherit; border-spacing: inherit; -webkit-box-align: inherit; -webkit-box-decoration-break: inherit; -webkit-box-direction: inherit; -webkit-box-flex: inherit; -webkit-box-ordinal-group: inherit; -webkit-box-orient: inherit; -webkit-box-pack: inherit; -webkit-box-reflect: inherit; -webkit-line-break: inherit; -webkit-line-clamp: inherit; -webkit-mask-box-image: inherit; -webkit-rtl-ordering: inherit; -webkit-ruby-position: inherit; -webkit-tap-highlight-color: inherit; -webkit-text-combine: inherit; -webkit-text-decorations-in-effect: inherit; -webkit-text-fill-color: inherit; -webkit-text-security: inherit; -webkit-text-stroke: inherit; -webkit-user-drag: inherit; white-space-collapse: inherit; widows: inherit; width: inherit; will-change: inherit; word-break: inherit; word-spacing: inherit; x: inherit; y: inherit; z-index: inherit;"><span class="opblock-summary-method" style="background: rgb(97, 175, 254); border-radius: 3px; color: rgb(255, 255, 255); font-family: sans-serif; font-size: 14px; font-weight: 700; min-width: 80px; padding: 6px 0px; text-align: center; text-shadow: rgba(0, 0, 0, 0.1) 0px 1px 0px;">GET</span><div class="opblock-summary-path-description-wrapper" style="box-sizing: border-box; align-items: center; display: flex; flex-flow: wrap; flex-grow: 1; gap: 0px 10px; padding: 0px 10px;"><span class="opblock-summary-path" data-path="/camera/capture_metadata" style="align-items: center; color: rgb(59, 65, 81); display: flex; font-family: monospace; font-size: 16px; font-weight: 600; word-break: break-word; flex-shrink: 1;"><a class="nostyle" href="http://100.88.140.127:5000/docs#/default/get_property_camera_capture_metadata_get" style="background-color: transparent; box-sizing: border-box; display: inline; color: inherit; cursor: pointer; text-decoration: inherit;"><span>/camera<wbr>/capture_metadata</span></a></span><div class="opblock-summary-description" style="box-sizing: border-box; color: rgb(59, 65, 81); font-family: sans-serif; font-size: 13px; word-break: break-word;">Return the metadata from the camera</div></div></button><div class="view-line-link copy-to-clipboard" title="Copy to clipboard" style="box-sizing: border-box; cursor: pointer; margin: 0px; position: static; top: 2px; transition: 0.5s; width: 0px; align-items: center; background: rgb(125, 130, 147); border: none; border-radius: 4px; bottom: 10px; display: flex; height: 26px; justify-content: center; right: 100px;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 16" width="15" height="16" aria-hidden="true" focusable="false"><g transform="translate(2, -1)"><path fill="#ffffff" fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"></path></g></svg></div><button aria-label="get ​/camera​/capture_metadata" class="opblock-control-arrow" aria-expanded="false" tabindex="-1" style="font-family: sans-serif; font-size: 16px; line-height: 1.15; margin: 0px; overflow: visible; text-transform: none; appearance: button; cursor: pointer; background: none; border: none; text-align: center;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="arrow" width="20" height="20" aria-hidden="true" focusable="false"><path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"></path></svg></button></div></div></span><span style="color: rgb(59, 65, 81); font-family: sans-serif; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="opblock opblock-get" id="operations-default-list_invocations_camera_capture_raw_get" style="box-sizing: border-box; border: 1px solid rgb(97, 175, 254); border-radius: 4px; box-shadow: rgba(0, 0, 0, 0.19) 0px 0px 3px; margin: 0px 0px 15px; background: rgba(97, 175, 254, 0.1);"><div class="opblock-summary opblock-summary-get" style="box-sizing: border-box; align-items: center; cursor: pointer; display: flex; padding: 5px; border-color: rgb(97, 175, 254);"><button aria-expanded="false" class="opblock-summary-control" style="color-scheme: inherit; forced-color-adjust: inherit; mask: inherit; math-depth: inherit; position: inherit; position-anchor: inherit; text-size-adjust: inherit; appearance: inherit; color: inherit; font: inherit; font-palette: inherit; font-synthesis: inherit; position-area: inherit; text-orientation: inherit; text-rendering: inherit; text-spacing-trim: inherit; -webkit-font-smoothing: inherit; -webkit-locale: inherit; -webkit-text-orientation: inherit; -webkit-writing-mode: inherit; writing-mode: inherit; zoom: inherit; accent-color: inherit; place-content: inherit; place-items: inherit; place-self: inherit; alignment-baseline: inherit; anchor-name: inherit; anchor-scope: inherit; animation-composition: inherit; animation: inherit; app-region: inherit; aspect-ratio: inherit; backdrop-filter: inherit; backface-visibility: inherit; background: inherit; background-blend-mode: inherit; baseline-shift: inherit; baseline-source: inherit; block-size: inherit; border-block: inherit; border-bottom: 0px; border-radius: inherit; border-collapse: inherit; border-end-end-radius: inherit; border-end-start-radius: inherit; border-image: inherit; border-inline: inherit; border-left: inherit; border-right: inherit; border-start-end-radius: inherit; border-start-start-radius: inherit; border-top: inherit; inset: inherit; box-decoration-break: inherit; box-shadow: inherit; box-sizing: inherit; break-after: inherit; break-before: inherit; break-inside: inherit; buffered-rendering: inherit; caption-side: inherit; caret-color: inherit; clear: inherit; clip: inherit; clip-path: inherit; clip-rule: inherit; color-interpolation: inherit; color-interpolation-filters: inherit; color-rendering: inherit; columns: inherit; column-fill: inherit; gap: inherit; column-rule: inherit; column-span: inherit; contain: inherit; contain-intrinsic-block-size: inherit; contain-intrinsic-size: inherit; contain-intrinsic-inline-size: inherit; container: inherit; content: inherit; content-visibility: inherit; counter-increment: inherit; counter-reset: inherit; counter-set: inherit; cursor: inherit; cx: inherit; cy: inherit; d: inherit; display: inherit; dominant-baseline: inherit; dynamic-range-limit: inherit; empty-cells: inherit; field-sizing: inherit; fill: inherit; fill-opacity: inherit; fill-rule: inherit; filter: inherit; flex: 1 1 0%; flex-flow: inherit; float: inherit; flood-color: inherit; flood-opacity: inherit; grid: inherit; grid-area: inherit; height: inherit; hyphenate-character: inherit; hyphenate-limit-chars: inherit; hyphens: inherit; image-orientation: inherit; image-rendering: inherit; initial-letter: inherit; inline-size: inherit; inset-block: inherit; inset-inline: inherit; interpolate-size: inherit; isolation: inherit; letter-spacing: inherit; lighting-color: inherit; line-break: inherit; list-style: inherit; margin-block: inherit; margin: inherit; margin-inline: inherit; marker: inherit; mask-type: inherit; math-shift: inherit; math-style: inherit; max-block-size: inherit; max-height: inherit; max-inline-size: inherit; max-width: inherit; min-block-size: inherit; min-height: inherit; min-inline-size: inherit; min-width: inherit; mix-blend-mode: inherit; object-fit: inherit; object-position: inherit; object-view-box: inherit; offset: inherit; opacity: inherit; order: inherit; orphans: inherit; outline: inherit; outline-offset: inherit; overflow-anchor: inherit; overflow-block: inherit; overflow-clip-margin: inherit; overflow-inline: inherit; overflow-wrap: inherit; overflow: inherit; overlay: inherit; overscroll-behavior-block: inherit; overscroll-behavior-inline: inherit; overscroll-behavior: inherit; padding-block: inherit; padding: 0px; padding-inline: inherit; page: inherit; page-orientation: inherit; paint-order: inherit; perspective: inherit; perspective-origin: inherit; pointer-events: inherit; position-try: inherit; position-visibility: inherit; print-color-adjust: inherit; quotes: inherit; r: inherit; resize: inherit; rotate: inherit; ruby-align: inherit; ruby-position: inherit; rx: inherit; ry: inherit; scale: inherit; scroll-behavior: inherit; scroll-initial-target: inherit; scroll-margin-block: inherit; scroll-margin: inherit; scroll-margin-inline: inherit; scroll-marker-group: inherit; scroll-padding-block: inherit; scroll-padding: inherit; scroll-padding-inline: inherit; scroll-snap-align: inherit; scroll-snap-stop: inherit; scroll-snap-type: inherit; scroll-timeline: inherit; scrollbar-color: inherit; scrollbar-gutter: inherit; scrollbar-width: inherit; shape-image-threshold: inherit; shape-margin: inherit; shape-outside: inherit; shape-rendering: inherit; size: inherit; speak: inherit; stop-color: inherit; stop-opacity: inherit; stroke: inherit; stroke-dasharray: inherit; stroke-dashoffset: inherit; stroke-linecap: inherit; stroke-linejoin: inherit; stroke-miterlimit: inherit; stroke-opacity: inherit; stroke-width: inherit; tab-size: inherit; table-layout: inherit; text-align: inherit; text-align-last: inherit; text-anchor: inherit; text-box: inherit; text-combine-upright: inherit; text-decoration: inherit; text-decoration-skip-ink: inherit; text-emphasis: inherit; text-emphasis-position: inherit; text-indent: inherit; text-overflow: inherit; text-shadow: inherit; text-transform: inherit; text-underline-offset: inherit; text-underline-position: inherit; text-wrap: inherit; timeline-scope: inherit; touch-action: inherit; transform: inherit; transform-box: inherit; transform-origin: inherit; transform-style: inherit; transition: inherit; translate: inherit; user-select: inherit; vector-effect: inherit; vertical-align: inherit; view-timeline: inherit; view-transition-class: inherit; view-transition-name: inherit; visibility: inherit; border-spacing: inherit; -webkit-box-align: inherit; -webkit-box-decoration-break: inherit; -webkit-box-direction: inherit; -webkit-box-flex: inherit; -webkit-box-ordinal-group: inherit; -webkit-box-orient: inherit; -webkit-box-pack: inherit; -webkit-box-reflect: inherit; -webkit-line-break: inherit; -webkit-line-clamp: inherit; -webkit-mask-box-image: inherit; -webkit-rtl-ordering: inherit; -webkit-ruby-position: inherit; -webkit-tap-highlight-color: inherit; -webkit-text-combine: inherit; -webkit-text-decorations-in-effect: inherit; -webkit-text-fill-color: inherit; -webkit-text-security: inherit; -webkit-text-stroke: inherit; -webkit-user-drag: inherit; white-space-collapse: inherit; widows: inherit; width: inherit; will-change: inherit; word-break: inherit; word-spacing: inherit; x: inherit; y: inherit; z-index: inherit;"><br class="Apple-interchange-newline">[
  {
    "status": "pending",
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "action": "string",
    "href": "string",
    "timeStarted": "2025-06-02T06:33:33.877Z",
    "timeRequested": "2025-06-02T06:33:33.877Z",
    "timeCompleted": "2025-06-02T06:33:33.877Z",
    "input": {
      "resolution": "main",
      "wait": 0.9
    },
    "output": {
      "additionalProp1": "string",
      "additionalProp2": "string",
      "additionalProp3": "string"
    },
    "log": [
      {
        "message": "string",
        "levelname": "string",
        "levelno": 0,
        "lineno": 0,
        "filename": "string",
        "created": "2025-06-02T06:33:33.877Z"
      }
    ],
    "links": [
      {
        "href": "string",
        "type": "string",
        "rel": "string",
        "anchor": "string",
        "additionalProp1": {}
      }
    ]
  }
]

First question now: Is this intentianally? I'm working with the latest version from Github and don't seem to get any errors on the server side. Looking into the JPEGBlob return type I should be able to get a JPEG image, right? the following code produces an error:

import io
import requests
import numpy as np
from PIL import Image


def capture_jpeg_numpy(
    host: str = "http://100.88.140.127:5000",
    resolution: str = "main",
    timeout: float = 2.0,
) -> np.ndarray:
    """
    Download a JPEG from the Pi-camera service and return it as a NumPy array (H, W, 3).
    """
    url = f"{host.rstrip('/')}/camera/capture_jpeg"
    r = requests.post(url, json={"resolution": resolution}, timeout=timeout)
    r.raise_for_status()
    return np.array(Image.open(io.BytesIO(r.content)))


if __name__ == "__main__":
    img = capture_jpeg_numpy()
    print(img.shape, img.dtype)

The error states - it'S not an image - surprise ;-)

---------------------------------------------------------------------------
UnidentifiedImageError                    Traceback (most recent call last)
Cell In[3], line 17
     14 r = requests.post(url, json={"resolution": resolution}, timeout=timeout)
     15 r.raise_for_status()
---> 17 img = np.array(Image.open(io.BytesIO(r.content)))
     20 img = capture_jpeg_numpy()
     21 print(img.shape, img.dtype)

File ~/mambaforge/envs/imswitch311/lib/python3.11/site-packages/PIL/Image.py:3536, in open(fp, mode, formats)
   3534     warnings.warn(message)
   3535 msg = "cannot identify image file %r" % (filename if filename else fp)
-> 3536 raise UnidentifiedImageError(msg)

UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x10997fc90>

I guess I'll do something obviously wrong, maybe you know the cause already? :)

CC: @julianstirling

Dominant language
Python
Stars
3
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from labthings/labthings-picamera2

All issues in labthings/labthings-picamera2

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.