Skip to main content

Crate spatialrust_vision

Crate spatialrust_vision 

Source
Expand description

AI-ready CPU image processing and vision algorithms.

Algorithms are feature-gated by area. GPU implementations belong in an explicit backend and must not introduce hidden device transfers.

Structs§

AbsolutePose
Object-to-camera pose X_cam = R X_obj + t used by absolute orientation (PnP).
AdaptiveBackgroundModel
Stateful single-Gaussian grayscale background model.
AffineTransform
A source-to-destination 2D affine transform.
AreaResizeU8Plan
Reusable weighted-span plan for packed u8 area resize.
BackgroundModelOptions
Adaptive Gaussian background-model controls.
BackgroundUpdate
Output of one background-model update.
BilinearResizeU8Plan
Reusable source coordinates and fixed-point coefficients for u8 bilinear resize.
BinaryMask
Validated binary mask (0 background, 1 foreground).
BoundingBox2
Axis-aligned bounding box using half-open (min, max) coordinates.
CameraMatrix3
Calibrated pinhole intrinsic matrix and its analytic inverse.
CannyOptions
Validated Canny thresholds and gradient settings.
CannyResult
Edge map and numerical stages produced by Canny.
CannyWorkspace
Reusable caller-owned storage for the allocation-light Canny path.
ComponentStats
Per-component statistics.
ConfidenceMap
Dense confidence values constrained to [0, 1].
ConnectedComponents
Connected-component labeling output.
Contour
One closed polygonal contour on pixel-grid corner coordinates.
CornerSelectionOptions
Shared response thresholding and spatial suppression options.
DenseFlowOptions
Integer block-matching controls for dense grayscale optical flow.
DepthMap
Metric or relative dense depth map. Non-positive and non-finite values are invalid.
DescriptorBuffer
Row-major descriptor matrix with a fixed width and explicit scalar kind.
Detection
One scored detection used by class-aware post-processing.
DistanceTransformWorkspace
Reusable host scratch storage for the unit-spacing exact distance transform.
Essential3
A calibrated two-view epipolar constraint matrix.
ExposureFusionOptions
Well-exposedness fusion controls.
FastOptions
FAST detector configuration for the standard 9-of-16 radius-three circle.
FeatureMatch
One descriptor correspondence from a query feature to a train feature.
FeatureSet2
Keypoints paired one-to-one with descriptor rows.
FlowField
Dense (dx, dy) optical-flow field in pixel units.
Fundamental3
An uncalibrated two-view epipolar constraint matrix.
GaussianBlurU8Workspace
Reusable scratch storage and fixed-point kernel cache for gaussian_blur_u8_into.
GeometricEstimate
A geometric model paired with one inlier decision and residual per input row.
GridSelectionOptions
Controls deterministic spatial distribution of candidate keypoints.
HarrisOptions
Harris detector configuration.
Homography3
A pixel-to-pixel planar projective transform.
IntegralImage
Summed-area table with a zero top row and left column.
Kernel1D
Validated one-dimensional correlation kernel.
Kernel2D
Validated two-dimensional correlation kernel.
Keypoint2
One scale-space image keypoint in pixel coordinates.
LabelImage
Connected-component label image (0 is background).
LetterboxTransform
Mapping between a source image and its letterboxed output.
LucasKanadeOptions
Configuration for sparse Lucas–Kanade tracking.
MaskRle
Alternating zero/one run lengths, always beginning with a zero run.
MatchOptions
Filtering applied to brute-force descriptor correspondences.
MemoryVideoSource
Deterministic in-memory source used for adapter conformance and replay.
MonocularOdometryEstimate
Scale-ambiguous monocular odometry result.
MultiObjectTracker
Deterministic same-class greedy IoU multi-object tracker.
MultiObjectTrackerOptions
IoU tracker controls.
NearestResizeU8Plan
Reusable source-coordinate plan for packed u8 nearest-neighbor resize.
ObjectImageCorrespondence
One ordered object-to-image correspondence for absolute pose estimation.
ObjectTrack
One deterministic detection track.
OrbOptions
Multi-scale ORB detector and descriptor configuration.
Padding
Padding applied around an image.
Panorama
Pairwise panorama and its integer world-coordinate origin.
PanoramaOptions
Bounded pairwise panorama settings.
PerspectiveTransform
A source-to-destination projective 2D transform.
PointCorrespondence2
One ordered pixel correspondence from a source image to a target image.
PointMap
Dense per-pixel XYZ point map. Non-finite triples represent invalid points.
RectMorphologyWorkspace
Reusable scratch storage for packed grayscale rectangular morphology.
RelativePose
Target-camera pose expressed in the source-camera coordinate frame.
RelativePoseEstimate
Essential-matrix pose disambiguation and per-correspondence triangulation.
RgbdOdometryEstimate
Metric previous-camera to current-camera odometry result.
RgbdOdometryOptions
Depth filtering and PnP RANSAC controls for metric RGB-D odometry.
RobustEstimationOptions
Deterministic robust-model sampling and inlier classification settings.
RobustTrackOptions
Forward/backward consistency settings layered over pyramidal LK.
RobustTracks
One target coordinate, validity decision, and round-trip error per source point.
ScoredIndex
Index and possibly updated score returned by Soft-NMS.
ShiTomasiOptions
Shi–Tomasi minimum-eigenvalue detector configuration.
StereoBmOptions
Block-matching stereo options.
StereoRectifyMaps
Remap grids produced by stereo rectification for explicit warp::remap.
StereoRig
Calibrated two-camera stereo geometry.
StructuringElement
A validated binary neighborhood mask and anchor.
TrackedPoints
Result of sparse point tracking between two frames.
TriangulatedPoint
One two-view triangulation with cheirality and reprojection diagnostics.
VideoFrame
Timestamped owned video frame.

