1. Download source code from opencv.org Opencv-2.4.9.zip
2. Unzip to the prepared directory
Unzip Opencv-2.4.9.zip
3. Enter the source directory and create the release directory
CD opencv-2.4.9 mkdir release
4. Install the pre-installed software
sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy Libavcodec-dev Libavformat-dev Libswscale-dev
Why are these? From CMakeLists.txt, I don't know now.
5. Go to the release directory and install OpenCV All files will be placed in this release directory
CD release
6. CMake Compile OpenCV source code, install all LIB files will be installed in the/usr/local directory
Cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local.
7. Compiling and installing
8. Test, create a test.cpp file in a directory
#include <cv.h>#includeusing namespaceCV; intMainintargcChar*argv[]) {Mat image; Image= Imread (argv[1],1); if(ARGC! =2|| !image.data) {printf ("No Image data\n"); return-1; } Namedwindow ("Display Image", cv_window_autosize); Imshow ("Display Image", image); Waitkey (0); return 0; }
9. Write a cmake makefile, also known as CMakeLists.txt
Project (test) find_package (OpenCV REQUIRED) add_executable (test test) target_link_libraries (test ${opencv_libs}) 2.8)
10. Compile + Run
CMake. Make
Pay attention to CMake "." Get test executable after executing instruction
11. Do a random jpg picture to do a test, note to the above executable file in the same directory, my name here is test.jpg.
12. Execute the following command if you can see the picture, it means success.
./test Test.jpg
[ tested successfully on compatible machine 1 ]
Reference:
http://my.oschina.net/u/1757926/blog/293976http://blog.csdn.net/qust_waiwai/article/details/43890339http:// Www.cnblogs.com/fische/p/4094390.html
UBUNTU 14.04 Installation OPENCV 2.4.9