/*!

  Initialize a point feature with polar coordinates
  \f$(\rho,\theta)\f$ using the coordinates of the point in pixels
  obtained by image processing. This point is the center
  of gravity of a dot tracked using vpDot. Using the camera
  parameters, the pixels coordinates of the dot are first
  converted in cartesian \f$(x,y)\f$ coordinates in meter in the
  camera frame and than in polar coordinates by:

  \f[\rho = \sqrt{x^2+y^2}  \hbox{,}\; \; \theta = \arctan \frac{y}{x}\f]

  \warning This function does not initialize \f$Z\f$ which is
  requested to compute the interaction matrix by
  vpfeaturePointPolar::interaction().
  
  \param s : Visual feature \f$(\rho,\theta)\f$ to initialize. Be
  aware, the 3D depth \f$Z\f$ requested to compute the interaction
  matrix is not initialized by this function.
  
  \param cam : Camera parameters.

  \param dot : Tracked dot. The center of gravity corresponds to the
  coordinates of the point in the image plane.

  The code below shows how to initialize a vpFeaturePointPolar visual
  feature. First, we initialize the \f$\rho,\theta\f$, and lastly we
  set the 3D depth \f$Z\f$ of the point which is generally the result
  of a pose estimation.

  \code
  vpImage<unsigned char> I; // Image container
  vpCameraParameters cam;   // Default intrinsic camera parameters
  vpDot2 dot;               // Dot tracker

  vpFeaturePointPolar s;    // Point feature with polar coordinates
  ...
  // Tracking on the dot
  dot.track(I);

  // Initialize rho,theta visual feature
  vpFeatureBuilder::create(s, cam, dot);
  
  // A pose estimation is requested to initialize Z, the depth of the
  // point in the camera frame.
  double Z = 1; // Depth of the point in meters
  ....
  s.set_Z(Z);
  \endcode

*/
void vpFeatureBuilder::create(vpFeaturePointPolar &s,
			      const vpCameraParameters &cam,
			      const vpDot &dot)
{
  try {
    double x=0, y=0;

    vpImagePoint cog;
    cog = dot.getCog();

    vpPixelMeterConversion::convertPoint(cam, cog, x, y) ;

    double rho   = sqrt(x*x + y*y);
    double theta = atan2(y, x);
 
    s.set_rho(rho) ;
    s.set_theta(theta) ;
  }
  catch(...) {
    vpERROR_TRACE("Error caught") ;
    throw ;
  }
}
Exemple #2
0
bool
vpDot::operator==(const vpDot& d)
{
  return ( cog == d.getCog() );
}