【发布时间】:2014-11-09 10:02:30
【问题描述】:
我正在使用安装教程末尾提供给您的示例源代码测试 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++ > General
C:\opencv\build\include\opencv
C:\opencv\build\include\opencv2
C:\opencv\build\include
我已将以下内容添加到链接器 > 常规 > 附加库目录:
C:\opencv\build\x646\vc11\lib
以及链接器 > 输入的库(尤其是返回加载错误的库,nvidia 除外)。我还在环境变量中添加了 vc11\bin 路径。
我尝试使用 cin.get() 强制暂停,但它不起作用。这是否与某些 DLL 返回的加载错误有关?
谁能指出我正确的方向?感谢阅读!
【问题讨论】:
标签: c++ opencv visual-c++