简体   繁体   中英

OpenCV Image Loading Program Exits

I'm testing out OpenCV 2.4.10 using the example source code given to you at the end of the installation tutorial. The code compiles, but it exits really soon after starting. I see a flash of the first "cout message", but I don't see even a flash of an image loading or anything else. I am using Visual Studios 2012 C++ and OpenCV 2.4.10.

Test Code:

#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;
}

When I build it, I inadvertently load some unnecessary DLL's probably due to a global setting from a previous project. Some of the loads give me this error:

'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.

And the program exits with:

The program '[9084] test.exe' has exited with code -1 (0xffffffff).

I'm not exactly sure what is going on here, I've added the following to C/C++ > General

C:\opencv\build\include\opencv
C:\opencv\build\include\opencv2
C:\opencv\build\include

I've added the following to Linker > General > Additional Library Directories:

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

And the libraries (especially the ones returning a load error, except the nvidia ones) to Linker > Input. I've also added the vc11\\bin path to the environment variables.

I've tried using cin.get() to force a pause, but it doesn't work. Does this have something to do with the load errors some of the DLL's are returning?

Can anyone point me in the right direction? Thanks for reading!

Put a breakpoint at the start of your main and single step until it crashes. My guess is that either your image cannot load because it is not found or it is in a format unrecognized by opencv

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM