openCV 与 Visual Studio 2013 年的集成

openCV Integration with Visual Studio 2013 issue

首先感谢阅读。我浏览了很多关于如何在 VS2013 中安装 openCV 的教程。我想我正确地遵循了所有步骤,但最后当我 运行 控制台 win32 应用程序 c++ 时,我得到了这个错误:

'openCV.exe' (Win32): Loaded 'C:\Users\GASTON\Documents\Visual Studio 2013\Projects\openCV\x64\Debug\openCV.exe'. Symbols loaded.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Users\GASTON\Documents\opencv\build\x64\vc11\bin\opencv_highgui2410d.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Users\GASTON\Documents\opencv\build\x64\vc11\bin\opencv_core2410d.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\msvcp120d.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\msvcr120d.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\oleaut32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\comctl32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\msvfw32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\avifil32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\avicap32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\msvcp110d.dll'. Symbols loaded.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\msvcr110d.dll'. Symbols loaded.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\winmm.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\msacm32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\winmmbase.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\cfgmgr32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\devobj.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Cannot find or open the PDB file.
'openCV.exe' (Win32): Loaded 'C:\Windows\System32\msctf.dll'. Cannot find or open the PDB file.
The program '[5168] openCV.exe' has exited with code -1 (0xffffffff).

我不明白为什么 VS 无法加载库,因为我进行了所有配置(至少我认为如此)

我的全局变量是:

PATH= "C:\Users\GASTON\Documents\opencv\build\x64\vc11\bin";

open 的安装位置。

这是我的代码main.cpp

#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(argv[1], 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;
}

vc11 适用于 VS2012,对于 VS2013,你应该使用 vc12.

针对您的情况,更改

PATH= "C:\Users\GASTON\Documents\opencv\build\x64\vc11\bin";

PATH= "C:\Users\GASTON\Documents\opencv\build\x64\vc12\bin";

p.s.: 还要确保您的项目是在 x64 平台下构建的。

我正在阅读,上面的行并不意味着错误。错误 -1 是另一个,发生的原因是代码是 get int if (argc != 2) 导致实际上没有收到任何参数(错误只是为了做而不是想:P)所以给一个图像作为参数一切正常完美。很抱歉打扰你们,希望这对遇到同样问题的其他人有所帮助 =)

此外感谢@herohuyongtao vc11 用于 VS2012,对于 VS2013,你应该使用 vc12.

针对您的情况,更改

路径="C:\Users\GASTON\Documents\opencv\build\x64\vc11\bin"; 至

路径="C:\Users\GASTON\Documents\opencv\build\x64\vc12\bin"; p.s.: 还要确保你的项目是在x64平台下构建的。