Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpImageDraw Class Reference

#include <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 vpImageCircle &circle, unsigned char color, 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 vpImageCircle &circle, const vpColor &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_normalized_centered_moments, unsigned char color, double smallalpha=0, double highalpha=2 *M_PI, unsigned int thickness=1)
static void drawEllipse (vpImage< vpRGBa > &I, const vpImagePoint &center, double coef1, double coef2, double coef3, bool use_normalized_centered_moments, const vpColor &color, double smallalpha=0, double highalpha=2 *M_PI, 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.

Tutorials & Examples

Tutorials
If you are interested in inserting basic drawings in an image, you may have a look at:

Definition at line 66 of file vpImageDraw.h.

Member Function Documentation

◆ drawArrow() [1/2]

BEGIN_VISP_NAMESPACE 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: Initial image point.
[in]ip2: Final image point with the arrow.
[in]color: Arrow color.
[in]w: Arrow width.
[in]h: Arrow height.
[in]thickness: Thickness of the lines used to display the arrow.
Examples
testImageDraw.cpp.

Definition at line 249 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(), and 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: Initial image point.
[in]ip2: Final image point with the arrow.
[in]color: Arrow color.
[in]w: Arrow width.
[in]h: Arrow height.
[in]thickness: Thickness of the lines used to display the arrow.

Definition at line 297 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/4]

void vpImageDraw::drawCircle ( vpImage< unsigned char > & I,
const vpImageCircle & circle,
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]circle: Circle to draw.
[in]color: Circle color.
[in]thickness: Thickness of the circle.
Examples
testImageDraw.cpp, tutorial-circle-hough.cpp, and tutorial-draw-circle.cpp.

Definition at line 342 of file vpImageDraw.cpp.

References vpImageCircle::getCenter(), and vpImageCircle::getRadius().

◆ drawCircle() [2/4]

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.

Definition at line 356 of file vpImageDraw.cpp.

◆ drawCircle() [3/4]

void vpImageDraw::drawCircle ( vpImage< vpRGBa > & I,
const vpImageCircle & circle,
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]circle: Circle to draw.
[in]color: Circle color.
[in]thickness: Thickness of the circle.

Definition at line 369 of file vpImageDraw.cpp.

References vpImageCircle::getCenter(), and vpImageCircle::getRadius().

◆ drawCircle() [4/4]

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 383 of file vpImageDraw.cpp.

◆ 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, testImageDraw.cpp, and tutorial-circle-hough.cpp.

Definition at line 397 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 421 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: Initial line image point.
[in]ip2: Final line image point.
[in]color: Line color.
[in]thickness: Dashed line thickness.
Examples
testImageDraw.cpp.

Definition at line 445 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: Initial line image point.
[in]ip2: Final line image point.
[in]color: Line color.
[in]thickness: Dashed line thickness.

Definition at line 493 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_normalized_centered_moments,
unsigned char color,
double smallalpha = 0,
double highalpha = 2 * M_PI,
unsigned int thickness = 1 )
static

Draw an ellipse in an image from its parameters expressed in pixels. Depending on use_normalized_centered_moments flag, we consired two ellipse representations:

  • the one using second order normalized centered moments $ (n_{20}, n_{11}, n_{02}) $ expressed in pixels, such that $ n_{ij} = \mu_{ij}/a $ where $ \mu_{ij} $ are the centered moments and a the area,
  • the other one with the major and minor axis length and the eccentricity of the ellipse in radians $ (a, b, e) $.
Parameters
[in,out]I: Image where to draw the ellipse.
[in]center: Center $(u_c, v_c)$ of the ellipse.
[in]coef1: Depending on the parameter use_normalized_centered_moments this parameter is either
  • the second order centered moment $ n_{20} $ of the ellipse normalized by its area and expressed in pixels,
  • the major axis length $ a $ in pixels.
[in]coef2: Depending on the parameter use_normalized_centered_moments this parameter is either
  • the second order centered moment $ n_{11} $ of the ellipse normalized by its area and expressed in pixels,
  • the minor axis length $ b $ in pixels.
[in]coef3: Depending on the parameter use_normalized_centered_moments this parameter is either
  • the second order centered moment $ n_{02} $ of the ellipse normalized by its area and expressed in pixels,
  • the eccentricity $ e $ of the ellipse in radians.
