Install OpenCV2.4.13 under Ubuntu16.04
Software version
Ubuntu 16.04; OpenCV 2.4.13
installation steps
1. First install some compilation tools
# Install build tools sudo apt-get install build-essential # install dependencies sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev # install optional packages sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
2. Download opencv
https://github.com/Itseez/opencv/archive/2.4.13.zip
3. Compile and install
# Open the folder "opencv-2.4.13": cd opencv-2.4.13 # Create a new folder for temporary files: mkdir release # Switch to the temporary folder: cd release # Start compiling: cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. make -j4 # Open the thread according to its own configuration sudo make install
4. System configuration
# Configure the environment and add the opencv library to the path so that the system can find it sudo gedit /etc/ld.so.conf.d/opencv.conf # Add /usr/local/lib at the end, save and exit sudo ldconfig # make the configuration take effect sudo gedit /etc/bash.bashrc # add at the end PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH # save and exit sudo source /etc/bash.bashrc #Make the configuration take effect (This step may report an error that the command cannot be found, because the source is the root command) su # Enter root privileges enter password source /etc/bash.bashrc Ctrl+d #Exit root sudo updatedb #更新database
test
1. Test the code to display the lena image
//File name lena.cpp #include <stdio.h> #include <opencv2/opencv.hpp> using namespace cv; int main( ) { Mat image; image = imread("lena.jpg", 1 );//The directory follows its own directory if ( !image.data ) { printf("No image data \n"); return -1; } namedWindow("Display Image", WINDOW_AUTOSIZE ); imshow("Display Image", image); waitKey(0); return 0; }
2. Compile
g++ lena.cpp `pkg-config --cflags --libs opencv` -o lena
3. Run in the folder
./lena
https://www.cnblogs.com/eczhou/p/7860586.html
Software version
Ubuntu 16.04; OpenCV 2.4.13
installation steps
1. First install some compilation tools
# Install build tools sudo apt-get install build-essential # install dependencies sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev # install optional packages sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
2. Download opencv
https://github.com/Itseez/opencv/archive/2.4.13.zip
3. Compile and install
# Open the folder "opencv-2.4.13": cd opencv-2.4.13 # Create a new folder for temporary files: mkdir release # Switch to the temporary folder: cd release # Start compiling: cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. make -j4 # Open the thread according to its own configuration sudo make install
4. System configuration
# Configure the environment and add the opencv library to the path so that the system can find it sudo gedit /etc/ld.so.conf.d/opencv.conf # Add /usr/local/lib at the end, save and exit sudo ldconfig # make the configuration take effect sudo gedit /etc/bash.bashrc # add at the end PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH # save and exit sudo source /etc/bash.bashrc #Make the configuration take effect (This step may report an error that the command cannot be found, because the source is the root command) su # Enter root privileges enter password source /etc/bash.bashrc Ctrl+d #Exit root sudo updatedb #更新database
test
1. Test the code to display the lena image
//File name lena.cpp #include <stdio.h> #include <opencv2/opencv.hpp> using namespace cv; int main( ) { Mat image; image = imread("lena.jpg", 1 );//The directory follows its own directory if ( !image.data ) { printf("No image data \n"); return -1; } namedWindow("Display Image", WINDOW_AUTOSIZE ); imshow("Display Image", image); waitKey(0); return 0; }
2. Compile
g++ lena.cpp `pkg-config --cflags --libs opencv` -o lena
3. Run in the folder
./lena