gpt4 book ai didi

c++ - OpenCV 图像加载程序退出

转载 作者:行者123 更新时间:2023-11-28 06:35:37 25 4
gpt4 key购买 nike

我正在使用安装教程末尾提供给您的示例源代码测试 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

我已将以下内容添加到 Linker > General > Additional Library Directories:

C:\opencv\build\x646\vc11\lib

还有库(尤其是返回加载错误的库,nvidia 库除外)到链接器 > 输入。我还在环境变量中添加了 vc11\bin 路径。

我试过使用 cin.get() 强制暂停,但它不起作用。这是否与某些 DLL 返回的加载错误有关?

谁能指出我正确的方向?感谢阅读!

最佳答案

在主步骤和单步骤的开始处放置一个断点,直到它崩溃。我的猜测是您的图像无法加载,因为它未找到,或者它的格式无法被 opencv 识别

关于c++ - OpenCV 图像加载程序退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26827057/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com