1

I want to fetch the no of frame in python-opencv ,but it doesnot work perfectly. what can i do actually for this? I use this function to print the no of frames but it shows -1. what actually it is?

       cam = cv2.VideoCapture(-1)
       print(cam.get(cv2.CAP_PROP_POS_FRAMES))
santosh ghimire
  • 169
  • 1
  • 10
  • If you're trying to get the frame count (i.e., the **total** number of frames), you're using the wrong property (see the question in my next comment) – GPhilo Jul 30 '20 at 11:07
  • 1
    Does this answer your question? [How to know total number of Frame in a file with cv2 in python](https://stackoverflow.com/questions/25359288/how-to-know-total-number-of-frame-in-a-file-with-cv2-in-python) – GPhilo Jul 30 '20 at 11:08
  • `POS_FRAMES` is rather for frame's position - not for count frames (`CAP_PROP_FRAME_COUNT`) or speed in frames per second (`CAP_PROP_FPS`). And at start it may not have position or you can't get frame's position for stream like from webcam. – furas Jul 30 '20 at 13:45
  • I want to count the frame when the webcam opened. – santosh ghimire Jul 31 '20 at 01:26

0 Answers0