Color Convention
For color images, the channel ordering is normally Blue, Green, Red (BGR). This is what imshow, imread, and imwrite expect. If you form a color using the Scalar constructor, it should look like:Line Drawing
line
Draws a line segment connecting two points.Image.
First point of the line segment.
Second point of the line segment.
Line color.
Line thickness.
Type of the line. See LineTypes.
Number of fractional bits in the point coordinates.
- C++
- Python
arrowedLine
Draws an arrow segment pointing from the first point to the second one.Image.
The point the arrow starts from.
The point the arrow points to.
Line color.
Line thickness.
Type of the line. See LineTypes.
Number of fractional bits in the point coordinates.
The length of the arrow tip in relation to the arrow length.
Shape Drawing
rectangle
Draws a simple, thick, or filled up-right rectangle.Image.
Vertex of the rectangle.
Vertex of the rectangle opposite to pt1.
Alternative rectangle specification.
Rectangle color or brightness (grayscale image).
Thickness of lines that make up the rectangle. Negative values, like FILLED, mean that the function has to draw a filled rectangle.
Type of the line. See LineTypes.
Number of fractional bits in the point coordinates.
- C++
- Python
circle
Draws a circle.Image where the circle is drawn.
Center of the circle.
Radius of the circle.
Circle color.
Thickness of the circle outline, if positive. Negative values, like FILLED, mean that a filled circle is to be drawn.
Type of the circle boundary. See LineTypes.
Number of fractional bits in the coordinates of the center and in the radius value.
- C++
- Python
ellipse
Draws a simple or thick elliptic arc or fills an ellipse sector.Image.
Center of the ellipse.
Half of the size of the ellipse main axes.
Ellipse rotation angle in degrees.
Starting angle of the elliptic arc in degrees.
Ending angle of the elliptic arc in degrees.
Alternative ellipse representation via RotatedRect. This means that the function draws an ellipse inscribed in the rotated rectangle.
Ellipse color.
Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that a filled ellipse sector is to be drawn.
Type of the ellipse boundary. See LineTypes.
Number of fractional bits in the coordinates of the center and values of axes.
Polygon Drawing
polylines
Draws several polygonal curves.Image.
Array of polygonal curves.
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.
Polyline color.
Thickness of the polyline edges.
Type of the line segments. See LineTypes.
Number of fractional bits in the vertex coordinates.
fillPoly
Fills the area bounded by one or more polygons.Image.
Array of polygons where each polygon is represented as an array of points.
Polygon color.
Type of the polygon boundaries. See LineTypes.
Number of fractional bits in the vertex coordinates.
Optional offset of all points of the contours.
fillConvexPoly
Fills a convex polygon.Image.
Polygon vertices.
Polygon color.
Type of the polygon boundaries. See LineTypes.
Number of fractional bits in the vertex coordinates.
Text Rendering
putText
Draws a text string.Image.
Text string to be drawn.
Bottom-left corner of the text string in the image.
Font type. See HersheyFonts.
Font scale factor that is multiplied by the font-specific base size.
Text color.
Thickness of the lines used to draw a text.
Line type. See LineTypes.
When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner.
- C++
- Python
getTextSize
Calculates the width and height of a text string.Input text string.
Font to use. See HersheyFonts.
Font scale factor that is multiplied by the font-specific base size.
Thickness of lines used to render the text.
y-coordinate of the baseline relative to the bottom-most text point.
Enumerations
LineTypes
Types of line:FILLED(-1) - Filled shapeLINE_4(4) - 4-connected lineLINE_8(8) - 8-connected lineLINE_AA(16) - Antialiased line
HersheyFonts
Hershey font types:FONT_HERSHEY_SIMPLEX(0) - Normal size sans-serif fontFONT_HERSHEY_PLAIN(1) - Small size sans-serif fontFONT_HERSHEY_DUPLEX(2) - Normal size sans-serif font (more complex than SIMPLEX)FONT_HERSHEY_COMPLEX(3) - Normal size serif fontFONT_HERSHEY_TRIPLEX(4) - Normal size serif font (more complex than COMPLEX)FONT_HERSHEY_COMPLEX_SMALL(5) - Smaller version of COMPLEXFONT_HERSHEY_SCRIPT_SIMPLEX(6) - Hand-writing style fontFONT_HERSHEY_SCRIPT_COMPLEX(7) - More complex variant of SCRIPT_SIMPLEXFONT_ITALIC(16) - Flag for italic font
MarkerTypes
Marker types used for the drawMarker function:MARKER_CROSS(0) - A crosshair marker shapeMARKER_TILTED_CROSS(1) - A 45 degree tilted crosshair marker shapeMARKER_STAR(2) - A star marker shapeMARKER_DIAMOND(3) - A diamond marker shapeMARKER_SQUARE(4) - A square marker shapeMARKER_TRIANGLE_UP(5) - An upwards pointing triangle marker shapeMARKER_TRIANGLE_DOWN(6) - A downwards pointing triangle marker shape
