WIP/Experiment - Camera Viewport and Snapshot #172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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...