我尝试使用 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()));
}