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 0x7ff6a9fefac0>>

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.

  1. __init__(self: visp._visp.core.ImagePoint) -> None

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

  1. __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\) .

  1. __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

__init__

Overloaded function.

distance

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

getBBox

param ipVec:

Vector of input image points.

get_i

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

get_j

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

get_u

Gets the point coordinate corresponding to the \(u\) axes in the frame (u,v).

get_v

Gets the point coordinate corresponding to the \(v\) axes in the frame (u,v).

inRectangle

Check if an image point belongs to a rectangle.

inSegment

Test if the image point belongs to a segment represented by two image points.

nextInSegment

Considering current image point, returns the next image point that belongs to the segment [start,end].

set_i

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

set_ij

Sets the point coordinates in the frame (i,j).

set_j

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

set_u

Sets the point coordinate corresponding to the \(u\) axes in the frame (u,v).

set_uv

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

set_v

Sets the point coordinate corresponding to the \(v\) axes in the frame (u,v).

sqrDistance

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

Inherited Methods

Operators

__doc__

__iadd__

Operator +=.

__imul__

Operator *=.

__init__

Overloaded function.

__isub__

Operator -=.

__itruediv__

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>

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.

  1. __init__(self: visp._visp.core.ImagePoint) -> None

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

  1. __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\) .

  1. __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>

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>

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()

Parameters:
ii: float

The desired value for the coordinate along the \(i\) axes.

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()

Parameters:
ii: float

The desired value for the coordinate along the \(i\) axes.

jj: float

The desired value for the coordinate along the \(j\) axes.

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()

Parameters:
jj: float

The desired value for the coordinate along the \(j\) axes.

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()

Parameters:
u: float

The desired value for the coordinate along the \(u\) axes.

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()

Parameters:
u: float

The desired value for the coordinate along the \(u\) axes.

v: float

The desired value for the coordinate along the \(v\) axes.

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()

Parameters:
v: float

The desired value for the coordinate along the \(v\) axes.

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.