Page 1 of 1

Checking if the camera is still working

Posted: Fri May 17, 2019 5:36 am
by Zephyrus29
Hi,
I'm making a project using a compute module and piCamera that uses a continuously running circular buffer to capture data.
When I start recording, I get a nice exception if the camera isn't connected. The problem is that I get nothing if I disconnect the camera mid recording. Trying to capture some video just gives me whatever was in the buffer before.

This is a pretty big problem in my application, I would prefer to have no video rather than misleading video. Is there any way I can find out if the camera is still working and connected? I can't stop and start the video to do this, I want to poll a function or similiar. Preferably actually outputting data rather than just having the I2C connected.

Re: Checking if the camera is still working

Posted: Fri May 17, 2019 9:08 am
by 6by9
Each buffer that comes back has a timestamp on it - https://picamera.readthedocs.io/en/late ... .timestamp

Record the timestamp of the last frame, and compare that to the current time, as reported by the timestamp property - https://picamera.readthedocs.io/en/late ... .timestamp

Re: Checking if the camera is still working

Posted: Mon May 20, 2019 3:12 am
by Zephyrus29
Thanks for that, that's exactly the sort of thing I was looking for.

I don't know who maintains that library, but it would be nice if the documentation was a bit more explicit that this wasn't detected. It seems to imply that the wait_recording function implements checking for this sort of failure, but sadly it doesn't.

Re: Checking if the camera is still working

Posted: Mon May 20, 2019 9:44 am
by 6by9