@@ -105,7 +105,8 @@ class FacemarkAAMImpl : public FacemarkAAM {
105
105
106
106
protected:
107
107
108
- bool fit ( InputArray image, InputArray faces, InputOutputArray landmarks, void * runtime_params);// !< from many ROIs
108
+ bool fit (InputArray image, InputArray faces, OutputArray landmarks);
109
+ bool fit (InputArray image, InputArray faces, OutputArray landmarks, const std::vector<Config> &runtime_params);// !< from many ROIs
109
110
bool fitImpl ( const Mat image, std::vector<Point2f>& landmarks,const Mat R,const Point2f T,const float scale, const int sclIdx=0 );
110
111
111
112
bool addTrainingSample (InputArray image, InputArray landmarks);
@@ -152,6 +153,9 @@ class FacemarkAAMImpl : public FacemarkAAM {
152
153
Ptr<FacemarkAAM> FacemarkAAM::create (const FacemarkAAM::Params ¶meters){
153
154
return Ptr<FacemarkAAMImpl>(new FacemarkAAMImpl (parameters));
154
155
}
156
+ Ptr<FacemarkAAM> FacemarkAAM::create (){
157
+ return Ptr<FacemarkAAMImpl>();
158
+ }
155
159
156
160
FacemarkAAMImpl::FacemarkAAMImpl ( const FacemarkAAM::Params ¶meters ) :
157
161
params ( parameters ),
@@ -312,7 +316,7 @@ void FacemarkAAMImpl::training(void* parameters){
312
316
if (params.verbose ) printf (" Training is completed\n " );
313
317
}
314
318
315
- bool FacemarkAAMImpl::fit ( InputArray image, InputArray roi, InputOutputArray _landmarks, void * runtime_params )
319
+ bool FacemarkAAMImpl::fit ( InputArray image, InputArray roi, OutputArray _landmarks, const std::vector<Config> &conf )
316
320
{
317
321
std::vector<Rect> & faces = *(std::vector<Rect> *)roi.getObj ();
318
322
if (faces.size ()<1 ) return false ;
@@ -322,23 +326,33 @@ bool FacemarkAAMImpl::fit( InputArray image, InputArray roi, InputOutputArray _l
322
326
landmarks.resize (faces.size ());
323
327
324
328
Mat img = image.getMat ();
325
- if (runtime_params!=0 ){
326
329
327
- std::vector<Config> conf = *(std::vector<Config>*)runtime_params;
328
- if (conf.size ()!=faces.size ()) {
329
- CV_Error (Error::StsBadArg, " Number of faces and extra_parameters are different!" );
330
- }
331
- for (size_t i=0 ; i<conf.size ();i++){
332
- fitImpl (img, landmarks[i], conf[i].R ,conf[i].t , conf[i].scale , conf[i].model_scale_idx );
333
- }
334
- }else {
335
- Mat R = Mat::eye (2 , 2 , CV_32F);
336
- Point2f t = Point2f ((float )(img.cols /2.0 ),(float )(img.rows /2.0 ));
337
- float scale = 1.0 ;
330
+ if (conf.size ()!=faces.size ()) {
331
+ CV_Error (Error::StsBadArg, " Number of faces and extra_parameters are different!" );
332
+ }
333
+ for (size_t i=0 ; i<conf.size ();i++){
334
+ fitImpl (img, landmarks[i], conf[i].R ,conf[i].t , conf[i].scale , conf[i].model_scale_idx );
335
+ }
338
336
339
- for (unsigned i=0 ; i<faces.size ();i++){
340
- fitImpl (img, landmarks[i], R,t, scale);
341
- }
337
+ return true ;
338
+ }
339
+
340
+ bool FacemarkAAMImpl::fit ( InputArray image, InputArray roi, OutputArray _landmarks)
341
+ {
342
+ std::vector<Rect> & faces = *(std::vector<Rect> *)roi.getObj ();
343
+ if (faces.size ()<1 ) return false ;
344
+
345
+ std::vector<std::vector<Point2f> > & landmarks =
346
+ *(std::vector<std::vector<Point2f> >*) _landmarks.getObj ();
347
+ landmarks.resize (faces.size ());
348
+
349
+ Mat img = image.getMat ();
350
+ Mat R = Mat::eye (2 , 2 , CV_32F);
351
+ Point2f t = Point2f ((float )(img.cols /2.0 ),(float )(img.rows /2.0 ));
352
+ float scale = 1.0 ;
353
+
354
+ for (unsigned i=0 ; i<faces.size ();i++){
355
+ fitImpl (img, landmarks[i], R,t, scale);
342
356
}
343
357
344
358
return true ;
0 commit comments