Struct opencv::dnn::Net

source ·
pub struct Net { /* private fields */ }
Expand description

This class allows to create and manipulate comprehensive artificial neural networks.

Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances, and edges specify relationships between layers inputs and outputs.

Each network layer has unique integer id and unique string name inside its network. LayerId can store either layer name or layer id.

This class supports reference counting of its instances, i. e. copies point to the same instance.

Implementations§

source§

impl Net

source

pub fn default() -> Result<Net>

source

pub fn read_from_model_optimizer(xml: &str, bin: &str) -> Result<Net>

Create a network from Intel’s Model Optimizer intermediate representation (IR).

Parameters
  • xml: XML configuration file with network’s topology.
  • bin: Binary file with trained weights. Networks imported from Intel’s Model Optimizer are launched in Intel’s Inference Engine backend.
source

pub fn read_from_model_optimizer_1( buffer_model_config: &Vector<u8>, buffer_weights: &Vector<u8> ) -> Result<Net>

Create a network from Intel’s Model Optimizer in-memory buffers with intermediate representation (IR).

Parameters
  • bufferModelConfig: buffer with model’s configuration.
  • bufferWeights: buffer with model’s trained weights.
Returns

Net object.

source

pub fn read_from_model_optimizer_2( buffer_model_config_ptr: &u8, buffer_model_config_size: size_t, buffer_weights_ptr: &u8, buffer_weights_size: size_t ) -> Result<Net>

Create a network from Intel’s Model Optimizer in-memory buffers with intermediate representation (IR).

Parameters
  • bufferModelConfigPtr: buffer pointer of model’s configuration.
  • bufferModelConfigSize: buffer size of model’s configuration.
  • bufferWeightsPtr: buffer pointer of model’s trained weights.
  • bufferWeightsSize: buffer size of model’s trained weights.
Returns

Net object.

Trait Implementations§

source§

impl Boxed for Net

source§

unsafe fn from_raw(ptr: *mut c_void) -> Self

Wrap the specified raw pointer Read more
source§

fn into_raw(self) -> *mut c_void

Return an the underlying raw pointer while consuming this wrapper. Read more
source§

fn as_raw(&self) -> *const c_void

Return the underlying raw pointer. Read more
source§

fn as_raw_mut(&mut self) -> *mut c_void

Return the underlying mutable raw pointer Read more
source§

impl Clone for Net

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Drop for Net

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl NetTrait for Net

source§

fn as_raw_mut_Net(&mut self) -> *mut c_void

source§

fn dump(&mut self) -> Result<String>

Dump net to String Read more
source§

fn dump_to_file(&mut self, path: &str) -> Result<()>

Dump net structure, hyperparameters, backend, target and fusion to dot file Read more
source§

fn add_layer_type( &mut self, name: &str, typ: &str, dtype: &i32, params: &mut LayerParams ) -> Result<i32>

Adds new layer to the net. Read more
source§

fn add_layer( &mut self, name: &str, typ: &str, params: &mut LayerParams ) -> Result<i32>

Adds new layer to the net. Read more
source§

fn add_layer_to_prev_type( &mut self, name: &str, typ: &str, dtype: &i32, params: &mut LayerParams ) -> Result<i32>

Adds new layer and connects its first input to the first output of previously added layer. Read more
source§

fn add_layer_to_prev( &mut self, name: &str, typ: &str, params: &mut LayerParams ) -> Result<i32>

Adds new layer and connects its first input to the first output of previously added layer. Read more
source§

fn connect_first_second(&mut self, out_pin: &str, inp_pin: &str) -> Result<()>

Connects output of the first layer to input of the second layer. Read more
source§

fn connect( &mut self, out_layer_id: i32, out_num: i32, inp_layer_id: i32, inp_num: i32 ) -> Result<()>

Connects #@p outNum output of the first layer to #@p inNum input of the second layer. Read more
source§

fn register_output( &mut self, output_name: &str, layer_id: i32, output_port: i32 ) -> Result<i32>

Registers network output with name Read more
source§

fn set_inputs_names(&mut self, input_blob_names: &Vector<String>) -> Result<()>

Sets outputs names of the network input pseudo layer. Read more
source§

fn set_input_shape(&mut self, input_name: &str, shape: &MatShape) -> Result<()>

Specify shape of network input.
source§

fn forward_single(&mut self, output_name: &str) -> Result<Mat>

