Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 53

QT 'emit': undeclared identifier error after included

$
0
0
I'm using OpenCV with QT and trying to implement facial recognition but as soon as I include `` from the "contrib" branch, QT complains about `error: C2065: 'emit': undeclared identifier`. I've tried including `"qobjectdefs.h"` and `#define emit` at the top of the appropriate header file, but it does not work. Code: **Header** #ifndef FACEDETECTOR_H #define FACEDETECTOR_H #include #include #include #include #include #include #include #include #include //This causes the error as soon as I uncomment it #include #include class FaceDetector : public QObject { Q_OBJECT public: FaceDetector(QObject *parent=0) : QObject(parent), processAll_(true) {} void setProcessAll(bool all); ~FaceDetector(); signals: void image_signal(const QImage&); public slots: void processFrame(const cv::Mat& frame); void facecascade_filename(QString filename); private: QString facecascade_filename_; QString eyecascade_filename_; QBasicTimer timer_; QVector m_CSVimages; QVector m_CSVlabels; cv::Mat frame_; bool processAll_; cv::CascadeClassifier faceCascade; cv::CascadeClassifier eyeCascade; //I need face.hpp for this: //cv::Ptr m_faceModel; void process(cv::Mat frame); void loadFiles(const cv::String& faceCascadeFilename, const cv::String& eyesCascadeFilename); static void loadCSV(const cv::String& filePath, QVector& images, QVector& labels, char separator = ';'); void queue(const cv::Mat & frame); void timerEvent(QTimerEvent* ev); static void matDeleter(void* mat); }; #endif // FACEDETECTOR_H **Implementation** Other functions omitted for brevity #include "faceDetector.h" void FaceDetector::process(cv::Mat frame) { cv::Mat grey_image; cv::cvtColor(frame, grey_image, CV_BGR2GRAY); cv::equalizeHist(grey_image, grey_image); std::vector faces; // Calculate the camera size and set the size to 1/8 of screen height faceCascade.detectMultiScale(grey_image, faces, 1.1, 8, 0|CV_HAAR_SCALE_IMAGE, cv::Size(frame.cols/4, frame.rows/4)); // Minimum size of obj //-- Draw rectangles around faces for( size_t i = 0; i < faces.size(); i++) { cv::rectangle(frame, faces[i], cv::Scalar( 255, 0, 255 )); } cv::cvtColor(frame, frame, cv::COLOR_BGR2RGB); const QImage image(static_cast(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_RGB888, &matDeleter, new cv::Mat(frame)); image.rgbSwapped(); Q_ASSERT(image.constBits() == frame.data); //This is the error location emit image_signal(image); }

Viewing all articles
Browse latest Browse all 53

Trending Articles