Cmake Installation
In Versions later than OpenCV 2.2, you must use Cmake to generate the makefile file. Therefore, you must first install cmake.
Installing cmake in Ubuntu is relatively simple,
Apt-get install cmake
If you find that your own version does not meet the requirements, you can download the installation package.
Download the latest installation package:
Http://www.cmake.org/cmake/resources/software.html
Download the compiled file here, so you only need to decompress it to the desired directory to use it:
Tar zxvf cmake-2.8.10.2-Linux-i386.tar.gz-C/usr/local/
Set environment variables:
Sudo gedit/home/emouse/. bashrc
After opening the file, add:
Export PATH = $ PATH:/usr/local/cmake-2.8.10.2-Linux-i386/bin
Check the version and test whether the installation is successful:
Root @ emouse:/home # cmake -- version
Cmake version 2.8.10.2
Install OpenCV in Ubuntu
Software environment:
Ubuntu 12.04
OpenCV 2.4.3
Cmake 2.8.10.1
Gcc 4.6.3 (default)
1. Install libgtk2.0-dev and pkg-config first. Otherwise, the following problems may occur during program compilation and running:
OpenCV Error: Unspecified error (The function is not implemented. rebuild the library with Windows, GTK + 2.x or Carbon support. if you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file/usr/local/opencv/OpenCV-2.0.0/src/highgui/window. cpp, line 100
Terminate called after throwing an instance of 'cv: exception'
Get Installation via network:
# apt-get install libgtk2.0-dev# apt-get install pkg-config
2, download OpenCV, file name: OpenCV-2.4.3.tar.bz2 ,:
Http://www.opencv.org.cn/index.php/Download
Decompress:
# Tar jxvf OpenCV-2.4.3.tar.bz2
Get folder OpenCV-2.4.3
Here you create a new folder OpenCV-x86 as the PC compiling directory.
3. # cmake-gui open the cmake gui and start configuration.
Cmake is mainly used for configuration settings to generate makefile files for compilation and installation. It is intuitive and convenient to configure and set parameters through the interface. Specify the source code, compilation directory, and generation method in the configuration.
Follow these steps:
Click Finish to load the default configuration, as shown in:
The middle part of the window is the configuration list, which is consistent with the makefile file generated directly using the cmake Command, as shown in
$ Cmake-D CMAKE_BUILD_TYPE = RELEASE-D CMAKE_INSTALL_PREFIX =/home/OpenCV
The configuration is made through the graphical interface, which is more intuitive and convenient.
Modify a place. Enter the value of CMAKE_BUILD_TYPE in the RELEASE field, and keep the rest unchanged. The blue dotted line shows the default installation directory, the makefile file will be installed in this directory when the make install command is executed. You can change it as needed. In the configuration here, I checked WITH_QT and removed WITH_TIFF. Other configurations are not clear, and the OpenCV Chinese website does not find the system description, click Generate to Generate the configuration file.
Go to the OpenCV-x86 directory to view the Makefile file, you can pay attention to the file generation time is consistent with the previous generation time.
4. Execute make and make install in the OpenCV-x86 to complete the compilation and installation.
5. After installation, You need to configure the system environment variables:
sudo gedit /etc/ld.so.conf.d/opencv.conf
Add the following content to the end:
/Usr/local/lib
Next, configure the Library:
sudo ldconfig
Change environment variables:
sudo gedit /etc/bash.bashrc
Add the following content after the file:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH
Save and exit. Before running the following routine, you need to restart the terminal for the configuration to take effect.
Recommended reading:
Install OpenCV2.4.2 on Ubuntu 12.04
OpenCV in CentOS cannot read Video Files
Summary of installing OpenCV 2.4.5 in Ubuntu 12.04
Install OpenCv2.1 in Ubuntu 10.04
Face Recognition System Based on QT and OpenCV