The preview window has x, y, width and height parameters. More details in chapter 3 of the manual.I use GScrop tool to capture eg. 688x136@402fps videos with GS camera:
https://stamm-wilbrandt.de/GS
After using it for any mode different than 1456x1088, no rpicam* command preview does work (fails to start streaming).
I use "GScrop 1456 1088 60 100" to reset to full view, then rpicam* previews work again.
Today I played with picamera2 zoom demo:
https://github.com/raspberrypi/picamera ... es/zoom.py
It was surprisingly easy to get preview of centered 688x136 crop I typically use with GScrop tool:688x136.preview.pngCode:
import timefrom picamera2 import Picamera2, Previewpicam2 = Picamera2()preview_config = picam2.create_preview_configuration({"size": (688, 136)})picam2.configure(preview_config)picam2.start_preview(Preview.QTGL)picam2.set_controls({"ScalerCrop": (376, 476, 688, 136)})picam2.start()time.sleep(99)
Hopefully simple to answer questions first:
1) how to reduce height of preview window to 136?
Unfortunately not. You can get it to display certain camera-related information in the window title, but I don't think it lets you hide it completely. It's a thing we could think about, I suppose. It would also be easy to change if you downloaded the Picamera2 sources and tweaked the code.2) is pure 688x136 preview possible without a window title?
The video recording should be the full frame that is being returned by the camera system, so if that is cropped, then the video recording should reflect that. If it doesn't seem to be doing that, maybe post a short script demonstrating the problem?Next I tried to record 688x136 video (with default framerate for now) based on capture_video.py:
https://github.com/raspberrypi/picamera ... e_video.py
I tried many things, but always full frame got recorded
How can I tell the encoder to capture 688x136 centered frame only, that I was able to preview?
I think there are various things you could do. For example, you could just create a combined image with numpy and display it with OpenCV. On a Pi 5, particularly with relatively small images, I think that would be fine.P.S.
Is it possible to preview both GS cameras connected to my Pi5 together, with single picamera2 app?
That would allow for correct stereo preview, better than this handcrafted prototype ...
Another idea is this one. It allocates a larger buffer for one camera and then copies in the other half from the other camera, allowing you to use the built-in preview. I believe it works on a Pi 5, not sure about earlier Pis.
Do bear in mind, however, that you won't get super-fast framerates when you're displaying preview windows, even more so if you're copying image buffers around.
Statistics: Posted by therealdavidp — Mon Jun 24, 2024 7:45 am