#[non_exhaustive]pub struct SemanticOptions {
pub mode: Option<DecodeMode>,
pub content_region: Option<[f32; 4]>,
}Expand description
Runtime options of one semantic decode.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.mode: Option<DecodeMode>Decode mode; None uses the model’s default.
content_region: Option<[f32; 4]>Image content within the model input as normalized
[xmin, ymin, xmax, ymax], as produced by a letterbox resize. The
region is cropped and stretched over the whole class map. None
means the image fills the input.
Implementations§
Source§impl SemanticOptions
impl SemanticOptions
Sourcepub fn with_mode(self, mode: DecodeMode) -> Self
pub fn with_mode(self, mode: DecodeMode) -> Self
Overrides the model’s decode mode.
Sourcepub fn with_content_region(self, region: [f32; 4]) -> Self
pub fn with_content_region(self, region: [f32; 4]) -> Self
Sets the content region: where the image sits in the model input.
Sourcepub fn with_convert(
self,
convert: &impl ContentRegionSource,
src: (usize, usize),
dst: (usize, usize),
) -> DecoderResult<Self>
pub fn with_convert( self, convert: &impl ContentRegionSource, src: (usize, usize), dst: (usize, usize), ) -> DecoderResult<Self>
Sets the content region from the options of the convert that
prepared the model input, so the class map uses exactly the geometry
the convert painted. src is the source image and dst the model
input, each (width, height). A stretch leaves the region unset.
§Errors
DecoderError::InvalidConfig when the convert geometry does not
resolve.
use edgefirst_decoder::semantic::SemanticOptions;
use edgefirst_tensor::PreprocessSpec;
let options = SemanticOptions::new().with_convert(&PreprocessSpec::new(), (1280, 720), (640, 640))?;
assert_eq!(options.content_region, Some([0.0, 0.21875, 1.0, 0.78125]));Trait Implementations§
Source§impl Clone for SemanticOptions
impl Clone for SemanticOptions
impl Copy for SemanticOptions
Source§impl Debug for SemanticOptions
impl Debug for SemanticOptions
Source§impl Default for SemanticOptions
impl Default for SemanticOptions
Source§impl PartialEq for SemanticOptions
impl PartialEq for SemanticOptions
impl StructuralPartialEq for SemanticOptions
Auto Trait Implementations§
impl Freeze for SemanticOptions
impl RefUnwindSafe for SemanticOptions
impl Send for SemanticOptions
impl Sync for SemanticOptions
impl Unpin for SemanticOptions
impl UnsafeUnpin for SemanticOptions
impl UnwindSafe for SemanticOptions
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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