OpenCV source code compilation under the Windows platform

Source: Internet
Author: User

OPENCV Library Official site for the http://opencv.org/. At the site can download the latest OpenCV for Windows, such as the current I downloaded is Opencv-2.4.9.exe, double-click the file extracted to a folder, the extracted root folder for the Opencv,opencv folder has 2 sub-folders, The build and Sources,build folders are stored in the compiled library, and the Sources folder is the source code.

Below we will compile the source code in the Sources folder.

In the Sources folder you can see that there is a CMakeLists.txt file, which is used to generate VSProject with CMake.

Click Configure and generate respectively, the VS2008 is installed on my machine, so select VS2008.

You will then be able to see configuration files such as VS resolution in the Cmake-bin folder.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbg1pbmdfmdg=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "align=" Middle ">

Double-click OpenCV.sln to open VS, Project shows a demo like the following:

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbg1pbmdfmdg=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "align=" Top "height=" 583 "width=" 267 ">

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbg1pbmdfmdg=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "align=" Middle ">

Press F7 to compile , then you can go to the toilet. Drink tea or something, (^_^) ∠※

When I came back, I found that there was an error in Project compilation:


1>------Started Build: project: Opencv_python, config: Debug Win32------1> is linking ... 1>link:fatal error LNK1104: Can't open File "Python27_d.lib"
Online Search for the relevant answers are: http://blog.csdn.net/loonger_leon/article/details/5862150

I can't use Python on a temporary basis. So it's just a matter of temporary.

Finally, you can install the OpenCV library into the Cmake-bin/install folder by right-clicking on the build install project. You can later write OPENCV applications to reference library files and header files under the Cmake-bin/install folder.

A reference to facilitate the application. Here we also need environment variable settings. Run on the command line:

Setx-m Opencv_dir F:\OPENCV_CODE\sources\cmake-bin\install

The environment variable of the OPENCV library path is set and can be queried using the SET command

Opencv_dir=f:\opencv_code\sources\cmake-bin\install

In order to facilitate dynamic loading. We need to put the loaded dynamic link library in the PATH environment variable,


Otherwise, it needs to be placed in the same folder as the executable file, and an application is OK. If you have more than one, copy each dynamic library to the same folder as the executable file.


OpenCV source code compilation under the Windows platform

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.