Image operations

This section covers the API to the supplied low-level image operations. For more examples and information, refer to the relevant guides in the User Guide.

Format conversion

gray(frame)

Convert a frame to grayscale.

bgr(frame)

Convert a frame to BGR format.

hsv(frame)

Convert a frame to HSV format.

Drawing

draw_contours(img, contours, *args, **kwargs)

Convenience function for drawing contour(s) on an image.

draw_rectangles(img, dims, *args, **kwargs)

Convenience function for drawing rectangle(s) on an image.

draw_circles(img, dims, *args, **kwargs)

Convenience function for drawing circle(s) on an image.

draw_ellipses(img, dims, *args, **kwargs)

Convenience function for drawing ellipse(s) on an image.

Mask constructors

Mask(mask)

Convenience class for performing segmentation to a mask.

shrink(img[, by])

Mask an image to a new roi.

rect_mask(img, dims)

Create a rectangular mask.

circle_mask(img, dims)

Create a circular mask.

contour_mask(img, contours)

Create a contour mask at the dimensions of contour(s).

ellipse_mask(img, dims)

Create an ellipse mask.

Contour filters

smallest(contours)

Contour filter that returns the smallest contour by area.

largest(contours)

Contour filter that returns the largest contour by area.

parents(contours, hierarchy)

Contour filter that returns only parent contours.

Area([min, max])

Filter contours by area based on a lower or upper limit, or both.

Eccentricity([min, max])

Filter contours by eccentricity based on a lower or upper limit, or both.

Solidity([min, max])

Filter contours by solidity based on a lower or upper limit, or both.

Additional contour functions

fit_rectangles(contours[, rotate])

Fit bounding boxes to contour(s).

fit_circles(contours)

Fit minimum enclosing circles to contour(s).

fit_ellipses(contours)

Fit ellipses to contour(s).

find_contours(img, *args, **kwargs)

Convenience function for contour detection.

cast_contours(contours, x, y)

Convenience function to cast contour(s) to a given x,y.