我正在使用安装教程结尾处给出的示例源代码测试OpenCV 2.4.10。代码编译,但它在启动后很快就会退出。我看到第一个" cout消息"的闪光,但我甚至看不到图像加载的闪光或其他任何东西。我正在使用Visual Studios 2012 C ++和OpenCV 2.4.10。
测试代码:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread("opencv-logo.png", IMREAD_COLOR); // Read the file
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;
}
当我构建它时,我无意中加载了一些不必要的DLL,可能是由于之前项目的全局设置。一些负载给我这个错误:
'test.exe' (Win32): Loaded 'C:\opencv\build\x64\vc11\bin\opencv_highgui2410d.dll'. Cannot find or open the PDB file.
'test.exe' (Win32): Loaded 'C:\opencv\build\x64\vc11\bin\opencv_core2410d.dll'. Cannot find or open the PDB file.
'test.exe' (Win32): Loaded 'C:\Program Files\NVIDIA Corporation\coprocmanager\_etoured.dll'. Cannot find or open the PDB file.
'test.exe' (Win32): Loaded 'C:\Program Files\NVIDIA Corporation\coprocmanager\Nvd3d9wrapx.dll'. Cannot find or open the PDB file.
'test.exe' (Win32): Loaded 'C:\Program Files\NVIDIA Corporation\coprocmanager\nvdxgiwrapx.dll'. Cannot find or open the PDB file.
'test.exe' (Win32): Loaded 'C:\Windows\System32\guard64.dll'. Cannot find or open the PDB file.
程序退出时:
The program '[9084] test.exe' has exited with code -1 (0xffffffff).
我不确定这里发生了什么,我已将以下内容添加到C / C ++&gt;一般
C:\opencv\build\include\opencv
C:\opencv\build\include\opencv2
C:\opencv\build\include
我已将以下内容添加到链接器&gt;一般&gt;其他图书馆馆目:
C:\opencv\build\x646\vc11\lib
这些库(特别是那些返回加载错误的库,除了nvidia的库)到Linker&gt;输入。我还在环境变量中添加了vc11 \ bin路径。
我尝试过使用cin.get()强制暂停,但它不起作用。这是否与某些DLL正在返回的加载错误有关?
有人能指出我正确的方向吗?谢谢你的阅读!
答案 0 :(得分:1)
在主要步骤开始时设置一个断点,直到崩溃为止。我的猜测是你的图像无法加载,因为它没有被找到,或者它的格式是opencv无法识别的