use std::os::raw::{c_char, c_void};
use libc::{ptrdiff_t, size_t};
use crate::{Error, Result, core, sys, types};
use crate::core::{_InputArray, _OutputArray};
pub const EltwiseLayer_PROD: i32 = 0;
pub const EltwiseLayer_SUM: i32 = 1;
pub const LRNLayer_CHANNEL_NRM: i32 = 0;
pub const LRNLayer_SPATIAL_NRM: i32 = 1;
pub const PoolingLayer_AVE: i32 = 1;
pub const PoolingLayer_MAX: i32 = 0;
pub const PoolingLayer_STOCHASTIC: i32 = 2;
pub fn create_caffe_importer(prototxt: &str, caffe_model: &str) -> Result<types::PtrOfImporter> {
string_arg!(prototxt);
string_arg!(caffe_model);
unsafe { sys::cv_dnn_createCaffeImporter_String_String(prototxt.as_ptr(), caffe_model.as_ptr()) }.into_result().map(|ptr| types::PtrOfImporter { ptr })
}
pub fn create_tensorflow_importer(model: &str) -> Result<types::PtrOfImporter> {
string_arg!(model);
unsafe { sys::cv_dnn_createTensorflowImporter_String(model.as_ptr()) }.into_result().map(|ptr| types::PtrOfImporter { ptr })
}
pub fn create_torch_importer(filename: &str, is_binary: bool) -> Result<types::PtrOfImporter> {
string_arg!(filename);
unsafe { sys::cv_dnn_createTorchImporter_String_bool(filename.as_ptr(), is_binary) }.into_result().map(|ptr| types::PtrOfImporter { ptr })
}
pub fn init_module() -> Result<()> {
unsafe { sys::cv_dnn_initModule() }.into_result()
}
pub fn read_net_from_caffe(prototxt: &str, caffe_model: &str) -> Result<crate::dnn::Net> {
string_arg!(prototxt);
string_arg!(caffe_model);
unsafe { sys::cv_dnn_readNetFromCaffe_String_String(prototxt.as_ptr(), caffe_model.as_ptr()) }.into_result().map(|ptr| crate::dnn::Net { ptr })
}
pub struct AbsLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::AbsLayer {
fn drop(&mut self) {
unsafe { sys::cv_AbsLayer_delete(self.ptr) };
}
}
impl crate::dnn::AbsLayer {
#[inline(always)] pub fn as_raw_AbsLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for AbsLayer {}
impl crate::dnn::Layer for AbsLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl AbsLayer {
pub fn create() -> Result<types::PtrOfAbsLayer> {
unsafe { sys::cv_dnn_AbsLayer_create() }.into_result().map(|ptr| types::PtrOfAbsLayer { ptr })
}
}
pub struct BNLLLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::BNLLLayer {
fn drop(&mut self) {
unsafe { sys::cv_BNLLLayer_delete(self.ptr) };
}
}
impl crate::dnn::BNLLLayer {
#[inline(always)] pub fn as_raw_BNLLLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for BNLLLayer {}
impl crate::dnn::Layer for BNLLLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl BNLLLayer {
pub fn create() -> Result<types::PtrOfBNLLLayer> {
unsafe { sys::cv_dnn_BNLLLayer_create() }.into_result().map(|ptr| types::PtrOfBNLLLayer { ptr })
}
}
pub trait BaseConvolutionLayer: crate::dnn::Layer {
#[inline(always)] fn as_raw_BaseConvolutionLayer(&self) -> *mut c_void;
fn kernel(&self) -> Result<core::Size> {
unsafe { sys::cv_dnn_BaseConvolutionLayer_kernel_const(self.as_raw_BaseConvolutionLayer()) }.into_result()
}
fn stride(&self) -> Result<core::Size> {
unsafe { sys::cv_dnn_BaseConvolutionLayer_stride_const(self.as_raw_BaseConvolutionLayer()) }.into_result()
}
fn pad(&self) -> Result<core::Size> {
unsafe { sys::cv_dnn_BaseConvolutionLayer_pad_const(self.as_raw_BaseConvolutionLayer()) }.into_result()
}
fn dilation(&self) -> Result<core::Size> {
unsafe { sys::cv_dnn_BaseConvolutionLayer_dilation_const(self.as_raw_BaseConvolutionLayer()) }.into_result()
}
fn pad_mode(&mut self) -> Result<String> {
unsafe { sys::cv_dnn_BaseConvolutionLayer_padMode(self.as_raw_BaseConvolutionLayer()) }.into_result().map(crate::templ::receive_string_mut)
}
fn set_pad_mode(&mut self, val: &str) -> Result<()> {
string_arg!(mut val);
unsafe { sys::cv_dnn_BaseConvolutionLayer_set_padMode_String(self.as_raw_BaseConvolutionLayer(), val.as_ptr() as _) }.into_result()
}
}
pub struct ConcatLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::ConcatLayer {
fn drop(&mut self) {
unsafe { sys::cv_ConcatLayer_delete(self.ptr) };
}
}
impl crate::dnn::ConcatLayer {
#[inline(always)] pub fn as_raw_ConcatLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for ConcatLayer {}
impl crate::dnn::Layer for ConcatLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl ConcatLayer {
pub fn create(axis: i32) -> Result<types::PtrOfConcatLayer> {
unsafe { sys::cv_dnn_ConcatLayer_create_int(axis) }.into_result().map(|ptr| types::PtrOfConcatLayer { ptr })
}
}
pub struct ConvolutionLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::ConvolutionLayer {
fn drop(&mut self) {
unsafe { sys::cv_ConvolutionLayer_delete(self.ptr) };
}
}
impl crate::dnn::ConvolutionLayer {
#[inline(always)] pub fn as_raw_ConvolutionLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for ConvolutionLayer {}
impl crate::dnn::BaseConvolutionLayer for ConvolutionLayer {
#[inline(always)] fn as_raw_BaseConvolutionLayer(&self) -> *mut c_void { self.ptr }
}
impl crate::dnn::Layer for ConvolutionLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl ConvolutionLayer {
pub fn create(kernel: core::Size, stride: core::Size, pad: core::Size, dilation: core::Size) -> Result<types::PtrOfBaseConvolutionLayer> {
unsafe { sys::cv_dnn_ConvolutionLayer_create_Size_Size_Size_Size(kernel, stride, pad, dilation) }.into_result().map(|ptr| types::PtrOfBaseConvolutionLayer { ptr })
}
}
pub struct CropLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::CropLayer {
fn drop(&mut self) {
unsafe { sys::cv_CropLayer_delete(self.ptr) };
}
}
impl crate::dnn::CropLayer {
#[inline(always)] pub fn as_raw_CropLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for CropLayer {}
impl crate::dnn::Layer for CropLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl CropLayer {
pub fn start_axis(&self) -> Result<i32> {
unsafe { sys::cv_dnn_CropLayer_startAxis_const(self.as_raw_CropLayer()) }.into_result()
}
pub fn create(start_axis: i32, offset: &types::VectorOfint) -> Result<types::PtrOfCropLayer> {
unsafe { sys::cv_dnn_CropLayer_create_int_VectorOfint(start_axis, offset.as_raw_VectorOfint()) }.into_result().map(|ptr| types::PtrOfCropLayer { ptr })
}
}
pub struct DeconvolutionLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::DeconvolutionLayer {
fn drop(&mut self) {
unsafe { sys::cv_DeconvolutionLayer_delete(self.ptr) };
}
}
impl crate::dnn::DeconvolutionLayer {
#[inline(always)] pub fn as_raw_DeconvolutionLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for DeconvolutionLayer {}
impl crate::dnn::BaseConvolutionLayer for DeconvolutionLayer {
#[inline(always)] fn as_raw_BaseConvolutionLayer(&self) -> *mut c_void { self.ptr }
}
impl crate::dnn::Layer for DeconvolutionLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl DeconvolutionLayer {
pub fn create(kernel: core::Size, stride: core::Size, pad: core::Size, dilation: core::Size) -> Result<types::PtrOfBaseConvolutionLayer> {
unsafe { sys::cv_dnn_DeconvolutionLayer_create_Size_Size_Size_Size(kernel, stride, pad, dilation) }.into_result().map(|ptr| types::PtrOfBaseConvolutionLayer { ptr })
}
}
pub trait Dict {
#[inline(always)] fn as_raw_Dict(&self) -> *mut c_void;
fn has(&self, key: &str) -> Result<bool> {
string_arg!(key);
unsafe { sys::cv_dnn_Dict_has_const_String(self.as_raw_Dict(), key.as_ptr()) }.into_result()
}
unsafe fn ptr_mut(&mut self, key: &str) -> Result<crate::dnn::DictValue> {
string_arg!(key);
{ sys::cv_dnn_Dict_ptr_String(self.as_raw_Dict(), key.as_ptr()) }.into_result().map(|ptr| crate::dnn::DictValue { ptr })
}
fn get(&self, key: &str) -> Result<crate::dnn::DictValue> {
string_arg!(key);
unsafe { sys::cv_dnn_Dict_get_const_String(self.as_raw_Dict(), key.as_ptr()) }.into_result().map(|ptr| crate::dnn::DictValue { ptr })
}
fn set(&mut self, key: &str, value: &mut crate::dnn::DictValue) -> Result<crate::dnn::DictValue> {
string_arg!(key);
unsafe { sys::cv_dnn_Dict_set_String_DictValue(self.as_raw_Dict(), key.as_ptr(), value.as_raw_DictValue()) }.into_result().map(|ptr| crate::dnn::DictValue { ptr })
}
}
pub struct DictValue {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::DictValue {
fn drop(&mut self) {
unsafe { sys::cv_DictValue_delete(self.ptr) };
}
}
impl crate::dnn::DictValue {
#[inline(always)] pub fn as_raw_DictValue(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for DictValue {}
impl DictValue {
pub fn copy(r: &crate::dnn::DictValue) -> Result<crate::dnn::DictValue> {
unsafe { sys::cv_dnn_DictValue_DictValue_DictValue(r.as_raw_DictValue()) }.into_result().map(|ptr| crate::dnn::DictValue { ptr })
}
pub fn from_i64(i: i64) -> Result<crate::dnn::DictValue> {
unsafe { sys::cv_dnn_DictValue_DictValue_int64(i) }.into_result().map(|ptr| crate::dnn::DictValue { ptr })
}
pub fn from_i32(i: i32) -> Result<crate::dnn::DictValue> {
unsafe { sys::cv_dnn_DictValue_DictValue_int(i) }.into_result().map(|ptr| crate::dnn::DictValue { ptr })
}
pub fn from_u32(p: u32) -> Result<crate::dnn::DictValue> {
unsafe { sys::cv_dnn_DictValue_DictValue_unsigned(p) }.into_result().map(|ptr| crate::dnn::DictValue { ptr })
}
pub fn from_f64(p: f64) -> Result<crate::dnn::DictValue> {
unsafe { sys::cv_dnn_DictValue_DictValue_double(p) }.into_result().map(|ptr| crate::dnn::DictValue { ptr })
}
pub fn from_str(s: &str) -> Result<crate::dnn::DictValue> {
string_arg!(s);
unsafe { sys::cv_dnn_DictValue_DictValue_const_char_X(s.as_ptr()) }.into_result().map(|ptr| crate::dnn::DictValue { ptr })
}
pub fn size(&self) -> Result<i32> {
unsafe { sys::cv_dnn_DictValue_size_const(self.as_raw_DictValue()) }.into_result()
}
pub fn is_int(&self) -> Result<bool> {
unsafe { sys::cv_dnn_DictValue_isInt_const(self.as_raw_DictValue()) }.into_result()
}
pub fn is_string(&self) -> Result<bool> {
unsafe { sys::cv_dnn_DictValue_isString_const(self.as_raw_DictValue()) }.into_result()
}
pub fn is_real(&self) -> Result<bool> {
unsafe { sys::cv_dnn_DictValue_isReal_const(self.as_raw_DictValue()) }.into_result()
}
}
pub struct EltwiseLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::EltwiseLayer {
fn drop(&mut self) {
unsafe { sys::cv_EltwiseLayer_delete(self.ptr) };
}
}
impl crate::dnn::EltwiseLayer {
#[inline(always)] pub fn as_raw_EltwiseLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for EltwiseLayer {}
impl crate::dnn::Layer for EltwiseLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl EltwiseLayer {
}
pub trait Importer {
#[inline(always)] fn as_raw_Importer(&self) -> *mut c_void;
fn populate_net(&mut self, net: &crate::dnn::Net) -> Result<()> {
unsafe { sys::cv_dnn_Importer_populateNet_Net(self.as_raw_Importer(), net.as_raw_Net()) }.into_result()
}
}
pub struct InnerProductLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::InnerProductLayer {
fn drop(&mut self) {
unsafe { sys::cv_InnerProductLayer_delete(self.ptr) };
}
}
impl crate::dnn::InnerProductLayer {
#[inline(always)] pub fn as_raw_InnerProductLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for InnerProductLayer {}
impl crate::dnn::Layer for InnerProductLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl InnerProductLayer {
pub fn axis(&self) -> Result<i32> {
unsafe { sys::cv_dnn_InnerProductLayer_axis_const(self.as_raw_InnerProductLayer()) }.into_result()
}
pub fn create(axis: i32) -> Result<types::PtrOfInnerProductLayer> {
unsafe { sys::cv_dnn_InnerProductLayer_create_int(axis) }.into_result().map(|ptr| types::PtrOfInnerProductLayer { ptr })
}
}
pub struct LRNLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::LRNLayer {
fn drop(&mut self) {
unsafe { sys::cv_LRNLayer_delete(self.ptr) };
}
}
impl crate::dnn::LRNLayer {
#[inline(always)] pub fn as_raw_LRNLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for LRNLayer {}
impl crate::dnn::Layer for LRNLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl LRNLayer {
pub fn _type(&self) -> Result<i32> {
unsafe { sys::cv_dnn_LRNLayer_type_const(self.as_raw_LRNLayer()) }.into_result()
}
pub fn size(&self) -> Result<i32> {
unsafe { sys::cv_dnn_LRNLayer_size_const(self.as_raw_LRNLayer()) }.into_result()
}
pub fn alpha(&self) -> Result<f64> {
unsafe { sys::cv_dnn_LRNLayer_alpha_const(self.as_raw_LRNLayer()) }.into_result()
}
pub fn beta(&self) -> Result<f64> {
unsafe { sys::cv_dnn_LRNLayer_beta_const(self.as_raw_LRNLayer()) }.into_result()
}
pub fn bias(&self) -> Result<f64> {
unsafe { sys::cv_dnn_LRNLayer_bias_const(self.as_raw_LRNLayer()) }.into_result()
}
pub fn norm_by_size(&self) -> Result<bool> {
unsafe { sys::cv_dnn_LRNLayer_normBySize_const(self.as_raw_LRNLayer()) }.into_result()
}
pub fn create(_type: i32, size: i32, alpha: f64, beta: f64, bias: f64, norm_by_size: bool) -> Result<types::PtrOfLRNLayer> {
unsafe { sys::cv_dnn_LRNLayer_create_int_int_double_double_double_bool(_type, size, alpha, beta, bias, norm_by_size) }.into_result().map(|ptr| types::PtrOfLRNLayer { ptr })
}
}
pub trait LSTMLayer: crate::dnn::Layer {
#[inline(always)] fn as_raw_LSTMLayer(&self) -> *mut c_void;
fn set_use_timstamps_dim(&mut self, _use: bool) -> Result<()> {
unsafe { sys::cv_dnn_LSTMLayer_setUseTimstampsDim_bool(self.as_raw_LSTMLayer(), _use) }.into_result()
}
fn set_produce_cell_output(&mut self, produce: bool) -> Result<()> {
unsafe { sys::cv_dnn_LSTMLayer_setProduceCellOutput_bool(self.as_raw_LSTMLayer(), produce) }.into_result()
}
fn input_name_to_index(&mut self, input_name: &str) -> Result<i32> {
string_arg!(mut input_name);
unsafe { sys::cv_dnn_LSTMLayer_inputNameToIndex_String(self.as_raw_LSTMLayer(), input_name.as_ptr() as _) }.into_result()
}
fn output_name_to_index(&mut self, output_name: &str) -> Result<i32> {
string_arg!(mut output_name);
unsafe { sys::cv_dnn_LSTMLayer_outputNameToIndex_String(self.as_raw_LSTMLayer(), output_name.as_ptr() as _) }.into_result()
}
}
impl dyn LSTMLayer + '_ {
pub fn create() -> Result<types::PtrOfLSTMLayer> {
unsafe { sys::cv_dnn_LSTMLayer_create() }.into_result().map(|ptr| types::PtrOfLSTMLayer { ptr })
}
}
pub trait Layer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void;
fn name(&mut self) -> Result<String> {
unsafe { sys::cv_dnn_Layer_name(self.as_raw_Layer()) }.into_result().map(crate::templ::receive_string_mut)
}
fn set_name(&mut self, val: &str) -> Result<()> {
string_arg!(mut val);
unsafe { sys::cv_dnn_Layer_set_name_String(self.as_raw_Layer(), val.as_ptr() as _) }.into_result()
}
fn _type(&mut self) -> Result<String> {
unsafe { sys::cv_dnn_Layer_type(self.as_raw_Layer()) }.into_result().map(crate::templ::receive_string_mut)
}
fn set_type(&mut self, val: &str) -> Result<()> {
string_arg!(mut val);
unsafe { sys::cv_dnn_Layer_set_type_String(self.as_raw_Layer(), val.as_ptr() as _) }.into_result()
}
fn input_name_to_index(&mut self, input_name: &str) -> Result<i32> {
string_arg!(mut input_name);
unsafe { sys::cv_dnn_Layer_inputNameToIndex_String(self.as_raw_Layer(), input_name.as_ptr() as _) }.into_result()
}
fn output_name_to_index(&mut self, output_name: &str) -> Result<i32> {
string_arg!(mut output_name);
unsafe { sys::cv_dnn_Layer_outputNameToIndex_String(self.as_raw_Layer(), output_name.as_ptr() as _) }.into_result()
}
fn set_params_from(&mut self, params: &crate::dnn::LayerParams) -> Result<()> {
unsafe { sys::cv_dnn_Layer_setParamsFrom_LayerParams(self.as_raw_Layer(), params.as_raw_LayerParams()) }.into_result()
}
}
pub struct LayerFactory {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::LayerFactory {
fn drop(&mut self) {
unsafe { sys::cv_LayerFactory_delete(self.ptr) };
}
}
impl crate::dnn::LayerFactory {
#[inline(always)] pub fn as_raw_LayerFactory(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for LayerFactory {}
impl LayerFactory {
pub fn unregister_layer(_type: &str) -> Result<()> {
string_arg!(_type);
unsafe { sys::cv_dnn_LayerFactory_unregisterLayer_String(_type.as_ptr()) }.into_result()
}
pub fn create_layer_instance(_type: &str, params: &mut crate::dnn::LayerParams) -> Result<types::PtrOfLayer> {
string_arg!(_type);
unsafe { sys::cv_dnn_LayerFactory_createLayerInstance_String_LayerParams(_type.as_ptr(), params.as_raw_LayerParams()) }.into_result().map(|ptr| types::PtrOfLayer { ptr })
}
}
pub struct LayerParams {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::LayerParams {
fn drop(&mut self) {
unsafe { sys::cv_LayerParams_delete(self.ptr) };
}
}
impl crate::dnn::LayerParams {
#[inline(always)] pub fn as_raw_LayerParams(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for LayerParams {}
impl crate::dnn::Dict for LayerParams {
#[inline(always)] fn as_raw_Dict(&self) -> *mut c_void { self.ptr }
}
impl LayerParams {
pub fn name(&mut self) -> Result<String> {
unsafe { sys::cv_dnn_LayerParams_name(self.as_raw_LayerParams()) }.into_result().map(crate::templ::receive_string_mut)
}
pub fn set_name(&mut self, val: &str) -> Result<()> {
string_arg!(mut val);
unsafe { sys::cv_dnn_LayerParams_set_name_String(self.as_raw_LayerParams(), val.as_ptr() as _) }.into_result()
}
pub fn _type(&mut self) -> Result<String> {
unsafe { sys::cv_dnn_LayerParams_type(self.as_raw_LayerParams()) }.into_result().map(crate::templ::receive_string_mut)
}
pub fn set_type(&mut self, val: &str) -> Result<()> {
string_arg!(mut val);
unsafe { sys::cv_dnn_LayerParams_set_type_String(self.as_raw_LayerParams(), val.as_ptr() as _) }.into_result()
}
pub fn default() -> Result<crate::dnn::LayerParams> {
unsafe { sys::cv_dnn_LayerParams_LayerParams() }.into_result().map(|ptr| crate::dnn::LayerParams { ptr })
}
}
pub struct MVNLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::MVNLayer {
fn drop(&mut self) {
unsafe { sys::cv_MVNLayer_delete(self.ptr) };
}
}
impl crate::dnn::MVNLayer {
#[inline(always)] pub fn as_raw_MVNLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for MVNLayer {}
impl crate::dnn::Layer for MVNLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl MVNLayer {
pub fn eps(&self) -> Result<f64> {
unsafe { sys::cv_dnn_MVNLayer_eps_const(self.as_raw_MVNLayer()) }.into_result()
}
pub fn norm_variance(&self) -> Result<bool> {
unsafe { sys::cv_dnn_MVNLayer_normVariance_const(self.as_raw_MVNLayer()) }.into_result()
}
pub fn across_channels(&self) -> Result<bool> {
unsafe { sys::cv_dnn_MVNLayer_acrossChannels_const(self.as_raw_MVNLayer()) }.into_result()
}
pub fn create(norm_variance: bool, across_channels: bool, eps: f64) -> Result<types::PtrOfMVNLayer> {
unsafe { sys::cv_dnn_MVNLayer_create_bool_bool_double(norm_variance, across_channels, eps) }.into_result().map(|ptr| types::PtrOfMVNLayer { ptr })
}
}
pub struct Net {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::Net {
fn drop(&mut self) {
unsafe { sys::cv_Net_delete(self.ptr) };
}
}
impl crate::dnn::Net {
#[inline(always)] pub fn as_raw_Net(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for Net {}
impl Net {
pub fn default() -> Result<crate::dnn::Net> {
unsafe { sys::cv_dnn_Net_Net() }.into_result().map(|ptr| crate::dnn::Net { ptr })
}
pub fn empty(&self) -> Result<bool> {
unsafe { sys::cv_dnn_Net_empty_const(self.as_raw_Net()) }.into_result()
}
pub fn add_layer(&mut self, name: &str, _type: &str, params: &mut crate::dnn::LayerParams) -> Result<i32> {
string_arg!(name);
string_arg!(_type);
unsafe { sys::cv_dnn_Net_addLayer_String_String_LayerParams(self.as_raw_Net(), name.as_ptr(), _type.as_ptr(), params.as_raw_LayerParams()) }.into_result()
}
pub fn add_layer_to_prev(&mut self, name: &str, _type: &str, params: &mut crate::dnn::LayerParams) -> Result<i32> {
string_arg!(name);
string_arg!(_type);
unsafe { sys::cv_dnn_Net_addLayerToPrev_String_String_LayerParams(self.as_raw_Net(), name.as_ptr(), _type.as_ptr(), params.as_raw_LayerParams()) }.into_result()
}
pub fn get_layer_id(&mut self, layer: &str) -> Result<i32> {
string_arg!(layer);
unsafe { sys::cv_dnn_Net_getLayerId_String(self.as_raw_Net(), layer.as_ptr()) }.into_result()
}
pub fn get_layer_names(&self) -> Result<types::VectorOfString> {
unsafe { sys::cv_dnn_Net_getLayerNames_const(self.as_raw_Net()) }.into_result().map(|ptr| types::VectorOfString { ptr })
}
pub fn get_layer(&mut self, layer_id: &crate::dnn::DictValue) -> Result<types::PtrOfLayer> {
unsafe { sys::cv_dnn_Net_getLayer_DictValue(self.as_raw_Net(), layer_id.as_raw_DictValue()) }.into_result().map(|ptr| types::PtrOfLayer { ptr })
}
pub fn delete_layer(&mut self, layer: &crate::dnn::DictValue) -> Result<()> {
unsafe { sys::cv_dnn_Net_deleteLayer_DictValue(self.as_raw_Net(), layer.as_raw_DictValue()) }.into_result()
}
pub fn connect_first_second(&mut self, out_pin: &str, inp_pin: &str) -> Result<()> {
string_arg!(mut out_pin);
string_arg!(mut inp_pin);
unsafe { sys::cv_dnn_Net_connect_String_String(self.as_raw_Net(), out_pin.as_ptr() as _, inp_pin.as_ptr() as _) }.into_result()
}
pub fn connect(&mut self, out_layer_id: i32, out_num: i32, inp_layer_id: i32, inp_num: i32) -> Result<()> {
unsafe { sys::cv_dnn_Net_connect_int_int_int_int(self.as_raw_Net(), out_layer_id, out_num, inp_layer_id, inp_num) }.into_result()
}
pub fn set_net_inputs(&mut self, input_blob_names: &types::VectorOfString) -> Result<()> {
unsafe { sys::cv_dnn_Net_setNetInputs_VectorOfString(self.as_raw_Net(), input_blob_names.as_raw_VectorOfString()) }.into_result()
}
pub fn allocate(&mut self) -> Result<()> {
unsafe { sys::cv_dnn_Net_allocate(self.as_raw_Net()) }.into_result()
}
pub fn forward(&mut self, to_layer: &crate::dnn::DictValue) -> Result<()> {
unsafe { sys::cv_dnn_Net_forward_DictValue(self.as_raw_Net(), to_layer.as_raw_DictValue()) }.into_result()
}
pub fn forward_1(&mut self, start_layer: &crate::dnn::DictValue, to_layer: &crate::dnn::DictValue) -> Result<()> {
unsafe { sys::cv_dnn_Net_forward_DictValue_DictValue(self.as_raw_Net(), start_layer.as_raw_DictValue(), to_layer.as_raw_DictValue()) }.into_result()
}
pub fn forward_2(&mut self, start_layers: &types::VectorOfDictValue, to_layers: &types::VectorOfDictValue) -> Result<()> {
unsafe { sys::cv_dnn_Net_forward_VectorOfDictValue_VectorOfDictValue(self.as_raw_Net(), start_layers.as_raw_VectorOfDictValue(), to_layers.as_raw_VectorOfDictValue()) }.into_result()
}
pub fn forward_opt(&mut self, to_layer: &crate::dnn::DictValue) -> Result<()> {
unsafe { sys::cv_dnn_Net_forwardOpt_DictValue(self.as_raw_Net(), to_layer.as_raw_DictValue()) }.into_result()
}
pub fn forward_opt_1(&mut self, to_layers: &types::VectorOfDictValue) -> Result<()> {
unsafe { sys::cv_dnn_Net_forwardOpt_VectorOfDictValue(self.as_raw_Net(), to_layers.as_raw_VectorOfDictValue()) }.into_result()
}
}
pub struct PoolingLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::PoolingLayer {
fn drop(&mut self) {
unsafe { sys::cv_PoolingLayer_delete(self.ptr) };
}
}
impl crate::dnn::PoolingLayer {
#[inline(always)] pub fn as_raw_PoolingLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for PoolingLayer {}
impl crate::dnn::Layer for PoolingLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl PoolingLayer {
pub fn _type(&self) -> Result<i32> {
unsafe { sys::cv_dnn_PoolingLayer_type_const(self.as_raw_PoolingLayer()) }.into_result()
}
pub fn kernel(&self) -> Result<core::Size> {
unsafe { sys::cv_dnn_PoolingLayer_kernel_const(self.as_raw_PoolingLayer()) }.into_result()
}
pub fn stride(&self) -> Result<core::Size> {
unsafe { sys::cv_dnn_PoolingLayer_stride_const(self.as_raw_PoolingLayer()) }.into_result()
}
pub fn pad(&self) -> Result<core::Size> {
unsafe { sys::cv_dnn_PoolingLayer_pad_const(self.as_raw_PoolingLayer()) }.into_result()
}
pub fn global_pooling(&self) -> Result<bool> {
unsafe { sys::cv_dnn_PoolingLayer_globalPooling_const(self.as_raw_PoolingLayer()) }.into_result()
}
pub fn pad_mode(&mut self) -> Result<String> {
unsafe { sys::cv_dnn_PoolingLayer_padMode(self.as_raw_PoolingLayer()) }.into_result().map(crate::templ::receive_string_mut)
}
pub fn set_pad_mode(&mut self, val: &str) -> Result<()> {
string_arg!(mut val);
unsafe { sys::cv_dnn_PoolingLayer_set_padMode_String(self.as_raw_PoolingLayer(), val.as_ptr() as _) }.into_result()
}
pub fn create(_type: i32, kernel: core::Size, stride: core::Size, pad: core::Size, pad_mode: &str) -> Result<types::PtrOfPoolingLayer> {
string_arg!(pad_mode);
unsafe { sys::cv_dnn_PoolingLayer_create_int_Size_Size_Size_String(_type, kernel, stride, pad, pad_mode.as_ptr()) }.into_result().map(|ptr| types::PtrOfPoolingLayer { ptr })
}
pub fn create_global(_type: i32) -> Result<types::PtrOfPoolingLayer> {
unsafe { sys::cv_dnn_PoolingLayer_createGlobal_int(_type) }.into_result().map(|ptr| types::PtrOfPoolingLayer { ptr })
}
}
pub struct PowerLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::PowerLayer {
fn drop(&mut self) {
unsafe { sys::cv_PowerLayer_delete(self.ptr) };
}
}
impl crate::dnn::PowerLayer {
#[inline(always)] pub fn as_raw_PowerLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for PowerLayer {}
impl crate::dnn::Layer for PowerLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl PowerLayer {
pub fn power(&self) -> Result<f64> {
unsafe { sys::cv_dnn_PowerLayer_power_const(self.as_raw_PowerLayer()) }.into_result()
}
pub fn scale(&self) -> Result<f64> {
unsafe { sys::cv_dnn_PowerLayer_scale_const(self.as_raw_PowerLayer()) }.into_result()
}
pub fn shift(&self) -> Result<f64> {
unsafe { sys::cv_dnn_PowerLayer_shift_const(self.as_raw_PowerLayer()) }.into_result()
}
pub fn create(power: f64, scale: f64, shift: f64) -> Result<types::PtrOfPowerLayer> {
unsafe { sys::cv_dnn_PowerLayer_create_double_double_double(power, scale, shift) }.into_result().map(|ptr| types::PtrOfPowerLayer { ptr })
}
}
pub trait RNNLayer: crate::dnn::Layer {
#[inline(always)] fn as_raw_RNNLayer(&self) -> *mut c_void;
fn set_produce_hidden_output(&mut self, produce: bool) -> Result<()> {
unsafe { sys::cv_dnn_RNNLayer_setProduceHiddenOutput_bool(self.as_raw_RNNLayer(), produce) }.into_result()
}
}
impl dyn RNNLayer + '_ {
pub fn create() -> Result<types::PtrOfRNNLayer> {
unsafe { sys::cv_dnn_RNNLayer_create() }.into_result().map(|ptr| types::PtrOfRNNLayer { ptr })
}
}
pub struct ReLULayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::ReLULayer {
fn drop(&mut self) {
unsafe { sys::cv_ReLULayer_delete(self.ptr) };
}
}
impl crate::dnn::ReLULayer {
#[inline(always)] pub fn as_raw_ReLULayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for ReLULayer {}
impl crate::dnn::Layer for ReLULayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl ReLULayer {
pub fn negative_slope(&self) -> Result<f64> {
unsafe { sys::cv_dnn_ReLULayer_negativeSlope_const(self.as_raw_ReLULayer()) }.into_result()
}
pub fn create(negative_slope: f64) -> Result<types::PtrOfReLULayer> {
unsafe { sys::cv_dnn_ReLULayer_create_double(negative_slope) }.into_result().map(|ptr| types::PtrOfReLULayer { ptr })
}
}
pub struct ReshapeLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::ReshapeLayer {
fn drop(&mut self) {
unsafe { sys::cv_ReshapeLayer_delete(self.ptr) };
}
}
impl crate::dnn::ReshapeLayer {
#[inline(always)] pub fn as_raw_ReshapeLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for ReshapeLayer {}
impl crate::dnn::Layer for ReshapeLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl ReshapeLayer {
pub fn new_shape_range(&mut self) -> Result<core::Range> {
unsafe { sys::cv_dnn_ReshapeLayer_newShapeRange(self.as_raw_ReshapeLayer()) }.into_result().map(|ptr| core::Range { ptr })
}
pub fn set_new_shape_range(&mut self, val: core::Range) -> Result<()> {
unsafe { sys::cv_dnn_ReshapeLayer_set_newShapeRange_Range(self.as_raw_ReshapeLayer(), val.as_raw_Range()) }.into_result()
}
}
pub struct SigmoidLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::SigmoidLayer {
fn drop(&mut self) {
unsafe { sys::cv_SigmoidLayer_delete(self.ptr) };
}
}
impl crate::dnn::SigmoidLayer {
#[inline(always)] pub fn as_raw_SigmoidLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for SigmoidLayer {}
impl crate::dnn::Layer for SigmoidLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl SigmoidLayer {
pub fn create() -> Result<types::PtrOfSigmoidLayer> {
unsafe { sys::cv_dnn_SigmoidLayer_create() }.into_result().map(|ptr| types::PtrOfSigmoidLayer { ptr })
}
}
pub struct SliceLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::SliceLayer {
fn drop(&mut self) {
unsafe { sys::cv_SliceLayer_delete(self.ptr) };
}
}
impl crate::dnn::SliceLayer {
#[inline(always)] pub fn as_raw_SliceLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for SliceLayer {}
impl crate::dnn::Layer for SliceLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl SliceLayer {
pub fn axis(&self) -> Result<i32> {
unsafe { sys::cv_dnn_SliceLayer_axis_const(self.as_raw_SliceLayer()) }.into_result()
}
pub fn create(axis: i32) -> Result<types::PtrOfSliceLayer> {
unsafe { sys::cv_dnn_SliceLayer_create_int(axis) }.into_result().map(|ptr| types::PtrOfSliceLayer { ptr })
}
pub fn create_1(axis: i32, slice_indices: &types::VectorOfint) -> Result<types::PtrOfSliceLayer> {
unsafe { sys::cv_dnn_SliceLayer_create_int_VectorOfint(axis, slice_indices.as_raw_VectorOfint()) }.into_result().map(|ptr| types::PtrOfSliceLayer { ptr })
}
}
pub struct SoftmaxLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::SoftmaxLayer {
fn drop(&mut self) {
unsafe { sys::cv_SoftmaxLayer_delete(self.ptr) };
}
}
impl crate::dnn::SoftmaxLayer {
#[inline(always)] pub fn as_raw_SoftmaxLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for SoftmaxLayer {}
impl crate::dnn::Layer for SoftmaxLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl SoftmaxLayer {
pub fn create(axis: i32) -> Result<types::PtrOfSoftmaxLayer> {
unsafe { sys::cv_dnn_SoftmaxLayer_create_int(axis) }.into_result().map(|ptr| types::PtrOfSoftmaxLayer { ptr })
}
}
pub struct SplitLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::SplitLayer {
fn drop(&mut self) {
unsafe { sys::cv_SplitLayer_delete(self.ptr) };
}
}
impl crate::dnn::SplitLayer {
#[inline(always)] pub fn as_raw_SplitLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for SplitLayer {}
impl crate::dnn::Layer for SplitLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl SplitLayer {
pub fn create(outputs_count: i32) -> Result<types::PtrOfSplitLayer> {
unsafe { sys::cv_dnn_SplitLayer_create_int(outputs_count) }.into_result().map(|ptr| types::PtrOfSplitLayer { ptr })
}
}
pub struct TanHLayer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::TanHLayer {
fn drop(&mut self) {
unsafe { sys::cv_TanHLayer_delete(self.ptr) };
}
}
impl crate::dnn::TanHLayer {
#[inline(always)] pub fn as_raw_TanHLayer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for TanHLayer {}
impl crate::dnn::Layer for TanHLayer {
#[inline(always)] fn as_raw_Layer(&self) -> *mut c_void { self.ptr }
}
impl TanHLayer {
pub fn create() -> Result<types::PtrOfTanHLayer> {
unsafe { sys::cv_dnn_TanHLayer_create() }.into_result().map(|ptr| types::PtrOfTanHLayer { ptr })
}
}
pub struct _LayerStaticRegisterer {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::dnn::_LayerStaticRegisterer {
fn drop(&mut self) {
unsafe { sys::cv__LayerStaticRegisterer_delete(self.ptr) };
}
}
impl crate::dnn::_LayerStaticRegisterer {
#[inline(always)] pub fn as_raw__LayerStaticRegisterer(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for _LayerStaticRegisterer {}
impl _LayerStaticRegisterer {
}
pub use crate::manual::dnn::*;