Windows下 OpenCV 3.2配置和在VS2015下的简单demo

来源:互联网 发布:公司员工工资表数据 编辑:程序博客网 时间:2024/05/16 08:30



1. Download the opencv 3.2 
   https://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.2.0/opencv-3.2.0-vc14.exe/download
   
2. Unpack
   The downloaded opencv-3.2.0-vc14.exe is self-extractable. 
   You need to double click the exe file and the extracted file/folder named 'opencv' will be found in your local directory.
   
   For example, the unpacked the files are located at folder:
   C:\OpenCV\opencv3.2
   
   
3. set OpenCV environment variables as system variables and add to the system path

3.1 -- set system variables

   OPENCV_DIR = C:\OpenCV\opencv3.2
   OPENCV_VER = 320


3.2 --- set system path
   set the PATH in Windows environment:  
   %OPENCV_DIR%\build\x64\vc14\bin




4. configure VS2015 with customized property


4.1- create a new project property sheet named as 'opencv'



4.2- Add additional dependencies 'opencv_world320d.lib' which is located at C:\OpenCV\opencv3.2\build\x64\vc14\lib. Please refer to the following picture (a) and (b).

(a)


(b)





4.3- Add OpenCV include directory




5. Create a console application with VS2015

    The demo code is as following:

#include "opencv2/core/core.hpp"#include "opencv2/highgui/highgui.hpp"using namespace cv;int main(){    //Read png file    Mat img = imread("G:\\VisualStudio2015\\Projects\\opencvdemo\\1.png");     if (!img.data) {        return -1;    }    namedWindow("Demo", CV_WINDOW_AUTOSIZE);    imshow("Demo", img);    waitKey();    return 0;}


6. Build and run.

     Enjoy!



0 0
原创粉丝点击