每次我将编译好的OpenCV程序运行都会报错,下面是恶心的错误提示窗口:
我将opencv_world310d.dll放到工程文件夹下后,程序就运行正常了。虽然这样可以暂时解决问题,但是总是感觉不舒服。我想知道为什么会这样,另外有没有好的解决方案可以彻底解决这个问题,不用每次添加opencv_world310d.dll文件。
如果有人想看代码的话,我这里干脆就放一个OpenCV的测试代码吧。这个代码编译是没问题的,但是在我的电脑上一运行就会出现前面我说的问题。
#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat image;
image = imread("opencv-logo.png", IMREAD_COLOR);
if (!image.data) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}
namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
Note:顺便说一下,我的vs版本是2015,opencv版本是3.1,系统是win10.
PHP中文网2017-04-17 14:59:25
I found a more reasonable answer. First of all, there was no problem when I used OpenCV before, but then there was a problem after the system upgrade, so I think it is likely that the system upgrade caused this problem.
So how to solve it? In fact, it is very simple. Just add the missing dynamic link library to the path C:WindowsSystem32
or C:WindowsSysWOW64
, so that you don’t have to put the dynamic link library in the folder where the project is located every time. Of course, @araraloren's method should also be possible.
大家讲道理2017-04-17 14:59:25
This is the runtime library needed to run the program. If you don’t want to do this, you can compile it statically, but this requires a static opencv
library