smallalpha: Smallest $ alpha $ angle in rad (0 for a complete ellipse).
highalpha: Highest $ alpha $ angle in rad (2 $ \Pi $ for a complete ellipse).
use_normalized_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 normalized centered moments $n_{20}, n_{11},
n_{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.

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);
ellipse.get_nij()[0], ellipse.get_nij()[1], ellipse.get_nij()[2],
true,
ellipse.getSmallestAngle(), ellipse.getHighestAngle(),
static const vpColor orange
Definition vpColor.h:208
static void drawEllipse(vpImage< unsigned char > &I, const vpImagePoint &center, double coef1, double coef2, double coef3, bool use_normalized_centered_moments, unsigned char color, double smallalpha=0, double highalpha=2 *M_PI, unsigned int thickness=1)
Class that tracks an ellipse or a circle using moving edges.
double getHighestAngle() const
double getSmallestAngle() const
vpImagePoint getCenter() const
vpColVector get_nij() const
void track(const vpImage< unsigned char > &I)

Definition at line 578 of file vpImageDraw.cpp.

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

◆ drawEllipse() [2/2]

void vpImageDraw::drawEllipse ( vpImage< vpRGBa > & I,
const vpImagePoint & center,
double coef1,
double coef2,
double coef3,
bool use_normalized_centered_moments,
const vpColor & color,
double smallalpha = 0,
double highalpha = 2 * M_PI,
unsigned int thickness = 1 )
static

Draw an ellipse in an image from its parameters expressed in pixels. Depending on use_normalized_centered_moments flag, we consired two ellipse representations:

  • the one using second order normalized centered moments $ (n_{20}, n_{11}, n_{02}) $ expressed in pixels, such that $ n_{ij} = \mu_{ij}/a $ where $ \mu_{ij} $ are the centered moments and a the area,
  • the other one with the major and minor axis length and the eccentricity of the ellipse in radians $ (a, b, e) $.
Parameters
[in,out]I: Image where to draw the ellipse.
[in]center: Center $(u_c, v_c)$ of the ellipse.
[in]coef1: Depending on the parameter use_normalized_centered_moments this parameter is either
  • the second order centered moment $ n_{20} $ of the ellipse normalized by its area and expressed in pixels,
  • the major axis length $ a $ in pixels.
[in]coef2: Depending on the parameter use_normalized_centered_moments this parameter is either
  • the second order centered moment $ n_{11} $ of the ellipse normalized by its area and expressed in pixels,
  • the minor axis length $ b $ in pixels.
[in]coef3: Depending on the parameter use_normalized_centered_moments this parameter is either
  • the second order centered moment $ n_{02} $ of the ellipse normalized by its area and expressed in pixels,
  • the eccentricity $ e $ of the ellipse in radians.
smallalpha: Smallest $ alpha $ angle in rad (0 for a complete ellipse).
highalpha: Highest $ alpha $ angle in rad (2 $ \Pi $ for a complete ellipse).
use_normalized_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 normalized centered moments $n_{20}, n_{11},
n_{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.

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);
ellipse.get_nij()[0], ellipse.get_nij()[1], ellipse.get_nij()[2],
true,
ellipse.getSmallestAngle(), ellipse.getHighestAngle(),

Definition at line 702 of file vpImageDraw.cpp.

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

◆ 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 796 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 838 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: Initial line image point.
[in]ip2: Final line image point.
[in]color: Line color.
[in]thickness: Dashed line thickness.
Examples
testGenericTracker.cpp, testImageDraw.cpp, and tutorial-mb-generic-tracker-read.cpp.

Definition at line 887 of file vpImageDraw.cpp.

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

Referenced by drawArrow(), drawArrow(), drawCross(), drawCross(), drawDottedLine(), drawDottedLine(), drawEllipse(), 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: Initial line image point.
[in]ip2: Final line image point.
[in]color: Line color.
[in]thickness: Dashed line thickness.

Definition at line 902 of file vpImageDraw.cpp.

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

◆ 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 916 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 929 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 942 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 956 of file vpImageDraw.cpp.

◆ 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 974 of file vpImageDraw.cpp.

Referenced by drawPoint(), and 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 997 of file vpImageDraw.cpp.