CSI camera - snapshot issue

Hello,

I have a project which is the following:
On a jeston 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()
	cv2.imshow("image",image)
	cv2.waitKey(5000)

	if cv2.waitKey(1) & 0xFF == ord(' '):
		break
cap.release()
cv2.destroyAllWindows()

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?

Thanks

Does the original python code have displaying problem?

what do you mean by “original code”?

I mean the sample code CSI_camera.py working well?

yes, this is working well.

Only the cv.waitKey(5000) seems to be the problem.

Could you modify the sample code to 5000 to check.

if cv2.waitKey(25) & 0xFF == ord(‘q’):