I want to extract and process frame every 200 ms from video stream from webcam, I tried frameRate = cap.get(5) ie.(CAP_PROP_FPS) and frameIndex = cap.get(1) ie.(CAP_PROP_POS_FRAMES) but I get frameRate = 0.0 & frameIndex = -1.0. Please help, Any help is appreciated. Thank You.
Asked
Active
Viewed 637 times
1 Answers
0
For simple application I would use cv2.waitKey() in myyour code to introduce delay. If you want to have one frame every exactly 200ms you have to addtime measurement, for example like described here:
Python speed testing - Time Difference - milliseconds
I would include one if statement in my code and wait untill time difference is equal 200ms.
As I mentioned on the begining it is simple, not the best solution, but easiest to implement to begin with.

Kamil Szelag
- 708
- 3
- 12
-
Thank you very much. I tried what you've suggested (datetime) and it worked for me because my while loop(while cap.isOpened():) is not taking more than 100-150 ms. As you said it is a simple solution not best, having said that it is simple & best as well because, if only one frame takes more than 200 ms for processing anyhow I'm going to miss the next frame. – Prathamesh Konkar Sep 28 '17 at 08:17