I just bought a new camera for my pi so I installed it and then I wanted to test it out so I got a simple python program to test it:
import cv2 as cv def testDevice(source): cap = cv.VideoCapture(source) if cap is None or not cap.isOpened(): print('Warning: unable to open video source: ', source) testDevice(0) # no printout testDevice(1) # prints message
but when I run this program I get the following error:
Traceback (most recent call last): File "/home/pi/Desktop/tests/cam.py", line 1, in <module> import cv2 as cv ImportError: No module named 'cv2'
oh, looks like the module cv2 is missing. Ok I tried to install it two different ways but failed:
pip install opencv-python ERROR: Command errored out with exit status 1: /usr/bin/python /home/pi/.local/lib/python2.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-G_YoLY/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools wheel scikit-build cmake pip 'numpy==1.11.3; python_version=='"'"'3.5'"'"'' 'numpy==1.13.3; python_version=='"'"'3.6'"'"'' 'numpy==1.14.5; python_version=='"'"'3.7'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"'' Check the logs for full command output. pip3 install opencv-python Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-8f0epjtp/opencv-python/
Should I use opencv or is there something else? If I should, how do I get it to work?