· Raspberry PI Minimalist Installation OpenCv
Xiaosongshine. Github. IO /
The original address: blog.csdn.net/xiaosongshi… Recently, I was developing the raspberry PI + USB camera recognition module and planned to use OpenCv. However, I found that the installation tutorials of Raspberry PI OpenCv on the Internet were too tedious and took up a lot of memory. After my own experiments, I found a very simple and quick way, which could be installed in ten minutes if the Internet speed was OK.
My environment:
- Raspberry pie 3 b +
- Python3.5.4
- Raspberry PI official operating system
Here are the installation steps:
- Raspberry PI related library installation: sudo apt-get update sudo apt-get install libjpeg-dev sudo apt-get install libatlas-base-dev sudo apt-get install libjpeg-dev sudo apt-get install libtiff5-dev sudo apt-get install libpng12-dev sudo apt-get install libqtgui4 libqt4-test sudo apt-get install libjasper-dev
- Sudo pip3 install opencv-python
The installation is complete
- test
Enter: python3 at the terminal
Then: import cv2
If the installation is successful, there will be no problem with the import
Here you can output the version number of OpenCv
Use: print (cv2.version)
Exit Python with: exit()
Simple application
Use OpenCv library to read USB camera, real-time display, take photos
- The code is as follows:
import cv2 import numpy as np cap = cv2.VideoCapture(0) while(1): # get a frame ret, frame = cap.read() # show a frame cv2.imshow("capture", frame) if cv2.waitKey(1) & 0xFF == ord('q'): Cv2.imwrite ("takephoto2.jpg", frame) print("take Photo Ok") break cap.release() cv2.DestroyallWindows ()Copy the code
- Run a screenshot
(Postscript: This blog is written on raspberry PI, I am not used to the system, and the Chinese input method is also difficult to use.)