Skip to content

Webcam with OpenCV using a Donkey#147

Open
iliketocode2 wants to merge 25 commits intoinvent-framework:mainfrom
iliketocode2:webcam-opencv-donkey
Open

Webcam with OpenCV using a Donkey#147
iliketocode2 wants to merge 25 commits intoinvent-framework:mainfrom
iliketocode2:webcam-opencv-donkey

Conversation

@iliketocode2
Copy link
Copy Markdown
Contributor

@iliketocode2 iliketocode2 commented Apr 15, 2026

Important

TODO: needs to integrate the new donkey plugin logic? This would require a rewrite of the "test page"-- open_cv_playground. Since branch donkey-independence is a branch off of this branch, I would recommend making future changes there for ease of merge.

Implementation

What was changed

  • src/invent/ui/widgets/webcam.py
    • Added a property so the webcam preview appears side by side with the camera feed ("stacked" | "side-by-side"). In side-by-side mode the live camera feed and the capture/result panel sit in a horizontal row at equal size
    • Added show_image(data_url) which is a public method that pushes any image into the preview panel. This allows the processed OpenCV result to replace the captured photo in place
    • Removed unused public methods (find_capture, remove_capture, clear_captures, photo_bytes, trigger) from the older implementation of the webcam and also I removed some of the unused imports (IntegerProperty, base64, the icon() classmethod)
  • src/invent/themes/default.css
    • The new css allows the clean side-by-side layout I mentioned above. The media row uses display: contents by default so the stacked layout costs nothing
  • examples/open_cv_playground/main.py**
    • opencv_webcam now uses preview_layout="side-by-side" and mode="photo".
    • Removed the separate Image output widget. The right-hand panel in the webcam serves as the single display area: it shows the captured photo immediately after the shutter is pressed, then opencv_webcam.show_image(processed_data_url) replaces it with the processed result when Run Code completes.

Testing

The styles all work great in light & dark modes, and also the side-by-side camera stacks on mobile screens!

Why this should not be merged yet

There is a new page: open_cv_playground with an associated main.py, index.html, and config.json file. These are simply to show off and test the current webcam with openCV so they should be removed from this PR before merging. I am submitting this for now to get another set of eyes on the Donkey and OpenCV logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant