Ask Your Question
0

Problems with FaceRecognition

asked 2018-01-15 12:06:51 -0500

Lucas Amparo Barbosa gravatar image

updated 2018-01-15 12:10:26 -0500

berak gravatar image

Hello everyone,

I'm try to follow the tutorial from docs (here) , but when I try to compile, doesn't work.

Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create();
model->train(images, labels);

The error:

error: ‘EigenFaceRecognizer’ was not declared in this scope
Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create();
reconhecimento.cpp:72:25: error: template argument 1 is invalid
Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create();
reconhecimento.cpp:72:35: error: ‘EigenFaceRecognizer’ is not a class, namespace, or enumeration
Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create();                               ^
reconhecimento.cpp:73:7: error: base operand of ‘->’ is not a pointer model->train(images, labels);
reconhecimento.cpp:76:29: error: base operand of ‘->’ is not a pointer
int predictedLabel = model->predict(imread(path_output+paths_out[i]+".png"));

If I change to

Ptr<BasicFaceRecognizer> model = createEigenFaceRecognizer();

The error turns to

reconhecimento.cpp:(.text+0x756): undefined reference to `cv::face::createEigenFaceRecognizer(int, double)'
reconhecimento.cpp:(.text+0x8cc): undefined reference to cv::face::FaceRecognizer::predict(cv::_InputArray const&) const'
collect2: error: ld returned 1 exit status

Someone can help me? Thanks.

edit retag flag offensive close merge delete

Comments

I added the flag -lopencv_face, and the error turns to:

OpenCV Error: Bad argument (Wrong shapes for given matrices. Was size(src) = (1,49152), size(W) = (16384,24).) in subspaceProject, file /home/lucasamparo/Downloads/OpenCV/modules/core/src/lda.cpp, line 183
Lucas Amparo Barbosa gravatar imageLucas Amparo Barbosa ( 2018-01-15 12:14:48 -0500 )edit

your test image must have the same size as the train images

berak gravatar imageberak ( 2018-01-17 09:32:18 -0500 )edit

I've solved that. Thanks everyone.

Lucas Amparo Barbosa gravatar imageLucas Amparo Barbosa ( 2018-04-05 11:59:53 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2018-01-15 12:12:29 -0500

berak gravatar image

looks like a namespace problem.

either have a:

using cv::face;

or:

Ptr<cv::face::EigenFaceRecognizer> model = cv::face::EigenFaceRecognizer::create();
edit flag offensive delete link more

Comments

No, man... I've declared the namespace before. But thanks...

Lucas Amparo Barbosa gravatar imageLucas Amparo Barbosa ( 2018-01-15 12:14:08 -0500 )edit

please use latest 3.4 and the 3.4 docs

berak gravatar imageberak ( 2018-01-15 12:18:32 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-01-15 12:06:51 -0500

Seen: 106 times

Last updated: Jan 15