简体   繁体   中英

OpenCV project doesn't compile

I have this code that compiled perfectly, but had to format my machine and now it will not compile, a window pops up "The application failed to initialize properly (0xc0150002). Click OK to close the application."

Does anyone know how to solve this problem?

Below the code and log visual studio. I am using visual studio express 2010, windows 8.

Code:

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

using namespace cv;

int main ( int argc, char **argv )
{
Mat im_gray;
Mat img_bw;
Mat img_final;

Mat im_rgb  = imread("img.jpg");
cvtColor(im_rgb,im_gray,CV_RGB2GRAY);


adaptiveThreshold(im_gray, img_bw, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY_INV, 105, 1);


dilate(img_bw, img_final, Mat(), Point(-1, -1), 5, 1, 1);

imwrite("img_final.jpg", img_final);

return 0;

}

Output:

'opencv.exe': Loaded 'C:\Users\Anne\Documents\opencv\Debug\opencv.exe', Symbols loaded.
'opencv.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Users\Anne\Documents\opencv\opencv\opencv_core230d.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Users\Anne\Documents\opencv\opencv\opencv_highgui230d.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Users\Anne\Documents\opencv\opencv\opencv_imgproc230d.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'opencv.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
'opencv.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.9200.16658_none_bf1359a245f1cd12\comctl32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\avifil32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\msvfw32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\avicap32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\OpenCV2.3\build\x86\vc9\bin\tbb_debug.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\combase.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\sechost.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\winmm.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\msacm32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\shell32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:\Windows\System32\version.dll', Cannot find or open the PDB file
The program '[2112] opencv.exe: Native' has exited with code -1072365566 (0xc0150002).

Update:

I followed this and solved my problem. Now everything is working normally. Thank you all for the help. http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windowssetpathandenviromentvariable

I've test this code (your code with minor edition) and it works fine:

#include <opencv2/opencv.hpp>
using namespace cv;
int main ( int argc, char **argv )
{
    Mat im_gray;
    Mat img_bw;
    Mat img_final;
    Mat im_rgb  = imread("D:\\ImagesForTest\\lena.jpg");
    cvtColor(im_rgb,im_gray,cv::COLOR_RGB2GRAY);
    adaptiveThreshold(im_gray, img_bw, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY_INV, 105, 1);
    dilate(img_bw, img_final, Mat(), Point(-1, -1), 5, 1, 1);
    imwrite("img_final.jpg", img_final);
    return 0;
}

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