Exemple #1
0
void EyeTracker::remove_corneal_reflection( int sx, int sy, int window_size, 
											int biggest_crr, int& crx, int& cry )
{
	int crar = -1;	//corneal reflection approximate radius
	crx = cry = crar = -1;

	float angle_delta = (float)(1 * PI / 180);
	int angle_num = (int)(2*PI/angle_delta);
	//printf("(corneal reflection) sx:%d; sy:%d\n", sx, sy);
	double *angle_array = (double*)malloc(angle_num*sizeof(double));
	double *sin_array = (double*)malloc(angle_num*sizeof(double));
	double *cos_array = (double*)malloc(angle_num*sizeof(double));
	for (int i = 0; i < angle_num; i++) {
		angle_array[i] = i*angle_delta;
		sin_array[i] = sin(angle_array[i]);
		cos_array[i] = cos(angle_array[i]);
	}

	locate_corneal_reflection( sx, sy, window_size, (int)(biggest_crr/2.5), crx, cry, crar);
	corneal_reflection_r = fit_circle_radius_to_corneal_reflection( crx, cry, crar, (int)(biggest_crr/2.5),  sin_array, cos_array, angle_num);
	corneal_reflection_r = (int)(2.5*corneal_reflection_r);
	interpolate_corneal_reflection( crx, cry , sin_array, cos_array, angle_num);

	free(angle_array);
	free(sin_array);
	free(cos_array);
}
void remove_corneal_reflection(IplImage *image, IplImage *threshold_image, int sx, int sy, int window_size, int 
biggest_crr, int &crx, int &cry, int &crr, int *valid_point_calc)
{
  int crar = -1;	//corneal reflection approximate radius
  crx = cry = crar = -1;

  float angle_delta = 1*PI/180;
  int angle_num = (int)(2*PI/angle_delta);
  printf("(corneal reflection) sx:%d; sy:%d\n", sx, sy);
  double *angle_array = (double*)malloc(angle_num*sizeof(double));
  double *sin_array = (double*)malloc(angle_num*sizeof(double));
  double *cos_array = (double*)malloc(angle_num*sizeof(double));
  for (int i = 0; i < angle_num; i++) {
    angle_array[i] = i*angle_delta;
    sin_array[i] = sin(angle_array[i]);
    cos_array[i] = cos(angle_array[i]);
  }

  locate_corneal_reflection(image, threshold_image, sx, sy, window_size, (int)(biggest_crr/2.5), crx, cry, crar, valid_point_calc);
  crr = fit_circle_radius_to_corneal_reflection(image, crx, cry, crar, (int)(biggest_crr/2.5),  sin_array, cos_array, angle_num, valid_point_calc);
  crr = (int)(2.5*crr);
  interpolate_corneal_reflection(image, crx, cry, crr, sin_array, cos_array, angle_num, valid_point_calc);

  free(angle_array);
  free(sin_array);
  free(cos_array);
}