ViSP  2.8.0
vpImagePoint Class Reference

#include <vpImagePoint.h>

Public Member Functions

 vpImagePoint ()
 
 vpImagePoint (double i, double j)
 
 vpImagePoint (const vpImagePoint &ip)
 
virtual ~vpImagePoint ()
 
const vpImagePointoperator= (const vpImagePoint &ip)
 
void set_i (const double i)
 
void set_j (const double j)
 
void set_ij (const double i, const double j)
 
double get_i () const
 
double get_j () const
 
void set_u (const double u)
 
void set_v (const double v)
 
void set_uv (const double u, const double v)
 
double get_u () const
 
double get_v () const
 
bool inRectangle (const vpRect &rect) const
 
vpImagePoint projection (const vpHomography &aHb)
 

Static Public Member Functions

static double distance (const vpImagePoint &iP1, const vpImagePoint &iP2)
 
static double sqrDistance (const vpImagePoint &iP1, const vpImagePoint &iP2)
 

Related Functions

(Note that these are not member functions.)

VISP_EXPORT bool operator== (const vpImagePoint &ip1, const vpImagePoint &ip2)
 
VISP_EXPORT bool operator!= (const vpImagePoint &ip1, const vpImagePoint &ip2)
 
VISP_EXPORT vpImagePoint operator+ (const vpImagePoint &ip1, const vpImagePoint &ip2)
 
VISP_EXPORT vpImagePoint operator+ (const vpImagePoint &ip1, const int offset)
 
VISP_EXPORT vpImagePoint operator+ (const vpImagePoint &ip1, const double offset)
 
VISP_EXPORT vpImagePoint operator- (const vpImagePoint &ip1, const vpImagePoint &ip2)
 
VISP_EXPORT vpImagePoint operator- (const vpImagePoint &ip1, const int offset)
 
VISP_EXPORT vpImagePoint operator- (const vpImagePoint &ip1, const double offset)
 
VISP_EXPORT vpImagePoint operator* (const vpImagePoint &ip1, const double scale)
 
VISP_EXPORT vpImagePoint operator/ (const vpImagePoint &ip1, const double scale)
 
VISP_EXPORT std::ostream & operator<< (std::ostream &os, const vpImagePoint &ip)
 

Detailed Description

Class that defines a 2D point in an image. This class is useful for image processing and stores only the 2D coordinates given in sub-pixel.

Warning
If you want to define a point thanks to its coordinates given in meter in the object frame, the camera frame or the image plane, you have to use the class vpPoint.

In this class, the 2D coordinates are not necessary integer values. It is easy to manipulate the given coordinates in the two frames used in ViSP : the (i,j) coordinates and the (u,v) coordinates. The two following images illustrate the two coordinate systems.

vpImagePoint.gif
Warning
An instance of the vpImagePoint class corresponds to a particular point. Thus, if you change the point coordinate using the method set_i(const double i), it produces the same effect than if you used the method set_v(const double v). These two methods change the same private attribute. It is also true for the two methods set_j(const double j) and set_u(const double u).
Examples:
AROgre.cpp, AROgreBasic.cpp, BSpline.cpp, displayD3D.cpp, displayGDI.cpp, displayGTK.cpp, displayOpenCV.cpp, displayX.cpp, displayXMulti.cpp, fernClassifier.cpp, keyPointSurf.cpp, manDisplay.cpp, Nurbs.cpp, planarObjectDetector.cpp, poseVirtualVS.cpp, servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma4Point2DCamVelocityKalman.cpp, servoAfma62DhalfCamVelocity.cpp, servoAfma6Ellipse2DCamVelocity.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp, servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoAfma6Segment2DCamVelocity.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, servoViper650FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper650FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper650Point2DCamVelocity.cpp, servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper850FourPoints2DArtVelocityInteractionDesired.cpp, servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper850FourPointsKinect.cpp, servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp, servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp, servoViper850Point2DArtVelocity.cpp, servoViper850Point2DCamVelocity.cpp, servoViper850Point2DCamVelocityKalman.cpp, SickLDMRS-Process.cpp, testClick.cpp, testDisplays.cpp, testImagePoint.cpp, testMouseEvent.cpp, testRobotAfma6Pose.cpp, testRobotViper850Pose.cpp, testSurfKeyPoint.cpp, testTrackDot.cpp, trackDot.cpp, trackDot2.cpp, trackDot2WithAutoDetection.cpp, trackMeCircle.cpp, trackMeEllipse.cpp, trackMeLine.cpp, trackMeNurbs.cpp, tutorial-ibvs-4pts-display.cpp, tutorial-ibvs-4pts-wireframe-camera.cpp, tutorial-ibvs-4pts-wireframe-robot-afma6.cpp, tutorial-ibvs-4pts-wireframe-robot-viper.cpp, tutorial-image-viewer.cpp, and tutorial-pose-from-points-image.cpp.

