我安装了 visual studio 2012 。我有Windows 8.1.然后我在c分区中提取 opencv 2.4.10 。
创建了visual C ++项目 - > win32控制台应用程序。
因为我有x64机器
build menu->Configuration manager->platform->x64
然后我在我的vs项目中设置了以下配置。
project->properties->configuration->all configuration
VC++Directories->Library Directories->
C:\opencv\build\x64\vc11\bin,C:\opencv\build\x64\vc11\lib
C/C++->Genaral->Additional Include Derectories->
C:\opencv\build\include,C:\opencv\build\include\opencv2,C:\opencv\build\include\opencv
更改
Configuration->Debug
Select Linker->Input->Additional Dependencies
opencv_core2410d.lib
opencv_highgui2410d.lib
opencv_imgproc2410d.lib
opencv_calib3d2410d.lib
opencv_contrib2410d.lib
opencv_features2d2410d.lib
opencv_flann2410d.lib
opencv_gpu2410d.lib
opencv_legacy2410d.lib
opencv_ml2410d.lib
opencv_nonfree2410d.lib
opencv_objdetect2410d.lib
opencv_photo2410d.lib
opencv_stitching2410d.lib
opencv_superres2410d.lib
opencv_ts2410d.lib
opencv_video2410d.lib
然后
change Configuration->Release
select Linker->Input->Additional Dependencies
opencv_core2410.lib
opencv_highgui2410.lib
opencv_imgproc2410.lib
opencv_calib3d2410.lib
opencv_contrib2410.lib
opencv_features2d2410.lib
opencv_flann2410.lib
opencv_gpu2410.lib
opencv_legacy2410.lib
opencv_ml2410.lib
opencv_nonfree2410.lib
opencv_objdetect2410.lib
opencv_photo2410.lib
opencv_stitching2410.lib
opencv_superres2410.lib
opencv_ts2410.lib
opencv_video2410.lib
opencv_videostab2410.lib
然后我创建了一个类并编写了代码
#include "stdafx.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
int main(){
//declare a new iplimage pointer
IplImage*myimage;
//load image
myimage = cvLoadImage("D:\\visual studio 2012\\katussa.jpg",1);
cvNamedWindow("Smile",1);
cvShowImage("Smile",myimage);
//wait for the key to close the window
cvWaitKey(0);
cvDestroyWindow("Smile");
cvReleaseImage(&myimage);
return 0;
}
当我运行时,我收到了错误消息 程序无法启动,因为缺少opencv_core2410d.dll 。
答案 0 :(得分:9)
您需要将OpenCV添加到系统路径:
您需要将目录C:\ opencv \ build \ x86 \ vc10 \ bin添加到系统路径。该目录包含运行代码所需的OpenCV DLL。
打开控制面板→系统→高级系统设置→高级选项卡→环境变量...
在System Variables部分,选择Path(1),Edit(2),然后输入C:\ opencv \ build \ x86 \ vc10 \ bin; (3),然后单击“确定”。
忍者编辑:
确保您已遵循所有 this tutorial
上的步骤答案 1 :(得分:1)
有时,即使将相关bin文件(例如\opencv-x.x.x\build\install\x64\vc15\bin
)添加到系统路径环境变量,也可能会出现此错误。
就我而言,一旦我重新启动电脑,它就能正常工作。或者在重启系统之前,可能只需重新启动visual studio并查看它是否正常工作。