image — machine vision

The image module is used for machine vision.

Classes

Functions

image.binary_to_grayscale(value: int) int

Convert a binary value (0-1) to a grayscale value (0-255).

image.binary_to_rgb(value: int) Tuple[int, int, int]

Convert a binary value (0-1) to a 3-value RGB888 tuple.

image.binary_to_lab(value: int) Tuple[int, int, int]

Convert a binary value (0-1) to a 3-value LAB tuple. L is 0-100; A/B are -128 to 127.

image.binary_to_yuv(value: int) Tuple[int, int, int]

Convert a binary value (0-1) to a 3-value YUV tuple. Y is 0-255; U/V are -128 to 127.

image.grayscale_to_binary(value: int) int

Convert a grayscale value (0-255) to a binary value (0-1).

image.grayscale_to_rgb(value: int) Tuple[int, int, int]

Convert a grayscale value (0-255) to a 3-value RGB888 tuple.

image.grayscale_to_lab(value: int) Tuple[int, int, int]

Convert a grayscale value (0-255) to a 3-value LAB tuple. L is 0-100; A/B are -128 to 127.

image.grayscale_to_yuv(value: int) Tuple[int, int, int]

Convert a grayscale value (0-255) to a 3-value YUV tuple. Y is 0-255; U/V are -128 to 127.

image.rgb_to_binary(value: Tuple[int, int, int]) int

Convert a 3-value RGB888 tuple to a binary value (0-1).

image.rgb_to_grayscale(value: Tuple[int, int, int]) int

Convert a 3-value RGB888 tuple to a grayscale value (0-255).

image.rgb_to_lab(value: Tuple[int, int, int]) Tuple[int, int, int]

Convert a 3-value RGB888 tuple to a 3-value LAB tuple. L is 0-100; A/B are -128 to 127.

image.rgb_to_yuv(value: Tuple[int, int, int]) Tuple[int, int, int]

Convert a 3-value RGB888 tuple to a 3-value YUV tuple. Y is 0-255; U/V are -128 to 127.

image.lab_to_binary(value: Tuple[int, int, int]) int

Convert a 3-value LAB tuple to a binary value (0-1).

image.lab_to_grayscale(value: Tuple[int, int, int]) int

Convert a 3-value LAB tuple to a grayscale value (0-255).

image.lab_to_rgb(value: Tuple[int, int, int]) Tuple[int, int, int]

Convert a 3-value LAB tuple to a 3-value RGB888 tuple.

image.lab_to_yuv(value: Tuple[int, int, int]) Tuple[int, int, int]

Convert a 3-value LAB tuple to a 3-value YUV tuple. Y is 0-255; U/V are -128 to 127.

image.yuv_to_binary(value: Tuple[int, int, int]) int

Convert a 3-value YUV tuple to a binary value (0-1).

image.yuv_to_grayscale(value: Tuple[int, int, int]) int

Convert a 3-value YUV tuple to a grayscale value (0-255).

image.yuv_to_rgb(value: Tuple[int, int, int]) Tuple[int, int, int]

Convert a 3-value YUV tuple to a 3-value RGB888 tuple.

image.yuv_to_lab(value: Tuple[int, int, int]) Tuple[int, int, int]

Convert a 3-value YUV tuple to a 3-value LAB tuple. L is 0-100; A/B are -128 to 127.

image.HaarCascade(path: str, stages: int = -1) Cascade

Load a Haar Cascade from a binary file at path and return a cascade object usable with Image.find_features(). Pass "frontalface" or "eye" to load a built-in cascade.

stages selects how many cascade stages to evaluate. -1 uses all stages in the file. Lowering this value speeds up detection at the cost of more false positives.

image.load_descriptor(path: str) Any

Load a descriptor object (lbp_desc or kp_desc) from the file at path and return it.

image.save_descriptor(descriptor: Any, path: str) None

Save the descriptor object (lbp_desc or kp_desc) to the file at path.

image.match_descriptor(descriptor0: Any, descriptor1: Any, threshold: int = 85, filter_outliers: bool = False) int | kptmatch

Match two descriptors of the same type.

For LBP descriptors returns an integer distance between the two descriptors (lower is a closer match).

For ORB descriptors returns a kptmatch object.

threshold (0-100) is used by ORB matching to filter ambiguous matches. Lower values tighten matching.

filter_outliers enables outlier filtering for ORB matches.

image.get_solidity(blob: blob) float

Return the solidity (blob area divided by convex-hull area) of blob.

image.get_convexity(blob: blob) float

Return the convexity (convex-hull perimeter divided by blob perimeter) of blob.

image.get_major_axis_line(blob: blob) line

Return a line object along the major axis of blob.

image.get_minor_axis_line(blob: blob) line

Return a line object along the minor axis of blob.

image.get_enclosing_circle(blob: blob) circle

Return a circle object that encloses blob.

image.get_enclosed_ellipse(blob: blob) ellipse

Return an ellipse attribute tuple (x, y, rx, ry, rotation) enclosed by blob.

Constants

image.BINARY: int

BINARY (bitmap) pixel format. Each pixel is 1-bit.

image.GRAYSCALE: int

GRAYSCALE pixel format. Each pixel is 8-bits, 1-byte.

image.RGB565: int

