OpenCV 错误:"Cannot load image!"



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

#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
    Mat im = imread("C:projectscvtest3lena.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图像。这里的代码有什么问题吗?

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

'cvtest3.exe': Loaded 'C:projectscvtest3Debugcvtest3.exe', Symbols loaded.
'cvtest3.exe': Loaded 'C:WindowsSysWOW64ntdll.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64kernel32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64KernelBase.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:UsersantonioDocumentsopencv_build_32bitsinstallbinopencv_core249d.dll', Symbols loaded.
'cvtest3.exe': Loaded 'C:Program FilesNVIDIA GPU Computing ToolkitCUDAv5.0bincudart32_50_35.dll', Binary was not built with debug information.
'cvtest3.exe': Loaded 'C:Program FilesNVIDIA GPU Computing ToolkitCUDAv5.0binnpp32_50_35.dll', Binary was not built with debug information.
'cvtest3.exe': Loaded 'C:WindowsSysWOW64msvcp100d.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64msvcr100d.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:UsersantonioDocumentsopencv_build_32bitsinstallbinopencv_highgui249d.dll', Symbols loaded.
'cvtest3.exe': Loaded 'C:WindowsSysWOW64user32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64gdi32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64lpk.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64usp10.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64msvcrt.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64advapi32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64sechost.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64rpcrt4.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64sspicli.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64cryptbase.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64ole32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64oleaut32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:Windowswinsxsx86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149afcomctl32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64avifil32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64winmm.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64msacm32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64msvfw32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64shell32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64shlwapi.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64avicap32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64version.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64imm32.dll', Cannot find or open the PDB file
'cvtest3.exe': Loaded 'C:WindowsSysWOW64msctf.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. 尝试使用2.4.3版本的最新opencv
  2. 链接适当的库
  3. 正确添加包含路径
  4. 将bin文件夹的路径添加到环境变量路径

相关内容

  • 没有找到相关文章

最新更新