Add a public function to face recognition src-file [closed]
I have a c++ program from where I can create a LBPHFaceRecognizer, train it with with data, send an image for prediction etc. But now I want to customize lbph_faces.cpp. I can change/add private stuff in it, build and compile, and it works fine but when I try to add something public I get lost. Can someone tell me, if I want to add a public function in lbph_faces.cpp, what do I have to do? Which headerfiles do I have to update?
Example:
lbph_faces.cpp
class LBPH : public LBPHFaceRecognizer {
public:
void test();
};
void LBPH::test() {
std::cout << "test function" << std::endl;
}
My program has
#include "opencv2/face.hpp"
And if I try to add the test-function in face.hpp like this for example:
class CV_EXPORTS_W FaceRecognizer : public Algorithm {
public:
CV_WRAP virtual void test();
};
I get:
Undefined symbols for architecture x86_64:
"cv::face::BasicFaceRecognizer::test()", referenced from:
vtable for cv::face::Eigenfaces in eigen_faces.cpp.o
vtable for BasicFaceRecognizerImpl in eigen_faces.cpp.o
vtable for cv::face::Fisherfaces in fisher_faces.cpp.o
vtable for BasicFaceRecognizerImpl in fisher_faces.cpp.o
"typeinfo for cv::face::FaceRecognizer", referenced from:
typeinfo for cv::face::LBPHFaceRecognizer in lbph_faces.cpp.o
"typeinfo for cv::face::BasicFaceRecognizer", referenced from:
typeinfo for BasicFaceRecognizerImpl in eigen_faces.cpp.o
typeinfo for BasicFaceRecognizerImpl in fisher_faces.cpp.o
"vtable for cv::face::FaceRecognizer", referenced from:
BasicFaceRecognizerImpl::~BasicFaceRecognizerImpl() in eigen_faces.cpp.o
BasicFaceRecognizerImpl::~BasicFaceRecognizerImpl() in fisher_faces.cpp.o
cv::face::LBPH::~LBPH() in lbph_faces.cpp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@berak answered my question but it is only visible under my notification, don't know why... Anyway his first suggestion worked fine!
1: the easy way, have a base implementation:
oh, sorry.
i deleted the answer after a minute, somehow i was not happy with it.
Ok I see, but it helped me so thanks :)