@@ -661,11 +661,10 @@ FacemarkLBFImpl::BBox::BBox(double _x, double _y, double w, double h) {
661
661
662
662
// Project absolute shape to relative shape binding to this bbox
663
663
Mat FacemarkLBFImpl::BBox::project (const Mat &shape) const {
664
- Mat_<double > res (shape.rows , shape.cols );
665
- const Mat_<double > &shape_ = (Mat_<double >)shape;
664
+ Mat res (shape.rows , shape.cols , CV_64FC1);
666
665
for (int i = 0 ; i < shape.rows ; i++) {
667
- res (i, 0 ) = (shape_ (i, 0 ) - x_center) / x_scale;
668
- res (i, 1 ) = (shape_ (i, 1 ) - y_center) / y_scale;
666
+ res. at < double > (i, 0 ) = (shape. at < double > (i, 0 ) - x_center) / x_scale;
667
+ res. at < double > (i, 1 ) = (shape. at < double > (i, 1 ) - y_center) / y_scale;
669
668
}
670
669
return res;
671
670
}
@@ -997,7 +996,7 @@ void FacemarkLBFImpl::RandomForest::train(std::vector<Mat> &imgs, std::vector<Ma
997
996
}
998
997
999
998
Mat FacemarkLBFImpl::RandomForest::generateLBF (Mat &img, Mat ¤t_shape, BBox &bbox, Mat &mean_shape) {
1000
- Mat_< int > lbf_feat (1 , landmark_n*trees_n);
999
+ Mat lbf_feat (1 , landmark_n*trees_n, CV_32SC1 );
1001
1000
double scale;
1002
1001
Mat_<double > rotate;
1003
1002
calcSimilarityTransform (bbox.project (current_shape), mean_shape, scale, rotate);
@@ -1036,7 +1035,7 @@ Mat FacemarkLBFImpl::RandomForest::generateLBF(Mat &img, Mat ¤t_shape, BBo
1036
1035
idx = 2 * idx + 1 ;
1037
1036
}
1038
1037
}
1039
- lbf_feat (i*trees_n + j) = (i*trees_n + j)*base + code;
1038
+ lbf_feat. at < int > (i*trees_n + j) = (i*trees_n + j)*base + code;
1040
1039
}
1041
1040
}
1042
1041
return lbf_feat;
@@ -1365,7 +1364,7 @@ Mat FacemarkLBFImpl::Regressor::supportVectorRegression(
1365
1364
1366
1365
Mat FacemarkLBFImpl::Regressor::globalRegressionPredict (const Mat &lbf, int stage) {
1367
1366
const Mat_<double > &weight = (Mat_<double >)gl_regression_weights[stage];
1368
- Mat_< double > delta_shape (weight.rows / 2 , 2 );
1367
+ Mat delta_shape (weight.rows / 2 , 2 , CV_64FC1 );
1369
1368
const double *w_ptr = NULL ;
1370
1369
const int *lbf_ptr = lbf.ptr <int >(0 );
1371
1370
@@ -1374,12 +1373,12 @@ Mat FacemarkLBFImpl::Regressor::globalRegressionPredict(const Mat &lbf, int stag
1374
1373
w_ptr = weight.ptr <double >(2 * i);
1375
1374
double y = 0 ;
1376
1375
for (int j = 0 ; j < lbf.cols ; j++) y += w_ptr[lbf_ptr[j]];
1377
- delta_shape (i, 0 ) = y;
1376
+ delta_shape. at < double > (i, 0 ) = y;
1378
1377
1379
1378
w_ptr = weight.ptr <double >(2 * i + 1 );
1380
1379
y = 0 ;
1381
1380
for (int j = 0 ; j < lbf.cols ; j++) y += w_ptr[lbf_ptr[j]];
1382
- delta_shape (i, 1 ) = y;
1381
+ delta_shape. at < double > (i, 1 ) = y;
1383
1382
}
1384
1383
return delta_shape;
1385
1384
} // Regressor::globalRegressionPredict
0 commit comments