Python 如何在Yolo v3中获取视频文件长度

Python 如何在Yolo v3中获取视频文件长度,python,keras,yolo,Python,Keras,Yolo,我想知道视频文件中的帧数 vid = cv2.VideoCapture(video_path) #reading the video file NumberOfFrame = int(vid.get(cv2.CAP_PROP_FRAME_COUNT)) [UPD]之前我以为是Yolo做的,但后来我意识到是OpenCV处理视频文件中的帧数。 资料来源: 实际上,这段代码只是全部Yolo3模型的一部分,但我认为处理视频帧数的部分包含在这里。如果你是指当前的FPS。是以字符串形式显示当前FPS的部分

我想知道视频文件中的帧数

vid = cv2.VideoCapture(video_path) #reading the video file
NumberOfFrame = int(vid.get(cv2.CAP_PROP_FRAME_COUNT))
[UPD]之前我以为是Yolo做的,但后来我意识到是OpenCV处理视频文件中的帧数。 资料来源:


实际上,这段代码只是全部Yolo3模型的一部分,但我认为处理视频帧数的部分包含在这里。

如果你是指当前的FPS。是以字符串形式显示当前FPS的部分

while True:
    return_value, frame = vid.read()
    image = Image.fromarray(frame)
    image = yolo.detect_image(image)
    result = np.asarray(image)
    curr_time = timer()
    exec_time = curr_time - prev_time
    prev_time = curr_time
    accum_time = accum_time + exec_time
    curr_fps = curr_fps + 1
    if accum_time > 1:
        accum_time = accum_time - 1
        fps = "FPS: " + str(curr_fps)
        curr_fps = 0
    cv2.putText(result, text=fps, org=(3, 15), fontFace=cv2.FONT_HERSHEY_SIMPLEX,
                fontScale=0.50, color=(255, 0, 0), thickness=2)
    cv2.namedWindow("result", cv2.WINDOW_NORMAL)
    cv2.imshow("result", result)
    if curr_fps == 10: # Stops at 10th frame.
        time.sleep(60) # Delay for 1 minute (60 seconds).
    if isOutput:
        out.write(result)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

我想控制视频文件中的每10帧,多亏了上面的评论,我发现我要找的行是:

curr_fps = curr_fps + 1
UPD:以下代码标识视频文件中的帧数

vid = cv2.VideoCapture(video_path) #reading the video file
NumberOfFrame = int(vid.get(cv2.CAP_PROP_FRAME_COUNT))

检查部分。@ArkistarvhKltzuonstev实际上,我也认为你指的是那一部分,但具体是哪一行?不。我是说我正在处理的视频文件每秒有30帧。该模型以逐帧的方式处理视频。因此,我想控制它,使其在处理第10帧时停止一段时间。在第206行的cv2.imshow(“result”,result)下,添加if curr_fps==10:pass虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接供参考。如果链接页面发生更改,仅链接的答案可能无效。-这并不能回答这个问题。一旦你有足够的钱,你将能够;相反-