2011-02-22 21:43:26 +01:00
Drawing Functions
=================
.. highlight :: cpp
Drawing functions work with matrices/images of arbitrary depth.
The boundaries of the shapes can be rendered with antialiasing (implemented only for 8-bit images for now).
2011-04-10 22:54:37 +02:00
All the functions include the parameter `` color `` that uses an RGB value (that may be constructed
2011-02-26 12:05:10 +01:00
with `` CV_RGB `` or the :ref: `Scalar` constructor
2011-02-22 21:43:26 +01:00
) for color
2011-04-19 13:41:12 +02:00
images and brightness for grayscale images. For color images, the channel ordering
is normally *Blue, Green, Red* .
2011-06-16 14:48:23 +02:00
This is what :ocv:func: `imshow` , :ocv:func: `imread` , and :ocv:func: `imwrite` expect.
2011-04-10 22:54:37 +02:00
So, if you form a color using the
2011-02-26 12:05:10 +01:00
:ref: `Scalar` constructor, it should look like:
2011-02-22 21:43:26 +01:00
.. math ::
2011-02-26 12:05:10 +01:00
\texttt{Scalar} (blue \_ component, green \_ component, red \_ component[, alpha \_ component])
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
If you are using your own image rendering and I/O functions, you can use any channel ordering. The drawing functions process each channel independently and do not depend on the channel order or even on the used color space. The whole image can be converted from BGR to RGB or to a different color space using
2011-06-16 14:48:23 +02:00
:ocv:func: `cvtColor` .
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
If a drawn figure is partially or completely outside the image, the drawing functions clip it. Also, many drawing functions can handle pixel coordinates specified with sub-pixel accuracy. This means that the coordinates can be passed as fixed-point numbers encoded as integers. The number of fractional bits is specified by the `` shift `` parameter and the real point coordinates are calculated as
:math: `\texttt{Point}(x,y)\rightarrow\texttt{Point2f}(x*2^{-shift},y*2^{-shift})` . This feature is especially effective when rendering antialiased shapes.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
**Note** :
The functions do not support alpha-transparency when the target image is 4-channel. In this case, the `` color[3] `` is simply copied to the repainted pixels. Thus, if you want to paint semi-transparent shapes, you can paint them in a separate buffer and then blend it with the main image.
2011-02-22 21:43:26 +01:00
.. index :: circle
2011-02-28 22:26:43 +01:00
circle
2011-02-22 21:43:26 +01:00
----------
2011-06-16 14:48:23 +02:00
.. ocv:function :: void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
Draws a circle.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param img: Image where the circle is drawn.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param center: Center of the circle.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param radius: Radius of the circle.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param color: Circle color.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param thickness: Thickness of the circle outline if positive. Negative thickness means that a filled circle is to be drawn.
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
:param lineType: Type of the circle boundary. See :ocv:func:`line` description.
2011-02-22 21:43:26 +01:00
2011-04-19 13:41:12 +02:00
:param shift: Number of fractional bits in the center's coordinates and in the radius value.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
The function `` circle `` draws a simple or filled circle with a given center and radius.
2011-02-22 21:43:26 +01:00
.. index :: clipLine
2011-02-28 22:26:43 +01:00
clipLine
2011-02-22 21:43:26 +01:00
------------
2011-06-16 14:48:23 +02:00
.. ocv:function :: bool clipLine(Size imgSize, Point& pt1, Point& pt2)
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
.. ocv:function :: bool clipLine(Rect imgRect, Point& pt1, Point& pt2)
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
Clips the line against the image rectangle.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param imgSize: Image size. The image rectangle is ``Rect(0, 0, imgSize.width, imgSize.height)`` .
:param imgSize: Image rectangle.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param pt1: The first line point.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param pt2: The second line point.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
The functions `` clipLine `` calculate a part of the line segment which is entirely within the specified rectangle.
They return `` false `` if the line segment is completely outside the rectangle. Otherwise, it returns `` true `` .
2011-02-22 21:43:26 +01:00
.. index :: ellipse
2011-02-28 22:26:43 +01:00
ellipse
2011-02-22 21:43:26 +01:00
-----------
2011-06-16 14:48:23 +02:00
.. ocv:function :: void ellipse(Mat& img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
.. ocv:function :: void ellipse(Mat& img, const RotatedRect& box, const Scalar& color, int thickness=1, int lineType=8)
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
Draws a simple or thick elliptic arc or fills an ellipse sector.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param img: Image.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param center: Center of the ellipse.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param axes: Length of the ellipse axes.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param angle: Ellipse rotation angle in degrees.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param startAngle: Starting angle of the elliptic arc in degrees.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param endAngle: Ending angle of the elliptic arc in degrees.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param box: Alternative ellipse representation via :ref:`RotatedRect` . This means that the function draws an ellipse inscribed in the rotated rectangle.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param color: Ellipse color.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param thickness: Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that a filled ellipse sector is to be drawn.
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
:param lineType: Type of the ellipse boundary. See :ocv:func:`line` description.
2011-02-22 21:43:26 +01:00
2011-04-19 13:41:12 +02:00
:param shift: Number of fractional bits in the center's coordinates and axes' values.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
The functions `` ellipse `` with less parameters draw an ellipse outline, a filled ellipse, an elliptic arc, or a filled ellipse sector.
2011-02-26 12:05:10 +01:00
A piecewise-linear curve is used to approximate the elliptic arc boundary. If you need more control of the ellipse rendering, you can retrieve the curve using
2011-06-16 14:48:23 +02:00
:ocv:func: `ellipse2Poly` and then render it with
:ocv:func: `polylines` or fill it with
:ocv:func: `fillPoly` . If you use the first variant of the function and want to draw the whole ellipse, not an arc, pass `` startAngle=0 `` and `` endAngle=360 `` . The picture below explains the meaning of the parameters.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
**Figure 1. Parameters of Elliptic Arc**
2011-02-22 21:43:26 +01:00
2011-03-03 08:29:55 +01:00
.. image :: pics/ellipse.png
2011-02-22 21:43:26 +01:00
.. index :: ellipse2Poly
2011-02-28 22:26:43 +01:00
ellipse2Poly
2011-02-22 21:43:26 +01:00
----------------
2011-06-16 14:48:23 +02:00
.. ocv:function :: void ellipse2Poly( Point center, Size axes, int angle, int startAngle, int endAngle, int delta, vector<Point>& pts )
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
Approximates an elliptic arc with a polyline.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param center: Center of the arc.
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
:param axes: Half-sizes of the arc. See :ocv:func:`ellipse` for details.
2011-04-10 22:54:37 +02:00
2011-06-16 14:48:23 +02:00
:param angle: Rotation angle of the ellipse in degrees. See :ocv:func: `ellipse` for details.
2011-04-10 22:54:37 +02:00
:param startAngle: Starting angle of the elliptic arc in degrees.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param endAngle: Ending angle of the elliptic arc in degrees.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param delta: Angle between the subsequent polyline vertices. It defines the approximation accuracy.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param pts: Output vector of polyline vertices.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
The function `` ellipse2Poly `` computes the vertices of a polyline that approximates the specified elliptic arc. It is used by
2011-06-16 14:48:23 +02:00
:ocv:func: `ellipse` .
2011-02-22 21:43:26 +01:00
.. index :: fillConvexPoly
2011-02-28 22:26:43 +01:00
fillConvexPoly
2011-02-22 21:43:26 +01:00
------------------
2011-06-16 14:48:23 +02:00
.. ocv:function :: void fillConvexPoly(Mat& img, const Point* pts, int npts, const Scalar& color, int lineType=8, int shift=0)
2011-02-22 21:43:26 +01:00
Fills a convex polygon.
2011-04-10 22:54:37 +02:00
:param img: Image.
2011-02-26 12:05:10 +01:00
2011-04-10 22:54:37 +02:00
:param pts: Polygon vertices.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param npts: Number of polygon vertices.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param color: Polygon color.
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
:param lineType: Type of the polygon boundaries. See :ocv:func:`line` description.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param shift: Number of fractional bits in the vertex coordinates.
2011-02-26 12:05:10 +01:00
The function `` fillConvexPoly `` draws a filled convex polygon.
2011-04-10 22:54:37 +02:00
This function is much faster than the function `` fillPoly `` . It can fill not only convex polygons but any monotonic polygon without self-intersections,
that is, a polygon whose contour intersects every horizontal line (scan line) twice at the most (though, its top-most and/or the bottom edge could be horizontal).
2011-02-22 21:43:26 +01:00
.. index :: fillPoly
2011-02-28 22:26:43 +01:00
fillPoly
2011-02-22 21:43:26 +01:00
------------
2011-06-16 14:48:23 +02:00
.. ocv:function :: void fillPoly(Mat& img, const Point** pts, const int* npts, int ncontours, const Scalar& color, int lineType=8, int shift=0, Point offset=Point() )
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
Fills the area bounded by one or more polygons.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param img: Image.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param pts: Array of polygons where each polygon is represented as an array of points.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param npts: Array of polygon vertex counters.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param ncontours: Number of contours that bind the filled region.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param color: Polygon color.
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
:param lineType: Type of the polygon boundaries. See :ocv:func:`line` description.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param shift: Number of fractional bits in the vertex coordinates.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
The function `` fillPoly `` fills an area bounded by several polygonal contours. The function can fill complex areas, for example,
2011-02-22 21:43:26 +01:00
areas with holes, contours with self-intersections (some of thier parts), and so forth.
.. index :: getTextSize
2011-02-28 22:26:43 +01:00
getTextSize
2011-02-22 21:43:26 +01:00
---------------
2011-06-16 14:48:23 +02:00
.. ocv:function :: Size getTextSize(const string& text, int fontFace, double fontScale, int thickness, int* baseLine)
2011-02-22 21:43:26 +01:00
Calculates the width and height of a text string.
2011-04-10 22:54:37 +02:00
:param text: Input text string.
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
:param fontFace: Font to use. See :ocv:func:`putText` for details.
2011-04-10 22:54:37 +02:00
2011-06-16 14:48:23 +02:00
:param fontScale: Font scale. See :ocv:func: `putText` for details.
2011-04-10 22:54:37 +02:00
2011-06-16 14:48:23 +02:00
:param thickness: Thickness of lines used to render the text. See :ocv:func: `putText` for details.
2011-04-10 22:54:37 +02:00
:param baseLine: Output parameter - y-coordinate of the baseline relative to the bottom-most text point.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
The function `` getTextSize `` calculates and returns the size of a box that contains the specified text.
That is, the following code renders some text, the tight box surrounding it, and the baseline: ::
2011-02-22 21:43:26 +01:00
// Use "y" to show that the baseLine is about
string text = "Funny text inside the box";
int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX;
double fontScale = 2;
int thickness = 3;
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
Mat img(600, 800, CV_8UC3, Scalar::all(0));
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
int baseline=0;
Size textSize = getTextSize(text, fontFace,
fontScale, thickness, &baseline);
baseline += thickness;
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
// center the text
Point textOrg((img.cols - textSize.width)/2,
(img.rows + textSize.height)/2);
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
// draw the box
rectangle(img, textOrg + Point(0, baseline),
textOrg + Point(textSize.width, -textSize.height),
Scalar(0,0,255));
// ... and the baseline first
line(img, textOrg + Point(0, thickness),
textOrg + Point(textSize.width, thickness),
Scalar(0, 0, 255));
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
// then put the text itself
putText(img, text, textOrg, fontFace, fontScale,
Scalar::all(255), thickness, 8);
.. index :: line
2011-02-28 22:26:43 +01:00
line
2011-02-22 21:43:26 +01:00
--------
2011-06-16 14:48:23 +02:00
.. ocv:function :: void line(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
Draws a line segment connecting two points.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param img: Image.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param pt1: The first point of the line segment.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param pt2: The second point of the line segment.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param color: Line color.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param thickness: Line thickness.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param lineType: Type of the line:
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
* **8** (or omitted) 8-connected line.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
* **4** 4-connected line.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
* **CV_AA** antialiased line.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param shift: Number of fractional bits in the point coordinates.
2011-02-26 12:05:10 +01:00
2011-04-10 22:54:37 +02:00
The function `` line `` draws the line segment between `` pt1 `` and `` pt2 `` points in the image. The line is clipped by the image boundaries. For non-antialiased lines with integer coordinates, the 8-connected or 4-connected Bresenham algorithm is used. Thick lines are drawn with rounding endings.
Antialiased lines are drawn using Gaussian filtering. To specify the line color, you may use the macro `` CV_RGB(r, g, b) `` .
2011-02-22 21:43:26 +01:00
.. index :: LineIterator
.. _LineIterator:
LineIterator
------------
2011-02-28 22:26:43 +01:00
.. c:type :: LineIterator
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
Class for iterating pixels on a raster line ::
2011-02-22 21:43:26 +01:00
class LineIterator
{
public:
// creates iterators for the line connecting pt1 and pt2
// the line will be clipped on the image boundaries
// the line is 8-connected or 4-connected
// If leftToRight=true, then the iteration is always done
// from the left-most point to the right most,
// not to depend on the ordering of pt1 and pt2 parameters
LineIterator(const Mat& img, Point pt1, Point pt2,
int connectivity=8, bool leftToRight=false);
// returns pointer to the current line pixel
uchar* operator * ();
// move the iterator to the next pixel
LineIterator& operator ++();
LineIterator operator ++(int);
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
// internal state of the iterator
uchar* ptr;
int err, count;
int minusDelta, plusDelta;
int minusStep, plusStep;
};
2011-04-10 22:54:37 +02:00
The class `` LineIterator `` is used to get each pixel of a raster line. It can be treated as versatile implementation of the Bresenham algorithm where you can stop at each pixel and do some extra processing, for example, grab pixel values along the line, or draw a line with an effect (for example, with XOR operation).
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
The number of pixels along the line is stored in `` LineIterator::count `` . ::
2011-02-22 21:43:26 +01:00
// grabs pixels along the line (pt1, pt2)
// from 8-bit 3-channel image to the buffer
LineIterator it(img, pt1, pt2, 8);
vector<Vec3b> buf(it.count);
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
for(int i = 0; i < it.count; i++, ++it)
buf[i] = *(const Vec3b)* it;
.. index :: rectangle
2011-02-28 22:26:43 +01:00
rectangle
2011-02-22 21:43:26 +01:00
-------------
2011-06-16 14:48:23 +02:00
.. ocv:function :: void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
2011-06-08 00:51:31 +02:00
2011-06-16 14:48:23 +02:00
.. ocv:function :: void rectangle(Mat& img, Rect r, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
2011-02-22 21:43:26 +01:00
Draws a simple, thick, or filled up-right rectangle.
2011-04-10 22:54:37 +02:00
:param img: Image.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param pt1: One of the rectangle's vertices.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param pt2: Opposite to ``pt1`` rectangle vertex.
2011-06-08 00:51:31 +02:00
:param r: Alternative specification of the drawn rectangle
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param color: Rectangle color or brightness (grayscale image).
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param thickness: Thickness of lines that make up the rectangle. Negative values, like ``CV_FILLED`` , mean that the function has to draw a filled rectangle.
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
:param lineType: Type of the line. See :ocv:func:`line` description.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param shift: Number of fractional bits in the point coordinates.
2011-02-26 12:05:10 +01:00
2011-06-08 00:51:31 +02:00
The function `` rectangle `` draws a rectangle outline or a filled rectangle whose two opposite corners are `` pt1 `` and `` pt2 `` , or `` r.tl() `` and `` r.br()-Point(1,1) `` .
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
.. index :: polylines
2011-02-22 21:43:26 +01:00
2011-02-28 22:26:43 +01:00
polylines
2011-02-22 21:43:26 +01:00
-------------
2011-06-16 14:48:23 +02:00
.. ocv:function :: void polylines(Mat& img, const Point** pts, const int* npts, int ncontours, bool isClosed, const Scalar& color, int thickness=1, int lineType=8, int shift=0 )
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
Draws several polygonal curves.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param img: Image.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param pts: Array of polygonal curves.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param npts: Array of polygon vertex counters.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param ncontours: Number of curves.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param isClosed: Flag indicating whether the drawn polylines are closed or not. If they are closed, the function draws a line from the last vertex of each curve to its first vertex.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param color: Polyline color.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param thickness: Thickness of the polyline edges.
2011-02-22 21:43:26 +01:00
2011-06-16 14:48:23 +02:00
:param lineType: Type of the line segments. See :ocv:func:`line` description.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param shift: Number of fractional bits in the vertex coordinates.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
The function `` polylines `` draws one or more polygonal curves.
2011-02-22 21:43:26 +01:00
.. index :: putText
2011-02-28 22:26:43 +01:00
putText
2011-02-22 21:43:26 +01:00
-----------
2011-06-16 14:48:23 +02:00
.. ocv:function :: void putText( Mat& img, const string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
Draws a text string.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param img: Image.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param text: Text string to be drawn.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param org: Bottom-left corner of the text string in the image.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param fontFace: Font type. One of ``FONT_HERSHEY_SIMPLEX`` , ``FONT_HERSHEY_PLAIN`` , ``FONT_HERSHEY_DUPLEX`` , ``FONT_HERSHEY_COMPLEX`` , ``FONT_HERSHEY_TRIPLEX`` , ``FONT_HERSHEY_COMPLEX_SMALL`` , ``FONT_HERSHEY_SCRIPT_SIMPLEX`` , or ``FONT_HERSHEY_SCRIPT_COMPLEX`` ,
where each of the font ID's can be combined with `` FONT_HERSHEY_ITALIC `` to get the slanted letters.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param fontScale: Font scale factor that is multiplied by the font-specific base size.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param color: Text color.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param thickness: Thickness of the lines used to draw a text.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param lineType: Line type. See ``line`` for details.
2011-02-22 21:43:26 +01:00
2011-04-10 22:54:37 +02:00
:param bottomLeftOrigin: When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
The function `` putText `` renders the specified text string in the image.
2011-04-10 22:54:37 +02:00
Symbols that cannot be rendered using the specified font are
2011-02-26 12:05:10 +01:00
replaced by question marks. See
2011-06-16 14:48:23 +02:00
:ocv:func: `getTextSize` for a text rendering code example.
2011-02-22 21:43:26 +01:00