我想在 Visual Studio 2013 中编译一个 opencv 控制台 C++ 程序。这是我的代码:
#include "stdafx.h"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, const char** argv)
{
Mat img = imread("rgb_1.png", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "MyPic.JPG" and store it in 'img'
if (img.empty()) //check whether the image is loaded or not
{
cout << "Error : Image cannot be loaded..!!" << endl;
//system("pause"); //wait for a key press
return -1;
}
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window
waitKey(0); //wait infinite time for a keypress
destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"
return 0;
}
尽管我已经在 Computer 和 Visual Studio 目录的属性中定义了所有目录,但出现以下错误:
“程序无法启动,因为您的计算机中缺少 opencv_world300.dll。”
我该如何解决这个问题?
原文由 yusuf 发布,翻译遵循 CC BY-SA 4.0 许可协议
在 windows 下,您可以从以下位置复制它:
并将其放入您的 Visual Studio 解决方案中(我假设您使用的是 x64/Release 配置):
或者你可以将上面的 OpenCV 添加到你的 PATH 环境变量中