I am developing a project in C++ with Qt and OpenCV 3.0. When trying to use the face recognition module of OpenCV, I get an error.
When accessing the file predict_collector.hpp and the class below
class CV_EXPORTS_W PredictCollector {
protected:
...
public:
...
CV_WRAP virtual bool emit(const int label, const double dist, const int state = 0);
};
The compiler links the emit keyword with its definition in Qt, generating this error:
\libs\opencv3.0.0\opencv_contrib-master\modules\face\include\opencv2\face/predict_collector.hpp(77): error C2059: syntax error: 'const'
because 'const'
is a keyword in C++ and cannot be passed an argument to the Qt emit function. You see that the compiler treats emit as if it is the Qt version.
Noting that emit is a macro function, it is not an ordinary one, so we cannot use namespaces, a you can see in qobjectsdef.h:
#ifndef QT_NO_EMIT
# define emit
#endif
I tried to make
#undef emit
in the file predict_collector.hpp but it will generate errors in all of the project.
How to resolve this issue?