ImagePoint¶
- class ImagePoint(*args, **kwargs)¶
Bases:
pybind11_object
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.
<unparsed image <doxmlparser.compound.docImageType object at 0x7f8138b3a980>>
Warning
An instance of the vpImagePoint class corresponds to a particular point. Thus, if you change the point coordinate using the method set_i(double i) , it produces the same effect than if you used the method set_v(double v) . These two methods change the same private attribute. It is also true for the two methods set_j(double j) and set_u(double u) .
Overloaded function.
__init__(self: visp._visp.core.ImagePoint) -> None
Default constructor that initialize the coordinates of the image point to zero.
__init__(self: visp._visp.core.ImagePoint, ii: float, jj: float) -> None
Default constructor that initialize the coordinates of the image thanks to the parameters \(ii\) and \(jj\) .
__init__(self: visp._visp.core.ImagePoint, ip: visp._visp.core.ImagePoint) -> None
Copy constructor.
Initialize the coordinates of the image point with ip .
- Parameters:
- ip
An image point.
Methods
Overloaded function.
Compute the distance \(|iP1 - iP2| = \sqrt{(i_1-i_2)^2+(j_1-j_2)^2}\)
- param ipVec:
Vector of input image points.
Gets the point coordinate corresponding to the \(i\) axes in the frame (i,j).
Gets the point coordinate corresponding to the \(j\) axes in the frame (i,j).
Gets the point coordinate corresponding to the \(u\) axes in the frame (u,v).
Gets the point coordinate corresponding to the \(v\) axes in the frame (u,v).
Check if an image point belongs to a rectangle.
Test if the image point belongs to a segment represented by two image points.
Considering current image point, returns the next image point that belongs to the segment [start,end].
Sets the point coordinate corresponding to the \(i\) axes in the frame (i,j).
Sets the point coordinates in the frame (i,j).
Sets the point coordinate corresponding to the \(j\) axes in the frame (i,j).
Sets the point coordinate corresponding to the \(u\) axes in the frame (u,v).
Sets the point coordinates in the frame (u,v).
Sets the point coordinate corresponding to the \(v\) axes in the frame (u,v).
Compute the distance \(|iP1 - iP2| = (i_1-i_2)^2+(j_1-j_2)^2\)
Inherited Methods
Operators
__doc__
Operator +=.
Operator *=.
Overloaded function.
Operator -=.
Operator /=.
__module__
__repr__
Attributes
__annotations__
- __iadd__(self, ip: visp._visp.core.ImagePoint) visp._visp.core.ImagePoint ¶
Operator +=.
This operator can be used to compute the center of gravity of a set of image points.
#include <iostream> #include <vector> #include <visp3/core/vpImagePoint.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { std::vector<vpImagePoint> ip(2); ip[0].set_ij(100, 200); ip[1].set_ij(300, 400); vpImagePoint cog(0,0); for(unsigned int i=0; i<ip.size(); ++i) cog += ip[i]; cog /= ip.size(); std::cout << "cog: " << cog << std::endl; }
- __imul__(self, scale: float) visp._visp.core.ImagePoint ¶
Operator *=.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.core.ImagePoint) -> None
Default constructor that initialize the coordinates of the image point to zero.
__init__(self: visp._visp.core.ImagePoint, ii: float, jj: float) -> None
Default constructor that initialize the coordinates of the image thanks to the parameters \(ii\) and \(jj\) .
__init__(self: visp._visp.core.ImagePoint, ip: visp._visp.core.ImagePoint) -> None
Copy constructor.
Initialize the coordinates of the image point with ip .
- Parameters:
- ip
An image point.
- __isub__(self, ip: visp._visp.core.ImagePoint) visp._visp.core.ImagePoint ¶
Operator -=.
- __itruediv__(self, scale: float) visp._visp.core.ImagePoint ¶
Operator /=.
This operator can be used to compute the center of gravity of a set of image points.
#include <iostream> #include <vector> #include <visp3/core/vpImagePoint.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { std::vector<vpImagePoint> ip(2); ip[0].set_ij(100, 200); ip[1].set_ij(300, 400); vpImagePoint cog(0,0); for(unsigned int i=0; i<ip.size(); ++i) cog += ip[i]; cog /= ip.size(); std::cout << "cog: " << cog << std::endl; }
- static distance(iP1: visp._visp.core.ImagePoint, iP2: visp._visp.core.ImagePoint) float ¶
Compute the distance \(|iP1 - iP2| = \sqrt{(i_1-i_2)^2+(j_1-j_2)^2}\)
- Parameters:
- iP1: visp._visp.core.ImagePoint¶
First point
- iP2: visp._visp.core.ImagePoint¶
Second point
- Returns:
the distance between the two points.
- static getBBox(ipVec: list[visp._visp.core.ImagePoint]) visp._visp.core.Rect ¶
- Parameters:
- ipVec: list[visp._visp.core.ImagePoint]¶
Vector of input image points.
- Returns:
Bounding box of the points.
- get_i(self) float ¶
Gets the point coordinate corresponding to the \(i\) axes in the frame (i,j).
Note
See get_j() , get_u() , get_v()
- Returns:
The value of the coordinate along the \(i\) axes.
- get_j(self) float ¶
Gets the point coordinate corresponding to the \(j\) axes in the frame (i,j).
Note
See get_i() , get_u() , get_v()
- Returns:
The value of the coordinate along the \(j\) axes.
- get_u(self) float ¶
Gets the point coordinate corresponding to the \(u\) axes in the frame (u,v).
Note
See get_i() , get_j() , get_v()
- Returns:
The value of the coordinate along the \(u\) axes.
- get_v(self) float ¶
Gets the point coordinate corresponding to the \(v\) axes in the frame (u,v).
Note
See get_i() , get_j() , get_u()
- Returns:
The value of the coordinate along the \(v\) axes.
- inRectangle(self, rect: visp._visp.core.Rect) bool ¶
Check if an image point belongs to a rectangle.
- Parameters:
- rect: visp._visp.core.Rect¶
the rectangle.
- Returns:
Returns true if the point belongs to the rectangle.
- inSegment(self, start: visp._visp.core.ImagePoint, end: visp._visp.core.ImagePoint) bool ¶
Test if the image point belongs to a segment represented by two image points.
To see how to use this function, a code snippet is given in nextInSegment() .
Note
See nextInSegment()
- Parameters:
- start: visp._visp.core.ImagePoint¶
Segment start image point.
- end: visp._visp.core.ImagePoint¶
Segment end image point.
- Returns:
True if current image point belongs to the segment. False otherwise.
- nextInSegment(self, start: visp._visp.core.ImagePoint, end: visp._visp.core.ImagePoint) visp._visp.core.ImagePoint ¶
Considering current image point, returns the next image point that belongs to the segment [start,end].
The following sample code shows how to use this function to find all the pixels that belong to the segment defined by 2 image points with coordinates [10,12] and [20,16]:
#include <iostream> #include <visp3/core/vpImagePoint.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpImagePoint start_pixel(10, 12); vpImagePoint end_pixel(20, 16); for (auto curr_pixel = start_pixel; curr_pixel.inSegment(start_pixel, end_pixel); curr_pixel = curr_pixel.nextInSegment(start_pixel, end_pixel)) { std::cout << "pixel: " << curr_pixel << std::endl; if (curr_pixel == end_pixel) break; } return EXIT_SUCCESS; }
It produces the following output by printing all the pixels belonging to the segment:
pixel: 10, 12 pixel: 11, 12.4 pixel: 12, 12.8 pixel: 13, 13.2 pixel: 14, 13.6 pixel: 15, 14 pixel: 16, 14.4 pixel: 17, 14.8 pixel: 18, 15.2 pixel: 19, 15.6 pixel: 20, 16
Note
See inSegment()
- Parameters:
- start: visp._visp.core.ImagePoint¶
Segment start image point.
- end: visp._visp.core.ImagePoint¶
Segment end image point.
- Returns:
Regarding current image point, next image point that belongs to the liSegmentne [start,end].
- set_i(self, ii: float) None ¶
Sets the point coordinate corresponding to the \(i\) axes in the frame (i,j).
Note
See set_j() , set_u() , set_v()
- set_ij(self, ii: float, jj: float) None ¶
Sets the point coordinates in the frame (i,j).
Note
See set_i() , set_j() , set_u() , set_v()
- set_j(self, jj: float) None ¶
Sets the point coordinate corresponding to the \(j\) axes in the frame (i,j).
Note
See set_i() , set_u() , set_v()
- set_u(self, u: float) None ¶
Sets the point coordinate corresponding to the \(u\) axes in the frame (u,v).
Note
See set_i() , set_j() , set_v()
- set_uv(self, u: float, v: float) None ¶
Sets the point coordinates in the frame (u,v).
Note
See set_i() , set_j() , set_u() , set_v()
- set_v(self, v: float) None ¶
Sets the point coordinate corresponding to the \(v\) axes in the frame (u,v).
Note
See set_i() , set_j() , set_u()
- static sqrDistance(iP1: visp._visp.core.ImagePoint, iP2: visp._visp.core.ImagePoint) float ¶
Compute the distance \(|iP1 - iP2| = (i_1-i_2)^2+(j_1-j_2)^2\)
- Parameters:
- iP1: visp._visp.core.ImagePoint¶
First point
- iP2: visp._visp.core.ImagePoint¶
Second point
- Returns:
the distance between the two points.