Runs forward pass to compute output of layer with name @p outputName. Read more
source§

fn forward_async(&mut self, output_name: &str) -> Result<AsyncArray>

Runs forward pass to compute output of layer with name @p outputName. Read more
source§

fn forward_layer( &mut self, output_blobs: &mut dyn ToOutputArray, output_name: &str ) -> Result<()>

Runs forward pass to compute output of layer with name @p outputName. Read more
source§

fn forward( &mut self, output_blobs: &mut dyn ToOutputArray, out_blob_names: &Vector<String> ) -> Result<()>

Runs forward pass to compute outputs of layers listed in @p outBlobNames. Read more
source§

fn forward_and_retrieve( &mut self, output_blobs: &mut Vector<Vector<Mat>>, out_blob_names: &Vector<String> ) -> Result<()>

Runs forward pass to compute outputs of layers listed in @p outBlobNames. Read more
source§

fn quantize( &mut self, calib_data: &dyn ToInputArray, inputs_dtype: i32, outputs_dtype: i32, per_channel: bool ) -> Result<Net>

Returns a quantized Net from a floating-point Net. Read more
source§

fn set_halide_scheduler(&mut self, scheduler: &str) -> Result<()>

Compile Halide layers. Read more
source§

fn set_preferable_backend(&mut self, backend_id: i32) -> Result<()>

Ask network to use specific computation backend where it supported. Read more
source§

fn set_preferable_target(&mut self, target_id: i32) -> Result<()>

Ask network to make computations on specific target device. Read more
source§

fn set_input( &mut self, blob: &dyn ToInputArray, name: &str, scalefactor: f64, mean: Scalar ) -> Result<()>

Sets the new input value for the network Read more
source§

fn set_param(&mut self, layer: i32, num_param: i32, blob: &Mat) -> Result<()>

Sets the new value for the learned param of the layer. Read more
source§

fn set_param_1( &mut self, layer_name: &str, num_param: i32, blob: &Mat ) -> Result<()>

source§

fn enable_fusion(&mut self, fusion: bool) -> Result<()>

Enables or disables layer fusion in the network. Read more
source§

fn enable_winograd(&mut self, use_winograd: bool) -> Result<()>

Enables or disables the Winograd compute branch. The Winograd compute branch can speed up 3x3 Convolution at a small loss of accuracy. Read more
source§

fn get_perf_profile(&mut self, timings: &mut Vector<f64>) -> Result<i64>

Returns overall time for inference and timings (in ticks) for layers. Read more
source§

impl NetTraitConst for Net

source§

fn as_raw_Net(&self) -> *const c_void

source§

fn empty(&self) -> Result<bool>

Returns true if there are no layers in the network.
source§

fn get_layer_id(&self, layer: &str) -> Result<i32>

Converts string name of the layer to the integer identifier. Read more
source§

fn get_layer_names(&self) -> Result<Vector<String>>

source§

fn get_layer(&self, layer_id: i32) -> Result<Ptr<Layer>>

Returns pointer to layer with specified id or name which the network use.
source§

fn get_layer_1(&self, layer_name: &str) -> Result<Ptr<Layer>>

👎Deprecated: Use int getLayerId(const String &layer)
Returns pointer to layer with specified id or name which the network use. Read more
source§

fn get_layer_2(&self, layer_id: &Net_LayerId) -> Result<Ptr<Layer>>

👎Deprecated: to be removed
Returns pointer to layer with specified id or name which the network use. Read more
source§

fn get_layer_inputs(&self, layer_id: i32) -> Result<Vector<Ptr<Layer>>>

Returns pointers to input layers of specific layer.
source§

fn get_input_details( &self, scales: &mut Vector<f32>, zeropoints: &mut Vector<i32> ) -> Result<()>

Returns input scale and zeropoint for a quantized Net. Read more
source§

fn get_output_details( &self, scales: &mut Vector<f32>, zeropoints: &mut Vector<i32> ) -> Result<()>

Returns output scale and zeropoint for a quantized Net. Read more
source§

fn get_param(&self, layer: i32, num_param: i32) -> Result<Mat>

Returns parameter blob of the layer. Read more
source§

fn get_param_1(&self, layer_name: &str, num_param: i32) -> Result<Mat>

C++ default parameters Read more
source§

fn get_unconnected_out_layers(&self) -> Result<Vector<i32>>

Returns indexes of layers with unconnected outputs. Read more
source§