Definition at line 92 of file vpImagePoint.h.

Constructor & Destructor Documentation

vpImagePoint::vpImagePoint ( )
inline

Default constructor that initialize the coordinates of the image point to zero.

Definition at line 99 of file vpImagePoint.h.

vpImagePoint::vpImagePoint ( double  i,
double  j 
)
inline

Default constructor that initialize the coordinates of the image thanks to the parameters $ i $ and $ j $.

Definition at line 107 of file vpImagePoint.h.

vpImagePoint::vpImagePoint ( const vpImagePoint ip)
inline

Copy constructor.

Initialize the coordinates of the image point with ip.

Parameters
ip: An image point.

Definition at line 118 of file vpImagePoint.h.

virtual vpImagePoint::~vpImagePoint ( )
inlinevirtual

Destructor.

Definition at line 123 of file vpImagePoint.h.

Member Function Documentation

static double vpImagePoint::distance ( const vpImagePoint iP1,
const vpImagePoint iP2 
)
inlinestatic

Compute the distance $ |iP1 - iP2| = \sqrt{(i_1-i_2)^2+(j_1-j_2)^2} $

Parameters
iP1: First point
iP2: Second point
Returns
the distance between the two points.

Definition at line 261 of file vpImagePoint.h.

References get_i(), get_j(), and vpMath::sqr().

Referenced by vpNurbs::globalCurveInterp(), vpMeNurbs::seekExtremities(), vpMeNurbs::track(), and vpMeNurbs::updateDelta().

double vpImagePoint::get_i ( ) const
inline

Gets the point coordinate corresponding to the $ i $ axes in the frame (i,j).

Returns
The value of the coordinate along the $ i $ axes.
See also
get_j(), get_u(), get_v()
Examples:
keyPointSurf.cpp, and testSurfKeyPoint.cpp.

Definition at line 181 of file vpImagePoint.h.

Referenced by vpKeyPointSurf::buildReference(), vpFernClassifier::buildReference(), vpNurbs::computeCurveDersPoint(), vpMeEllipse::display(), vpDisplayOpenCV::displayArrow(), vpDisplayX::displayArrow(), vpDisplayGTK::displayArrow(), vpDisplayOpenCV::displayCross(), vpDisplayX::displayCross(), vpDisplayGTK::displayCross(), vpDisplayOpenCV::displayImageROI(), vpDisplayX::displayImageROI(), vpDisplayGTK::displayImageROI(), vpMbtKltPolygon::displayPrimitive(), vpDisplayWin32::displayRectangle(), vpDisplay::displayRectangle(), distance(), vpMbtPolygon::getNbCornerInsideImage(), vpImage< vpRGBa >::getValue(), vpImage< unsigned char >::getValue(), vpImage< Type >::getValue(), vpMbtDistanceLine::initMovingEdge(), vpMbtDistanceCylinder::initMovingEdge(), vpMeEllipse::initTracking(), vpMeLine::initTracking(), vpDot2::initTracking(), vpDot::initTracking(), vpImage< Type >::insert(), vpTriangle::inTriangle(), vpPolygon::isInside(), vpPlanarObjectDetector::matchPoint(), vpKeyPointSurf::matchPoint(), vpFernClassifier::matchPoint(), vpWireFrameSimulator::navigation(), operator!=(), vpImage< unsigned char >::operator()(), operator*(), operator+(), operator-(), operator/(), operator<<(), operator==(), vpMeTracker::outOfImage(), vpNurbs::removeCurveKnot(), vpMeNurbs::seekExtremitiesCanny(), sqrDistance(), vpMbtDistanceLine::updateMovingEdge(), and vpMbtDistanceCylinder::updateMovingEdge().

