Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Python Opencv VideoCapture::read returns None only in a virtual environment

The code below runs fine, except when it is put in my virtual env.

I've tried building opencv from source with a new env and no difference...

cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 320)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)

while True:
    ret, img = cap.read()
    print(ret)  # False in venv
    print(img)  # None in venv

    cv2.imshow('img', img)
        k = cv2.waitKey(30) & 0xff
        if k == 27:
            break

Why might this be happening? Can I get access to any logs (None isn't really helpful)

Is it possible that some of the scripts in the virtual env don't have the correct permissions for binaries in my opencv install?

Python 3.6.2, virtualenvwrapper, Fedora 25

Python Opencv VideoCapture::read returns None only in a virtual environment

The code below runs fine, except when it is put in my virtual env.

I've tried building opencv from source with a new env and no difference...

cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 320)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)

while True:
    ret, img = cap.read()
    print(ret)  # False in venv
    print(img)  # None in venv

    cv2.imshow('img', img)
     k = cv2.waitKey(30) & 0xff
     if k == 27:
         break

Why might this be happening? Can I get access to any logs (None isn't really helpful)

Is it possible that some of the scripts in the virtual env don't have the correct permissions for binaries in my opencv install?

Python 3.6.2, virtualenvwrapper, Fedora 25