CSI camera - snapshot issue


I have a project which is the following:
On a Jetson Nano, I have a CSI camera. I want to take one picture (fram) every 5s from this cam , and then evaluate this picture in a tensorflow model.
The tensorflow part is working without problem if I use pictures from the hard drive.
The problem is to get one picture every 5 seconds.

I just create this simple piece of code:

cam=nano.Camera(flip=0, width=640, height=480, fps=30)

while True:	
	image = cam.read()

	if cv2.waitKey(1) & 0xFF == ord(' '):

nano.Camera is just coming from a library:

The problem is that, the delay between displaing 2 pictures is really longer than 5s (more than a minute), it seems that the system is laging.
And when I’m sending the picture to the model, it seems that the evaluation is done correctly. Only the display in cv2.imshow seems to have a problem.

For information, the live from the camera is working fine.
Any idea on this issue?


you can’t just throttle a camera like that.

you must read every frame right away. you can throw them away but you must read them, without any delay of any kind.

oh, and you have two waitkeys. that is wrong. why? you discard the result of the long-running one… but you surely want to know its result because that one will catch the key!

OK, but how do you explain that this is working fine with a webcam?

And so, what can be the technique if I want to get an image every xx seconds from the camera and use it in another part of my code?