Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
vpImageDraw Class Reference

#include <visp3/core/vpImageDraw.h>

Static Public Member Functions

static void drawArrow (vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, unsigned char color, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)
 
static void drawArrow (vpImage< vpRGBa > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)
 
static void drawCircle (vpImage< unsigned char > &I, const vpImagePoint &center, unsigned int radius, unsigned char color, unsigned int thickness=1)
 
static void drawCircle (vpImage< vpRGBa > &I, const vpImagePoint &center, unsigned int radius, const vpColor &color, unsigned int thickness=1)
 
static void drawCross (vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, unsigned char color, unsigned int thickness=1)
 
static void drawCross (vpImage< vpRGBa > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
 
static void drawDottedLine (vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, unsigned char color, unsigned int thickness=1)
 
static void drawDottedLine (vpImage< vpRGBa > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
 
static void drawEllipse (vpImage< unsigned char > &I, const vpImagePoint &center, double coef1, double coef2, double coef3, bool use_centered_moments, unsigned char color, double theta1=0, double theta2=360, unsigned int thickness=1)
 
static void drawEllipse (vpImage< vpRGBa > &I, const vpImagePoint &center, double coef1, double coef2, double coef3, bool use_centered_moments, const vpColor &color, double theta1=0, double theta2=360, unsigned int thickness=1)
 
static void drawFrame (vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, unsigned char color, unsigned int thickness=1, const vpImagePoint &offset=vpImagePoint(0, 0))
 
static void drawFrame (vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color=vpColor::none, unsigned int thickness=1, const vpImagePoint &offset=vpImagePoint(0, 0))
 
static void drawLine (vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, unsigned char color, unsigned int thickness=1)
 
static void drawLine (vpImage< vpRGBa > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
 
static void drawPoint (vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned char color, unsigned int thickness=1)
 
static void drawPoint (vpImage< vpRGBa > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
 
static void drawPolygon (vpImage< unsigned char > &I, const std::vector< vpImagePoint > &vip, unsigned char color, unsigned int thickness=1, bool closed=true)
 
static void drawPolygon (vpImage< vpRGBa > &I, const std::vector< vpImagePoint > &vip, const vpColor &color, unsigned int thickness=1, bool closed=true)
 
static void drawRectangle (vpImage< unsigned char > &I, const vpRect &rectangle, unsigned char color, bool fill=false, unsigned int thickness=1)
 
static void drawRectangle (vpImage< vpRGBa > &I, const vpRect &rectangle, const vpColor &color, bool fill=false, unsigned int thickness=1)
 

Detailed Description

Drawing functions for image.

Definition at line 57 of file vpImageDraw.h.

Member Function Documentation

◆ drawArrow() [1/2]

void vpImageDraw::drawArrow ( vpImage< unsigned char > &  I,
const vpImagePoint ip1,
const vpImagePoint ip2,
unsigned char  color,
unsigned int  w = 4,
unsigned int  h = 2,
unsigned int  thickness = 1 
)
static

Draw an arrow from image point ip1 to image point ip2.

Parameters
[in,out]I: Image where to draw the arrow.
[in]ip1,ip2: Initial and final image points.
[in]color: Arrow color.
[in]w,h: Width and height of the arrow.
[in]thickness: Thickness of the lines used to display the arrow.
Examples:
testImageDraw.cpp.

Definition at line 237 of file vpImageDraw.cpp.

References vpImagePoint::distance(), drawLine(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpImagePoint::set_i(), vpImagePoint::set_j(), and vpMath::sqr().

Referenced by drawFrame().

◆ drawArrow() [2/2]

void vpImageDraw::drawArrow ( vpImage< vpRGBa > &  I,
const vpImagePoint ip1,
const vpImagePoint ip2,
const vpColor color,
unsigned int  w = 4,
unsigned int  h = 2,
unsigned int  thickness = 1 
)
static

Draw an arrow from image point ip1 to image point ip2.

Parameters
[in,out]I: Image where to draw the arrow.
[in]ip1,ip2: Initial and final image points.
[in]color: Arrow color.
[in]w,h: Width and height of the arrow.
[in]thickness: Thickness of the lines used to display the arrow.

Definition at line 282 of file vpImageDraw.cpp.

References vpImagePoint::distance(), drawLine(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpImagePoint::set_i(), vpImagePoint::set_j(), and vpMath::sqr().

◆ drawCircle() [1/2]

void vpImageDraw::drawCircle ( vpImage< unsigned char > &  I,
const vpImagePoint center,
unsigned int  radius,
unsigned char  color,
unsigned int  thickness = 1 
)
static

Draw a circle in an image.

Parameters
[in,out]I: Image where to draw the circle.
[in]center: Circle center position.
[in]radius: Circle radius.
[in]color: Circle color.
[in]thickness: Thickness of the circle.
Examples:
testImageDraw.cpp.

Definition at line 327 of file vpImageDraw.cpp.

◆ drawCircle() [2/2]

void vpImageDraw::drawCircle ( vpImage< vpRGBa > &  I,
const vpImagePoint center,
unsigned int  radius,
const vpColor color,
unsigned int  thickness = 1 
)
static

Draw a circle in an image.

Parameters
[in,out]I: Image where to draw the circle.
[in]center: Circle center position.
[in]radius: Circle radius.
[in]color: Circle color.
[in]thickness: Thickness of the circle.

Definition at line 341 of file vpImageDraw.cpp.

References vpRGBa::B, vpRGBa::G, and vpRGBa::R.

◆ drawCross() [1/2]

void vpImageDraw::drawCross ( vpImage< unsigned char > &  I,
const vpImagePoint ip,
unsigned int  size,
unsigned char  color,
unsigned int  thickness = 1 
)
static

Draw a cross in an image at position given by ip location.

Parameters
[in,out]I: Image where to draw the cross.
[in]ip: Cross location.
[in]size: Size (width and height) of the cross.
[in]color: Cross color.
[in]thickness: Thickness of the lines used to display the cross.
Examples:
testGenericTracker.cpp, and testImageDraw.cpp.

Definition at line 355 of file vpImageDraw.cpp.

References drawLine(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpImagePoint::set_i(), and vpImagePoint::set_j().

◆ drawCross() [2/2]

void vpImageDraw::drawCross ( vpImage< vpRGBa > &  I,
const vpImagePoint ip,
unsigned int  size,
const vpColor color,
unsigned int  thickness = 1 
)
static

Draw a cross in an image at position given by ip location.

Parameters
[in,out]I: Image where to draw the cross.
[in]ip: Cross location.
[in]size: Size (width and height) of the cross.
[in]color: Cross color.
[in]thickness: Thickness of the lines used to display the cross.

Definition at line 379 of file vpImageDraw.cpp.

References drawLine(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpImagePoint::set_i(), and vpImagePoint::set_j().

◆ drawDottedLine() [1/2]

void vpImageDraw::drawDottedLine ( vpImage< unsigned char > &  I,
const vpImagePoint ip1,
const vpImagePoint ip2,
unsigned char  color,
unsigned int  thickness = 1 
)
static

Draw a dashed line in an image between two image points.

Parameters
[in,out]I: Image where to draw the dashed line.
[in]ip1,ip2: Initial and final image points.
[in]color: Line color.
[in]thickness: Dashed line thickness.
Examples:
testImageDraw.cpp.

Definition at line 402 of file vpImageDraw.cpp.

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

◆ drawDottedLine() [2/2]

void vpImageDraw::drawDottedLine ( vpImage< vpRGBa > &  I,
const vpImagePoint ip1,
const vpImagePoint ip2,
const vpColor color,
unsigned int  thickness = 1 
)
static

Draw a dashed line in an image between two image points.

Parameters
[in,out]I: Image where to draw the dashed line.
[in]ip1,ip2: Initial and final image points.
[in]color: Line color.
[in]thickness: Dashed line thickness.

Definition at line 445 of file vpImageDraw.cpp.

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

◆ drawEllipse() [1/2]

void vpImageDraw::drawEllipse ( vpImage< unsigned char > &  I,
const vpImagePoint center,
double  coef1,
double  coef2,
double  coef3,
bool  use_centered_moments,
unsigned char  color,
double  theta1 = 0,
double  theta2 = 360,
unsigned int  thickness = 1 
)
static

Draw an ellipse in an image from its parameters expressed in pixels.

Parameters
[in,out]I: Image where to draw the ellipse.
[in]center: Center $(u_c, v_c)$ of the ellipse.
[in]coef1,coef2,coef3: Depending on the parameter use_centered_moments these parameters are:
  • the centered moments expressed in pixels: $\mu_{20}, \mu_{11}, \mu_{02}$;
  • the major and minor axis lenght in pixels and the excentricity of the ellipse in radians: $a, b, e$.
[in]theta1,theta2: Angles $(\theta_1, \theta_2)$ in radians used to select a portion of the ellipse. If theta1=0 and theta2=vpMath::rad(360) all the ellipse is displayed.
[in]use_centered_moments: When false, the parameters coef1, coef2, coef3 are the parameters $a, b, e$. When true, the parameters coef1, coef2, coef3 are rather the centered moments $\mu_{20}, \mu_{11}, \mu_{02}$ expressed in pixels. In that case, we compute the parameters a, b and e from the centered moments.
[in]color: Ellipse color.
[in]thickness: Ellipse thickness.

All the points $(u_\theta,v_\theta)$ on the ellipse are drawn thanks to its parametric representation:

\[ \left(\begin{array}{c} u_\theta \\ v_\theta \end{array} \right) = \left(\begin{array}{c} u_c \\ v_c \end{array} \right) + \left(\begin{array}{cc} \cos(e) & -\sin(e) \\ \sin(e) & \cos(e) \end{array} \right) \left(\begin{array}{c} a \cos(\theta) \\ b \sin(\theta) \end{array} \right) \]

with $\theta_1 \leq \theta \leq \theta_2$.

The following example shows how to use for example this function to draw the result of a tracking.

vpMeEllipse ellipse;
...
vpDisplay::display(I);
ellipse.track(I);
vpImageDraw::DrawEllipse(I, ellipse.getCenter(), ellipse.get_mu20(),
ellipse.get_mu11(), ellipse.get_mu02(),
ellipse.getSmallestAngle(),
ellipse.getHighestAngle(), true, vpColor::orange, 1);

Definition at line 535 of file vpImageDraw.cpp.

References drawLine(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpMath::rad(), vpImagePoint::set_i(), vpImagePoint::set_j(), and vpMath::sqr().

◆ drawEllipse() [2/2]

void vpImageDraw::drawEllipse ( vpImage< vpRGBa > &  I,
const vpImagePoint center,
double  coef1,
double  coef2,
double  coef3,
bool  use_centered_moments,
const vpColor color,
double  theta1 = 0,
double  theta2 = 360,
unsigned int  thickness = 1 
)
static

Draw an ellipse in an image from its parameters expressed in pixels.

Parameters
[in,out]I: Image where to draw the ellipse.
[in]center: Center $(u_c, v_c)$ of the ellipse.
[in]coef1,coef2,coef3: Depending on the parameter use_centered_moments these parameters are:
  • the centered moments expressed in pixels: $\mu_{20}, \mu_{11}, \mu_{02}$;
  • the major and minor axis lenght in pixels and the excentricity of the ellipse in radians: $a, b, e$.
[in]theta1,theta2: Angles $(\theta_1, \theta_2)$ in radians used to select a portion of the ellipse. If theta1=0 and theta2=vpMath::rad(360) all the ellipse is displayed.
[in]use_centered_moments: When false, the parameters coef1, coef2, coef3 are the parameters $a, b, e$. When true, the parameters coef1, coef2, coef3 are rather the centered moments $\mu_{20}, \mu_{11}, \mu_{02}$ expressed in pixels. In that case, we compute the parameters a, b and e from the centered moments.
[in]color: Ellipse color.
[in]thickness: Ellipse thickness.

All the points $(u_\theta,v_\theta)$ on the ellipse are drawn thanks to its parametric representation:

\[ \left(\begin{array}{c} u_\theta \\ v_\theta \end{array} \right) = \left(\begin{array}{c} u_c \\ v_c \end{array} \right) + \left(\begin{array}{cc} \cos(e) & -\sin(e) \\ \sin(e) & \cos(e) \end{array} \right) \left(\begin{array}{c} a \cos(\theta) \\ b \sin(\theta) \end{array} \right) \]

with $\theta_1 \leq \theta \leq \theta_2$.

The following example shows how to use for example this function to draw the result of a tracking.

vpMeEllipse ellipse;
...
vpDisplay::display(I);
ellipse.track(I);
vpImageDraw::DrawEllipse(I, ellipse.getCenter(), ellipse.get_mu20(),
ellipse.get_mu11(), ellipse.get_mu02(),
ellipse.getSmallestAngle(),
ellipse.getHighestAngle(), true, vpColor::orange, 1);

Definition at line 664 of file vpImageDraw.cpp.

References drawLine(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpMath::rad(), vpImagePoint::set_i(), vpImagePoint::set_j(), and vpMath::sqr().

◆ drawFrame() [1/2]

void vpImageDraw::drawFrame ( vpImage< unsigned char > &  I,
const vpHomogeneousMatrix cMo,
const vpCameraParameters cam,
double  size,
unsigned char  color,
unsigned int  thickness = 1,
const vpImagePoint offset = vpImagePoint(0, 0) 
)
static

Draw the projection in an image of an object frame represented by 3 arrows in the image. Red, green and blue arrows correspond to frame X, Y and Z axis respectively.

Parameters
[in,out]I: Image where to draw the ellipse.
[in]cMo: Homogeneous matrix that gives the transformation between the camera frame and the object frame to project in the image.
[in]cam: Camera intrinsic parameters.
[in]size: Size of the object frame.
[in]color: Color used to display the frame in the image.
[in]thickness: the thickness of the line.
[in]offset: Offset in pixels applied to the frame origin location in the image.
Examples:
testImageDraw.cpp.

Definition at line 752 of file vpImageDraw.cpp.

References vpMeterPixelConversion::convertPoint(), drawArrow(), vpTracker::p, and vpForwardProjection::track().

◆ drawFrame() [2/2]

void vpImageDraw::drawFrame ( vpImage< vpRGBa > &  I,
const vpHomogeneousMatrix cMo,
const vpCameraParameters cam,
double  size,
const vpColor color = vpColor::none,
unsigned int  thickness = 1,
const vpImagePoint offset = vpImagePoint(0, 0) 
)
static

Draw the projection in an image of an object frame represented by 3 arrows in the image. Red, green and blue arrows correspond to frame X, Y and Z axis respectively.

Parameters
[in,out]I: Image where to draw the ellipse.
[in]cMo: Homogeneous matrix that gives the transformation between the camera frame and the object frame to project in the image.
[in]cam: Camera intrinsic parameters.
[in]size: Size of the object frame.
[in]color: Color used to display the frame in the image.
[in]thickness: the thickness of the line.
[in]offset: Offset in pixels applied to the frame origin location in the image.

Definition at line 794 of file vpImageDraw.cpp.

References vpColor::blue, vpMeterPixelConversion::convertPoint(), drawArrow(), vpColor::green, vpColor::none, vpTracker::p, vpColor::red, and vpForwardProjection::track().

◆ drawLine() [1/2]

void vpImageDraw::drawLine ( vpImage< unsigned char > &  I,
const vpImagePoint ip1,
const vpImagePoint ip2,
unsigned char  color,
unsigned int  thickness = 1 
)
static

Draw a line in an image between two image points.

Parameters
[in,out]I: Image where to draw the line.
[in]ip1,ip2: Initial and final image points.
[in]color: Line color.
[in]thickness: Dashed line thickness.
Examples:
testGenericTracker.cpp, and testImageDraw.cpp.

Definition at line 841 of file vpImageDraw.cpp.

References vpImagePoint::get_u(), and vpImagePoint::get_v().

Referenced by drawArrow(), drawCross(), drawDottedLine(), and drawEllipse().

◆ drawLine() [2/2]

void vpImageDraw::drawLine ( vpImage< vpRGBa > &  I,
const vpImagePoint ip1,
const vpImagePoint ip2,
const vpColor color,
unsigned int  thickness = 1 
)
static

Draw a line in an image between two image points.

Parameters
[in,out]I: Image where to draw the line.
[in]ip1,ip2: Initial and final image points.
[in]color: Line color.
[in]thickness: Dashed line thickness.

Definition at line 856 of file vpImageDraw.cpp.

References vpRGBa::B, vpRGBa::G, vpImagePoint::get_u(), vpImagePoint::get_v(), and vpRGBa::R.

◆ drawPoint() [1/2]

void vpImageDraw::drawPoint ( vpImage< unsigned char > &  I,
const vpImagePoint ip,
unsigned char  color,
unsigned int  thickness = 1 
)
static

Draw in an image a point at the image point ip location.

Parameters
[in,out]I: Image where to draw the point.
[in]ip: Point location.
[in]color: Point color.
[in]thickness: Thickness of the point
Examples:
testImageDraw.cpp.

Definition at line 870 of file vpImageDraw.cpp.

References drawRectangle().

◆ drawPoint() [2/2]

void vpImageDraw::drawPoint ( vpImage< vpRGBa > &  I,
const vpImagePoint ip,
const vpColor color,
unsigned int  thickness = 1 
)
static

Draw in an image a point at the image point ip location.

Parameters
[in,out]I: Image where to draw the point.
[in]ip: Point location.
[in]color: Point color.
[in]thickness: Thickness of the point

Definition at line 882 of file vpImageDraw.cpp.

References drawRectangle().

◆ drawPolygon() [1/2]

void vpImageDraw::drawPolygon ( vpImage< unsigned char > &  I,
const std::vector< vpImagePoint > &  vip,
unsigned char  color,
unsigned int  thickness = 1,
bool  closed = true 
)
static

Draw in an image a polygon defined by a vector of image points.

Parameters
[in,out]I: Image where to draw the polygon.
[in]vip: Vector of image point that define the vertexes of the polygon.
[in]color: Polygon color.
[in]thickness: Polygon thickness.
[in]closed: When true display a closed polygon with a segment between first and last image point.
Examples:
testImageDraw.cpp.

Definition at line 895 of file vpImageDraw.cpp.

◆ drawPolygon() [2/2]

void vpImageDraw::drawPolygon ( vpImage< vpRGBa > &  I,
const std::vector< vpImagePoint > &  vip,
const vpColor color,
unsigned int  thickness = 1,
bool  closed = true 
)
static

Draw in an image a polygon defined by a vector of image points.

Parameters
[in,out]I: Image where to draw the polygon.
[in]vip: Vector of image point that define the vertexes of the polygon.
[in]color: Polygon color.
[in]thickness: Polygon thickness.
[in]closed: When true display a closed polygon with a segment between first and last image point.

Definition at line 909 of file vpImageDraw.cpp.

References vpRGBa::B, vpRGBa::G, and vpRGBa::R.

◆ drawRectangle() [1/2]

void vpImageDraw::drawRectangle ( vpImage< unsigned char > &  I,
const vpRect rectangle,
unsigned char  color,
bool  fill = false,
unsigned int  thickness = 1 
)
static

Draw in an image a rectangle with topLeft as the top-left corner and width and height the rectangle size.

Parameters
[in,out]I: Image where to draw the rectangle.
[in]rectangle: Rectangle characteristics.
[in]color: Rectangle color.
[in]fill: When set to true fill the rectangle.
[in]thickness: Thickness of the four lines used to display the rectangle. This parameter is only useful when fill is set to false.
Examples:
testImageDraw.cpp.

Definition at line 927 of file vpImageDraw.cpp.

Referenced by drawPoint().

◆ drawRectangle() [2/2]

void vpImageDraw::drawRectangle ( vpImage< vpRGBa > &  I,
const vpRect rectangle,
const vpColor color,
bool  fill = false,
unsigned int  thickness = 1 
)
static

Draw in an image a rectangle with topLeft as the top-left corner and width and height the rectangle size.

Parameters
[in,out]I: Image where to draw the rectangle.
[in]rectangle: Rectangle characteristics.
[in]color: Rectangle color.
[in]fill: When set to true fill the rectangle.
[in]thickness: Thickness of the four lines used to display the rectangle. This parameter is only useful when fill is set to false.

Definition at line 948 of file vpImageDraw.cpp.

References vpRGBa::B, vpRGBa::G, and vpRGBa::R.