double vpImagePoint::get_j ( ) const
inline

Gets the point coordinate corresponding to the $ j $ axes in the frame (i,j).

Returns
The value of the coordinate along the $ j $ axes.
See also
get_i(), get_u(), get_v()
Examples:
keyPointSurf.cpp, and testSurfKeyPoint.cpp.

Definition at line 192 of file vpImagePoint.h.

Referenced by vpKeyPointSurf::buildReference(), vpFernClassifier::buildReference(), vpNurbs::computeCurveDersPoint(), vpPlanarObjectDetector::computeRoi(), vpMeEllipse::display(), vpDisplayOpenCV::displayArrow(), vpDisplayX::displayArrow(), vpDisplayGTK::displayArrow(), vpDisplayOpenCV::displayCross(), vpDisplayX::displayCross(), vpDisplayGTK::displayCross(), vpDisplayOpenCV::displayImageROI(), vpDisplayX::displayImageROI(), vpDisplayGTK::displayImageROI(), vpMbtKltPolygon::displayPrimitive(), vpDisplayWin32::displayRectangle(), vpDisplay::displayRectangle(), distance(), vpMbtPolygon::getNbCornerInsideImage(), vpImage< vpRGBa >::getValue(), vpImage< unsigned char >::getValue(), vpImage< Type >::getValue(), vpMbtDistanceLine::initMovingEdge(), vpMbtDistanceCylinder::initMovingEdge(), vpMeEllipse::initTracking(), vpMeLine::initTracking(), vpDot2::initTracking(), vpDot::initTracking(), vpImage< Type >::insert(), vpTriangle::inTriangle(), vpPolygon::isInside(), vpPlanarObjectDetector::matchPoint(), vpKeyPointSurf::matchPoint(), vpFernClassifier::matchPoint(), vpWireFrameSimulator::navigation(), operator!=(), vpImage< unsigned char >::operator()(), operator*(), operator+(), operator-(), operator/(), operator<<(), operator==(), vpMeTracker::outOfImage(), vpNurbs::removeCurveKnot(), vpMeNurbs::seekExtremitiesCanny(), sqrDistance(), vpMbtDistanceLine::updateMovingEdge(), and vpMbtDistanceCylinder::updateMovingEdge().

double vpImagePoint::get_u ( ) const
inline
double vpImagePoint::get_v ( ) const
inline
bool vpImagePoint::inRectangle ( const vpRect rect) const

Check if an image point belongs to a rectangle.

Parameters
rect: the rectangle.
Returns
Returns true if the point belongs to the rectangle.

Definition at line 58 of file vpImagePoint.cpp.

References vpRect::getBottom(), vpRect::getLeft(), vpRect::getRight(), and vpRect::getTop().

Referenced by vpPlot::navigate().

const vpImagePoint& vpImagePoint::operator= ( const vpImagePoint ip)
inline

Copy operator.

Definition at line 130 of file vpImagePoint.h.

vpImagePoint vpImagePoint::projection ( const vpHomography aHb)

Project the current image point (in frame b) into the frame a using the homography aHb.