Enums§

AdaptiveThresholdMethod
Adaptive neighborhood statistic.
BorderMode
Out-of-bounds sampling behavior for CPU image operations.
Connectivity
Pixel connectivity used by binary-mask algorithms.
DescriptorKind
Scalar representation used by a descriptor matrix.
Interpolation
Sampling filter used by image resampling and geometric warps.
MorphologyOperation
Composite morphology operation.
MorphologyShape
Built-in structuring-element geometry.
OrbScoreType
Response used to rank ORB keypoints.
RleOrder
Linearization order used by run-length encoded masks.
SoftNmsMethod
Soft-NMS score-decay strategy.
ThresholdType
Point-wise threshold transformation.
TrackState
Track lifecycle state.
VisionError
Errors raised by image and vision algorithms.

Constants§

INVALID_DISPARITY
Invalid disparity sentinel written by stereo_block_match.

Traits§

PixelComponent
Scalar component supported by generic CPU image kernels.
VideoFrameSource
Pull-based video source implemented by optional codec/camera adapters.

Functions§

adaptive_threshold
Applies adaptive binary thresholding to an 8-bit grayscale image.
approximate_polygon
Simplifies a closed contour with Ramer–Douglas–Peucker approximation.
batched_nms
Class-aware greedy NMS over detection records.
bilateral_filter
Applies an edge-preserving bilateral filter.
box_blur
Applies a normalized rectangular box filter.
build_gaussian_pyramid
Builds a packed Gaussian pyramid including the input as level zero.
canny
Finds edges in a single-channel u8 image.
canny_into
Finds edges into caller-owned output using reusable CPU workspace.
canny_with_intermediates
Runs Canny and retains gradient, magnitude, and suppression stages.
clahe
Applies contrast-limited adaptive histogram equalization to grayscale u8.
connected_components
Labels foreground components and computes bounding boxes and centroids.
connected_components_u8
Labels connected non-zero pixels from packed u8 mask storage.
convolve2d
Applies true convolution by reversing the supplied kernel around its anchor.
crop
Copies a checked rectangular region into a packed image.
decode_rle
Decodes a run-length mask and validates its total length.
dense_flow_block_match
Computes a dense integer flow field with deterministic local block matching.
depth_map_to_point_cloud
Unprojects a depth map with a calibrated camera into an XYZ point cloud.
depth_tensor_to_depth_map
Converts a host depth tensor into a DepthMap.
detect_and_describe_orb
Detects oriented multi-scale keypoints and computes 256-bit rotated BRIEF descriptors.
detect_fast
Detects FAST-9/16 corners in scan order, matching OpenCV’s radius-three ROI.
detect_harris
Detects Harris corners and returns strongest-first keypoints.
detect_shi_tomasi
Detects Shi–Tomasi corners and returns strongest-first keypoints.
detection_tensor_to_detections
Decodes axis-aligned detections from an [N,6] tensor of x0,y0,x1,y1,score,class.
dilate
Dilates each channel independently.
dilate_rect_u8
Dilates a grayscale u8 image with a rectangular element in linear time.
dilate_rect_u8_into
Dilates into caller-owned packed output using reusable scratch storage.
disparity_to_depth
Converts horizontal disparity to metric depth with Z = f * B / d.
disparity_to_xyz
Reprojects disparity into left-camera XYZ using rectified intrinsics.
distance_transform_edt
Computes the exact Euclidean distance from every foreground pixel to the nearest background pixel using unit pixel spacing.
distance_transform_edt_into
Computes the exact unit-spacing Euclidean distance transform into a reusable slice.
distance_transform_edt_u8_into
Computes a unit-spacing exact distance transform from a packed u8 mask.
distance_transform_edt_with_spacing
Computes the exact Euclidean distance transform with physical pixel spacing.
encode_rle
Encodes a binary mask into alternating runs.
equalize_histogram
Equalizes an 8-bit grayscale histogram.
erode
Erodes each channel independently.
erode_rect_u8
Erodes a grayscale u8 image with a rectangular element in linear time.
erode_rect_u8_into
Erodes into caller-owned packed output using reusable scratch storage.
estimate_and_stitch_panorama
Estimates a source-to-target homography and stitches the pair.
estimate_essential
Estimates an essential matrix after normalizing pixels with both cameras.
estimate_essential_ransac
Robustly estimates an essential matrix in normalized-camera coordinates.
estimate_fundamental
Estimates a fundamental matrix from at least eight correspondences.
estimate_fundamental_ransac
Robustly estimates a fundamental matrix using deterministic eight-point RANSAC.
estimate_homography
Estimates a homography from at least four correspondences using normalized DLT.
estimate_homography_ransac
Robustly estimates a homography using deterministic four-point RANSAC.
estimate_monocular_odometry
Estimates calibrated monocular motion with essential RANSAC and cheirality.
estimate_rgbd_odometry
Estimates metric motion from source depth and source-to-target pixel tracks.
filter2d
Applies OpenCV-style correlation and converts the result back to the input dtype.
filter2d_f32
Applies OpenCV-style correlation and preserves signed/fractional results as f32.
find_contours
Extracts oriented boundary loops, including hole contours.
fuse_exposures
Fuses aligned RGB exposures with normalized per-pixel well-exposedness.
gaussian_blur
Applies a separable Gaussian blur with explicit odd sizes and standard deviations.
gaussian_blur_u8
Applies a specialized 3×3, 5×5, or 7×7 Gaussian blur to interleaved u8 input.
gaussian_blur_u8_into
Applies the specialized u8 Gaussian blur into caller-owned packed output and workspace.
gray_to_rgb
Replicates a gray channel into RGB.
gray_world_white_balance
Applies deterministic gray-world white balance to an RGB image.
harris_response
Computes an unnormalized Harris structure-tensor response image.
histogram
Computes a configurable one-channel histogram, optionally through a mask.
histogram_u8
Computes the exact 256-bin histogram of an 8-bit grayscale image.
integral_image
Computes a summed-area table for one selected channel.
laplacian
Computes a Laplacian response as signed f32 values.
letterbox
Aspect-preserving resize followed by centered constant padding.
match_descriptors
Matches each query descriptor to its nearest train descriptor.
median_blur
Applies a per-channel median filter with an odd square aperture.
morphology_ex
Applies a composite morphology operation.
morphology_rect_u8
Applies composite grayscale u8 morphology using the rectangular fast path.
morphology_rect_u8_into
Applies composite rectangular morphology into caller-owned packed output.
nms
Greedy non-maximum suppression. Returned indices are score-descending.
normalize
Converts packed scalar values to f32, then applies value * scale, mean subtraction, and per-channel standard-deviation normalization.
normalize_into
Normalizes interleaved pixels into caller-owned f32 storage.
otsu_threshold_u8
Selects an Otsu threshold for an 8-bit grayscale image and applies it.
otsu_threshold_u16
Selects an Otsu threshold for a 16-bit grayscale image and applies it.
pack_chw
Packs and normalizes an interleaved image into planar CHW storage.
pack_chw_into
Packs and normalizes interleaved pixels into a reusable planar CHW slice.
pad
Pads an image with a constant pixel value.
planar_f32_to_nchw
Packs a planar CHW f32 image into contiguous NCHW [1,C,H,W].
point_map_to_point_cloud
Flattens valid point-map pixels into an XYZ cloud, optionally filtering by confidence.
project_object_point
Projects an object point with an absolute pose into pixel coordinates.
pyr_down
Reduces each dimension by approximately two using the canonical 5×5 kernel.
pyr_up
Doubles each dimension using zero insertion and the canonical 5×5 kernel.
recover_relative_pose
Recovers the essential-matrix pose with the most positive-depth points.
remap
Samples an image at absolute coordinates supplied by two single-channel maps.
resize
Resizes an interleaved image while preserving semantic metadata.
resize_into
Resizes into caller-owned storage without allocating.
resize_pack_chw
Fuses bilinear RGB resize, normalization, and CHW packing without an intermediate image.
resize_pack_chw_into
Fuses bilinear RGB resize, normalization, and CHW packing into caller-owned storage.
resize_rgb_to_gray
Fuses bilinear RGB resize and BT.601 grayscale conversion without an intermediate RGB image.
resize_rgb_to_gray_into
Fuses bilinear RGB resize and BT.601 grayscale conversion into caller-owned storage.
rgb_to_gray
Converts RGB u8 pixels to BT.601 luma using fixed-point coefficients.
rgb_to_gray_into
Converts RGB u8 pixels into caller-owned gray storage without allocating.
rgb_to_hsv
Converts RGB u8 to OpenCV-style HSV (H in 0..=179, S/V in 0..=255).
rgb_u8_to_nchw_f32
Letterboxes an RGB u8 image and packs it as contiguous NCHW f32 [1,3,H,W].
scharr
Computes a 3×3 Scharr first derivative as signed f32 values.
score_tensor_to_binary_mask
Converts a host score tensor into a binary mask via threshold.
select_keypoints_grid
Retains the strongest keypoints in each image cell.
separable_filter
Applies horizontal and vertical kernels using an f64 intermediate buffer.
separable_filter_f32
Applies separable kernels and preserves signed/fractional output as f32.
shi_tomasi_response
Computes an unnormalized Shi–Tomasi minimum-eigenvalue response image.
sobel
Computes a Sobel derivative as signed f32 values.
sobel_3x3_u8
Computes a first-order 3x3 Sobel derivative directly into signed f32 output.
sobel_3x3_u8_into
Computes a first-order 3x3 Sobel derivative into caller-owned packed output.
sobel_abs_3x3_u8
Computes an exact absolute first-order 3x3 Sobel response as saturated u8.
sobel_abs_3x3_u8_into
Computes an exact absolute first-order 3x3 Sobel response into packed output.
sobel_l1_magnitude_u8
Computes exact 3×3 Sobel L1 magnitude (|Gx| + |Gy|) for grayscale u8.
sobel_l1_magnitude_u8_into
Computes exact fused 3×3 Sobel L1 magnitude into caller-owned packed output.
sobel_threshold_3x3_u8
Computes a binary edge mask from absolute 3x3 Sobel response.
sobel_threshold_3x3_u8_into
Computes a binary absolute-Sobel edge mask into caller-owned packed output.
soft_nms
Soft non-maximum suppression with deterministic score ordering.
solve_pnp
Estimates an object-to-camera pose from at least four correspondences.
solve_pnp_ransac
Robust PnP using deterministic six-point RANSAC and inlier refinement.
spatial_gradient_u8
Computes exact 3×3 Sobel X/Y gradients together for grayscale u8 input.
spatial_gradient_u8_into
Computes exact paired 3×3 Sobel gradients into caller-owned packed output.
stereo_block_match
Dense SAD block matching on already-rectified grayscale stereo images.
stereo_rectify
Builds left/right absolute remap grids that make epipolar lines horizontal.
stitch_panorama_pair
Warps source into target coordinates and feather-blends their overlap.
swap_red_blue
Swaps the red and blue channels of a three-channel image.
threshold
Applies a fixed threshold independently to every component.
track_points_forward_backward
Tracks points in both directions and rejects inconsistent round trips.
track_points_lucas_kanade
Tracks sparse points from previous to next with pyramidal Lucas–Kanade.
triangulate_correspondence
Triangulates one calibrated correspondence for a known relative pose.
warp_affine
Warps an image with a source-to-destination affine transform.
warp_perspective
Warps an image with a source-to-destination projective transform.

Type Aliases§

VisionResult
Result type for image and vision operations.