Skip to content

WIP/Experiment - Camera Viewport and Snapshot #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KurtE
Copy link

@KurtE KurtE commented Aug 6, 2025

Note: this all uses the Zephyr updates from my PR
zephyrproject-rtos/zephyr#93797

Which I added to the STM dcmi driver the ability to have the camera work in snapshot mode instead of in continuous video mode. This allows for example that we start the camera it grabs a frame and stops, we then take the buffer and process it, and repeat this. This helps minimize how much the SDRAM gets used concurrently.

In addition, I added to the VIDEO_STM32_DCMI and GC2145 the ability to use some of the new set_selection and get_selection code that was added for the DCMIPP. In particular the DCMI simply forwards these messages to the camera if it defined thise apis...

And with this it allows you to setup a viewport into the frame. For example: You can setup the frame on the GC2145 to be 800x600 and then define a view port to be 480x320 to fill an ST7796/ILI9486 tft display or you could do it 400x240 to half fill the GIGA display. You can also move that view port around within the frame (pan) I have examples that do this on Portenta H7 on the ST7796 display and another one that does this on the GIGA display shield.

Still WIP as we probably need to refine the APIS and the like

EDIT: Current set of changes:

a) I found a needed to add some ability to set the frame and viewport in one call as for example calling
the begin method with lets say 800x600 or worse 1600x1200 size frame will try to create the N buffers of that size.
which is unnecessary if you are using viewports and may not fit.
So added a variant of the begin that you can set both begin(800, 600, 480, 320, ...)

b) Add way to be able to set snaphot mode.

c) Add calls to call the set and get settings. These should probably change is I needed to add in the header file
for video.h to get the structures... But is good for test.

With this, I currently have some tests working. For example:
https://github.com/KurtE/Arduino_GIGA-stuff/blob/main/sketches/zephyr_giga_display_examples/Zephyr_GigaCameraDisplay_GFX_pan_zoom/Zephyr_GigaCameraDisplay_GFX_pan_zoom.ino

This sketch sets up display 800,600, 400, 240 and scales the image up to 800x480 and displays it on the GIGA shield.
It then pans left and right about 1/4 of the change (800-400)/4 = 100 each frame...
Note: I do run into failures (reasonably often) and the led on the GIGA flashes. But then it starts the next frame
and recovers...

Note: this all uses the Zephyr updates from my PR
zephyrproject-rtos/zephyr#93797

Which I added to the STM dcmi driver the ability to have the camera work in snapshot mode
instead of in continuous video mode.  This allows for example that we start the camera
it grabs a frame and stops, we then take the buffer and process it, and repeat this.
This helps minimize how much the SDRAM gets used concurrently.

In addition, I added to the VIDEO_STM32_DCMI and GC2145 the ability to use some of the
new set_selection and get_selection code that was added for the DCMIPP.  In particular
the DCMI simply forwards these messages to the camera if it defined thise apis...

And with this it allows you to setup a viewport into the frame.  For example:
You can setup the frame on the GC2145 to be 800x600 and then define a view port
to be 480x320 to fill an ST7796/ILI9486 tft display or you could do it 400x240 to half fill
the GIGA display.  You can also move that view port around within the frame (pan)
I have examples that do this on Portenta H7 on the ST7796 display and another one
that does this on the GIGA display shield.

Still WIP as we probably need to refine the APIS and the like
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