-
Notifications
You must be signed in to change notification settings - Fork 195
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
[SUGGESTION] Provide an option to capture_ methods that guarantee a frame after the request is made #849
Comments
Hi, thanks for that, I think that's an interesting idea. Are you thinking of maybe a timestamp argument for
and you'd be guaranteed to get a frame where the Just as a note, even that doesn't seem fully correct, you probably want to subtract the exposure time from the SensorTimestamp. Otherwise some of (even all) the pixels have started being exposed before the time in question. Presumably you'd prefer it that nothing gets exposed beforehand?
|
Thanks, David.
the capture would simply skip frames with a timestamp earlier than the system time of the call to For info, it's not happening every time, and appears to need to skip only one frame if it's caught. When I put something like the following into my capture code:
I get results like:
A range of 6 to 60mS. In this case the shutter speed is 10495, but not factored in the above check. |
I quite like the idea of being able to specify a timestamp, I could imagine some code being informed that some event happened "a short while ago", and you might want to use a timestamp that you're given. Or if it's not a single capture, and you're trying to pipeline your captures and synchronise them with other (asynchronous) events. Maybe one could have a "flush" parameter, where I'm still thinking that you really want "SensorTimestamp - ExposureTime >= timestamp", though - would you agree? |
The |
The SensorTimestamp is the time when the capture of the first pixel has happened. These are (mostly) rolling shutter sensors, so the rest of the frame is either still being exposed, or possibly hasn't even started being exposed yet! But anyway, here's a first attempt at something: #851 |
Thanks, David! That was a quick implementation! 👍 I suppose it would also make sense to make the |
I was looking for this feature exactly. Thanks. Edit:: think I found out (need to test.)
Does this new feature help apply config setigns as well? From Section 5.1 of manual:
These "several frames of delay" are not present when So in the following snippet
|
I haven't added this feature to the other capture methods as the parameter lists are getting quite cluttered already. I took the view that folks who were sufficiently advanced to care about these details would be able to do
but I'm always open to persuasion on this kind of thing. One thing to note is that this doesn't really help in capturing a frame when the exposure has changed. It takes several frames for the exposure to change even after you've sent the command to change it, so the only way to know that it has happened is to sit in a loop and watch the image metadata (at which point the sleep would be redundant). |
This is related to the discussion in issue #787 but is more of a feature request. It's probably relevant for projects requiring synchronising the camera to outside events or machine movement. I found myself with a problem where a photo has to be taken after some motors have stopped moving.
No matter what settings of buffer_count and queue=False sometimes an old frame that was taken while the motors were running is being supplied even when the request is made after the motors stop, leading to blurred images. Although this happened to some extent on the Pi4, it seems more frequent with the Pi5 and/or recent libcamera/picamera2 updates. Possibly related to the greater speed of the system?
With information from #787, my workaround is to store the time of the capture request using time.monotonic_ns() which is compared to SensorTimeStamp in the metadata of the request. If SensorTimeStamp is earlier, then another capture_request is made. Some partial code from my camera control object - the do_capture method is called when the motors stop:
Although the above seems to do the job, it would be nice to incorporate an option into the capture_ methods so that picamera2 can be told to always return a frame at or after the time of the request, and saves having this hacky workaround code in the signal_function.
The text was updated successfully, but these errors were encountered: