How to view video stream in OpenCV2 python

前端 未结 1 1977
無奈伤痛
無奈伤痛 2021-01-15 12:06

I\'m starting to play with Opencv. I am using the python bindings for opencv2 on Linux. I wrote a quick test program but it seems to hang indefinitely.

impor         


        
相关标签:
1条回答
  • 2021-01-15 12:32

    Code safely and test the return of the method:

    vid = cv2.VideoCapture(weblink)
    if not vid:
        print("!!! Failed VideoCapture: invalid parameter!")
    

    The address you are using is probably not supported by OpenCV.

    The same practice should be used whenever a method can fail:

    while (key < 0):
        success, img = vid.read()
        if not img:
            print("!!! Failed vid.read()")
            break
    
        cv2.imshow("video", img)
    
    0 讨论(0)
提交回复
热议问题