Convert Ptr<cv::face::FaceRecognizer> to Ptr<cv::face::BasicFaceRecognizer>
Hi to everyone! Is there any way to make a convertion from FaceRecognizer to BasicFaceRecognizer type in OpenCv 3.1?When i am trying to build a project, compiler show me the error: Cannot convert from Ptr<facerecognizer> to Ptr<basicfacerecognizer>.
Try using dynamicCast.
why do you need this cast ? can you show us some code ?
Thank you for reply! Yes sure i will post my code. I need this cast because i am trying to use function that use FaceRecognizer as parameter , and inside of the function i need to cast FaceRecognizer to BasicFaceRecognizer to be able to get the following methods:
Here is a function:
Intellisence doesn't understroke this cast, but error is shown during the build.
maybe you should not use a
Ptr<cv::face::FaceRecognizer> model
in the first place, but aPtr<cv::face::BasicFaceRecognizer> model
(or an EigenFaceRecognizer)Sorry, i posted the wrong code. Here is corrected version:
Can you explain please what do you mean by first place? I tried different ways, also put BasicFaceRecognition in func parameters. Finally i want to pass trained EigenFaceRecognizer model to this func and i need to be able to use getMean() inside the func body.
If you have a Ptr<basicface_>, I would think it would automatically convert to a Ptr<face_> when passed to a function that uses that as the parameter.
But if you're calling getMean() on a Ptr<face_> then you should probably change the type of the parameter, since there is no guarantee that function will exist if, for example, someone passes a LBPHFaceRecognizer.
What kind of type should i change? Can you explaine please a litle bit what should i do to make this func work. Thank you for reply.
I am going to use different models (Eigen, Fisher, LBPH) within this function. Also tried dynamicCast it doesnt work, it tells there is no dynamic cast for this conversion. Ok i will try to make this function specific to EigenFaceRecognizer and will see what happens! Let you know..
I looked into the cv::face and i found that there is no specific EigenFaceRecognizer, FisherFacerecognizer or LBPHRecognizer classes. How to make a specific function for any of this types? Maybe it would be better to ask how to make function in OpenCV 3.1 that uses EigenFaceRecognizer model as a parameter and can use the getMean(), getEigenVectors(), inside the body of the function for this model.. Does anybody can share a code sample? In OpenCV 2.4 model->get<mat>("mean") and model->get<mat>("eigenvalues") worked from FaceRecognizer class, but in OpenCv 3.1 it works only under BasicFaceRecognizer and that is a proplem..
If you want to use getMean, you cannot use FaceRecognizer. Period. You must use BasicFaceRecognizer or a class that derives from that.
The createEigenFaceRecognizer function returns a BasicFaceRecognition Pointer.
I suggest making two versions of the function, one that takes a Ptr<basicfacerecognizor> pointer, and one that takes just a Ptr<facerecognizer>. Only the first one can call getMean().