Reputation: 363
I am trying to compile a program, I am trying to track an object using openCV. Now whenever i compile the code i get the following error.
disguise_gui_1306.cpp:101:5: error: ‘FaceRecognizer’ was not declared in this scope Ptr model, mouthModel; ^
disguise_gui_1306.cpp:101:19: error: template argument 1 is invalid Ptr model, mouthModel; ^
disguise_gui_1306.cpp:101:26: error: invalid type in declaration before ‘,’ token Ptr model, mouthModel; ^
disguise_gui_1306.cpp: In function ‘void snapshotCB(Fl_Widget*, void*)’:
disguise_gui_1306.cpp:232:40: error: base operand of ‘->’ is not a pointer int predictedMouthLabel = mouthModel->predict(testSample); ^
disguise_gui_1306.cpp:242:31: error: base operand of ‘->’ is not a pointer int predictedLabel = model->predict(testSample); ^ disguise_gui_1306.cpp:260:29: error: base operand of ‘->’ is not a pointer int predictedLabel = model->predict(testSample); ^
disguise_gui_1306.cpp: In function ‘void trainFaceRecogniserModel(std::vector, std::vector)’:
disguise_gui_1306.cpp:394:39: error: ‘createEigenFaceRecognizer’ was not declared in this scope model = createEigenFaceRecognizer(); ^
disguise_gui_1306.cpp:395:10: error: base operand of ‘->’ is not a pointer model->train(img, lab); ^
disguise_gui_1306.cpp: In function ‘int main(int, char**)’:
disguise_gui_1306.cpp:416:39: error: ‘createEigenFaceRecognizer’ was not declared in this scope model = createEigenFaceRecognizer(); ^
disguise_gui_1306.cpp:417:10: error: base operand of ‘->’ is not a pointer model->train(images, labels); ^
disguise_gui_1306.cpp:432:15: error: base operand of ‘->’ is not a pointer mouthModel->train(mouthimages, mouthlabels);
While when the run the same on my friends laptop it compiles smoothly. We are same OS(debian),OpenCV 3.0.0-rc1. As per my research this problem should only arise if m using older version of openCV2.3. I have been trying various solutions like adding contrib.hpp and all. But nothing seems to help.
Kindly help.
Upvotes: 0
Views: 2228
Reputation: 679
As mentioned above, first check if OpenCV was compiled with contrib modules as described in https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html
then:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
include_directories( "/home/user/opencv-4.x","/home/user/opencv_contrib-4.x" )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
#include <opencv2/opencv.hpp>
#include <opencv2/face.hpp>
#include <opencv2/highgui.hpp>
Ptr<cv::face::FaceRecognizer> model = cv::face::EigenFaceRecognizer::create();
Upvotes: 2
Reputation: 71
Was your opencv3 built with OPENCV_EXTRA_MODULES_PATH option in make
?
-D OPENCV_EXTRA_MODULES_PATH=</path/to/opencv_contrib>/modules
Upvotes: 2