Skip to content

line

Image processingfunctionOpenCV 5.0.0
import { line } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSimg, pt1, pt2, color
FUNCTIONline
RETURN TYPEvoid
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Draws a line segment connecting two points.

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.

line(img: Mat, pt1: Point, pt2: Point, color: Scalar, thickness: number, lineType: number, shift: number): void;
4 available overloads
line(img: Mat, pt1: Point, pt2: Point, color: Scalar): void;
line(img: Mat, pt1: Point, pt2: Point, color: Scalar, thickness: number): void;
line(img: Mat, pt1: Point, pt2: Point, color: Scalar, thickness: number, lineType: number): void;
line(img: Mat, pt1: Point, pt2: Point, color: Scalar, thickness: number, lineType: number, shift: number): void;
img

Input/output value, modified by the native operation. Image.

pt1

First point of the line segment.

pt2

Second point of the line segment.

color

Line color.

thickness

Line thickness.

lineType

Type of the line. See #LineTypes.

shift

Number of fractional bits in the point coordinates.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.