Home > other >  The open CV cap. Get (7) for return to a negative total video frames
The open CV cap. Get (7) for return to a negative total video frames

Time:03-09

 import cv2 
The import argparse
The import OS


Def the parse () :
Parser=argparse. ArgumentParser (description="This is a example program")
Parser. Add_argument (
'- video_path'
Type=STR,
The default="D:/image/14. Mp4,
Help="video path.")
Parser. Add_argument (
'- pic_path' type=STR, default="D:/PIC/13, help=" PIC path. ")
Args=parser. Parse_args ()
Return the args

Def get_video_pic (name) :
Cap=cv2. VideoCapture (name)
Print (cap) get (7))
Print (count)
For I in range (0, int (count) :
Cap. The set (1, int (I))
# print (cap. The read ())
Rval, frame=cap. The read ()
If rval:
If (I % 5==0) :
If not OS. Path. The exists (args. Pic_path) :
OS. Makedirs (args. Pic_path)
Cv2. Imwrite (args. Pic_path + "/result" + STR (I//5) + 'JPG', frame) # image path
Cap. Release ()


If __name__=="__main__ ':
Args=the parse ()
Get_video_pic (args. Video_path)


Print the results as follows: 192153584101141.0, what reason is this excuse me, how to solve, to get the correct number of video frames

CodePudding user response:

Have you solved?
  • Related