OpenCV错误:“无法加载图片!" [英] OpenCV error: "Cannot load image!"

查看:70
本文介绍了OpenCV错误:“无法加载图片!"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编译OpenCV的源并将Windows 7和VS2010配置为正确链接库之后,我能够编译以下代码:

After compiling OpenCV's source and configuring Windows 7 and VS2010 to link the libraries correctly, I was able to compile the following code:

#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;
int main()
{
    Mat im = imread("C:\projects\cvtest3\lena.jpg"); // this *is* the proper path, I'm sure

    if (im.empty()) 
    {

        cout << "Cannot load image!" << endl;
                while (true){}
        return -1;
    }
    imshow("Image", im);
    waitKey(0);
}

即使正确指定了路径,我也无法获得此代码来显示lena图像.这里的代码有什么问题吗?

Even though the path is correctly specified I can't get this code to show the lena image. Is there anything wrong with the code here?

尽管代码可以编译,但这是构建时的完整输出:

Although the code compiles, this is the full output while building:

'cvtest3.exe': Loaded 'C:\projects\cvtest3\Debug\cvtest3.exe', Symbols loaded.
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Users\antonio\Documents\opencv_build_32bits\install\bin\opencv_core249d.dll', Symbols loaded.
'cvtest3.exe': Loaded 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\cudart32_50_35.dll', Binary was not built with debug information.
'cvtest3.exe': Loaded 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\npp32_50_35.dll', Binary was not built with debug information.
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Users\antonio\Documents\opencv_build_32bits\install\bin\opencv_highgui249d.dll', Symbols loaded.
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149af\comctl32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\avifil32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\msacm32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\msvfw32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\avicap32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
The thread 'Win32 Thread' (0x2028) has exited with code -1073741510 (0xc000013a).

推荐答案

尝试以下代码:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace std;
using namespace cv;

int main()
{
  Mat image = imread("C:\\projects\\cvtest3\\lena.jpg");
  if(image.empty())
    return -1;
  imshow("TEST",image);
  waitKey();

  return 0;
}

  1. 尝试使用最新的Opencv 2.4.3
  2. 链接适当的库
  3. 正确添加包含路径
  4. 将bin文件夹的路径添加到环境变量路径

这篇关于OpenCV错误:“无法加载图片!"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