Learning opencv 2.4.9 (1) --- opencv + vs2012 environment Configuration

Source: Internet
Author: User

Cool liukun321

From: http://blog.csdn.net/liukun321



First obtain the latest opencv 2.4.9 source code: opencv source code download

1. opencv environment variable configuration

1. Install the source code to the specified directory:


2. Add an environment variable for opencv: Computer --> properties click Advanced System settings



3. Click environment variables in the System Properties dialog box.


4. The following dialog box is displayed: select path and click New

5. Click "CREATE" to add an environment variable.



6. Include the opencv2.4.9 variable in the path


2. Check the configuration of vs2012 again.

1. Create a project: select the Win32 console application, name your project, and click OK.


Click Next


2. the Win32 Application Wizard is displayed. Press the selected option and click Finish.




3. Open the property manager of the Project. First, set the debug attribute of the Project, right-click debug | Win32, and select Add new project Attribute Table, for example:


4. Add a name for the attribute to be added --> Add:


5. The following dialog box is displayed to modify the include directory and library directory.

As follows:

6. Replace the content in the directory {opecv} \ build \ include {opencv} with the installation path of opencv.


7. Replace the contents in the library directory {opecv} \ build \ x86 \ vc11 \ Lib {opencv} with the installation path of opencv.



8. Click the shortcut menu in the dialog box below and click input.

 

Modify additional dependencies

9. Add the following content:

Opencv_core249d.lib

Opencv_imgproc249d.lib

Opencv_highgui249d.lib

Opencv_ml249d.lib

Opencv_video249d.lib

Opencv_features2d249d.lib

Opencv_calib3d249d.lib

Opencv_objdetect249d.lib

Opencv_contrib249d.lib

Opencv_legacy249d.lib

Opencv_flann249d.lib


Now, the attributes of the debug version are successfully configured. The release version is similar to the preceding steps. You only need to remove the D character after the additional dependency.


Run a simple opencv test program:

Attach my test source code:

#include <opencv2/opencv.hpp>    using namespace cv;  int main() {    Mat img = imread("../test.jpg",1);  // Mat img = imread("image.jpg");Mat grey;cvtColor(img, grey, CV_BGR2GRAY);Mat sobelx;Sobel(grey, sobelx, CV_32F, 1, 0);double minVal, maxVal;minMaxLoc(sobelx, &minVal, &maxVal); //find minimum and maximum intensitiesMat draw;sobelx.convertTo(draw, CV_8U, 255.0/(maxVal - minVal), -minVal * 255.0/(maxVal - minVal));namedWindow("src(http://blog.csdn.net/liukun321)", CV_WINDOW_AUTOSIZE);imshow("src(http://blog.csdn.net/liukun321)", img);imshow("dst(http://blog.csdn.net/liukun321)", draw);waitKey();     return 0; } 

After running the program:

The


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.