no such file or directory

核能气质少年 提交于 2021-02-17 05:40:07

问题


i'm trying to get the image from my webcam using qt, opencv here's my codes:

.pro file:

#-------------------------------------------------
#
# Project created by QtCreator 2013-12-20T07:42:20
#
#-------------------------------------------------

QT       += core gui

TARGET = QtCvCapture
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    imagecapture.cpp \
    moc_imagecapture.cpp \
    moc_mainwindow.cpp

HEADERS  += mainwindow.h \
    imagecapture.h \
    ui_mainwindow.h

FORMS    += mainwindow.ui

#include opencv for PC x86
#INCLUDEPATH += /usr/local/include/opencv
#LIBS +=/usr/local/lib/*.so


INCLUDEPATH += C:\opencv\build\include

LIBS += C:\opencv\release\bin\libopencv_core451.dll
LIBS += C:\opencv\release\bin\libopencv_highgui451.dll
LIBS += C:\opencv\release\bin\libopencv_imgcodecs451.dll
LIBS += C:\opencv\release\bin\libopencv_imgproc451.dll
LIBS += C:\opencv\release\bin\libopencv_features2d451.dll
LIBS += C:\opencv\release\bin\libopencv_calib3d451.dll
#include opencv for ARM
#INCLUDEPATH += /opt/opencv.arm/include/opencv
#LIBS += /opt/opencv.arm/lib/*.so

imagecapture.h:

#ifndef IMAGECAPTURE_H
#define IMAGECAPTURE_H

#include <QObject>
#include <QImage>
#include <QTimer>

#include <cv.h>
#include <highgui.h>

class ImageCapture : public QObject
{
    Q_OBJECT
public:
    explicit ImageCapture(QObject *parent = 0);
    ~ImageCapture();

signals:

public slots:
    //!< attempts to start camera, camera number is given in cameraIndex (see cvCaptureFromCAM docs)
    void captureFromCamera( int cameraIndex = -1 ); //index = -1 to capture form any camera
    void stopCapture();  //!< stops timer and release OpenCV capture structure
protected:
    QImage convert(IplImage * image);    //!< create QImage from OpenCV image data
    QImage IplImage2QImage(const IplImage *iplImage);
protected slots:
    void timer_stick(); //!< grab and send frame on each timer tick
signals:
        void imageCaptured( const QImage& image );
        void error( const QString& text );
protected:
        QTimer * _timer;    //!< timeout signal is used to capture frames at regular intervals (or whenever possible in case of camera)
        CvCapture * _cvCap; //!< used to grab image data from video or camera
        IplImage* imagerd;
};

#endif // IMAGECAPTURE_H

mainwindow.h:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <imagecapture.h>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
public slots:
    void on_actionOpen_Camera_triggered();
    void displayImage(const QImage &image);
protected slots:
    void captureError(const QString &text);

public:
    ImageCapture *_capture;

};

#endif // MAINWINDOW_H

(i don't know if this kind of presentation is acceptable, i haven't seen anyone doing it yet)

the problems are:

C:\Users\FPT Shop\Downloads\QtCvCapture\QtCvCapture\mainwindow.h:4: error: QMainWindow: No such file 
or directory
In file included from ..\QtCvCapture\mainwindow.cpp:1:
..\QtCvCapture\mainwindow.h:4:10: fatal error: QMainWindow: No such file or directory
same issues for cv.h and QtGUI/QApplicaiton, this happended when i try to #include them 

what I have done: I have installed OpenCV and CMake following the instruction in https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows#OpenCV the installation was successful, after which I compiled the program, then I'm met with the errors above. I have recheck and the files that the compiler claimed to be missing are there, in the folder (which I have linked in the .pro file). I found some answer said that it could be because my code is outdated? which I found reasonable because the code that's I'm using was published wayy back in 2013... sooo what do you guys think?

来源:https://stackoverflow.com/questions/66174771/no-such-file-or-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!