标签:int img 自动 src key legacy main alt 技术
配置环境变量
1、系统变量 Path:添加D:\Program Files\opencv\build\x86\vc12\bin
2、用户变量:添加opencv变量,值D:\Program Files\opencv\build,添加PATH变量(有就不需要添加,但是值需要添加)值D:\Program Files\opencv\build\x86\vc12\bin
说明:不管你系统是32位还是64位,路径目录均选择X86,因为编译都是使用32位编译;如果选用X64,则程序运行时候会出错。
新建visual C项目
新建 visual C++项目,如下图所示,项目选项注意:如下图。
工程目录的配置(Debug)
找到属性管理器,如果找不到,请安装下图方法找到。双击Debug|Win32打开如下窗口,
设置如下:(下图红框项为设置项)
1、包含目录:(VC++目录)
D:\Program Files\opencv\build\include
D:\Program Files\opencv\build\include\opencv
D:\Program Files\opencv\build\include\opencv2
2、库目录:(VC++目录)D:\Program Files\opencv\build\x86\vc12\lib
3、连接器->输入->附加依赖项:
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
其实以上都是D:\Program Files\opencv\build\x86\vc12\lib下所有的lib文件,你会发现,有的后面带上d,有的没有d,这是因为Debug的就有d,Release则没有d。
工程目录的配置(Release)
其他与Debug一样,只是连接器->输入->附加依赖项不一样,设置如下:
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
最终的测试
1、新建一个cpp文件,如下图:在cpp文件上输入以下代码:
#include<iostream> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> using namespace cv; using namespace std; int main() { // 读入一张图片(游戏原画) Mat img= imread("pic.jpg"); // 创建一个名为 "游戏原画"窗口 cvNamedWindow("游戏原画"); // 在窗口中显示游戏原画 imshow("游戏原画",img); // 等待6000 ms后窗口自动关闭 waitKey(6000); }
标签:int img 自动 src key legacy main alt 技术
原文地址:http://www.cnblogs.com/love29850706/p/6291174.html