pub struct CPUProcessor { /* private fields */ }Expand description
CPUConverter implements the ImageProcessor trait using the fallback CPU implementation for image processing.
Implementations§
Source§impl CPUProcessor
impl CPUProcessor
Sourcepub fn materialize_segmentations(
&self,
detect: &[DetectBox],
proto_data: &ProtoData,
letterbox: Option<[f32; 4]>,
) -> Result<Vec<Segmentation>>
pub fn materialize_segmentations( &self, detect: &[DetectBox], proto_data: &ProtoData, letterbox: Option<[f32; 4]>, ) -> Result<Vec<Segmentation>>
Materialize segmentation masks from proto data into Vec<Segmentation>.
This is the CPU-side decode step of the hybrid mask rendering path:
call this to get pre-decoded masks, then pass them to
draw_decoded_masks for GPU overlay.
Benchmarks show this hybrid path (CPU decode + GL overlay) is faster
than the fused GPU draw_proto_masks on all tested platforms.
Optimized: fused dequantization + dot product avoids a 3.1MB f32 allocation for the full proto tensor. Uses fast sigmoid approximation.
Sourcepub fn materialize_scaled_segmentations(
&self,
detect: &[DetectBox],
proto_data: &ProtoData,
letterbox: Option<[f32; 4]>,
width: u32,
height: u32,
) -> Result<Vec<Segmentation>>
pub fn materialize_scaled_segmentations( &self, detect: &[DetectBox], proto_data: &ProtoData, letterbox: Option<[f32; 4]>, width: u32, height: u32, ) -> Result<Vec<Segmentation>>
Produce per-detection masks at (width, height) pixel resolution by
upsampling the full proto plane once then cropping per bbox. Each
det.bbox is assumed to be in model-input normalized coordinates
(the convention used by the decoder output); when letterbox is
Some, (width, height) are original-content pixel dims and the
inverse letterbox transform is applied to both the bbox (for the
crop region and returned Segmentation metadata) and each output
pixel (for proto-plane sampling). Mask values are binary
uint8 {0, 255} after thresholding sigmoid > 0.5.
Used by [ImageProcessor::materialize_masks] when the caller selects
MaskResolution::Scaled.
Source§impl CPUProcessor
impl CPUProcessor
Sourcepub fn new_nearest() -> Self
pub fn new_nearest() -> Self
Creates a new CPUConverter with nearest neighbor resizing.
Trait Implementations§
Source§impl Clone for CPUProcessor
impl Clone for CPUProcessor
Source§fn clone(&self) -> CPUProcessor
fn clone(&self) -> CPUProcessor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CPUProcessor
impl Debug for CPUProcessor
Source§impl Default for CPUProcessor
impl Default for CPUProcessor
Source§impl ImageProcessorTrait for CPUProcessor
impl ImageProcessorTrait for CPUProcessor
Source§fn convert(
&mut self,
src: &TensorDyn,
dst: &mut TensorDyn,
rotation: Rotation,
flip: Flip,
crop: Crop,
) -> Result<()>
fn convert( &mut self, src: &TensorDyn, dst: &mut TensorDyn, rotation: Rotation, flip: Flip, crop: Crop, ) -> Result<()>
Source§fn draw_decoded_masks(
&mut self,
dst: &mut TensorDyn,
detect: &[DetectBox],
segmentation: &[Segmentation],
overlay: MaskOverlay<'_>,
) -> Result<()>
fn draw_decoded_masks( &mut self, dst: &mut TensorDyn, detect: &[DetectBox], segmentation: &[Segmentation], overlay: MaskOverlay<'_>, ) -> Result<()>
dst. Read moreSource§fn draw_proto_masks(
&mut self,
dst: &mut TensorDyn,
detect: &[DetectBox],
proto_data: &ProtoData,
overlay: MaskOverlay<'_>,
) -> Result<()>
fn draw_proto_masks( &mut self, dst: &mut TensorDyn, detect: &[DetectBox], proto_data: &ProtoData, overlay: MaskOverlay<'_>, ) -> Result<()>
impl Send for CPUProcessor
impl Sync for CPUProcessor
Auto Trait Implementations§
impl Freeze for CPUProcessor
impl RefUnwindSafe for CPUProcessor
impl Unpin for CPUProcessor
impl UnsafeUnpin for CPUProcessor
impl UnwindSafe for CPUProcessor
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.