CMake Compile Run OpenCV program _DEBUG summary __OPENCV

Source: Internet
Author: User

Task: Test author source code, CMake compile run OpenCV 1. CMake compilation

The author has already written the CMakeList.txt and has the documentation for installation use

Official documents compiled by OPENCV with CMake:
Using OpenCV with GCC and CMake

CMakeLists.txt in the code for OPENCV:

# Find OpenCV
find_package (OpenCV REQUIRED)

# Set compilation
target_link_libraries (${project_name} ${ Opencv_libs})
2. Found CMake did not find OpenCV

Download Findopencv.cmake
Put it in the CMake modules folder; There are many other find files in this folder.
The path on my computer:/usr/local/cellar/cmake/3.0.2/share/cmake/modules

can refer to:
StackOverflow Discussion

FINDOPENCV will find the OpenCV library file and header file path on the computer, and coexist in the variable for subsequent invocation.
Personally believe that the premise is the installation of OPENCV after the source code project has not been deleted, there are installed OpenCV cmake configuration files, FINDOPENCV through these configuration files to find the path.

The following are set after configuration was done:
Opencv_found
Opencv_libs
Opencv_include_dir
Opencv_version 3. Found that the author's OpenCV is version 2.4.

This machine installs the version 3.0, the error some classes are not defined

You can install multiple versions of OPENCV at the same time, you need to manually set the path
CMake Set header file and Lib file path, and connection library file:

# Set Header search Path 
include_directories (/usr/local/include/opencv2.4.9/)

# Set Libraries search Path 
Link_directories (/usr/local/lib/opencv2.4.9/)

set (Opencv_libs opencv_calib3d.2.4.9 opencv_contrib.2.4.9 opencv_core.2.4.9 opencv_features2d.2.4.9 opencv_flann.2.4.9 opencv_gpu.2.4.9 opencv_highgui.2.4.9 opencv_ imgproc.2.4.9 opencv_legacy.2.4.9 opencv_ml.2.4.9 opencv_nonfree.2.4.9 opencv_objdetect.2.4.9 opencv_ocl.2.4.9 opencv_photo.2.4.9 opencv_stitching.2.4.9 opencv_superres.2.4.9 opencv_video.2.4.9 opencv_videostab.2.4.9)

Target_link_libraries (${project_name} ${opencv_libs})

# You can also output variable names to detect whether the assignment is correct message
(STATUS "opencv_libs:" ${ Opencv_libs})

can refer to:
StackOverflow Discussion
CMake Official documents

attached: OpenCV2.4 and 3.0 changes in Machine Learning module
Official Document: Changes overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.