I am an opencv, C++, and eclipse CDT starter. I was following a tutorial to learn opencv. However, although I succeeded in compiling my program, it crashed soon after execution. I read through many related Q&A but didn't get a working solution. Any suggestion is highly appreciated. Below is some specification for your reference:
Replaced the OpenCVTest.cpp file content with the following content:
#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], CV_LOAD_IMAGE_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", CV_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;
}
Built the project and got the following console output (assumed successful):
Info: Internal Builder is used for build g++ "-IC:\opencv\build\include" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\OpenCVTest.o" "..\src\OpenCVTest.cpp" g++ "-LC:\opencv\build\x86\mingw\lib" -o OpenCVTest.exe "src\OpenCVTest.o" -lopencv_core246 -lopencv_highgui246 -lopencv_imgproc246
Ran the generated .exe without passing a image path (should be working) and the program crashed with the following prompt:
Problem signature: Problem Event Name: APPCRASH Application Name: OpenCVTest.exe Application Version: 0.0.0.0 Application Timestamp: 5230da00 Fault Module Name: libstdc++-6.dll Fault Module Version: 0.0.0.0 Fault Module Timestamp: 522c646d Exception Code: c0000005 Exception Offset: 0001df4b OS Version: 6.1.7600.2.0.0.256.48 Locale ID: 1033 Additional Information 1: 4c0d Additional Information 2: 4c0d4d78887f76d971d5d00f1f20a433 Additional Information 3: 4c0d Additional Information 4: 4c0d4d78887f76d971d5d00f1f20a433
Turns out it was not due to the libstdc++-6.dll. The answer of the related thread: OpenVC 2.4.5, eclipse CDT Juno, MinGW error 0xc0000005 actually had solved my problem. I didn't succeed because I left both the pre-built (that came along with opencv download) opencv libraries (*.dll) and the re-built (according to the above solution) libraries exposed under system path. As a result, my program used the pre-built version and ignored the new builds. After I replaced the pre-built *.dll's with the re-built ones, the program ran without any issue.