OpenCV图像加载程序退出
OpenCV Image Loading Program Exits
我正在使用安装教程末尾提供的示例源代码测试OpenCV 2.4.10。代码会编译,但启动后很快就会退出。我看到了第一条"cout消息"的闪光,但我甚至没有看到加载图像或其他任何东西的闪光。我使用的是Visual Studio 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:opencvbuildx64vc11binopencv_highgui2410d.dll'. Cannot find or open the PDB file.
'test.exe' (Win32): Loaded 'C:opencvbuildx64vc11binopencv_core2410d.dll'. Cannot find or open the PDB file.
'test.exe' (Win32): Loaded 'C:Program FilesNVIDIA Corporationcoprocmanager_etoured.dll'. Cannot find or open the PDB file.
'test.exe' (Win32): Loaded 'C:Program FilesNVIDIA CorporationcoprocmanagerNvd3d9wrapx.dll'. Cannot find or open the PDB file.
'test.exe' (Win32): Loaded 'C:Program FilesNVIDIA Corporationcoprocmanagernvdxgiwrapx.dll'. Cannot find or open the PDB file.
'test.exe' (Win32): Loaded 'C:WindowsSystem32guard64.dll'. Cannot find or open the PDB file.
程序退出时显示:
The program '[9084] test.exe' has exited with code -1 (0xffffffff).
我不太确定这里发生了什么,我已经在C/C++>通用中添加了以下内容
C:opencvbuildincludeopencv
C:opencvbuildincludeopencv2
C:opencvbuildinclude
我已将以下内容添加到Linker>General>Additional Library Directories:
C:opencvbuildx646vc11lib
将库(尤其是返回加载错误的库,英伟达库除外)添加到Linker>Input。我还向环境变量添加了vc11\bin路径。
我试过使用cin.get()来强制暂停,但它不起作用。这与某些DLL返回的加载错误有关吗?
有人能给我指正确的方向吗?感谢阅读!
在主步骤和单个步骤的开始处放置断点,直到它崩溃。我的猜测是,要么是因为找不到图像而无法加载,要么是opencv 无法识别的格式
相关文章:
- 为什么异常不退出程序?
- 虽然循环在使用回车键时不退出程序
- 如果 I/O read() 处于阻塞阶段,如何使用 Ctrl+C 退出 C++ 程序?
- 捕获异常后如何退出程序执行
- 在C++中使用exit()退出程序有问题吗
- 从函数打印 CLI 帮助消息后,我应该如何干净地退出 C++ 程序?
- 如何实现否定用户输入退出程序和打印列表?
- gdb 退出:程序接收信号 SIGILL,使用 gcc / intel_mkl / gfortran -mavx 编译的
- 试图调节我的 do-while 以停止在终端中退出程序.菜单不会根据需要循环使用当前语句
- 如何在C 中按ENTER/返回键时退出程序循环
- 退出程序,默认开关
- 我想让程序保持运行,直到用户输入 n 退出程序
- 我找不到第一个用户输入后立即退出程序的原因
- 安全地退出程序 Win32 C++从分离的 std::线程
- 如何使用QCloseEvent退出程序
- 在主之前退出程序是明确的行为吗?
- C++键盘挂钩-退出程序,但也防止密钥在其他地方被处理
- 在类中运行析构函数时退出程序
- 由于删除 [] 而未退出程序
- 输出缓冲区和Cntrl+C以退出程序