Parameters
aHb: Homography defining the relation between frame a and frame b.
Returns
The projected image point in the frame a.

Definition at line 74 of file vpImagePoint.cpp.

References set_i(), and set_j().

void vpImagePoint::set_i ( const double  i)
inline

Sets the point coordinate corresponding to the $ i $ axes in the frame (i,j).

Parameters
i: The desired value for the coordinate along the $ i $ axes.
See also
set_j(), set_u(), set_v()
Examples:
AROgre.cpp, AROgreBasic.cpp, displayD3D.cpp, displayGDI.cpp, displayGTK.cpp, displayOpenCV.cpp, displayX.cpp, displayXMulti.cpp, manDisplay.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, SickLDMRS-Process.cpp, testDisplays.cpp, testImagePoint.cpp, testTrackDot.cpp, trackMeCircle.cpp, trackMeEllipse.cpp, and trackMeLine.cpp.

Definition at line 145 of file vpImagePoint.h.

Referenced by vpKeyPointSurf::buildReference(), vpFernClassifier::buildReference(), vpBSpline::computeCurveDers(), vpNurbs::computeCurveDersPoint(), vpNurbs::computeCurvePoint(), vpBSpline::computeCurvePoint(), vpMeLine::computeRhoTheta(), vpMeLine::display(), vpMeEllipse::display(), vpDisplayOpenCV::displayArrow(), vpDisplayX::displayArrow(), vpDisplayGTK::displayArrow(), vpDisplay::displayArrow(), vpDisplay::displayCharString(), vpDisplay::displayCircle(), vpDisplayOpenCV::displayCross(), vpDisplayX::displayCross(), vpDisplayGTK::displayCross(), vpDisplay::displayCross(), vpDisplay::displayDotLine(), vpDisplay::displayLine(), vpDisplay::displayPoint(), vpMbtKltPolygon::displayPrimitive(), vpDisplayWin32::displayRectangle(), vpDisplay::displayRectangle(), vpMeLine::getExtremities(), vpMeSite::getQueryList(), vpImage< unsigned char >::getValue(), vpImage< vpRGBa >::getValue(), vpImage< Type >::getValue(), vpMeTracker::initTracking(), vpMeEllipse::initTracking(), vpMeLine::intersection(), vpPolygon::isInside(), vpPlanarObjectDetector::matchPoint(), vpKeyPointSurf::matchPoint(), vpFernClassifier::matchPoint(), projection(), vpNurbs::refineKnotVectCurve(), vpNurbs::removeCurveKnot(), vpMeLine::sample(), vpMeLine::seekExtremities(), vpImageSimulator::setCameraPosition(), vpMeTracker::track(), vpMeSite::track(), vpPolygon::updateCenter(), and vpMeEllipse::vpMeEllipse().

void vpImagePoint::set_ij ( const double  i,
const double  j 
)
inline
void vpImagePoint::set_j ( const double  j)
inline

Sets the point coordinate corresponding to the $ j $ axes in the frame (i,j).

Parameters
j: The desired value for the coordinate along the $ j $ axes.
See also
set_i(), set_u(), set_v()
Examples:
AROgre.cpp, AROgreBasic.cpp, displayD3D.cpp, displayGDI.cpp, displayGTK.cpp, displayOpenCV.cpp, displayX.cpp, displayXMulti.cpp, manDisplay.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, SickLDMRS-Process.cpp, testDisplays.cpp, testImagePoint.cpp, testTrackDot.cpp, trackMeCircle.cpp, trackMeEllipse.cpp, and trackMeLine.cpp.

Definition at line 156 of file vpImagePoint.h.