RGB565 pixel format. Each pixel is 16-bits, 2-bytes. 5-bits are used for red, 6-bits are used for green, and 5-bits are used for blue.

image.BAYER: int

Raw Bayer pixel format. Most image processing methods are not available on Bayer images.

image.YUV422: int

YUV422 pixel format. Each pixel pair is stored as Y1, U, Y2, V (4 bytes for 2 pixels). Only some image processing methods work with YUV422.

image.JPEG: int

A JPEG image.

image.PNG: int

A PNG image.

image.PALETTE_RAINBOW: int

Default OpenMV Cam color palette for thermal images using a smooth color wheel.

image.PALETTE_IRONBOW: int

Makes images look like the FLIR Lepton thermal images using a very non-linear color palette.

image.PALETTE_DEPTH: int

Depth color palette for depth images.

image.PALETTE_EVT_DARK: int

Dark background color palette for event images.

image.PALETTE_EVT_LIGHT: int

Light background color palette for event images.

image.AREA: int

Use area scaling when downscaling an image (Nearest Neighbor is used for upscaling).

image.BILINEAR: int

Use bilinear scaling. Subsamples when downscaling.

image.BICUBIC: int

Use bicubic scaling. Higher quality than bilinear but slower. Subsamples when downscaling.

image.VFLIP: int

Vertically flip the image being drawn.

image.HMIRROR: int

Horizontally mirror the image being drawn.

image.TRANSPOSE: int

Transpose (swap x/y) the image being drawn.

image.CENTER: int

Center the drawn image on the destination. Any x/y offsets become offsets from center.

image.EXTRACT_RGB_CHANNEL_FIRST: int

When extracting an RGB channel via Image.draw_image(), extract the channel before scaling instead of after.

image.APPLY_COLOR_PALETTE_FIRST: int

When applying a color palette via Image.draw_image(), apply the palette before scaling instead of after.

image.SCALE_ASPECT_KEEP: int

Scale the drawn image to fit inside the destination while maintaining aspect ratio.

image.SCALE_ASPECT_EXPAND: int

Scale the drawn image to fill the destination while maintaining aspect ratio (may crop).

image.SCALE_ASPECT_IGNORE: int

Scale the drawn image to fill the destination, ignoring aspect ratio.

image.BLACK_BACKGROUND: int

Skip reading the destination pixel when drawing on a known-black destination. Speeds up alpha effects.

image.ROTATE_90: int

Rotate the drawn image 90 degrees (equivalent to VFLIP | TRANSPOSE).

image.ROTATE_180: int

Rotate the drawn image 180 degrees (equivalent to HMIRROR | VFLIP).

image.ROTATE_270: int

Rotate the drawn image 270 degrees (equivalent to HMIRROR | TRANSPOSE).

image.JPEG_SUBSAMPLING_AUTO: int

Automatically select JPEG chroma subsampling based on image quality.

image.JPEG_SUBSAMPLING_444: int

Force 4:4:4 JPEG chroma subsampling.

image.JPEG_SUBSAMPLING_422: int

Force 4:2:2 JPEG chroma subsampling. Recommended when streaming MJPEG to third-party video players.

image.JPEG_SUBSAMPLING_420: int

Force 4:2:0 JPEG chroma subsampling.

image.SEARCH_EX: int

Exhaustive template matching search.

image.SEARCH_DS: int

Diamond-search (faster) template matching.

image.EDGE_CANNY: int

Canny edge detection algorithm. See Image.find_edges().

image.EDGE_SIMPLE: int

Thresholded high-pass-filter edge detection. See Image.find_edges().

image.CORNER_FAST: int

Faster, less accurate ORB corner detector.

image.CORNER_AGAST: int

Slower, more accurate ORB corner detector.

image.TAG16H5: int

AprilTag family. See Image.find_apriltags().

image.TAG25H9: int

AprilTag family. See Image.find_apriltags().

image.TAG36H10: int

AprilTag family. See Image.find_apriltags().

image.TAG36H11: int

AprilTag family. See Image.find_apriltags().

image.TAGCIRCLE21H7: int

AprilTag family. See Image.find_apriltags().

image.TAGCIRCLE49H12: int

AprilTag family. See Image.find_apriltags().

image.TAGCUSTOM48H12: int

AprilTag family. See Image.find_apriltags().

image.TAGSTANDARD41H12: int

AprilTag family. See Image.find_apriltags().

image.TAGSTANDARD52H13: int

AprilTag family. See Image.find_apriltags().

image.EAN2: int

EAN2 barcode type.

image.EAN5: int

EAN5 barcode type.

image.EAN8: int

EAN8 barcode type.

image.UPCE: int

UPCE barcode type.

image.ISBN10: int

ISBN10 barcode type.

image.UPCA: int

UPCA barcode type.

image.EAN13: int

EAN13 barcode type.

image.ISBN13: int

ISBN13 barcode type.

image.I25: int

Interleaved 2 of 5 barcode type.

image.DATABAR: int

GS1 DataBar barcode type.

image.DATABAR_EXP: int

GS1 DataBar Expanded barcode type.

image.CODABAR: int

Codabar barcode type.

image.CODE39: int

Code 39 barcode type.

image.PDF417: int

PDF417 barcode type.

image.CODE93: int

Code 93 barcode type.

image.CODE128: int

Code 128 barcode type.