[][src]Trait opencv::dnn::ModelTrait

pub trait ModelTrait: NetTrait {
    fn as_raw_Model(&self) -> *mut c_void;

    fn set_input_size(&mut self, size: Size) -> Result<Model> { ... }
fn set_input_size_1(&mut self, width: i32, height: i32) -> Result<Model> { ... }
fn set_input_mean(&mut self, mean: Scalar) -> Result<Model> { ... }
fn set_input_scale(&mut self, scale: f64) -> Result<Model> { ... }
fn set_input_crop(&mut self, crop: bool) -> Result<Model> { ... }
fn set_input_swap_rb(&mut self, swap_rb: bool) -> Result<Model> { ... }
fn set_input_params(
        &mut self,
        scale: f64,
        size: Size,
        mean: Scalar,
        swap_rb: bool,
        crop: bool
    ) -> Result<()> { ... }
fn predict(
        &mut self,
        frame: &dyn ToInputArray,
        outs: &mut dyn ToOutputArray
    ) -> Result<()> { ... } }

This class is presented high-level API for neural networks.

Model allows to set params for preprocessing input image. Model creates net from file with trained weights and config, sets preprocessing input and runs forward pass.

Required methods

Loading content...

Provided methods

fn set_input_size(&mut self, size: Size) -> Result<Model>

Set input size for frame.

Parameters

  • size: New input size.

Note: If shape of the new blob less than 0, then frame size not change.

fn set_input_size_1(&mut self, width: i32, height: i32) -> Result<Model>

Set input size for frame.

Parameters

  • width: New input width.
  • height: New input height.

Note: If shape of the new blob less than 0, then frame size not change.

fn set_input_mean(&mut self, mean: Scalar) -> Result<Model>

Set mean value for frame.

Parameters

  • mean: Scalar with mean values which are subtracted from channels.

fn set_input_scale(&mut self, scale: f64) -> Result<Model>

Set scalefactor value for frame.

Parameters

  • scale: Multiplier for frame values.

fn set_input_crop(&mut self, crop: bool) -> Result<Model>

Set flag crop for frame.

Parameters

  • crop: Flag which indicates whether image will be cropped after resize or not.

fn set_input_swap_rb(&mut self, swap_rb: bool) -> Result<Model>

Set flag swapRB for frame.

Parameters

  • swapRB: Flag which indicates that swap first and last channels.

fn set_input_params(
    &mut self,
    scale: f64,
    size: Size,
    mean: Scalar,
    swap_rb: bool,
    crop: bool
) -> Result<()>

Set preprocessing parameters for frame.

Parameters

  • size: New input size.
  • mean: Scalar with mean values which are subtracted from channels.
  • scale: Multiplier for frame values.
  • swapRB: Flag which indicates that swap first and last channels.
  • crop: Flag which indicates whether image will be cropped after resize or not. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )

C++ default parameters

  • scale: 1.0
  • size: Size()
  • mean: Scalar()
  • swap_rb: false
  • crop: false

fn predict(
    &mut self,
    frame: &dyn ToInputArray,
    outs: &mut dyn ToOutputArray
) -> Result<()>

Given the @p input frame, create input blob, run net and return the output @p blobs.

Parameters

  • frame: The input image.
  • outs: [out] Allocated output blobs, which will store results of the computation.
Loading content...

Implementors

impl ModelTrait for ClassificationModel[src]

impl ModelTrait for DetectionModel[src]

impl ModelTrait for KeypointsModel[src]

impl ModelTrait for Model[src]

impl ModelTrait for SegmentationModel[src]

Loading content...