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,dstis cleared to0x00000000(fully transparent) before masks are drawn.dstis always fully overwritten — its prior contents are never preserved. Callers who used to pre-load an image intodstbefore callingdraw_decoded_masks/draw_proto_masksmust now supply that image viabackgroundinstead (behaviour changed in v0.16.4).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>Compositing source image. Must have the same dimensions and pixel
format as dst. When Some, the output is background + masks.
When None, dst is cleared to 0x00000000 before masks are drawn.
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
Sourcepub fn with_background(self, bg: &'a TensorDyn) -> Self
pub fn with_background(self, bg: &'a TensorDyn) -> Self
Set the compositing source image.
bg must have the same dimensions and pixel format as the dst passed
to draw_decoded_masks /
draw_proto_masks.
The output will be bg + masks. Without a background, dst is cleared
to 0x00000000.
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 (const: unstable) · 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.