如何使用cv2处理所有帧

时间:2019-08-22 08:31:25

标签: python cv2

代码无法处理视频的最后一帧

除了处理最后一帧时,以下代码执行得很完美

它发生以下错误

error: OpenCV(3.4.3) /io/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

def FrameCapture(路径):

def FrameCapture (path): #Path to video file 

vidObj = cv2.VideoCapture(path) 

# Used as counter variable 
count = 0



while True: 

    # vidObj object calls read 
    # function extract frames 
    success, image = vidObj.read()

    if (success == False) 
     print("stop") break

    ## Convert the frame to gray color
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

主要

if __name__ == '__main__': # Calling the function 
FrameCapture("/content/drive/My Drive/Development/EyeClose/BenKen.mp4") 

代码应将所有提取的帧返回为灰度图像

0 个答案:

没有答案