pub struct MaskOverlay<'a> {
pub background: Option<&'a TensorDyn>,
pub opacity: f32,
pub letterbox: Option<[f32; 4]>,
pub color_mode: ColorMode,
}Expand description
Options for mask overlay rendering.
Controls how segmentation masks are composited onto the destination image:
background: when set, the background image is drawn first and masks are composited over it (result written todst). WhenNone, masks are composited directly overdst’s existing content.opacity: scales the alpha of rendered mask colors.1.0(default) preserves the class color’s alpha unchanged;0.5makes masks semi-transparent.color_mode: controls whether colors are assigned by class label, instance index, or track ID. Defaults toColorMode::Class.
Fields§
§background: Option<&'a TensorDyn>§opacity: f32§letterbox: Option<[f32; 4]>Normalized letterbox region [xmin, ymin, xmax, ymax] in model-input
space that contains actual image content (the rest is padding).
When set, bounding boxes and mask coordinates from the decoder (which are in model-input normalized space) are mapped back to the original image coordinate space before rendering.
Use with_letterbox_crop to compute this
from the Crop that was used in the model input convert call.
color_mode: ColorModeImplementations§
Source§impl<'a> MaskOverlay<'a>
impl<'a> MaskOverlay<'a>
pub fn new() -> Self
pub fn with_background(self, bg: &'a TensorDyn) -> Self
pub fn with_opacity(self, opacity: f32) -> Self
pub fn with_color_mode(self, mode: ColorMode) -> Self
Sourcepub fn with_letterbox_crop(
self,
crop: &Crop,
model_w: usize,
model_h: usize,
) -> Self
pub fn with_letterbox_crop( self, crop: &Crop, model_w: usize, model_h: usize, ) -> Self
Set the letterbox transform from the Crop used when preparing the
model input, so that bounding boxes and masks are correctly mapped back
to the original image coordinate space during rendering.
Pass the same crop that was given to
convert along with the model
input dimensions (model_w × model_h).
Has no effect when crop.dst_rect is None (no letterbox applied).
Trait Implementations§
Source§impl<'a> Clone for MaskOverlay<'a>
impl<'a> Clone for MaskOverlay<'a>
Source§fn clone(&self) -> MaskOverlay<'a>
fn clone(&self) -> MaskOverlay<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for MaskOverlay<'a>
impl<'a> Debug for MaskOverlay<'a>
Source§impl Default for MaskOverlay<'_>
impl Default for MaskOverlay<'_>
impl<'a> Copy for MaskOverlay<'a>
Auto Trait Implementations§
impl<'a> Freeze for MaskOverlay<'a>
impl<'a> !RefUnwindSafe for MaskOverlay<'a>
impl<'a> Send for MaskOverlay<'a>
impl<'a> Sync for MaskOverlay<'a>
impl<'a> Unpin for MaskOverlay<'a>
impl<'a> UnsafeUnpin for MaskOverlay<'a>
impl<'a> !UnwindSafe for MaskOverlay<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more