@@ -661,11 +661,10 @@ FacemarkLBFImpl::BBox::BBox(double _x, double _y, double w, double h) {
661661
662662// Project absolute shape to relative shape binding to this bbox
663663Mat 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);
666665 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;
669668 }
670669 return res;
671670}
@@ -997,7 +996,7 @@ void FacemarkLBFImpl::RandomForest::train(std::vector<Mat> &imgs, std::vector<Ma
997996}
998997
999998Mat 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 );
10011000 double scale;
10021001 Mat_<double > rotate;
10031002 calcSimilarityTransform (bbox.project (current_shape), mean_shape, scale, rotate);
@@ -1036,7 +1035,7 @@ Mat FacemarkLBFImpl::RandomForest::generateLBF(Mat &img, Mat ¤t_shape, BBo
10361035 idx = 2 * idx + 1 ;
10371036 }
10381037 }
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;
10401039 }
10411040 }
10421041 return lbf_feat;
@@ -1365,7 +1364,7 @@ Mat FacemarkLBFImpl::Regressor::supportVectorRegression(
13651364
13661365Mat FacemarkLBFImpl::Regressor::globalRegressionPredict (const Mat &lbf, int stage) {
13671366 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 );
13691368 const double *w_ptr = NULL ;
13701369 const int *lbf_ptr = lbf.ptr <int >(0 );
13711370
@@ -1374,12 +1373,12 @@ Mat FacemarkLBFImpl::Regressor::globalRegressionPredict(const Mat &lbf, int stag
13741373 w_ptr = weight.ptr <double >(2 * i);
13751374 double y = 0 ;
13761375 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;
13781377
13791378 w_ptr = weight.ptr <double >(2 * i + 1 );
13801379 y = 0 ;
13811380 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;
13831382 }
13841383 return delta_shape;
13851384} // Regressor::globalRegressionPredict
0 commit comments