mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-17 07:04:18 +08:00
Merge pull request #2069 from tegusi:landmark_fix
This commit is contained in:
@@ -74,8 +74,8 @@ public:
|
||||
@endcode
|
||||
*/
|
||||
CV_WRAP virtual bool fit( InputArray image,
|
||||
InputArray faces,
|
||||
OutputArrayOfArrays landmarks ) = 0;
|
||||
const std::vector<Rect>& faces,
|
||||
CV_OUT std::vector<std::vector<Point2f> >& landmarks ) = 0;
|
||||
}; /* Facemark*/
|
||||
|
||||
|
||||
|
@@ -146,7 +146,7 @@ public:
|
||||
};
|
||||
|
||||
//! overload with additional Config structures
|
||||
virtual bool fitConfig( InputArray image, InputArray roi, OutputArrayOfArrays _landmarks, const std::vector<Config> &runtime_params ) = 0;
|
||||
virtual bool fitConfig( InputArray image, const std::vector<Rect>& roi, std::vector<std::vector<Point2f> >& _landmarks, const std::vector<Config> &runtime_params ) = 0;
|
||||
|
||||
|
||||
//! initializer
|
||||
|
@@ -73,7 +73,7 @@ public:
|
||||
void loadModel(String fs) CV_OVERRIDE;
|
||||
bool setFaceDetector(FN_FaceDetector f, void* userdata) CV_OVERRIDE;
|
||||
bool getFaces(InputArray image, OutputArray faces) CV_OVERRIDE;
|
||||
bool fit(InputArray image, InputArray faces, OutputArrayOfArrays landmarks ) CV_OVERRIDE;
|
||||
bool fit(InputArray image, const std::vector<Rect>& faces, CV_OUT std::vector<std::vector<Point2f> >& landmarks ) CV_OVERRIDE;
|
||||
void training(String imageList, String groundTruth);
|
||||
bool training(vector<Mat>& images, vector< vector<Point2f> >& landmarks,string filename,Size scale,string modelFilename) CV_OVERRIDE;
|
||||
// Destructor for the class.
|
||||
|
@@ -103,12 +103,11 @@ public:
|
||||
|
||||
bool getData(void * items) CV_OVERRIDE;
|
||||
|
||||
bool fitConfig( InputArray image, InputArray roi, OutputArrayOfArrays _landmarks, const std::vector<Config> &runtime_params ) CV_OVERRIDE;
|
||||
bool fitConfig( InputArray image, const std::vector<Rect>& roi, std::vector<std::vector<Point2f> >& _landmarks, const std::vector<Config> &runtime_params ) CV_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
bool fit( InputArray image, InputArray faces, OutputArrayOfArrays landmarks ) CV_OVERRIDE;
|
||||
//bool fit( InputArray image, InputArray faces, InputOutputArray landmarks, void * runtime_params);//!< from many ROIs
|
||||
bool fit( InputArray image, const std::vector<Rect>& faces, CV_OUT std::vector<std::vector<Point2f> >& landmarks ) CV_OVERRIDE;
|
||||
bool fitImpl( const Mat image, std::vector<Point2f>& landmarks,const Mat R,const Point2f T,const float scale, const int sclIdx=0 );
|
||||
|
||||
bool addTrainingSample(InputArray image, InputArray landmarks) CV_OVERRIDE;
|
||||
@@ -323,19 +322,18 @@ void FacemarkAAMImpl::training(void* parameters){
|
||||
if(params.verbose) printf("Training is completed\n");
|
||||
}
|
||||
|
||||
bool FacemarkAAMImpl::fit( InputArray image, InputArray roi, OutputArrayOfArrays _landmarks )
|
||||
bool FacemarkAAMImpl::fit( InputArray image, const std::vector<Rect>& roi, CV_OUT std::vector<std::vector<Point2f> >& _landmarks )
|
||||
{
|
||||
std::vector<Config> config; // empty
|
||||
return fitConfig(image, roi, _landmarks, config);
|
||||
}
|
||||
|
||||
bool FacemarkAAMImpl::fitConfig( InputArray image, InputArray roi, OutputArrayOfArrays _landmarks, const std::vector<Config> &configs )
|
||||
bool FacemarkAAMImpl::fitConfig( InputArray image, const std::vector<Rect>& roi, std::vector<std::vector<Point2f> >& _landmarks, const std::vector<Config> &configs )
|
||||
{
|
||||
std::vector<Rect> & faces = *(std::vector<Rect> *)roi.getObj();
|
||||
const std::vector<Rect> & faces = roi;
|
||||
if(faces.size()<1) return false;
|
||||
|
||||
std::vector<std::vector<Point2f> > & landmarks =
|
||||
*(std::vector<std::vector<Point2f> >*) _landmarks.getObj();
|
||||
std::vector<std::vector<Point2f> > & landmarks = _landmarks;
|
||||
landmarks.resize(faces.size());
|
||||
|
||||
Mat img = image.getMat();
|
||||
|
@@ -115,7 +115,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
bool fit( InputArray image, InputArray faces, OutputArrayOfArrays landmarks ) CV_OVERRIDE;//!< from many ROIs
|
||||
bool fit( InputArray image, const std::vector<Rect> & faces, std::vector<std::vector<Point2f> > & landmarks ) CV_OVERRIDE;//!< from many ROIs
|
||||
bool fitImpl( const Mat image, std::vector<Point2f> & landmarks );//!< from a face
|
||||
|
||||
bool addTrainingSample(InputArray image, InputArray landmarks) CV_OVERRIDE;
|
||||
@@ -370,14 +370,12 @@ void FacemarkLBFImpl::training(void* parameters){
|
||||
isModelTrained = true;
|
||||
}
|
||||
|
||||
bool FacemarkLBFImpl::fit( InputArray image, InputArray roi, OutputArrayOfArrays _landmarks )
|
||||
bool FacemarkLBFImpl::fit( InputArray image, const std::vector<Rect> & roi, CV_OUT std::vector<std::vector<Point2f> > & _landmarks )
|
||||
{
|
||||
// FIXIT
|
||||
std::vector<Rect> & faces = *(std::vector<Rect> *)roi.getObj();
|
||||
const std::vector<Rect> & faces = roi;
|
||||
if (faces.empty()) return false;
|
||||
|
||||
std::vector<std::vector<Point2f> > & landmarks =
|
||||
*(std::vector<std::vector<Point2f> >*) _landmarks.getObj();
|
||||
std::vector<std::vector<Point2f> > & landmarks = _landmarks;
|
||||
|
||||
landmarks.resize(faces.size());
|
||||
|
||||
|
@@ -168,15 +168,15 @@ void FacemarkKazemiImpl :: loadModel(String filename){
|
||||
f.close();
|
||||
isModelLoaded = true;
|
||||
}
|
||||
bool FacemarkKazemiImpl::fit(InputArray img, InputArray roi, OutputArrayOfArrays landmarks){
|
||||
bool FacemarkKazemiImpl::fit(InputArray img, const std::vector<Rect>& roi, CV_OUT std::vector<std::vector<Point2f> >& landmarks){
|
||||
if(!isModelLoaded){
|
||||
String error_message = "No model loaded. Aborting....";
|
||||
CV_Error(Error::StsBadArg, error_message);
|
||||
return false;
|
||||
}
|
||||
Mat image = img.getMat();
|
||||
std::vector<Rect> & faces = *(std::vector<Rect>*)roi.getObj();
|
||||
std::vector<std::vector<Point2f> > & shapes = *(std::vector<std::vector<Point2f> >*) landmarks.getObj();
|
||||
const std::vector<Rect> & faces = roi;
|
||||
std::vector<std::vector<Point2f> > & shapes = landmarks;
|
||||
shapes.resize(faces.size());
|
||||
|
||||
if(image.empty()){
|
||||
|
Reference in New Issue
Block a user