Programming Experience: About OPENCV source Debugging Good Article reprint ~

Source: Internet
Author: User
Tags win32 visual studio

So long to see the configuration of the article on the Opencv+vs+cmake, especially about the OpenCV source debugging articles, a few two write the best, so reproduced to share to everyone, I hope you do not spend "unnecessary" time in the configuration.


First article: "VS2010 recompile OpenCV2.4.9 for debugging source code", http://blog.csdn.net/szlcw1/article/details/38489311.

1. Tools

Download and install these tools: CMake2.8, OpenCV2.4.9, VS2010 2, OpenCV2.4.9 solution with CMake generation VS2010

Basically follow the article "WIN7X64+VS2012+OPENCV2.4.3+CMAKE2.8.10+TBB41 recompile OpenCV" to operate.

Here, click the Configure button, select Visual Studio 10 in the dialog box that appears, and it looks like the new version doesn't need to be configured for TBB anymore, so just be careful:

(1) Set the source code path.

(2) Set the build path.

(3) Click Configure until there is no red bar, click Generate to generate Project projects.



3. Open the OPENCV project and compile the source code to generate the dynamic link library we need

Note here:

(1) You should select the All_build project and right click "Generate" instead of install.

(2) The project is generated in debug mode and release mode respectively.


(3) If link:fatal error LNK1181 occurred during the build: Cannot open input file ". \.. \lib\release\opencv_ocl249.lib ", then the Lib generation is not successful, the specific solution estimates are similar, can refer to this article (do not understand cmake hurt AH. )。


4. Configuring OPENCV Environment variables

Note that this is not the same as the above article, it is estimated that the OPENCV version of the reasons for the upgrade, resulting in a different configuration,

The environment variable path should add the following two paths:
D:\Program Files\opencv2.4.9\vc10solution\bin\debug and D:\Program files\opencv2.4.9\vc10solution\bin\release

Note: D:\Program files\opencv2.4.9\vc10solution is the directory where I built the VS2010 project with CMake.

Note: The previous use of OPENCV self-compiled version of attention, you should delete the original environment variables and then add. I did not delete at the beginning of the debugging is not successful, even if the source code can be traced, but as long as the function parameter is a const string& function, the string will not be passed normally, debugging found that the function parameter is always a < error pointer;, cannot be assigned a value. The specific reason does not understand very much, but toss a whole day.


5. Create test Project 5.1 Adding a new project property sheet

Create a new test engineering TESTOPENCV, and in the property manager, select Debug | Win32, right-click on "Add New project property sheet" and name it opencv249x86. Debug, same in Release | Create a new project property sheet at Win32 and name it opencv249x86. Release(PS: You can save these two project property sheets, when you need to create a new project, directly copied to the project, and added to the good. )


5.2 Configuration contains directory and library directories

Double-click the newly created Project property sheet opencv249x86. Debug, in the VC + + directory, including directories, VC + + directory to set up the library directory:

VC + + Directory includes:

D:\Program Files\opencv2.4.9\vc10solution\install\include

D:\Program FILES\OPENCV2.4.9\VC10SOLUTION\INSTALL\INCLUDE\OPENCV

D:\Program Files\opencv2.4.9\vc10solution\install\include\opencv2

VC + + Directory---Library directory:

D:\Program Files\opencv2.4.9\vc10solution\lib\debug



5.3 Adding additional dependencies

Add at additional dependencies, input, linker:

Opencv_calib3d249d.lib
Opencv_contrib249d.lib
Opencv_core249d.lib
Opencv_features2d249d.lib
Opencv_flann249d.lib
Opencv_gpu249d.lib
Opencv_highgui249d.lib
Opencv_imgproc249d.lib
Opencv_legacy249d.lib
Opencv_objdetect249d.lib
Opencv_ts249d.lib
Opencv_video249d.lib
Opencv_nonfree249d.lib
Opencv_ocl249d.lib
Opencv_photo249d.lib
Opencv_stitching249d.lib
Opencv_superres249d.lib
Opencv_videostab249d.lib


Similarly, in opencv249x86. A similar setting is also in Release:

VC + + Directory includes:

D:\Program Files\opencv2.4.9\vc10solution\install\include

D:\Program FILES\OPENCV2.4.9\VC10SOLUTION\INSTALL\INCLUDE\OPENCV

D:\Program Files\opencv2.4.9\vc10solution\install\include\opencv2

VC + + Directory---Library directory:

D:\Program Files\opencv2.4.9\vc10solution\lib\release

Add at additional dependencies, input, linker:

Opencv_calib3d249.lib
Opencv_contrib249.lib
Opencv_core249.lib
Opencv_features2d249.lib
Opencv_flann249.lib
Opencv_gpu249.lib
Opencv_highgui249.lib
Opencv_imgproc249.lib
Opencv_legacy249.lib
Opencv_ml249.lib
Opencv_objdetect249.lib
Opencv_ts249.lib
Opencv_video249.lib
Opencv_nonfree249.lib
Opencv_ocl249.lib
Opencv_photo249.lib
Opencv_stitching249.lib
Opencv_superres249.lib
Opencv_videostab249.lib

At this point, all of our configuration has been completed, the main difference from the article where the environment variable path, contains a different library directory .


5.4 Adding test code

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.