ubuntu16.04 mounted opencv3.4.0

1. The need to download the file:

  On a, source version of opencv. In the official website to download the best, albeit slow but the file will not be a problem. I downloaded the 3.4.0 version, link here: https://opencv.org/releases/page/3/ .
Here Insert Picture Description
  Attention must be source version, because the next step is to compile and install the source code. Downloaded a zip archive, first detour.

2. The need to rely on and build tools:

  Open a command line, type the following sentence statement and install any dependencies:

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev

  File a little more, it can be patient.
  Enter the next sentence statement install compilation tools cmake:

sudo apt-get install cmake

  May be more demanding compiled the future, you can install cmake install a tape interface After cmake:

sudo apt-get install cmake-gui

3. Compile source installation

  Please have a protagonist debut:
Here Insert Picture Description
  Here archive temporarily put on the table, extract directly on the desktop. If you have not been installed, then zip tools need to knock install the following statement:

sudo apt-get install zip

  Then decompress:

unzip opencv-3.4.0.zip

  Unzip the folder into finished their directory, where I created a new folder in the home directory opencv, then opencv-3.4.0 folder into.
Here Insert Picture Description
  Create a new folder in the opencv-3.4.0, to save the file compiled:

mkdir my_build

Here Insert Picture Description
  My_build into the new folder:

cd my_build

  Enter cmake to compile the following sentence be:

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..

  Run the above three instructions following schematic:
Here Insert Picture Description
  the make up after a good cmake:

sudo make

Here Insert Picture Description
  Install them:

sudo make install

Here Insert Picture Description

  Installed, ready to configure the environment variables.

4. Configuration Environment

  Enter the following, open profile

sudo gedit /etc/ld.so.conf.d/opencv.conf

  As shown below, there should be nothing.
Here Insert Picture Description
  Written in the file: /usr/local/libyou can save out.

/usr/local/lib 

  Note that usr, instead of writing user !!!
Here Insert Picture Description

  Run the following commands to validate the configuration:

sudo ldconfig 

  Continue to bash configuration file:

sudo gedit /etc/bash.bashrc

Here Insert Picture Description

  In the end of the file add:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig 
export PKG_CONFIG_PATH 

Here Insert Picture Description

  Save to close.
  source about the configuration to take effect immediately:

source /etc/bash.bashrc 

  And then update the look:

sudo updatedb 

  Since environment configuration is complete.

5. Routine test run

  Came opencv-3.4.0 folder. And then click Open samples, cpp, example_cmake. Here is the official routines can test.
  In turn enter the following statement:

cmake . 
make 
./opencv_example

Here Insert Picture DescriptionHere Insert Picture Description
Here Insert Picture Description
  The code to run successfully, ok.

Published 54 original articles · won praise 18 · views 9558

Guess you like

Origin blog.csdn.net/m0_37872216/article/details/103475542