0

我尝试使用 OpenCV 功能控制我的相机。构建进度很好,但是,当我尝试运行我的程序时它崩溃了,Qt 只提供有关退出代码 -1073741515 的信息。我尝试使用 OpenCV 函数注释所有代码,程序似乎没问题。我包含的库是错误的吗?

opencv.pro

QT       += core gui

TARGET = opencv
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

INCLUDEPATH += F:/opencv/build/include
INCLUDEPATH += F:/opencv/build/include/opencv

LIBS += F:/opencv/build/x86/mingw/lib/libopencv_calib3d231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_contrib231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_core231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_features2d231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_flann231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_gpu231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_highgui231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_imgproc231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_legacy231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_ml231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_objdetect231.dll.a
LIBS += F:/opencv/build/x86/mingw/lib/libopencv_video231.dll.a

主窗口.cpp

由于 MainWindow.cpp 很长,我将在此处粘贴构造函数并在需要时添加其余部分。

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    cam = NULL;
    frame = NULL;
    timer = new QTimer;
    imag = new QImage();
    connect(timer,SIGNAL(timeout()),this,SLOT(readFrame()));
    connect(ui->open,SIGNAL(clicked()),this,SLOT(openCamara()));
    connect(ui->pic,SIGNAL(clicked()),this,SLOT(takingPictures()));
    connect(ui->closeCam,SIGNAL(clicked()),this,SLOT(closeCamara()));
}
4

1 回答 1

0

终于开始工作了!当我尝试从 Windows 资源管理器运行该应用程序时,它抱怨缺少libstdc++-6.dll。虽然存在于 C:\QtSDK\mingw\bin 下,但它的版本对于 OpenCV 2.3 不正确(或任何其他原因?)并会导致错误。我从这里得到了一个,程序运行正常。

于 2012-06-24T06:31:01.773 回答