Referenced by vpKeyPointSurf::buildReference(), vpFernClassifier::buildReference(), vpBSpline::computeCurveDers(), vpNurbs::computeCurveDersPoint(), vpNurbs::computeCurvePoint(), vpBSpline::computeCurvePoint(), vpMeLine::computeRhoTheta(), vpMeLine::display(), vpMeEllipse::display(), vpDisplayOpenCV::displayArrow(), vpDisplayX::displayArrow(), vpDisplayGTK::displayArrow(), vpDisplay::displayArrow(), vpDisplay::displayCharString(), vpDisplay::displayCircle(), vpDisplayOpenCV::displayCross(), vpDisplayX::displayCross(), vpDisplayGTK::displayCross(), vpDisplay::displayCross(), vpDisplay::displayDotLine(), vpDisplay::displayLine(), vpDisplay::displayPoint(), vpMbtKltPolygon::displayPrimitive(), vpDisplayWin32::displayRectangle(), vpDisplay::displayRectangle(), vpMeLine::getExtremities(), vpMeSite::getQueryList(), vpImage< vpRGBa >::getValue(), vpImage< unsigned char >::getValue(), vpImage< Type >::getValue(), vpMeTracker::initTracking(), vpMeEllipse::initTracking(), vpMeLine::intersection(), vpPolygon::isInside(), vpPlanarObjectDetector::matchPoint(), vpKeyPointSurf::matchPoint(), vpFernClassifier::matchPoint(), projection(), vpNurbs::removeCurveKnot(), vpMeLine::sample(), vpMeLine::seekExtremities(), vpImageSimulator::setCameraPosition(), vpMeTracker::track(), vpMeSite::track(), vpPolygon::updateCenter(), and vpMeEllipse::vpMeEllipse().

void vpImagePoint::set_uv ( const double  u,
const double  v 
)
inline

Sets the point coordinates in the frame (u,v).

Parameters
u: The desired value for the coordinate along the $ u $ axes.
v: The desired value for the coordinate along the $ v $ axes.
See also
set_i(), set_j(), set_u(), set_v()

Definition at line 225 of file vpImagePoint.h.

Referenced by vpDot2::defineDots(), and vpPlanarObjectDetector::getDetectedCorners().

static double vpImagePoint::sqrDistance ( const vpImagePoint iP1,
const vpImagePoint iP2 
)
inlinestatic

Compute the distance $ |iP1 - iP2| = (i_1-i_2)^2+(j_1-j_2)^2 $

Parameters
iP1: First point
iP2: Second point
Returns
the distance between the two points.

Definition at line 273 of file vpImagePoint.h.

References get_i(), get_j(), and vpMath::sqr().

Referenced by vpMeNurbs::localReSample(), and vpMeNurbs::sample().

Friends And Related Function Documentation

VISP_EXPORT bool operator!= ( const vpImagePoint ip1,
const vpImagePoint ip2 
)
related

Returns true if ip1 and ip2 are different; otherwire returns true.

Definition at line 314 of file vpImagePoint.h.

References get_i(), get_j(), and vpMath::maximum().

VISP_EXPORT vpImagePoint operator* ( const vpImagePoint ip1,
const double  scale 
)
related

Returns a vpImagePoint with coordinates multiplied by a scale factor.

#include <iostream>
#include <visp/vpImagePoint.h>
int main()
{
vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200
std::cout << "ip: " << ip << std::endl; // coordinates (100, 200)
std::cout << "ip*2: " << ip*2 << std::endl; // new coordinates (200, 400)
return 0;
}

Definition at line 468 of file vpImagePoint.h.

References get_i(), and get_j().

VISP_EXPORT vpImagePoint operator+ ( const vpImagePoint ip1,
const vpImagePoint ip2 
)
related

Returns a vpImagePoint wich is the sum of $ ip1 $ and $ ip2 $.

Definition at line 336 of file vpImagePoint.h.

References get_i(), and get_j().

VISP_EXPORT vpImagePoint operator+ ( const vpImagePoint ip1,
const int  offset 
)
related

Returns a vpImagePoint with an offset added to the two coordinates.

