Installation and configuration of opencv3.3.1 under ubuntu14.04

When installing opencv, it was more tortuous, so I came to make this note to record it.

    References include:

Installation steps: https://blog.csdn.net/cocoaqin/article/details/78163171

Linux command: http://man.linuxde.net/mkdir

Problem with sudo: https://www.cnblogs.com/yves/p/4668837.html

 1. First, download the compressed package of the source version opencv3.3.1 (or other versions, the installation method is the same) from http://opencv.org/releases.html, or obtain this compression from other methods Bag.

2. Unzip the downloaded compressed package.

unzip opencv-3.3.1.zip

(Wait a minute, it will take a while)

3. Enter into the decompressed file package, mine is cd opencv-3.3.1 (cd means enter)

4. Install dependent libraries and cmake. If you are reminded that apt-get update is required, first sudo su to enter root privileges, then sudo apt-get update, and then execute the following command

sudo apt-get install cmake  
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev  
5. After installing cmake, execute the command. If the cmake folder is not created, you will be prompted (as shown below)

In-source builds are not allowed.

(PS: mkdir name. Is to create such a folder)

mkdir my_build_dir
cd my_build_dir

6, cmake about

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
Note: If it has been compiled in a new folder, but the previous error still occurs, delete cmakecache.txt and compile it again.

During the period, something may be downloaded, wait for a while and it will be OK

7. Then execute the command make, which takes a long time

sudo make

(PS: If you know that you are a computer with several cores, you can write make -j8 or make -j4. This can make full use of the advantages of multiple cores and compile faster)

8. Execute the command to install

sudo make install

write picture description here

The installation process is over here, and the next step is the configuration.

¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥Front high energy: ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !

9. First, we need to configure some compilation environments for opencv. Let the opencv library be added to the path, so that the system can find opencv (this is known to those who have configured opencv under windows)

cd~

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

             Note the following:                          

               [1, it is recommended to write this in the case of home, which is cd~]

                [2, it is better to use gksudo (password required) instead of sudo. If you use sudo, there may be an error as follows]

gedit:2714): IBUS-WARNING **: The owner of /home/ecomu/.config/ibus/bus is not root!

(gedit:2714): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files

                    [3, may also show connection timeout]

                    [4, gedit, as the same editor as nano and vi, the role of gedit here is to create a certain file somewhere]

10, and then a file will pop up. Don't be afraid whether it is blank or not, write it in the file, and save it. (This file is actually saved to computer/etc/ld.so.conf.d/opencv.conf)

/usr/local/lib  

write picture description here

11. Execute the following command to make the configuration just now take effect.

sudo ldconfig  
At this time, an error may be prompted as shown in the figure below (upper part)

write picture description here

sbin/ldconfig.real: /usr/lib/nvidia-375/libEGL.so.1 is not a symlink
/sbin/ldconfig.real: /usr/lib32/nvidia-375/libEGL.so.1 is not a symlink I
get this error May be due to system bug

Just enter the four lines of commands in the lower part of the above figure to solve
sudo mv /usr/lib/nvidia-375/libEGL.so.1 /usr/lib/nvidia-375/libEGL.so.1.org
sudo mv / usr/lib32/nvidia-375/libEGL.so.1 /usr/lib32/nvidia-375/libEGL.so.1.org
sudo ln -s /usr/lib/nvidia-375/libEGL.so.375.39 /usr/ lib/nvidia-375/libEGL.so.1
sudo ln -s /usr/lib32/nvidia-375/libEGL.so.375.39 /usr/lib32/nvidia-375/libEGL.so.1

12, configure bash

sudo gedit /etc/bash.bashrc  

13. Save and execute the command to make the above configuration take effect

source /etc/bash.bashrc 

14. Update (I don't know why to update, just do it)

sudo updatedb  

15. At this point, the configuration of opencv is over. Let's test it with the camera program that comes with opencv.

Use cd to enter the opencv-3.3.1/smaples/cpp/example_cmake directory. (Don't misspelling)

          [At this point, we can use the following command to see what is under the folder. ]

                             ls

(In fact, it is an example of cmake)

16. Execute in order

cmake .
make
./opencv_example

PS:

  [1, cmake is used to generate makefiles]

   [2, make to compile the makefile]

    [3, in fact, using make can also directly generate and compile makefiles, but because writing makefiles is too complicated, it is better to use cmake to generate more quickly and accurately]

     [4 ./opencv_example command is to display and run this program]

17. At this point, if ideal, you should see your computer camera turned on











    

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325379479&siteId=291194637