Error while including face.hpp file

asked 2018-02-21 02:19:20 -0500

Hi, I am working on face recognition. When i try to add face.hpp, it is showing below errors.

In file included from /usr/include/opencv2/face.hpp:51:0,
             from /usr/include/opencv2/face/facerec.hpp:11,
             from processImage.cpp:11:
/usr/include/opencv2/face/predict_collector.hpp:76:31: error: expected unqualified-id before ‘const’
 CV_WRAP virtual bool emit(const int label, const double dist, const int state = 0); //not abstract while Python generation require non-abstract class
/usr/include/opencv2/face/predict_collector.hpp:76:31: error: expected ‘)’ before ‘const’

enter code here

/usr/include/opencv2/face/predict_collector.hpp:91:23: error: expected unqualified-id before ‘const’
 CV_WRAP bool emit(const int label, const double dist, const int state = 0);
/usr/include/opencv2/face/predict_collector.hpp:91:23: error: expected ‘)’ before ‘const’
Makefile:2635: recipe for target 'processImg.o' failed

am i missing any thing else.

I added #include opencv2/face.hpp"" and i got those errors.

Thanks Tirupathi

edit retag flag offensive close merge delete


which opencv version is it ?

do you also include Qt headers (emit) ?

your code looks outdated

berak gravatar imageberak ( 2018-02-21 02:51:12 -0500 )edit

I am using opencv 3.1. I could able to detect the face with my application. But when i try to implement face recognition, it is throwing errors.

I started with cv::Ptr<cv::face::FaceRecognizer> model = cv::face::createFisherFaceRecognizer();. It started throwing error saying face is not member of cv. Then i added face.hpp, and now i got those errors which i posted above.

Tirupathi gravatar imageTirupathi ( 2018-02-21 03:19:55 -0500 )edit

3.1 is terribly outdated. please update both opencv(main) and opencv_contrib to latest master, rebuild, and try again.

berak gravatar imageberak ( 2018-02-21 03:24:44 -0500 )edit

wont it work without opencv_contrib and without updating it. We have limitation now.

In few examples, i have seen it using but when i use it, i am getting errors.

Here is the link i took as reference

Tirupathi gravatar imageTirupathi ( 2018-02-21 04:26:10 -0500 )edit

it will work, if you update it.

are you using Qt ? try to change the order of headers, or isolate the face reco code, to avoid conflicts about emit

berak gravatar imageberak ( 2018-02-21 04:29:33 -0500 )edit

yes. i am using qt.

Tirupathi gravatar imageTirupathi ( 2018-02-21 04:39:05 -0500 )edit

so, isolate it, so you don't have the face.hpp with your Qt code

berak gravatar imageberak ( 2018-02-21 04:40:14 -0500 )edit

Thanks. It worked.

Tirupathi gravatar imageTirupathi ( 2018-02-21 23:59:35 -0500 )edit