#include <iostream>
#include <visp/vpImagePoint.h>
int main()
{
vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200
std::cout << "ip: " << ip << std::endl; // coordinates (100, 200)
std::cout << "ip+10: " << ip+10 << std::endl; // new coordinates (110, 210)
return 0;
}

Definition at line 360 of file vpImagePoint.h.

References get_i(), and get_j().

VISP_EXPORT vpImagePoint operator+ ( const vpImagePoint ip1,
const double  offset 
)
related

Returns a vpImagePoint with an offset added to the two coordinates.

#include <iostream>
#include <visp/vpImagePoint.h>
int main()
{
vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200
std::cout << "ip: " << ip << std::endl; // coordinates (100, 200)
std::cout << "ip+12.34: " << ip+12.34 << std::endl; // new coordinates (112.34, 212.34)
return 0;
}

Definition at line 384 of file vpImagePoint.h.

References get_i(), and get_j().

VISP_EXPORT vpImagePoint operator- ( const vpImagePoint ip1,
const vpImagePoint ip2 
)
related

Returns a vpImagePoint wich is the difference between $ ip1 $ and $ ip2 $.

Definition at line 396 of file vpImagePoint.h.

References get_i(), and get_j().

VISP_EXPORT vpImagePoint operator- ( const vpImagePoint ip1,
const int  offset 
)
related

Returns a vpImagePoint with an offset substracted to the two coordinates.

#include <iostream>
#include <visp/vpImagePoint.h>
int main()
{
vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200
std::cout << "ip: " << ip << std::endl; // coordinates (100, 200)
std::cout << "ip-10: " << ip-10 << std::endl; // new coordinates (90, 190)
return 0;
}

Definition at line 420 of file vpImagePoint.h.

References get_i(), and get_j().

VISP_EXPORT vpImagePoint operator- ( const vpImagePoint ip1,
const double  offset 
)
related

Returns a vpImagePoint with an offset substracted to the two coordinates.

#include <iostream>
#include <visp/vpImagePoint.h>
int main()
{
vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200
std::cout << "ip: " << ip << std::endl; // coordinates (100, 200)
std::cout << "ip-12.34: " << ip-12.34 << std::endl; // new coordinates (87.66, 187.66)
return 0;
}

Definition at line 444 of file vpImagePoint.h.

References get_i(), and get_j().

VISP_EXPORT vpImagePoint operator/ ( const vpImagePoint ip1,
const double  scale 
)
related

Returns a vpImagePoint with coordinates divided by a scale factor.

#include <iostream>
#include <visp/vpImagePoint.h>
int main()
{
vpImagePoint ip(100, 200); // Create an image point with coordinates i=100, j=200
std::cout << "ip: " << ip << std::endl; // coordinates (100, 200)
std::cout << "ip/2: " << ip/2 << std::endl; // new coordinates (50, 100)
return 0;
}

Definition at line 492 of file vpImagePoint.h.

References get_i(), and get_j().

VISP_EXPORT std::ostream & operator<< ( std::ostream &  os,
const vpImagePoint ip 
)
related

Writes the image point coordinates ip to the stream os, and returns a reference to the stream. Writes the first coordinate along the i axis and then the second one along the j axis. The coordinates are separated by a comma.

The following code

#include <iostream>
#include <visp/vpImagePoint.h>
int main()
{
ip.set_i(10);
ip.set_j(11.1);
std::cout << "Image point with coordinates: " << ip << std::endl;
return 0;
}

The previous sample code produces the output:

Image point with coordinates: 10, 11.1

Definition at line 529 of file vpImagePoint.h.

References get_i(), and get_j().

VISP_EXPORT bool operator== ( const vpImagePoint ip1,
const vpImagePoint ip2 
)
related

Returns true if ip1 and ip2 are equal; otherwire returns false.

Definition at line 291 of file vpImagePoint.h.

References get_i(), get_j(), and vpMath::maximum().