本人亲测opencv2.4.4 在win7 32/64位 vs2012
win8 32/64位 vs2012 可行
(1)系统环境变量设置
右键单击->我的电脑->选择属性->高级系统设置->环境变量
用户PATH:D:\Program Files (x86)\opencv\build\x86\vc11\bin;
用户OPENCV: D:\Program Files (x86)\opencv\build
系统PATH: D:\Program Files (x86)\opencv\build\x86\vc11\bin;
(2)VS设置
1新建项目->win32控制台项目->完成
2视图->属性管理器(VS2012再其他窗口中)
3单击"Debuge|Win32"->双击"Microsoft.Cpp.Win32.user"
4单击"VC++目录"
配置如下:
a可执行文件: D:\Program Files (x86)\opencv\build\x86\vc11\bin;
b包含目录:
D:\Program Files (x86)\opencv\build\include
D:\Program Files (x86)\opencv\build\include\opencv
D:\Program Files (x86)\opencv\build\include\opencv2
c库目录: D:\Program Files (x86)\opencv\build\x86\vc11\lib
5单击"链接器"->"输入"
opencv_calib3d2411.lib
opencv_calib3d2411d.lib
opencv_contrib2411.lib
opencv_contrib2411d.lib
opencv_core2411.lib
opencv_core2411d.lib
opencv_features2d2411.lib
opencv_features2d2411d.lib
opencv_flann2411.lib
opencv_flann2411d.lib
opencv_gpu2411.lib
opencv_gpu2411d.lib
opencv_highgui2411.lib
opencv_highgui2411d.lib
opencv_imgproc2411.lib
opencv_imgproc2411d.lib
opencv_legacy2411.lib
opencv_legacy2411d.lib
opencv_ml2411.lib
opencv_ml2411d.lib
opencv_nonfree2411.lib
opencv_nonfree2411d.lib
opencv_objdetect2411.lib
opencv_objdetect2411d.lib
opencv_ocl2411.lib
opencv_ocl2411d.lib
opencv_photo2411.lib
opencv_photo2411d.lib
opencv_stitching2411.lib
opencv_stitching2411d.lib
opencv_superres2411.lib
opencv_superres2411d.lib
opencv_ts2411.lib
opencv_ts2411d.lib
opencv_video2411.lib
opencv_video2411d.lib
opencv_videostab2411.lib
opencv_videostab2411d.lib
6确定完成
(3)测试程序:
#include "stdafx.h"
#include "opencv/cv.h"
#include "opencv/cxcore.h"
#include "opencv/highgui.h"
#include "opencv/cvwimage.h"
int _tmain(int argc, _TCHAR* argv[])
{
IplImage* img = cvLoadImage("E:\\songwentaosb.jpg");
cvNamedWindow("example1",CV_WINDOW_AUTOSIZE);
cvShowImage("example1",img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("example1");
return 0;
}
另:vs2012编译错误:
error C4996: 'fopen': This function or variable may be unsafe.
解决方法:
在预编译头文件stdafx.h里(注意:一定要在没有include任何头文件之前)添加:
#define _CRT_SECURE_NO_DEPRECATE
(4)常用头文件:
#include "opencv/cv.h"
#include "opencv/cxcore.h"
#include "opencv/highgui.h"
#include "opencv/cvwimage.h"
#include "CchoosDialog.h"
#pragma comment(lib,"opencv_core244.lib")
#pragma comment(lib,"opencv_highgui244.lib")
#pragma comment(lib,"opencv_imgproc244.lib")
win8 32/64位 vs2012 可行
(1)系统环境变量设置
右键单击->我的电脑->选择属性->高级系统设置->环境变量
用户PATH:D:\Program Files (x86)\opencv\build\x86\vc11\bin;
用户OPENCV: D:\Program Files (x86)\opencv\build
系统PATH: D:\Program Files (x86)\opencv\build\x86\vc11\bin;
(2)VS设置
1新建项目->win32控制台项目->完成
2视图->属性管理器(VS2012再其他窗口中)
3单击"Debuge|Win32"->双击"Microsoft.Cpp.Win32.user"
4单击"VC++目录"
配置如下:
a可执行文件: D:\Program Files (x86)\opencv\build\x86\vc11\bin;
b包含目录:
D:\Program Files (x86)\opencv\build\include
D:\Program Files (x86)\opencv\build\include\opencv
D:\Program Files (x86)\opencv\build\include\opencv2
c库目录: D:\Program Files (x86)\opencv\build\x86\vc11\lib
5单击"链接器"->"输入"
opencv_calib3d2411.lib
opencv_calib3d2411d.lib
opencv_contrib2411.lib
opencv_contrib2411d.lib
opencv_core2411.lib
opencv_core2411d.lib
opencv_features2d2411.lib
opencv_features2d2411d.lib
opencv_flann2411.lib
opencv_flann2411d.lib
opencv_gpu2411.lib
opencv_gpu2411d.lib
opencv_highgui2411.lib
opencv_highgui2411d.lib
opencv_imgproc2411.lib
opencv_imgproc2411d.lib
opencv_legacy2411.lib
opencv_legacy2411d.lib
opencv_ml2411.lib
opencv_ml2411d.lib
opencv_nonfree2411.lib
opencv_nonfree2411d.lib
opencv_objdetect2411.lib
opencv_objdetect2411d.lib
opencv_ocl2411.lib
opencv_ocl2411d.lib
opencv_photo2411.lib
opencv_photo2411d.lib
opencv_stitching2411.lib
opencv_stitching2411d.lib
opencv_superres2411.lib
opencv_superres2411d.lib
opencv_ts2411.lib
opencv_ts2411d.lib
opencv_video2411.lib
opencv_video2411d.lib
opencv_videostab2411.lib
opencv_videostab2411d.lib
6确定完成
(3)测试程序:
#include "stdafx.h"
#include "opencv/cv.h"
#include "opencv/cxcore.h"
#include "opencv/highgui.h"
#include "opencv/cvwimage.h"
int _tmain(int argc, _TCHAR* argv[])
{
IplImage* img = cvLoadImage("E:\\songwentaosb.jpg");
cvNamedWindow("example1",CV_WINDOW_AUTOSIZE);
cvShowImage("example1",img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("example1");
return 0;
}
另:vs2012编译错误:
error C4996: 'fopen': This function or variable may be unsafe.
解决方法:
在预编译头文件stdafx.h里(注意:一定要在没有include任何头文件之前)添加:
#define _CRT_SECURE_NO_DEPRECATE
(4)常用头文件:
#include "opencv/cv.h"
#include "opencv/cxcore.h"
#include "opencv/highgui.h"
#include "opencv/cvwimage.h"
#include "CchoosDialog.h"
#pragma comment(lib,"opencv_core244.lib")
#pragma comment(lib,"opencv_highgui244.lib")
#pragma comment(lib,"opencv_imgproc244.lib")