grab frame NTSCtoUSB dongle, opencv2, python wrapper

后端 未结 3 1790
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 17:26

Context:

I have been playing around with python\'s wrapper for opencv2. I wanted to play with a few ideas and use a wide angle camera similar to \'rear view\' came

3条回答
  •  难免孤独
    2020-12-01 18:15

    I faced the same issue. As a workaround, I first tried the solution proposed by @user3380927 and it worked indeed. But since I didn't want to rely on an external software, I started tweaking parameters using opencv in Python.

    This lines of code worked like a charm (you have to insert them before reading the frame for the first time):

    cam.set(cv2.CAP_FFMPEG,True)
    cam.set(cv2.CAP_PROP_FPS,30)
    

    So, the full code for basic camera reading is as follows:

    import cv2
    
    cam = cv2.VideoCapture(1)
    cam.set(cv2.CAP_FFMPEG,True)
    cam.set(cv2.CAP_PROP_FPS,30)
    
    while(True):
        ret,frame = cam.read()
        cv2.imshow('frame',frame)
        if (cv2.waitKey(1) & 0xFF == ord('q')):
            break
    
    cam.release()
    cv2.destroyAllWindows()
    

    You can then apply image processing operations as usual. Just for reference, this was my configuration:

    • Opencv 3.1.0
    • Python 2.7.5
    • Windows 8.1
    • Elgato Video Capture device (this was also shown as Sound Video & Game controllers)

提交回复
热议问题