Add a public function to face recognition src-file [closed]

asked 2016-05-15 07:28:21 -0600

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)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Maharacha
close date 2016-05-15 09:09:14.585534

Comments

1

@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:

class CV_EXPORTS_W FaceRecognizer : public Algorithm {
public:
    CV_WRAP virtual void test() {} // <-- that's all !
};

class LBPH : public LBPHFaceRecognizer {
public:
void test();
};
void LBPH::test() {
    std::cout << "test function" << std::endl; // do someting special..
}
Maharacha gravatar imageMaharacha ( 2016-05-15 09:12:51 -0600 )edit

oh, sorry.

i deleted the answer after a minute, somehow i was not happy with it.

berak gravatar imageberak ( 2016-05-15 09:44:54 -0600 )edit

Ok I see, but it helped me so thanks :)

Maharacha gravatar imageMaharacha ( 2016-05-15 20:18:27 -0600 )edit