Beispiel #1
0
double calcMeanError(const vector<Mat_<double> >& gt_shapes, \
                     const vector<Mat_<double> >& current_shapes) {
  const Config& c = Config::GetInstance();
  const int N = gt_shapes.size();
  const int landmark_n = c.landmark_n;
  double e = 0.;
  Mat_<double> delta_shape;
  for (int i = 0; i < N; i++) {
    delta_shape = gt_shapes[i] - current_shapes[i];
    for (int j = 0; j < landmark_n; j++) {
      e += std::sqrt(std::pow(delta_shape(0, 2 * j), 2) + \
                     std::pow(delta_shape(0, 2 * j + 1), 2));
    }
  }
  e /= landmark_n * N;
  e /= c.img_o_size;
  return e;
}
Beispiel #2
0
double calcMeanError(const vector<Mat_<double> >& gt_shapes,
		const vector<Mat_<double> >& current_shapes){
	const Config& c = Config::GetInstance();
	const int N = gt_shapes.size();
	const int landmark_n = c.landmark_n;
	double e = 0.;
	Mat_<double> delta_shape;
	for(int i = 0; i < N; i++){
		double left_x, left_y, right_x, right_y;
		left_x = left_y = right_x = right_y = 0.;
		for(int j = 0; j < c.left_pupils.size(); j++){
			left_x += gt_shapes[i](0, 2 * c.left_pupils[j]);
			left_y += gt_shapes[i](0, 2 * c.left_pupils[j] + 1);
		}
		left_x /= c.left_pupils.size();
		left_y /= c.left_pupils.size();
		for(int j = 0; j < c.right_pupils.size(); j++){
			right_x += gt_shapes[i](0, 2 * c.right_pupils[j]);
			right_y += gt_shapes[i](0, 2 * c.right_pupils[j] + 1);
		}
		right_x /= c.right_pupils.size();
		right_y /= c.right_pupils.size();
		double pupil_dis;
		pupil_dis = std::sqrt(
				std::pow(left_x - right_x, 2) + std::pow(left_y - right_y, 2));

		delta_shape = gt_shapes[i] - current_shapes[i];
		double e_ = 0.;
		for(int j = 0; j < landmark_n; j++){
			e_ += std::sqrt(
					std::pow(delta_shape(0, 2 * j), 2)
							+ std::pow(delta_shape(0, 2 * j + 1), 2));
		}
		e += e_ / pupil_dis;
	}
	e /= landmark_n * N;
	return e;
}