报错截图及pro文件,代码如下
pro文件
#-------------------------------------------------
#
# Project created by QtCreator 2021-03-28T16:31:53
#
#-------------------------------------------------
QT += core gui
QT += network
QT += multimedia
QT += multimediawidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
FORMS += widget.ui
INCLUDEPATH += /opt/opencv/include \
/opt/opencv/include/opencv \
/opt/opencv/include/opencv2
LIBS += -L/opt/opencv/lib -lopencv_calib3d -lopencv_core -lopencv_dnn -lopencv_features2d \
-lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc \
-lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching \
-lopencv_superres -lopencv_video -lopencv_videoio -lopencv_videostab \
-lopencv_videoio -lopencv_video -lopencv_superres -lopencv_stitching \
-lopencv_shape -lopencv_photo -lopencv_objdetect -lopencv_ml -lopencv_imgproc \
-lopencv_imgcodecs -lopencv_highgui -lopencv_flann -lopencv_features2d \
-lopencv_dnn -lopencv_core -lopencv_calib3d -ldl
LIBS += -L/opt/zlib/lib -lz
#LIBS += /opt/opencv/lib/libopencv_core.a \
# /opt/opencv/lib/libopencv_imgproc.a \
# /opt/opencv/lib/libopencv_imgcodecs.a \
# /opt/opencv/lib/libopencv_flann.a \
# /opt/opencv/lib/libopencv_highgui.a \
# /opt/opencv/lib/libopencv_calib3d.a \
# /opt/opencv/lib/libopencv_ml.a \
# /opt/opencv/lib/libopencv_objdetect.a \
# /opt/opencv/lib/libopencv_photo.a \
# /opt/opencv/lib/libopencv_ml.a \
# /opt/opencv/lib/libopencv_features2d.a \
# /opt/opencv/lib/libopencv_superres.a \
# /opt/opencv/lib/libopencv_videoio.a \
# /opt/opencv/lib/libopencv_video.a \
# /opt/opencv/lib/libopencv_videostab.a \
# /opt/opencv/lib/libopencv_imgproc.a \
# /opt/opencv/lib/libopencv_calib3d.a \
# /opt/opencv/lib/libopencv_core.a \
void Widget::on_CamTest_clicked()
{
cout << "cam test is clicked" << endl;
cout << "Built with OpenCV " << CV_VERSION << endl;
Mat image;
VideoCapture capture;
capture.open(0);
if(capture.isOpened()){
cout << "Capture is opened" << endl;
for(;;){
capture >> image;
QCoreApplication::processEvents();
if(image.empty())
break;
if(waitKey(10) >= 0)
break;
cout << "get a fram pic" << endl;
}
}
else{
cout << "no camera" << endl;
}
}
离线