pub struct ImageProcessor {
pub cpu: Option<CPUProcessor>,
pub g2d: Option<G2DProcessor>,
pub opengl: Option<GLProcessorThreaded>,
}Expand description
Image converter that uses available hardware acceleration or CPU as a fallback.
Fields§
§cpu: Option<CPUProcessor>CPU-based image converter as a fallback. This is only None if the EDGEFIRST_DISABLE_CPU environment variable is set.
g2d: Option<G2DProcessor>G2D-based image converter for Linux systems. This is only available if the EDGEFIRST_DISABLE_G2D environment variable is not set and libg2d.so is available.
opengl: Option<GLProcessorThreaded>OpenGL-based image converter for Linux systems. This is only available if the EDGEFIRST_DISABLE_GL environment variable is not set and OpenGL ES is available.
Implementations§
Source§impl ImageProcessor
impl ImageProcessor
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new ImageProcessor instance, initializing available
hardware converters based on the system capabilities and environment
variables.
§Examples
let image = include_bytes!("../../../testdata/zidane.jpg");
let img = TensorImage::load(image, Some(RGBA), None)?;
let mut converter = ImageProcessor::new()?;
let mut dst = TensorImage::new(640, 480, RGB, None)?;
converter.convert(&img, &mut dst, Rotation::None, Flip::None, Crop::default())?;Sourcepub fn with_config(config: ImageProcessorConfig) -> Result<Self>
pub fn with_config(config: ImageProcessorConfig) -> Result<Self>
Creates a new ImageProcessor with the given configuration.
This allows overriding the EGL display type used for OpenGL
acceleration. The EDGEFIRST_DISABLE_GL=1 environment variable
still takes precedence over any override.
Sourcepub fn set_int8_interpolation_mode(
&mut self,
mode: Int8InterpolationMode,
) -> Result<()>
pub fn set_int8_interpolation_mode( &mut self, mode: Int8InterpolationMode, ) -> Result<()>
Sets the interpolation mode for int8 proto textures on the OpenGL backend. No-op if OpenGL is not available.
Sourcepub fn create_image(
&self,
width: usize,
height: usize,
fourcc: FourCharCode,
) -> Result<TensorImage>
pub fn create_image( &self, width: usize, height: usize, fourcc: FourCharCode, ) -> Result<TensorImage>
Create a TensorImage with the best available memory backend.
Priority: DMA-buf → PBO → system memory.
§Arguments
width- Image width in pixelsheight- Image height in pixelsfourcc- Pixel format as a FourCC code
§Returns
A TensorImage backed by the highest-performance memory type
available on this system.
§Errors
Returns an error if all allocation strategies fail.
Trait Implementations§
Source§impl Debug for ImageProcessor
impl Debug for ImageProcessor
Source§impl ImageProcessorTrait for ImageProcessor
impl ImageProcessorTrait for ImageProcessor
Source§fn convert(
&mut self,
src: &TensorImage,
dst: &mut TensorImage,
rotation: Rotation,
flip: Flip,
crop: Crop,
) -> Result<()>
fn convert( &mut self, src: &TensorImage, dst: &mut TensorImage, rotation: Rotation, flip: Flip, crop: Crop, ) -> Result<()>
Converts the source image to the destination image format and size. The image is cropped first, then flipped, then rotated
Prefer hardware accelerators when available, falling back to CPU if necessary.
Source§fn convert_ref(
&mut self,
src: &TensorImage,
dst: &mut TensorImageRef<'_>,
rotation: Rotation,
flip: Flip,
crop: Crop,
) -> Result<()>
fn convert_ref( &mut self, src: &TensorImage, dst: &mut TensorImageRef<'_>, rotation: Rotation, flip: Flip, crop: Crop, ) -> Result<()>
Source§fn draw_masks(
&mut self,
dst: &mut TensorImage,
detect: &[DetectBox],
segmentation: &[Segmentation],
) -> Result<()>
fn draw_masks( &mut self, dst: &mut TensorImage, detect: &[DetectBox], segmentation: &[Segmentation], ) -> Result<()>
Source§fn draw_masks_proto(
&mut self,
dst: &mut TensorImage,
detect: &[DetectBox],
proto_data: &ProtoData,
) -> Result<()>
fn draw_masks_proto( &mut self, dst: &mut TensorImage, detect: &[DetectBox], proto_data: &ProtoData, ) -> Result<()>
impl Send for ImageProcessor
impl Sync for ImageProcessor
Auto Trait Implementations§
impl Freeze for ImageProcessor
impl !RefUnwindSafe for ImageProcessor
impl Unpin for ImageProcessor
impl UnsafeUnpin for ImageProcessor
impl !UnwindSafe for ImageProcessor
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> 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.