A memo when introducing OpenCV to Raspberry pi ...
$ sudo apt-get install python python-dev
$ sudo apt-get install python-numpy python-scipy python-matplotlib
It's tedious to build and it takes time, so use apt-get I referred to this area Build an OpenCV-Python environment on Raspberry Pi B + Install OpenCV and Python on your Raspberry Pi 2 and B+
$ sudo apt-get install libopencv-dev
Apt-get Python package
$ sudo apt-get install python-opencv
I think it will take about 5 minutes.
I tried it with this source.
capture.py
#coding:utf-8
import cv2
color = (0, 2, 2)
def capture_camera(mirror=True, size=None):
cap = cv2.VideoCapture(1)
while True:
ret, frame = cap.read()
if mirror is True:
frame = frame[:,::-1]
if size is not None and len(size) == 2:
frame = cv2.resize(frame, size)
cv2.imshow('camera capture', frame)
k = cv2.waitKey(1)
if k == 27:
break
elif k== 'q':
break
cap.release()
cv2.destroyAllWindows()
capture_camera()
If you think
GdkGLExt-WARNING **: Window system doesn't support OpenGL.
Error message! It seems different if you think that vnc is the cause.
Fix For the time being, this was the solution.
sudo apt-get install libgl1-mesa-dri
And
sudo reboot
It worked safely. It also worked on vnc.
I referred to this area. Trouble with Raspberry Pi camera and OpenCV Troubleshooting
Recommended Posts