fn get_unconnected_out_layers_names(&self) -> Result<Vector<String>>

Returns names of layers with unconnected outputs. Read more
source§

fn get_layers_shapes( &self, net_input_shapes: &Vector<MatShape>, layers_ids: &mut Vector<i32>, in_layers_shapes: &mut Vector<Vector<MatShape>>, out_layers_shapes: &mut Vector<Vector<MatShape>> ) -> Result<()>

Returns input and output shapes for all layers in loaded model; preliminary inferencing isn’t necessary. Read more
source§

fn get_layers_shapes_1( &self, net_input_shape: &MatShape, layers_ids: &mut Vector<i32>, in_layers_shapes: &mut Vector<Vector<MatShape>>, out_layers_shapes: &mut Vector<Vector<MatShape>> ) -> Result<()>

Returns input and output shapes for all layers in loaded model; preliminary inferencing isn’t necessary. Read more
source§

fn get_layer_shapes( &self, net_input_shape: &MatShape, layer_id: i32, in_layer_shapes: &mut Vector<MatShape>, out_layer_shapes: &mut Vector<MatShape> ) -> Result<()>

Returns input and output shapes for layer with specified id in loaded model; preliminary inferencing isn’t necessary. Read more
source§

fn get_layer_shapes_1( &self, net_input_shapes: &Vector<MatShape>, layer_id: i32, in_layer_shapes: &mut Vector<MatShape>, out_layer_shapes: &mut Vector<MatShape> ) -> Result<()>

Returns input and output shapes for layer with specified id in loaded model; preliminary inferencing isn’t necessary. Read more
source§

fn get_flops(&self, net_input_shapes: &Vector<MatShape>) -> Result<i64>

Computes FLOP for whole loaded model with specified input shapes. Read more
source§

fn get_flops_1(&self, net_input_shape: &MatShape) -> Result<i64>

Computes FLOP for whole loaded model with specified input shapes. Read more
source§

fn get_flops_2( &self, layer_id: i32, net_input_shapes: &Vector<MatShape> ) -> Result<i64>

Computes FLOP for whole loaded model with specified input shapes. Read more
source§

fn get_flops_3(&self, layer_id: i32, net_input_shape: &MatShape) -> Result<i64>

Computes FLOP for whole loaded model with specified input shapes. Read more
source§

fn get_layer_types(&self, layers_types: &mut Vector<String>) -> Result<()>

Returns list of types for layer used in model. Read more
source§

fn get_layers_count(&self, layer_type: &str) -> Result<i32>

Returns count of layers of specified type. Read more
source§

fn get_memory_consumption( &self, net_input_shapes: &Vector<MatShape>, weights: &mut size_t, blobs: &mut size_t ) -> Result<()>

Computes bytes number which are required to store all weights and intermediate blobs for model. Read more
source§

fn get_memory_consumption_1( &self, net_input_shape: &MatShape, weights: &mut size_t, blobs: &mut size_t ) -> Result<()>

Computes bytes number which are required to store all weights and intermediate blobs for model. Read more
source§

fn get_memory_consumption_for_layer( &self, layer_id: i32, net_input_shapes: &Vector<MatShape>, weights: &mut size_t, blobs: &mut size_t ) -> Result<()>

Computes bytes number which are required to store all weights and intermediate blobs for model. Read more
source§

fn get_memory_consumption_2( &self, layer_id: i32, net_input_shape: &MatShape, weights: &mut size_t, blobs: &mut size_t ) -> Result<()>

Computes bytes number which are required to store all weights and intermediate blobs for model. Read more
source§

fn get_memory_consumption_for_layers( &self, net_input_shapes: &Vector<MatShape>, layer_ids: &mut Vector<i32>, weights: &mut Vector<size_t>, blobs: &mut Vector<size_t> ) -> Result<()>

Computes bytes number which are required to store all weights and intermediate blobs for each layer. Read more
source§

fn get_memory_consumption_3( &self, net_input_shape: &MatShape, layer_ids: &mut Vector<i32>, weights: &mut Vector<size_t>, blobs: &mut Vector<size_t> ) -> Result<()>

Computes bytes number which are required to store all weights and intermediate blobs for each layer. Read more
source§

impl Send for Net

Auto Trait Implementations§

§

impl RefUnwindSafe for Net

§

impl !Sync for Net

§

impl Unpin for Net

§

impl UnwindSafe for Net

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.