Python OpenCV : VideoCapture differences between P

2019-09-15 04:38发布

I'm connected to remote system through ssh, and trying to read frames using OpenCV VideoCapture in Python. The same code succeeds when using Python 2.7 and fails when using Python 3.5:

import cv2
cap = cv2.VideoCapture(0)

Python2.7:

print cap.isOpened() # prints True, further read() calls also return True

Python3.5:

print (cap.isOpened()) # prints False, and so are cap.open(), and of course cap.read().

What could cause such behavior?

Thanks!

1条回答
萌系小妹纸
2楼-- · 2019-09-15 04:58

I had exactly the same problem. OpenCV was installed from the sources. The difference between Python 2 and 3 environment was, that for Python 3 opencv-python was additionally installed via pip3. A

pip3 uninstall opencv-python

solved it in my case.

查看更多
登录 后发表回答