Install opencv2.4.9 and configure it in Visual Studio 2013

Source: Internet
Author: User
Install opencv2.4.9 and configure and download opencv in Visual Studio 2013 and install it in Windows:

The latest version of opencv is opencv2.4.9 of 2014.4.25. Select the latest version. Click opencv for Windows to download the file.

After the download is complete, double-click the icon

The following prompt box appears.

Select the location where you want to save opencv and extract internal files. I will save opencv in the contact folder for getting started with video analysis. (Note: After opencv is extracted, the size is 3.7 GB, so make sure there is enough space)

The build folder is compiled for use. The sources file is the source code. If you want to build your own library on the basis of opencv, you can build a branch on GitHub, address https://github.com/Itseez/opencv

After extracting the file, you must configure the environment variable. In the configuration procedure, choose computer> right-click Properties> advanced system Settings> Advanced Settings> Configure environment variables.

Add

"G: \ video analysis getting started exercise \ opencv \ build \ x64 \ vc12 \ bin"

And "G: \ video analysis getting started exercise \ opencv \ build \ x86 \ vc12 \ bin"

Note: I installed opencv on "G: \ video analysis getting started exercise \ opencv" to get two opencv, which is a little redundant.

Note: Select vc12, which means Visual Studio 2013. The reason why Visual Studio 2013 is selected is that version 13 is better than the previous version (new version can be used ).

The environment variable has been added. You need to log out or restart it to make it take effect !!

 

Configure in Visual Studio 2013

Create a project and select console application

Click Next

Hook up an empty project

Right-click the source file and choose add new item,

Name the new item. Here, the name is main.

Click project> properties.

Reference Directory Configuration

Select Configuration properties-> VC ++ directory-> include directory

Add the above G: \ video analysis getting started exercise \ opencv \ build \ include

G: \ getting started with video analysis \ opencv \ build \ include \ opencv

G: \ getting started with video analysis \ opencv \ build \ include \ opencv2

These three directories. (Different opencv directories are added here)

Library directory configuration: Same as just now, but add

Add

G: \ getting started with video analysis \ opencv \ build \ x64 \ vc12 \ Lib

G: \ getting started with video analysis \ opencv \ build \ x86 \ vc12 \ Lib

Two directories (different opencv directories, and different directories are added here)

Link Library Configuration

Project --> Property --> Configuration Property --> linker --> input --> additional dependency

For opencv2.4.9, add the following lib (in this Order, 19 debug lib with D are written in front, and 19 release without D are written in the back ):

 

Opencv_ml249d.lib
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


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
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

 

Copy and paste it.

 

Note that the pasted content is the previously decompressed opencv directory.

G: \ getting started with video analysis \ opencv \ build \ x86 \ vc12 \ bin

The debug file library name ends with "D" and "release" does not.

 

Test successful:

The test code is as follows: (if the configuration is successful, the image will be displayed normally)

 

# Include <iostream> # include <opencv2/CORE/core. HPP> # include <opencv2/highgui. HPP> using namespace CV; int main () {// read an image (original game image), image, and Main. CPP is located in the same directory mat IMG = imread ("zh.png"); // display the original game image imshow ("zhonghuan", IMG) in the window ); // Let the program wait for waitkey ();}


 

The image is displayed normally as follows:

 

If some problems occur, check:

1. Check whether the environment variables are correctly configured.

2. Contains the directory. Is the library directory correct?

3. Is the dependency attached to the linker correct.

If the check is complete and the confirmation is correct, please leave a message for discussion.

Related Article

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.