Zephyrus29
Posts: 2
Joined: Fri May 17, 2019 5:30 am

Checking if the camera is still working

Fri May 17, 2019 5:36 am

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.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7026
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Checking if the camera is still working

Fri May 17, 2019 9:08 am

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
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Zephyrus29
Posts: 2
Joined: Fri May 17, 2019 5:30 am

Re: Checking if the camera is still working

Mon May 20, 2019 3:12 am

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.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7026
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Checking if the camera is still working

Mon May 20, 2019 9:44 am

Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”