Python OpenCV : VideoCapture differences between Python 2.7 to Python 3.5

亡梦爱人 提交于 2019-12-13 06:38:29

问题


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:


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.



来源:https://stackoverflow.com/questions/42325764/python-opencv-videocapture-differences-between-python-2-7-to-python-3-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!