当前位置:网站首页>Raspberry pie 4B installation opencv3.4.0
Raspberry pie 4B installation opencv3.4.0
2022-07-06 16:23:00 【Handsome black cat Sheriff】
This thing is difficult for thieves to install , I pretended for two days ,make If you fail once, you have to start all over again ....
First of all, let me explain that this is : The raspberry pie installation runs on Python3 Upper OpenCV
Get to the point :
Installation premise :
1、 Configured with raspberry pie Raspbian operating system
2. Switch to domestic apt-get Download source and pip Download source , Prevent download speed from being too slow ( I won't go into details here , Please Baidu )
install opencv
1、 install numpy
install Python Scientific Computing Library numpy( Get administrator permission first ,su)
pip3 install numpy
2、 Expand the root directory to the whole... In the raspberry pie setting SD card
Command line interface input command , Enter the raspberry pie configuration interface . Use the up and down keys and the left and right keys to switch the cursor position .
raspi-config
Select the seventh row :Advanced Options
Choose the first Expand Filesystem, Expand the root directory to this SD card . If you don't take this step , Subsequent commands will get stuck .
Exit the setup screen , Restart raspberry pie (reboot).
3、 install OpenCV Required Library
Eight orders , Run one by one , The penultimate one needs four dev
sudo apt-get install build-essential git cmake pkg-config -y
sudo apt-get install libjpeg8-dev -y
sudo apt-get install libtiff5-dev -y
sudo apt-get install libjasper-dev -y
sudo apt-get install libpng12-dev -y
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y
sudo apt-get install libgtk2.0-dev -y
sudo apt-get install libatlas-base-dev gfortran -y
4、 download OpenCV
Download two compressed packages to raspberry pie **/home/pi/Downloads** Under the table of contents ( It's best to download to this place , The follow-up is convenient )
First switch to Downloads Under the table of contents ,( It depends on your own situation , Not necessarily the path I wrote below )
cd /home/pi/Downloads
use wget download
wget https://github.com/Itseez/opencv/archive/3.4.0.zip
wget https://github.com/Itseez/opencv_contrib/archive/3.4.0.zip
If visit GitHub Some difficulties , Take care of yourself ( There is a link at the end of the article ).
Once the download is complete , Unzip to downloads Folder
unzip opencv-3.4.0.zip
unzip opencv_contrib-3.4.0.zip
5、 Set compilation parameters
cd /home/pi/Downloads/opencv-3.4.0
mkdir build
cd build
Set up CMAKE Parameters , It's a little long , About ten minutes , Here is a whole sentence , Don't forget to copy the last two points
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/pi/Downloads/opencv_contrib-3.4.0/modules -D BUILD_EXAMPLES=ON -D WITH_LIBV4L=ON PYTHON3_EXECUTABLE=/usr/bin/python3.5 PYTHON_INCLUDE_DIR=/usr/include/python3.5 PYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.5m.so PYTHON3_NUMPY_INCLUDE_DIRS=/home/pi/.local/lib/python3.5/site-packages/numpy/core/include ..
After the execution is completed, the following figure shows success
6、 compile ( The one with the most moths and the most time-consuming )
First of all, you should have enough storage space ,5g above , It's better not to use it ssh Connect the raspberry pie , A span ssh Will automatically exit , Cause you don't know make Is it over . It is best to vnc Connect , You can also connect raspberries to the monitor .
cd /home/pi/Downloads/opencv-3.4.0/build
make
Raspberry pie 4b,4g Running memory , I ran for about four hours , And there are many thieves in the middle of something wrong . Let me summarize my
1、 Missing file type error
Report errors :Built target opencv_tracking [Makefile:163 : all] error 2, It means lack boostdesc_bgm.i,boostdesc_bgm_bi.i Wait for these documents
Because the downloaded installation package files are incomplete , Copy the missing files to :home/pi/Downloads/opencv_contrib-3.4.3/modules/xfeatures2d/src/ Then you can
Documents needed , I'll finally give you a link .
2、 Type of path error
Report errors :fatal error: opencv2/xfeatures2d/cuda.hpp: There is no file or directory .
Building CXX object modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/opencv_stitching_pch_dephelp.cxx.o
In file included from /home/pi/opencv-3.4.0/build/modules/stitching/opencv_stitching_pch_dephelp.cxx:1:
/home/pi/opencv-3.4.0/modules/stitching/src/precomp.hpp:91:12: fatal error: opencv2/xfeatures2d/cuda.hpp: There is no file or directory
include “opencv2/xfeatures2d/cuda.hpp”
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/build.make:63:modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/opencv_stitching_pch_dephelp.cxx.o] error 1
make[1]: *** [CMakeFiles/Makefile2:21443:modules/stitching/CMakeFiles/opencv_stitching_pch_dephelp.dir/all] error 2
make: *** [Makefile:163:all] error 2
This is a type , There will be all kinds of mistakes , such as cuda.hpp,xfeatures2d.hpp,nonfree.hpp Wait, several documents , All wrong “ There is no file or directory ”.
This is the difference between absolute path and relative path , The system defaults to the relative path , We just need to find the wrong file , Find the wrong line , Put the relative path , Change to an absolute path .
for example :include “opencv2/xfeatures2d/cuda.hpp” Report errors , It's because I can't find /cuda.hpp, Let's just put this cuda.hpp Set to absolute path , To find the /cuda.hpp file .
If you follow my path above , Generally speaking , All in /home/pi/Downloads/opencv_contrib-3.4.0/modules/xfeatures2d/include/opencv2/xfeatures2d here
Then we found the file that reported the error (/home/pi/opencv-3.4.0/modules/stitching/src/precomp.hpp), Modify the line reporting an error
And then include “opencv2/xfeatures2d/cuda.hpp” Change to include “/home/pi/Downloads/opencv_contrib-3.4.0/modules/xfeatures2d/include/opencv2/xfeatures2d/cuda.hpp”, Then save ,
In short, this type of solution is the same , All the missing files are here /home/pi/Downloads/opencv_contrib-3.4.0/modules/xfeatures2d/include/opencv2 The inside . encounter “ There is no file or directory ” Just go to this folder to find , use pwd Get the path , Then modify the path in the error file .
Another thing to note is ,make After failure , If you want to re make, First of all clean Before you drop it make Of , stay build Under the table of contents , perform
make clean
And then again
make
As shown in the figure below , It was successful ( It is estimated that more than three hours )
100% After that, no error was reported , Congratulations , It's going to work !
The next in build Under the table of contents , next ( You need to run under administrator conditions , If you are not an administrator , Please first su)
make insall
This command takes half a minute , If there is no error, it means success .
7、 stay Python3 Up test OpenCV
open python3, I don't need to say orders
First
import cv2
then ( Notice the two underscores )
cv2.__version__
The effect as shown in the figure appears , That's success .
Required documents
opencv3.4 Files and missing files .zip: https://089u.com/file/30936724-479224952 Access password :123456
边栏推荐
- AcWing:第56场周赛
- 分享一个在树莓派运行dash应用的实例。
- 快速转 TypeScript 指南
- Problem - 922D、Robot Vacuum Cleaner - Codeforces
- 1605. Sum the feasible matrix for a given row and column
- Basic Q & A of introductory C language
- 去掉input聚焦时的边框
- Raspberry pie csi/usb camera uses mjpg to realize web camera monitoring
- 875. 爱吃香蕉的珂珂 - 力扣(LeetCode)
- Advancedinstaller安装包自定义操作打开文件
猜你喜欢
969. Pancake sorting
Codeforces round 797 (Div. 3) no f
b站 實時彈幕和曆史彈幕 Protobuf 格式解析
读取和保存zarr文件
QT realizes window topping, topping state switching, and multi window topping priority relationship
Click QT button to switch qlineedit focus (including code)
1855. Maximum distance of subscript alignment
Pytorch extract skeleton (differentiable)
antd upload beforeUpload中禁止触发onchange
Codeforces Round #802(Div. 2)A~D
随机推荐
628. Maximum product of three numbers
Share an example of running dash application in raspberry pie.
Configuration du cadre flask loguru log Library
The "sneaky" new asteroid will pass the earth safely this week: how to watch it
Educational Codeforces Round 130 (Rated for Div. 2)A~C
快速转 TypeScript 指南
socket通讯
Problem - 1646C. Factorials and Powers of Two - Codeforces
拉取分支失败,fatal: ‘origin/xxx‘ is not a commit and a branch ‘xxx‘ cannot be created from it
Codeforces Round #797 (Div. 3)无F
Study notes of Tutu - process
QT style settings of qcobobox controls (rounded corners, drop-down boxes, up expansion, editable, internal layout, etc.)
Some problems encountered in installing pytorch in windows11 CONDA
Opencv learning log 27 -- chip positioning
860. Lemonade change
window11 conda安装pytorch过程中遇到的一些问题
Acwing - game 55 of the week
QWidget代码设置样式表探讨
pytorch提取骨架(可微)
Flask框架配置loguru日志库