In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to compile and install opencv in Ubuntu17.04 system, which is very detailed and has certain reference value. Friends who are interested must finish reading it.
Install the gcc cmake compilation environment
Sudo apt-get install build-essential pkg-config cmake cmake-gui
This article provides two ways of compiling source code, one is cmake command, and the other is compiled through cmake-gui of graphical interface.
This version of system ubuntu already comes with python 2.7and python 3.5.It is necessary to install pip to manage the python package.
Sudo apt-get install python-pipsudo apt-get install python3-pip
Configure the download and update speed of pip Tsinghua Source acceleration package (looking for the feeling of flying)
Mkdir ~ / .pipvim ~ / .pip / pip.conf# add the following to pip.conf [global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple[install]trusted-host=mirrors.aliyun.com
Install the data analysis package under python and python3
Pip install numpy scipy matplotlib scikit-image scikit-learn pip3 install numpy scipy matplotlib scikit-image scikit-learn
Install other dependencies
# git: version control # gfortran fortran compiler # yasm assembly compiler # ffmpeg system comes with sudo apt-get install checkinstall yasm gfortran git ffmpegsudo apt-get install libxvidcore4 libgtk-3-devsudo apt-get install libjpeg8-dev libjasper-dev sudo apt-get install libtiff5-devsudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-devsudo apt-get install libxine2-dev libv4l-devsudo apt-get install libqt4-dev libgtk2.0-dev libtbb-devsudo apt-get install libatlas-base-devsudo apt-get Install libfaac-dev libmp3lame-dev libtheora-devsudo apt-get install libvorbis-dev libxvidcore-devsudo apt-get install libopencore-amrnb-dev libopencore-amrwb-devsudo apt-get install x264 v4l-utils
4. Optional dependence
Sudo apt-get install libprotobuf-dev protobuf-compilersudo apt-get install libgoogle-glog-dev libgflags-devsudo apt-get install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen
Download and install OpenCV3
Install git
Sudo apt-get install git
Download OpenCV3
Git clone https://github.com/opencv/opencv.git
Download OpenCV_Contrib
Git clone https://github.com/opencv/opencv_contrib.git
OpenCV has separated part of the content (such as SIFT, etc.) into opencv_contrib since 3. 0. Therefore, to fully install OpenCV, you also need to install opencv_contrib.
Command compilation
Cd opencvmkdir buildcd buildcmake-D CMAKE_BUILD_TYPE=RELEASE\-D CMAKE_INSTALL_PREFIX=/usr/local\-D INSTALL_PYTHON_EXAMPLES=ON\-D WITH_TBB=ON\-D WITH_V4L=ON\-D WITH_QT=ON\-D WITH_OPENGL=ON\-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules\-D BUILD_EXAMPLES=ON. # check the number of cpu cores nproc# if you have 8 cores # switch to the build directory Execute the following command, compile the source code and link to generate the corresponding dynamic library and the executable file make-job. after the execution is complete, execute the following command to install the generated executable and the dynamic library into the specified installation directory. Sudo make installsudo sh-c 'echo "/ usr/local/lib" > > / etc/ld.so.conf.d/opencv.conf'sudo ldconfig
Using graphical tools to configure and generate makefile
Change to the opencv directory and create a new directory to hold the configuration files generated by cmake.
Mkdir build
Cd build
Find cmake-gui in your graphical interface software to open it.
Then add the directory path of opencv to Where is the source code and the build directory you just created in where to build the binaries
Then click Configure below, select Unix Makefiles, and then select default. Click OK to process the CMakeLists.txt in the opencv directory. And generate CMakeCache.txt and Makefile and other related files in the Build directory.
After the Configure configuration is finished, a configuration interface similar to the following appears
Here are the parts that need to be modified
Change CMAKE_BUILD_TYPE to RELEASE
OPENCV_EXTRA_MODULES_PATH is set to the path to the modules directory in opencv_contrib (for example, / home/arvin/opencv_contrib/modules)
Tick the check box in BUILD_EXAMPLES
Tick the check box in INSTALL_C_EXAMPLES
Tick the check box in INSTALL_PYTHON_EXAMPLES
Tick the check box in WITH_FFMPEG
Tick the check box in WITH_GTK
Tick the check box in WITH_V4L
Tick the check box in WITH_TIFF
Tick the check box in WITH_PNG
Tick the check box in WITH_JPEG
Tick the check box in WITH_JASPER
Uncheck the check box in WITH_CUDA
Uncheck the check box in WITH_CUFFT
Then click Configure, apply the previous changes and update the changes to CMakeCache.txt in the build directory. Then click Generate to update Makefile.
Outsource the installation of OpenCV3 and OpenCV3
Cd opencv/build/make-j8sudo make install sudo ldconfig
Test whether the environment is configured successfully
# Open your python interpreter on the command line and enter the following command. If import cv2 print cv2.__version__# sees output similar to the following, it means that the configuration is successful. The above is all the contents of the article "how to compile and install opencv in the Ubuntu17.04 system". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.