Beispiel #1
0
//! Performs one step of extremum interpolation. 
void interpolateStep(int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b, double* xi, double* xr, double* xc )
//void interpolateStep()
{
	CvMat* dD, * H, * H_inv, X;
	double x[3] = { 0 };

	dD = deriv3D( r, c, t, m, b );
	H = hessian3D( r, c, t, m, b );
	H_inv = CreateMat( 3, 3, CV_64FC1 );
	cvInvert( H, H_inv, CV_SVD ); // incomplete check after invert() => CreateSVD()
	//cvInitMatHeader( &X, 3, 1, CV_64FC1, x, CV_AUTOSTEP );
	InitMatHeader( &X, 3, 1, CV_64FC1, x, CV_AUTOSTEP );  //check
	cvGEMM( H_inv, dD, -1, NULL, 0, &X, 0 );  //incomplete

	free(&dD);
	free(&H);
	free(&H_inv);

	//cvReleaseMat( &dD );
	//cvReleaseMat( &H );
	//cvReleaseMat( &H_inv );

	*xi = x[2];
	*xr = x[1];
	*xc = x[0];
}
/**
 * Interpolate the interest point to subpixel accuracy, by the method
 * from (Brown and Lowe, 2002).
 *
 * This comes down to solving the equation Ax=b where A is the
 * second-order derivative of the scale-space function shifted (i.e.
 * the 3D Hessian), and b = -(dx,dy,ds). The scale-space function is
 * assumed shifted so the interest point candidate is at the origin.
 * The solution to this equation yields the position (x,y,s) in
 * scale-space of the actual extremum.
 *
 * The values for the partial derivatives are approximated by point
 * value differences in the response layers.
 */
void FastHessian::interpolate(Point p, ResponseLayer *b, ResponseLayer *m, ResponseLayer *t,
                              double *dx, double *dy, double *ds)
{
  Mat X; // holds solution
  Mat h3d = hessian3D(p, b, m, t);
  Mat d3d = deriv3D(p, b, m, t);
  d3d *= -1;
  if(solve(h3d, d3d, X)) {
    *dx = X.at<double>(0,0);
    *dy = X.at<double>(1,0);
    *ds = X.at<double>(2,0);
  } else {
    *dx = *dy = *ds = 0.0f;
  }
}
Beispiel #3
0
//! Performs one step of extremum interpolation. 
void FastHessian::interpolateStep(int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b, 
                                  double* xi, double* xr, double* xc )
{
  CvMat* dD, * H, * H_inv, X;
  double x[3] = { 0 };

  dD = deriv3D( r, c, t, m, b );
  H = hessian3D( r, c, t, m, b );
  H_inv = cvCreateMat( 3, 3, CV_64FC1 );
  cvInvert( H, H_inv, CV_SVD );
  cvInitMatHeader( &X, 3, 1, CV_64FC1, x, CV_AUTOSTEP );
  cvGEMM( H_inv, dD, -1, NULL, 0, &X, 0 );

  cvReleaseMat( &dD );
  cvReleaseMat( &H );
  cvReleaseMat( &H_inv );

  *xi = x[2];
  *xr = x[1];
  *xc = x[0];
}