cv3.draw.marker
- cv3.draw.marker(img, x, y, marker_type=None, marker_size=None, rel=None, color=None, t=None, line_type=None, copy=False)[source]
Draw a marker on an image.
This is an experimental function. To use it, set experimental mode with cv3.opt.set_exp().
- Parameters:
img (numpy.ndarray) – Input image to draw on.
x (int or float) – X-coordinate of the marker position.
y (int or float) – Y-coordinate of the marker position.
marker_type (int or str, optional) – The specific type of marker you want to use. Can be one of: ‘cross’, ‘tilted_cross’, ‘star’, ‘diamond’, ‘square’, ‘triangle_up’, ‘triangle_down’. Defaults to cv2.MARKER_CROSS.
marker_size (int, optional) – The length of the marker axis. Defaults to 20.
rel (bool, optional) – Whether to use relative coordinates. Defaults to None.
color – Color of the marker (default: opt.COLOR).
t – Thickness of the marker lines (default: opt.THICKNESS).
line_type – Type of line for drawing (default: opt.LINE_TYPE).
copy (bool) – Whether to copy the image before drawing (default: False).
- Returns:
Image with the marker drawn on it.
- Return type:
numpy.ndarray
Note
Relative coordinates are in the range [0, 1] where 0 is the top/left and 1 is the bottom/right of the image.
Example
>>> import cv3 >>> img = cv3.zeros(100, 100, 3) >>> # Draw a cross marker >>> img = cv3.marker(img, 50, 50, color='red', t=2) >>> # Draw a star marker with custom size >>> img = cv3.marker(img, 80, 80, marker_type='star', marker_size=30, color='blue')