OpenCV 项目无法编译

OpenCV project doesn't compile

本文关键字:编译 项目 OpenCV      更新时间:2023-10-16

我有这段代码编译得很好,但必须格式化我的机器,现在它无法编译,弹出一个窗口"应用程序未能正确初始化(0xc0150002)。单击"确定"关闭应用程序。"

有人知道如何解决这个问题吗?

下面的代码和日志可视化工作室。我使用的是visualstudioexpress2010,windows8。

代码:

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

}

输出:

'opencv.exe': Loaded 'C:UsersAnneDocumentsopencvDebugopencv.exe', Symbols loaded.
'opencv.exe': Loaded 'C:WindowsSystem32ntdll.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32kernel32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32KernelBase.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:UsersAnneDocumentsopencvopencvopencv_core230d.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:UsersAnneDocumentsopencvopencvopencv_highgui230d.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:UsersAnneDocumentsopencvopencvopencv_imgproc230d.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32msvcp100d.dll', Symbols loaded.
'opencv.exe': Loaded 'C:WindowsSystem32msvcr100d.dll', Symbols loaded.
'opencv.exe': Loaded 'C:WindowsSystem32user32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32gdi32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32ole32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32oleaut32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32advapi32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsWinSxSx86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.9200.16658_none_bf1359a245f1cd12comctl32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32avifil32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32msvfw32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32avicap32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:OpenCV2.3buildx86vc9bintbb_debug.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32combase.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32msvcrt.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32rpcrt4.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32sechost.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32winmm.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32msacm32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32shell32.dll', Cannot find or open the PDB file
'opencv.exe': Loaded 'C:WindowsSystem32version.dll', Cannot find or open the PDB file
The program '[2112] opencv.exe: Native' has exited with code -1072365566 (0xc0150002).

更新:

我照做了,解决了我的问题。现在一切正常。谢谢大家的帮助。http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windowssetpathandenviromentvariable

我已经测试了这个代码(您的代码有小版本),它运行良好:

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