环境
win8
VS2017或VS2013
opencv 3.2.0
配制环境变量
- 解压opencv到某个目录,比如D:ProgramUninstall,把设置OPENCV_HOME为D:ProgramUninstallopencv320opencvuild
2.添加 %OPENCV%in;%OPENCV%x64vc14in到path,这是为了程序在运行时能找到opencv要用的dll
测试程序
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char **argv)
{
Mat img = imread("2.png");
if (img.empty())
{
cout << "adafd" << endl;
return -1;
}
namedWindow("image", CV_WINDOW_AUTOSIZE);
imshow("image", img);
waitKey();
return 0;
}
用以下命令编译链接,可以生成可执行文件.
cl /I D:ProgramUninstallopencv320opencvuildinclude D:ProgramUninstallopencv320opencvuildx64vc14lib*.lib HelloOpencv.cpp /source-charset:utf-8
/I指定了头文件的位置.后面跟的是lib文件的位置./source-charset:utf-8指定utf8编码.