How to process images of a video, frame by frame, in video streaming using OpenCV and Python

后端 未结 6 884
鱼传尺愫
鱼传尺愫 2020-12-04 10:13

I am a beginner in OpenCV. I want to do some image processing on the frames of a video which is being uploaded to my server. I just want to read the available frames and wri

6条回答
  •  再見小時候
    2020-12-04 10:38

    The only solution I have found is not to set the index to a previous frame and wait (then OpenCV stops reading frames, anyway), but to initialize the capture one more time. So, it looks like this:

    cap = cv2.VideoCapture(camera_url)
    while True:
        ret, frame = cap.read()
    
        if not ret:
            cap = cv.VideoCapture(camera_url)
            continue
    
        # do your processing here
    

    And it works perfectly!

提交回复
热议问题