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 ANN_MLP_ANNEAL: i32 = 2;
pub const ANN_MLP_BACKPROP: i32 = 0;
pub const ANN_MLP_GAUSSIAN: i32 = 2;
pub const ANN_MLP_IDENTITY: i32 = 0;
pub const ANN_MLP_LEAKYRELU: i32 = 4;
pub const ANN_MLP_NO_INPUT_SCALE: i32 = 2;
pub const ANN_MLP_NO_OUTPUT_SCALE: i32 = 4;
pub const ANN_MLP_RELU: i32 = 3;
pub const ANN_MLP_RPROP: i32 = 1;
pub const ANN_MLP_SIGMOID_SYM: i32 = 1;
pub const ANN_MLP_UPDATE_WEIGHTS: i32 = 1;
pub const Boost_DISCRETE: i32 = 0;
pub const Boost_GENTLE: i32 = 3;
pub const Boost_LOGIT: i32 = 2;
pub const Boost_REAL: i32 = 1;
pub const COL_SAMPLE: i32 = 1;
pub const DTrees_PREDICT_AUTO: i32 = 0;
pub const DTrees_PREDICT_MASK: i32 = (3<<8);
pub const DTrees_PREDICT_MAX_VOTE: i32 = (2<<8);
pub const DTrees_PREDICT_SUM: i32 = (1<<8);
pub const EM_COV_MAT_DEFAULT: i32 = 1;
pub const EM_COV_MAT_DIAGONAL: i32 = 1;
pub const EM_COV_MAT_GENERIC: i32 = 2;
pub const EM_COV_MAT_SPHERICAL: i32 = 0;
pub const EM_DEFAULT_MAX_ITERS: i32 = 100;
pub const EM_DEFAULT_NCLUSTERS: i32 = 5;
pub const EM_START_AUTO_STEP: i32 = 0;
pub const EM_START_E_STEP: i32 = 1;
pub const EM_START_M_STEP: i32 = 2;
pub const KNearest_BRUTE_FORCE: i32 = 1;
pub const KNearest_KDTREE: i32 = 2;
pub const LogisticRegression_BATCH: i32 = 0;
pub const LogisticRegression_MINI_BATCH: i32 = 1;
pub const LogisticRegression_REG_DISABLE: i32 = -1;
pub const LogisticRegression_REG_L1: i32 = 0;
pub const LogisticRegression_REG_L2: i32 = 1;
pub const ROW_SAMPLE: i32 = 0;
pub const SVMSGD_ASGD: i32 = 1;
pub const SVMSGD_HARD_MARGIN: i32 = 1;
pub const SVMSGD_SGD: i32 = 0;
pub const SVMSGD_SOFT_MARGIN: i32 = 0;
pub const SVM_C: i32 = 0;
pub const SVM_CHI2: i32 = 4;
pub const SVM_COEF: i32 = 4;
pub const SVM_CUSTOM: i32 = -1;
pub const SVM_C_SVC: i32 = 100;
pub const SVM_DEGREE: i32 = 5;
pub const SVM_EPS_SVR: i32 = 103;
pub const SVM_GAMMA: i32 = 1;
pub const SVM_INTER: i32 = 5;
pub const SVM_LINEAR: i32 = 0;
pub const SVM_NU: i32 = 3;
pub const SVM_NU_SVC: i32 = 101;
pub const SVM_NU_SVR: i32 = 104;
pub const SVM_ONE_CLASS: i32 = 102;
pub const SVM_P: i32 = 2;
pub const SVM_POLY: i32 = 1;
pub const SVM_RBF: i32 = 2;
pub const SVM_SIGMOID: i32 = 3;
pub const StatModel_COMPRESSED_INPUT: i32 = 2;
pub const StatModel_PREPROCESSED_INPUT: i32 = 4;
pub const StatModel_RAW_OUTPUT: i32 = 1;
pub const StatModel_UPDATE_MODEL: i32 = 1;
pub const TEST_ERROR: i32 = 0;
pub const TRAIN_ERROR: i32 = 1;
pub const VAR_CATEGORICAL: i32 = 1;
pub const VAR_NUMERICAL: i32 = 0;
pub const VAR_ORDERED: i32 = 0;
pub fn create_concentric_spheres_test_set(nsamples: i32, nfeatures: i32, nclasses: i32, samples: &mut dyn core::ToOutputArray, responses: &mut dyn core::ToOutputArray) -> Result<()> {
output_array_arg!(samples);
output_array_arg!(responses);
unsafe { sys::cv_ml_createConcentricSpheresTestSet_int_int_int__OutputArray__OutputArray(nsamples, nfeatures, nclasses, samples.as_raw__OutputArray(), responses.as_raw__OutputArray()) }.into_result()
}
pub fn rand_mv_normal(mean: &dyn core::ToInputArray, cov: &dyn core::ToInputArray, nsamples: i32, samples: &mut dyn core::ToOutputArray) -> Result<()> {
input_array_arg!(mean);
input_array_arg!(cov);
output_array_arg!(samples);
unsafe { sys::cv_ml_randMVNormal__InputArray__InputArray_int__OutputArray(mean.as_raw__InputArray(), cov.as_raw__InputArray(), nsamples, samples.as_raw__OutputArray()) }.into_result()
}
pub trait ANN_MLP: crate::ml::StatModel {
#[inline(always)] fn as_raw_ANN_MLP(&self) -> *mut c_void;
fn set_train_method(&mut self, method: i32, param1: f64, param2: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setTrainMethod_int_double_double(self.as_raw_ANN_MLP(), method, param1, param2) }.into_result()
}
fn get_train_method(&self) -> Result<i32> {
unsafe { sys::cv_ml_ANN_MLP_getTrainMethod_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_activation_function(&mut self, _type: i32, param1: f64, param2: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setActivationFunction_int_double_double(self.as_raw_ANN_MLP(), _type, param1, param2) }.into_result()
}
fn set_layer_sizes(&mut self, _layer_sizes: &dyn core::ToInputArray) -> Result<()> {
input_array_arg!(_layer_sizes);
unsafe { sys::cv_ml_ANN_MLP_setLayerSizes__InputArray(self.as_raw_ANN_MLP(), _layer_sizes.as_raw__InputArray()) }.into_result()
}
fn get_layer_sizes(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_ANN_MLP_getLayerSizes_const(self.as_raw_ANN_MLP()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_term_criteria(&self) -> Result<core::TermCriteria> {
unsafe { sys::cv_ml_ANN_MLP_getTermCriteria_const(self.as_raw_ANN_MLP()) }.into_result().map(|ptr| core::TermCriteria { ptr })
}
fn set_term_criteria(&mut self, val: &core::TermCriteria) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setTermCriteria_TermCriteria(self.as_raw_ANN_MLP(), val.as_raw_TermCriteria()) }.into_result()
}
fn get_backprop_weight_scale(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_getBackpropWeightScale_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_backprop_weight_scale(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setBackpropWeightScale_double(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_backprop_momentum_scale(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_getBackpropMomentumScale_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_backprop_momentum_scale(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setBackpropMomentumScale_double(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_rprop_dw0(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_getRpropDW0_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_rprop_dw0(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setRpropDW0_double(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_rprop_dw_plus(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_getRpropDWPlus_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_rprop_dw_plus(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setRpropDWPlus_double(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_rprop_dw_minus(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_getRpropDWMinus_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_rprop_dw_minus(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setRpropDWMinus_double(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_rprop_dw_min(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_getRpropDWMin_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_rprop_dw_min(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setRpropDWMin_double(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_rprop_dw_max(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_getRpropDWMax_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_rprop_dw_max(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setRpropDWMax_double(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_anneal_initial_t(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_getAnnealInitialT_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_anneal_initial_t(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setAnnealInitialT_double(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_anneal_final_t(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_getAnnealFinalT_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_anneal_final_t(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setAnnealFinalT_double(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_anneal_cooling_ratio(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_getAnnealCoolingRatio_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_anneal_cooling_ratio(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setAnnealCoolingRatio_double(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_anneal_ite_per_step(&self) -> Result<i32> {
unsafe { sys::cv_ml_ANN_MLP_getAnnealItePerStep_const(self.as_raw_ANN_MLP()) }.into_result()
}
fn set_anneal_ite_per_step(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_setAnnealItePerStep_int(self.as_raw_ANN_MLP(), val) }.into_result()
}
fn get_weights(&self, layer_idx: i32) -> Result<core::Mat> {
unsafe { sys::cv_ml_ANN_MLP_getWeights_const_int(self.as_raw_ANN_MLP(), layer_idx) }.into_result().map(|ptr| core::Mat { ptr })
}
}
impl dyn ANN_MLP + '_ {
pub fn create() -> Result<types::PtrOfANN_MLP> {
unsafe { sys::cv_ml_ANN_MLP_create() }.into_result().map(|ptr| types::PtrOfANN_MLP { ptr })
}
pub fn load(filepath: &str) -> Result<types::PtrOfANN_MLP> {
string_arg!(filepath);
unsafe { sys::cv_ml_ANN_MLP_load_String(filepath.as_ptr()) }.into_result().map(|ptr| types::PtrOfANN_MLP { ptr })
}
}
pub trait ANN_MLP_ANNEAL: crate::ml::ANN_MLP {
#[inline(always)] fn as_raw_ANN_MLP_ANNEAL(&self) -> *mut c_void;
fn get_anneal_initial_t(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_ANNEAL_getAnnealInitialT_const(self.as_raw_ANN_MLP_ANNEAL()) }.into_result()
}
fn set_anneal_initial_t(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_ANNEAL_setAnnealInitialT_double(self.as_raw_ANN_MLP_ANNEAL(), val) }.into_result()
}
fn get_anneal_final_t(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_ANNEAL_getAnnealFinalT_const(self.as_raw_ANN_MLP_ANNEAL()) }.into_result()
}
fn set_anneal_final_t(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_ANNEAL_setAnnealFinalT_double(self.as_raw_ANN_MLP_ANNEAL(), val) }.into_result()
}
fn get_anneal_cooling_ratio(&self) -> Result<f64> {
unsafe { sys::cv_ml_ANN_MLP_ANNEAL_getAnnealCoolingRatio_const(self.as_raw_ANN_MLP_ANNEAL()) }.into_result()
}
fn set_anneal_cooling_ratio(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_ANNEAL_setAnnealCoolingRatio_double(self.as_raw_ANN_MLP_ANNEAL(), val) }.into_result()
}
fn get_anneal_ite_per_step(&self) -> Result<i32> {
unsafe { sys::cv_ml_ANN_MLP_ANNEAL_getAnnealItePerStep_const(self.as_raw_ANN_MLP_ANNEAL()) }.into_result()
}
fn set_anneal_ite_per_step(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_ANN_MLP_ANNEAL_setAnnealItePerStep_int(self.as_raw_ANN_MLP_ANNEAL(), val) }.into_result()
}
}
pub trait Boost: crate::ml::DTrees {
#[inline(always)] fn as_raw_Boost(&self) -> *mut c_void;
fn get_boost_type(&self) -> Result<i32> {
unsafe { sys::cv_ml_Boost_getBoostType_const(self.as_raw_Boost()) }.into_result()
}
fn set_boost_type(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_Boost_setBoostType_int(self.as_raw_Boost(), val) }.into_result()
}
fn get_weak_count(&self) -> Result<i32> {
unsafe { sys::cv_ml_Boost_getWeakCount_const(self.as_raw_Boost()) }.into_result()
}
fn set_weak_count(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_Boost_setWeakCount_int(self.as_raw_Boost(), val) }.into_result()
}
fn get_weight_trim_rate(&self) -> Result<f64> {
unsafe { sys::cv_ml_Boost_getWeightTrimRate_const(self.as_raw_Boost()) }.into_result()
}
fn set_weight_trim_rate(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_Boost_setWeightTrimRate_double(self.as_raw_Boost(), val) }.into_result()
}
}
impl dyn Boost + '_ {
pub fn create() -> Result<types::PtrOfBoost> {
unsafe { sys::cv_ml_Boost_create() }.into_result().map(|ptr| types::PtrOfBoost { ptr })
}
pub fn load(filepath: &str, node_name: &str) -> Result<types::PtrOfBoost> {
string_arg!(filepath);
string_arg!(node_name);
unsafe { sys::cv_ml_Boost_load_String_String(filepath.as_ptr(), node_name.as_ptr()) }.into_result().map(|ptr| types::PtrOfBoost { ptr })
}
}
pub trait DTrees: crate::ml::StatModel {
#[inline(always)] fn as_raw_DTrees(&self) -> *mut c_void;
fn get_max_categories(&self) -> Result<i32> {
unsafe { sys::cv_ml_DTrees_getMaxCategories_const(self.as_raw_DTrees()) }.into_result()
}
fn set_max_categories(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_DTrees_setMaxCategories_int(self.as_raw_DTrees(), val) }.into_result()
}
fn get_max_depth(&self) -> Result<i32> {
unsafe { sys::cv_ml_DTrees_getMaxDepth_const(self.as_raw_DTrees()) }.into_result()
}
fn set_max_depth(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_DTrees_setMaxDepth_int(self.as_raw_DTrees(), val) }.into_result()
}
fn get_min_sample_count(&self) -> Result<i32> {
unsafe { sys::cv_ml_DTrees_getMinSampleCount_const(self.as_raw_DTrees()) }.into_result()
}
fn set_min_sample_count(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_DTrees_setMinSampleCount_int(self.as_raw_DTrees(), val) }.into_result()
}
fn get_cv_folds(&self) -> Result<i32> {
unsafe { sys::cv_ml_DTrees_getCVFolds_const(self.as_raw_DTrees()) }.into_result()
}
fn set_cv_folds(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_DTrees_setCVFolds_int(self.as_raw_DTrees(), val) }.into_result()
}
fn get_use_surrogates(&self) -> Result<bool> {
unsafe { sys::cv_ml_DTrees_getUseSurrogates_const(self.as_raw_DTrees()) }.into_result()
}
fn set_use_surrogates(&mut self, val: bool) -> Result<()> {
unsafe { sys::cv_ml_DTrees_setUseSurrogates_bool(self.as_raw_DTrees(), val) }.into_result()
}
fn get_use1_se_rule(&self) -> Result<bool> {
unsafe { sys::cv_ml_DTrees_getUse1SERule_const(self.as_raw_DTrees()) }.into_result()
}
fn set_use1_se_rule(&mut self, val: bool) -> Result<()> {
unsafe { sys::cv_ml_DTrees_setUse1SERule_bool(self.as_raw_DTrees(), val) }.into_result()
}
fn get_truncate_pruned_tree(&self) -> Result<bool> {
unsafe { sys::cv_ml_DTrees_getTruncatePrunedTree_const(self.as_raw_DTrees()) }.into_result()
}
fn set_truncate_pruned_tree(&mut self, val: bool) -> Result<()> {
unsafe { sys::cv_ml_DTrees_setTruncatePrunedTree_bool(self.as_raw_DTrees(), val) }.into_result()
}
fn get_regression_accuracy(&self) -> Result<f32> {
unsafe { sys::cv_ml_DTrees_getRegressionAccuracy_const(self.as_raw_DTrees()) }.into_result()
}
fn set_regression_accuracy(&mut self, val: f32) -> Result<()> {
unsafe { sys::cv_ml_DTrees_setRegressionAccuracy_float(self.as_raw_DTrees(), val) }.into_result()
}
fn get_priors(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_DTrees_getPriors_const(self.as_raw_DTrees()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn set_priors(&mut self, val: &core::Mat) -> Result<()> {
unsafe { sys::cv_ml_DTrees_setPriors_Mat(self.as_raw_DTrees(), val.as_raw_Mat()) }.into_result()
}
fn get_roots(&self) -> Result<types::VectorOfint> {
unsafe { sys::cv_ml_DTrees_getRoots_const(self.as_raw_DTrees()) }.into_result().map(|ptr| types::VectorOfint { ptr })
}
fn get_nodes(&self) -> Result<types::VectorOfNode> {
unsafe { sys::cv_ml_DTrees_getNodes_const(self.as_raw_DTrees()) }.into_result().map(|ptr| types::VectorOfNode { ptr })
}
fn get_splits(&self) -> Result<types::VectorOfSplit> {
unsafe { sys::cv_ml_DTrees_getSplits_const(self.as_raw_DTrees()) }.into_result().map(|ptr| types::VectorOfSplit { ptr })
}
fn get_subsets(&self) -> Result<types::VectorOfint> {
unsafe { sys::cv_ml_DTrees_getSubsets_const(self.as_raw_DTrees()) }.into_result().map(|ptr| types::VectorOfint { ptr })
}
}
impl dyn DTrees + '_ {
pub fn create() -> Result<types::PtrOfDTrees> {
unsafe { sys::cv_ml_DTrees_create() }.into_result().map(|ptr| types::PtrOfDTrees { ptr })
}
pub fn load(filepath: &str, node_name: &str) -> Result<types::PtrOfDTrees> {
string_arg!(filepath);
string_arg!(node_name);
unsafe { sys::cv_ml_DTrees_load_String_String(filepath.as_ptr(), node_name.as_ptr()) }.into_result().map(|ptr| types::PtrOfDTrees { ptr })
}
}
pub struct DTrees_Node {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::ml::DTrees_Node {
fn drop(&mut self) {
unsafe { sys::cv_DTrees_Node_delete(self.ptr) };
}
}
impl crate::ml::DTrees_Node {
#[inline(always)] pub fn as_raw_DTrees_Node(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for DTrees_Node {}
impl DTrees_Node {
pub fn default() -> Result<crate::ml::DTrees_Node> {
unsafe { sys::cv_ml_DTrees_Node_Node() }.into_result().map(|ptr| crate::ml::DTrees_Node { ptr })
}
}
pub struct DTrees_Split {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::ml::DTrees_Split {
fn drop(&mut self) {
unsafe { sys::cv_DTrees_Split_delete(self.ptr) };
}
}
impl crate::ml::DTrees_Split {
#[inline(always)] pub fn as_raw_DTrees_Split(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for DTrees_Split {}
impl DTrees_Split {
pub fn default() -> Result<crate::ml::DTrees_Split> {
unsafe { sys::cv_ml_DTrees_Split_Split() }.into_result().map(|ptr| crate::ml::DTrees_Split { ptr })
}
}
pub trait EM: crate::ml::StatModel {
#[inline(always)] fn as_raw_EM(&self) -> *mut c_void;
fn get_clusters_number(&self) -> Result<i32> {
unsafe { sys::cv_ml_EM_getClustersNumber_const(self.as_raw_EM()) }.into_result()
}
fn set_clusters_number(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_EM_setClustersNumber_int(self.as_raw_EM(), val) }.into_result()
}
fn get_covariance_matrix_type(&self) -> Result<i32> {
unsafe { sys::cv_ml_EM_getCovarianceMatrixType_const(self.as_raw_EM()) }.into_result()
}
fn set_covariance_matrix_type(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_EM_setCovarianceMatrixType_int(self.as_raw_EM(), val) }.into_result()
}
fn get_term_criteria(&self) -> Result<core::TermCriteria> {
unsafe { sys::cv_ml_EM_getTermCriteria_const(self.as_raw_EM()) }.into_result().map(|ptr| core::TermCriteria { ptr })
}
fn set_term_criteria(&mut self, val: &core::TermCriteria) -> Result<()> {
unsafe { sys::cv_ml_EM_setTermCriteria_TermCriteria(self.as_raw_EM(), val.as_raw_TermCriteria()) }.into_result()
}
fn get_weights(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_EM_getWeights_const(self.as_raw_EM()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_means(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_EM_getMeans_const(self.as_raw_EM()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_covs(&self, covs: &mut types::VectorOfMat) -> Result<()> {
unsafe { sys::cv_ml_EM_getCovs_const_VectorOfMat(self.as_raw_EM(), covs.as_raw_VectorOfMat()) }.into_result()
}
fn predict(&self, samples: &dyn core::ToInputArray, results: &mut dyn core::ToOutputArray, flags: i32) -> Result<f32> {
input_array_arg!(samples);
output_array_arg!(results);
unsafe { sys::cv_ml_EM_predict_const__InputArray__OutputArray_int(self.as_raw_EM(), samples.as_raw__InputArray(), results.as_raw__OutputArray(), flags) }.into_result()
}
fn predict2(&self, sample: &dyn core::ToInputArray, probs: &mut dyn core::ToOutputArray) -> Result<core::Vec2d> {
input_array_arg!(sample);
output_array_arg!(probs);
unsafe { sys::cv_ml_EM_predict2_const__InputArray__OutputArray(self.as_raw_EM(), sample.as_raw__InputArray(), probs.as_raw__OutputArray()) }.into_result()
}
fn train_em(&mut self, samples: &dyn core::ToInputArray, log_likelihoods: &mut dyn core::ToOutputArray, labels: &mut dyn core::ToOutputArray, probs: &mut dyn core::ToOutputArray) -> Result<bool> {
input_array_arg!(samples);
output_array_arg!(log_likelihoods);
output_array_arg!(labels);
output_array_arg!(probs);
unsafe { sys::cv_ml_EM_trainEM__InputArray__OutputArray__OutputArray__OutputArray(self.as_raw_EM(), samples.as_raw__InputArray(), log_likelihoods.as_raw__OutputArray(), labels.as_raw__OutputArray(), probs.as_raw__OutputArray()) }.into_result()
}
fn train_e(&mut self, samples: &dyn core::ToInputArray, means0: &dyn core::ToInputArray, covs0: &dyn core::ToInputArray, weights0: &dyn core::ToInputArray, log_likelihoods: &mut dyn core::ToOutputArray, labels: &mut dyn core::ToOutputArray, probs: &mut dyn core::ToOutputArray) -> Result<bool> {
input_array_arg!(samples);
input_array_arg!(means0);
input_array_arg!(covs0);
input_array_arg!(weights0);
output_array_arg!(log_likelihoods);
output_array_arg!(labels);
output_array_arg!(probs);
unsafe { sys::cv_ml_EM_trainE__InputArray__InputArray__InputArray__InputArray__OutputArray__OutputArray__OutputArray(self.as_raw_EM(), samples.as_raw__InputArray(), means0.as_raw__InputArray(), covs0.as_raw__InputArray(), weights0.as_raw__InputArray(), log_likelihoods.as_raw__OutputArray(), labels.as_raw__OutputArray(), probs.as_raw__OutputArray()) }.into_result()
}
fn train_m(&mut self, samples: &dyn core::ToInputArray, probs0: &dyn core::ToInputArray, log_likelihoods: &mut dyn core::ToOutputArray, labels: &mut dyn core::ToOutputArray, probs: &mut dyn core::ToOutputArray) -> Result<bool> {
input_array_arg!(samples);
input_array_arg!(probs0);
output_array_arg!(log_likelihoods);
output_array_arg!(labels);
output_array_arg!(probs);
unsafe { sys::cv_ml_EM_trainM__InputArray__InputArray__OutputArray__OutputArray__OutputArray(self.as_raw_EM(), samples.as_raw__InputArray(), probs0.as_raw__InputArray(), log_likelihoods.as_raw__OutputArray(), labels.as_raw__OutputArray(), probs.as_raw__OutputArray()) }.into_result()
}
}
impl dyn EM + '_ {
pub fn create() -> Result<types::PtrOfEM> {
unsafe { sys::cv_ml_EM_create() }.into_result().map(|ptr| types::PtrOfEM { ptr })
}
pub fn load(filepath: &str, node_name: &str) -> Result<types::PtrOfEM> {
string_arg!(filepath);
string_arg!(node_name);
unsafe { sys::cv_ml_EM_load_String_String(filepath.as_ptr(), node_name.as_ptr()) }.into_result().map(|ptr| types::PtrOfEM { ptr })
}
}
pub trait KNearest: crate::ml::StatModel {
#[inline(always)] fn as_raw_KNearest(&self) -> *mut c_void;
fn get_default_k(&self) -> Result<i32> {
unsafe { sys::cv_ml_KNearest_getDefaultK_const(self.as_raw_KNearest()) }.into_result()
}
fn set_default_k(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_KNearest_setDefaultK_int(self.as_raw_KNearest(), val) }.into_result()
}
fn get_is_classifier(&self) -> Result<bool> {
unsafe { sys::cv_ml_KNearest_getIsClassifier_const(self.as_raw_KNearest()) }.into_result()
}
fn set_is_classifier(&mut self, val: bool) -> Result<()> {
unsafe { sys::cv_ml_KNearest_setIsClassifier_bool(self.as_raw_KNearest(), val) }.into_result()
}
fn get_emax(&self) -> Result<i32> {
unsafe { sys::cv_ml_KNearest_getEmax_const(self.as_raw_KNearest()) }.into_result()
}
fn set_emax(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_KNearest_setEmax_int(self.as_raw_KNearest(), val) }.into_result()
}
fn get_algorithm_type(&self) -> Result<i32> {
unsafe { sys::cv_ml_KNearest_getAlgorithmType_const(self.as_raw_KNearest()) }.into_result()
}
fn set_algorithm_type(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_KNearest_setAlgorithmType_int(self.as_raw_KNearest(), val) }.into_result()
}
fn find_nearest(&self, samples: &dyn core::ToInputArray, k: i32, results: &mut dyn core::ToOutputArray, neighbor_responses: &mut dyn core::ToOutputArray, dist: &mut dyn core::ToOutputArray) -> Result<f32> {
input_array_arg!(samples);
output_array_arg!(results);
output_array_arg!(neighbor_responses);
output_array_arg!(dist);
unsafe { sys::cv_ml_KNearest_findNearest_const__InputArray_int__OutputArray__OutputArray__OutputArray(self.as_raw_KNearest(), samples.as_raw__InputArray(), k, results.as_raw__OutputArray(), neighbor_responses.as_raw__OutputArray(), dist.as_raw__OutputArray()) }.into_result()
}
}
impl dyn KNearest + '_ {
pub fn create() -> Result<types::PtrOfKNearest> {
unsafe { sys::cv_ml_KNearest_create() }.into_result().map(|ptr| types::PtrOfKNearest { ptr })
}
pub fn load(filepath: &str) -> Result<types::PtrOfKNearest> {
string_arg!(filepath);
unsafe { sys::cv_ml_KNearest_load_String(filepath.as_ptr()) }.into_result().map(|ptr| types::PtrOfKNearest { ptr })
}
}
pub trait LogisticRegression: crate::ml::StatModel {
#[inline(always)] fn as_raw_LogisticRegression(&self) -> *mut c_void;
fn get_learning_rate(&self) -> Result<f64> {
unsafe { sys::cv_ml_LogisticRegression_getLearningRate_const(self.as_raw_LogisticRegression()) }.into_result()
}
fn set_learning_rate(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_LogisticRegression_setLearningRate_double(self.as_raw_LogisticRegression(), val) }.into_result()
}
fn get_iterations(&self) -> Result<i32> {
unsafe { sys::cv_ml_LogisticRegression_getIterations_const(self.as_raw_LogisticRegression()) }.into_result()
}
fn set_iterations(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_LogisticRegression_setIterations_int(self.as_raw_LogisticRegression(), val) }.into_result()
}
fn get_regularization(&self) -> Result<i32> {
unsafe { sys::cv_ml_LogisticRegression_getRegularization_const(self.as_raw_LogisticRegression()) }.into_result()
}
fn set_regularization(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_LogisticRegression_setRegularization_int(self.as_raw_LogisticRegression(), val) }.into_result()
}
fn get_train_method(&self) -> Result<i32> {
unsafe { sys::cv_ml_LogisticRegression_getTrainMethod_const(self.as_raw_LogisticRegression()) }.into_result()
}
fn set_train_method(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_LogisticRegression_setTrainMethod_int(self.as_raw_LogisticRegression(), val) }.into_result()
}
fn get_mini_batch_size(&self) -> Result<i32> {
unsafe { sys::cv_ml_LogisticRegression_getMiniBatchSize_const(self.as_raw_LogisticRegression()) }.into_result()
}
fn set_mini_batch_size(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_LogisticRegression_setMiniBatchSize_int(self.as_raw_LogisticRegression(), val) }.into_result()
}
fn get_term_criteria(&self) -> Result<core::TermCriteria> {
unsafe { sys::cv_ml_LogisticRegression_getTermCriteria_const(self.as_raw_LogisticRegression()) }.into_result().map(|ptr| core::TermCriteria { ptr })
}
fn set_term_criteria(&mut self, val: &core::TermCriteria) -> Result<()> {
unsafe { sys::cv_ml_LogisticRegression_setTermCriteria_TermCriteria(self.as_raw_LogisticRegression(), val.as_raw_TermCriteria()) }.into_result()
}
fn predict(&self, samples: &dyn core::ToInputArray, results: &mut dyn core::ToOutputArray, flags: i32) -> Result<f32> {
input_array_arg!(samples);
output_array_arg!(results);
unsafe { sys::cv_ml_LogisticRegression_predict_const__InputArray__OutputArray_int(self.as_raw_LogisticRegression(), samples.as_raw__InputArray(), results.as_raw__OutputArray(), flags) }.into_result()
}
fn get_learnt_thetas(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_LogisticRegression_get_learnt_thetas_const(self.as_raw_LogisticRegression()) }.into_result().map(|ptr| core::Mat { ptr })
}
}
impl dyn LogisticRegression + '_ {
pub fn create() -> Result<types::PtrOfLogisticRegression> {
unsafe { sys::cv_ml_LogisticRegression_create() }.into_result().map(|ptr| types::PtrOfLogisticRegression { ptr })
}
pub fn load(filepath: &str, node_name: &str) -> Result<types::PtrOfLogisticRegression> {
string_arg!(filepath);
string_arg!(node_name);
unsafe { sys::cv_ml_LogisticRegression_load_String_String(filepath.as_ptr(), node_name.as_ptr()) }.into_result().map(|ptr| types::PtrOfLogisticRegression { ptr })
}
}
pub trait NormalBayesClassifier: crate::ml::StatModel {
#[inline(always)] fn as_raw_NormalBayesClassifier(&self) -> *mut c_void;
fn predict_prob(&self, inputs: &dyn core::ToInputArray, outputs: &mut dyn core::ToOutputArray, output_probs: &mut dyn core::ToOutputArray, flags: i32) -> Result<f32> {
input_array_arg!(inputs);
output_array_arg!(outputs);
output_array_arg!(output_probs);
unsafe { sys::cv_ml_NormalBayesClassifier_predictProb_const__InputArray__OutputArray__OutputArray_int(self.as_raw_NormalBayesClassifier(), inputs.as_raw__InputArray(), outputs.as_raw__OutputArray(), output_probs.as_raw__OutputArray(), flags) }.into_result()
}
}
impl dyn NormalBayesClassifier + '_ {
pub fn create() -> Result<types::PtrOfNormalBayesClassifier> {
unsafe { sys::cv_ml_NormalBayesClassifier_create() }.into_result().map(|ptr| types::PtrOfNormalBayesClassifier { ptr })
}
pub fn load(filepath: &str, node_name: &str) -> Result<types::PtrOfNormalBayesClassifier> {
string_arg!(filepath);
string_arg!(node_name);
unsafe { sys::cv_ml_NormalBayesClassifier_load_String_String(filepath.as_ptr(), node_name.as_ptr()) }.into_result().map(|ptr| types::PtrOfNormalBayesClassifier { ptr })
}
}
pub struct ParamGrid {
#[doc(hidden)] pub(crate) ptr: *mut c_void
}
impl Drop for crate::ml::ParamGrid {
fn drop(&mut self) {
unsafe { sys::cv_ParamGrid_delete(self.ptr) };
}
}
impl crate::ml::ParamGrid {
#[inline(always)] pub fn as_raw_ParamGrid(&self) -> *mut c_void { self.ptr }
pub unsafe fn from_raw_ptr(ptr: *mut c_void) -> Self {
Self { ptr }
}
}
unsafe impl Send for ParamGrid {}
impl ParamGrid {
pub fn min_val(&self) -> Result<f64> {
unsafe { sys::cv_ml_ParamGrid_minVal_const(self.as_raw_ParamGrid()) }.into_result()
}
pub fn max_val(&self) -> Result<f64> {
unsafe { sys::cv_ml_ParamGrid_maxVal_const(self.as_raw_ParamGrid()) }.into_result()
}
pub fn log_step(&self) -> Result<f64> {
unsafe { sys::cv_ml_ParamGrid_logStep_const(self.as_raw_ParamGrid()) }.into_result()
}
pub fn default() -> Result<crate::ml::ParamGrid> {
unsafe { sys::cv_ml_ParamGrid_ParamGrid() }.into_result().map(|ptr| crate::ml::ParamGrid { ptr })
}
pub fn for_range(_min_val: f64, _max_val: f64, _log_step: f64) -> Result<crate::ml::ParamGrid> {
unsafe { sys::cv_ml_ParamGrid_ParamGrid_double_double_double(_min_val, _max_val, _log_step) }.into_result().map(|ptr| crate::ml::ParamGrid { ptr })
}
pub fn create(min_val: f64, max_val: f64, logstep: f64) -> Result<types::PtrOfParamGrid> {
unsafe { sys::cv_ml_ParamGrid_create_double_double_double(min_val, max_val, logstep) }.into_result().map(|ptr| types::PtrOfParamGrid { ptr })
}
}
pub trait RTrees: crate::ml::DTrees {
#[inline(always)] fn as_raw_RTrees(&self) -> *mut c_void;
fn get_calculate_var_importance(&self) -> Result<bool> {
unsafe { sys::cv_ml_RTrees_getCalculateVarImportance_const(self.as_raw_RTrees()) }.into_result()
}
fn set_calculate_var_importance(&mut self, val: bool) -> Result<()> {
unsafe { sys::cv_ml_RTrees_setCalculateVarImportance_bool(self.as_raw_RTrees(), val) }.into_result()
}
fn get_active_var_count(&self) -> Result<i32> {
unsafe { sys::cv_ml_RTrees_getActiveVarCount_const(self.as_raw_RTrees()) }.into_result()
}
fn set_active_var_count(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_RTrees_setActiveVarCount_int(self.as_raw_RTrees(), val) }.into_result()
}
fn get_term_criteria(&self) -> Result<core::TermCriteria> {
unsafe { sys::cv_ml_RTrees_getTermCriteria_const(self.as_raw_RTrees()) }.into_result().map(|ptr| core::TermCriteria { ptr })
}
fn set_term_criteria(&mut self, val: &core::TermCriteria) -> Result<()> {
unsafe { sys::cv_ml_RTrees_setTermCriteria_TermCriteria(self.as_raw_RTrees(), val.as_raw_TermCriteria()) }.into_result()
}
fn get_var_importance(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_RTrees_getVarImportance_const(self.as_raw_RTrees()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_votes(&self, samples: &dyn core::ToInputArray, results: &mut dyn core::ToOutputArray, flags: i32) -> Result<()> {
input_array_arg!(samples);
output_array_arg!(results);
unsafe { sys::cv_ml_RTrees_getVotes_const__InputArray__OutputArray_int(self.as_raw_RTrees(), samples.as_raw__InputArray(), results.as_raw__OutputArray(), flags) }.into_result()
}
}
impl dyn RTrees + '_ {
pub fn create() -> Result<types::PtrOfRTrees> {
unsafe { sys::cv_ml_RTrees_create() }.into_result().map(|ptr| types::PtrOfRTrees { ptr })
}
pub fn load(filepath: &str, node_name: &str) -> Result<types::PtrOfRTrees> {
string_arg!(filepath);
string_arg!(node_name);
unsafe { sys::cv_ml_RTrees_load_String_String(filepath.as_ptr(), node_name.as_ptr()) }.into_result().map(|ptr| types::PtrOfRTrees { ptr })
}
}
pub trait SVM: crate::ml::StatModel {
#[inline(always)] fn as_raw_SVM(&self) -> *mut c_void;
fn get_type(&self) -> Result<i32> {
unsafe { sys::cv_ml_SVM_getType_const(self.as_raw_SVM()) }.into_result()
}
fn set_type(&mut self, val: i32) -> Result<()> {
unsafe { sys::cv_ml_SVM_setType_int(self.as_raw_SVM(), val) }.into_result()
}
fn get_gamma(&self) -> Result<f64> {
unsafe { sys::cv_ml_SVM_getGamma_const(self.as_raw_SVM()) }.into_result()
}
fn set_gamma(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_SVM_setGamma_double(self.as_raw_SVM(), val) }.into_result()
}
fn get_coef0(&self) -> Result<f64> {
unsafe { sys::cv_ml_SVM_getCoef0_const(self.as_raw_SVM()) }.into_result()
}
fn set_coef0(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_SVM_setCoef0_double(self.as_raw_SVM(), val) }.into_result()
}
fn get_degree(&self) -> Result<f64> {
unsafe { sys::cv_ml_SVM_getDegree_const(self.as_raw_SVM()) }.into_result()
}
fn set_degree(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_SVM_setDegree_double(self.as_raw_SVM(), val) }.into_result()
}
fn get_c(&self) -> Result<f64> {
unsafe { sys::cv_ml_SVM_getC_const(self.as_raw_SVM()) }.into_result()
}
fn set_c(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_SVM_setC_double(self.as_raw_SVM(), val) }.into_result()
}
fn get_nu(&self) -> Result<f64> {
unsafe { sys::cv_ml_SVM_getNu_const(self.as_raw_SVM()) }.into_result()
}
fn set_nu(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_SVM_setNu_double(self.as_raw_SVM(), val) }.into_result()
}
fn get_p(&self) -> Result<f64> {
unsafe { sys::cv_ml_SVM_getP_const(self.as_raw_SVM()) }.into_result()
}
fn set_p(&mut self, val: f64) -> Result<()> {
unsafe { sys::cv_ml_SVM_setP_double(self.as_raw_SVM(), val) }.into_result()
}
fn get_class_weights(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_SVM_getClassWeights_const(self.as_raw_SVM()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn set_class_weights(&mut self, val: &core::Mat) -> Result<()> {
unsafe { sys::cv_ml_SVM_setClassWeights_Mat(self.as_raw_SVM(), val.as_raw_Mat()) }.into_result()
}
fn get_term_criteria(&self) -> Result<core::TermCriteria> {
unsafe { sys::cv_ml_SVM_getTermCriteria_const(self.as_raw_SVM()) }.into_result().map(|ptr| core::TermCriteria { ptr })
}
fn set_term_criteria(&mut self, val: &core::TermCriteria) -> Result<()> {
unsafe { sys::cv_ml_SVM_setTermCriteria_TermCriteria(self.as_raw_SVM(), val.as_raw_TermCriteria()) }.into_result()
}
fn get_kernel_type(&self) -> Result<i32> {
unsafe { sys::cv_ml_SVM_getKernelType_const(self.as_raw_SVM()) }.into_result()
}
fn set_kernel(&mut self, kernel_type: i32) -> Result<()> {
unsafe { sys::cv_ml_SVM_setKernel_int(self.as_raw_SVM(), kernel_type) }.into_result()
}
fn set_custom_kernel(&mut self, _kernel: &types::PtrOfKernel) -> Result<()> {
unsafe { sys::cv_ml_SVM_setCustomKernel_PtrOfKernel(self.as_raw_SVM(), _kernel.as_raw_PtrOfKernel()) }.into_result()
}
fn train_auto_with_data(&mut self, data: &types::PtrOfTrainData, k_fold: i32, cgrid: &crate::ml::ParamGrid, gamma_grid: &crate::ml::ParamGrid, p_grid: &crate::ml::ParamGrid, nu_grid: &crate::ml::ParamGrid, coeff_grid: &crate::ml::ParamGrid, degree_grid: &crate::ml::ParamGrid, balanced: bool) -> Result<bool> {
unsafe { sys::cv_ml_SVM_trainAuto_PtrOfTrainData_int_ParamGrid_ParamGrid_ParamGrid_ParamGrid_ParamGrid_ParamGrid_bool(self.as_raw_SVM(), data.as_raw_PtrOfTrainData(), k_fold, cgrid.as_raw_ParamGrid(), gamma_grid.as_raw_ParamGrid(), p_grid.as_raw_ParamGrid(), nu_grid.as_raw_ParamGrid(), coeff_grid.as_raw_ParamGrid(), degree_grid.as_raw_ParamGrid(), balanced) }.into_result()
}
fn train_auto(&mut self, samples: &dyn core::ToInputArray, layout: i32, responses: &dyn core::ToInputArray, k_fold: i32, cgrid: &types::PtrOfParamGrid, gamma_grid: &types::PtrOfParamGrid, p_grid: &types::PtrOfParamGrid, nu_grid: &types::PtrOfParamGrid, coeff_grid: &types::PtrOfParamGrid, degree_grid: &types::PtrOfParamGrid, balanced: bool) -> Result<bool> {
input_array_arg!(samples);
input_array_arg!(responses);
unsafe { sys::cv_ml_SVM_trainAuto__InputArray_int__InputArray_int_PtrOfParamGrid_PtrOfParamGrid_PtrOfParamGrid_PtrOfParamGrid_PtrOfParamGrid_PtrOfParamGrid_bool(self.as_raw_SVM(), samples.as_raw__InputArray(), layout, responses.as_raw__InputArray(), k_fold, cgrid.as_raw_PtrOfParamGrid(), gamma_grid.as_raw_PtrOfParamGrid(), p_grid.as_raw_PtrOfParamGrid(), nu_grid.as_raw_PtrOfParamGrid(), coeff_grid.as_raw_PtrOfParamGrid(), degree_grid.as_raw_PtrOfParamGrid(), balanced) }.into_result()
}
fn get_support_vectors(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_SVM_getSupportVectors_const(self.as_raw_SVM()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_uncompressed_support_vectors(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_SVM_getUncompressedSupportVectors_const(self.as_raw_SVM()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_decision_function(&self, i: i32, alpha: &mut dyn core::ToOutputArray, svidx: &mut dyn core::ToOutputArray) -> Result<f64> {
output_array_arg!(alpha);
output_array_arg!(svidx);
unsafe { sys::cv_ml_SVM_getDecisionFunction_const_int__OutputArray__OutputArray(self.as_raw_SVM(), i, alpha.as_raw__OutputArray(), svidx.as_raw__OutputArray()) }.into_result()
}
}
impl dyn SVM + '_ {
pub fn get_default_grid(param_id: i32) -> Result<crate::ml::ParamGrid> {
unsafe { sys::cv_ml_SVM_getDefaultGrid_int(param_id) }.into_result().map(|ptr| crate::ml::ParamGrid { ptr })
}
pub fn get_default_grid_ptr(param_id: i32) -> Result<types::PtrOfParamGrid> {
unsafe { sys::cv_ml_SVM_getDefaultGridPtr_int(param_id) }.into_result().map(|ptr| types::PtrOfParamGrid { ptr })
}
pub fn create() -> Result<types::PtrOfSVM> {
unsafe { sys::cv_ml_SVM_create() }.into_result().map(|ptr| types::PtrOfSVM { ptr })
}
pub fn load(filepath: &str) -> Result<types::PtrOfSVM> {
string_arg!(filepath);
unsafe { sys::cv_ml_SVM_load_String(filepath.as_ptr()) }.into_result().map(|ptr| types::PtrOfSVM { ptr })
}
}
pub trait SVM_Kernel: core::Algorithm {
#[inline(always)] fn as_raw_SVM_Kernel(&self) -> *mut c_void;
fn get_type(&self) -> Result<i32> {
unsafe { sys::cv_ml_SVM_Kernel_getType_const(self.as_raw_SVM_Kernel()) }.into_result()
}
fn calc(&mut self, vcount: i32, n: i32, vecs: &f32, another: &f32, results: &mut f32) -> Result<()> {
unsafe { sys::cv_ml_SVM_Kernel_calc_int_int_const_float_X_const_float_X_float_X(self.as_raw_SVM_Kernel(), vcount, n, vecs, another, results) }.into_result()
}
}
pub trait SVMSGD: crate::ml::StatModel {
#[inline(always)] fn as_raw_SVMSGD(&self) -> *mut c_void;
fn get_weights(&mut self) -> Result<core::Mat> {
unsafe { sys::cv_ml_SVMSGD_getWeights(self.as_raw_SVMSGD()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_shift(&mut self) -> Result<f32> {
unsafe { sys::cv_ml_SVMSGD_getShift(self.as_raw_SVMSGD()) }.into_result()
}
fn set_optimal_parameters(&mut self, svmsgd_type: i32, margin_type: i32) -> Result<()> {
unsafe { sys::cv_ml_SVMSGD_setOptimalParameters_int_int(self.as_raw_SVMSGD(), svmsgd_type, margin_type) }.into_result()
}
fn get_svmsgd_type(&self) -> Result<i32> {
unsafe { sys::cv_ml_SVMSGD_getSvmsgdType_const(self.as_raw_SVMSGD()) }.into_result()
}
fn set_svmsgd_type(&mut self, svmsgd_type: i32) -> Result<()> {
unsafe { sys::cv_ml_SVMSGD_setSvmsgdType_int(self.as_raw_SVMSGD(), svmsgd_type) }.into_result()
}
fn get_margin_type(&self) -> Result<i32> {
unsafe { sys::cv_ml_SVMSGD_getMarginType_const(self.as_raw_SVMSGD()) }.into_result()
}
fn set_margin_type(&mut self, margin_type: i32) -> Result<()> {
unsafe { sys::cv_ml_SVMSGD_setMarginType_int(self.as_raw_SVMSGD(), margin_type) }.into_result()
}
fn get_margin_regularization(&self) -> Result<f32> {
unsafe { sys::cv_ml_SVMSGD_getMarginRegularization_const(self.as_raw_SVMSGD()) }.into_result()
}
fn set_margin_regularization(&mut self, margin_regularization: f32) -> Result<()> {
unsafe { sys::cv_ml_SVMSGD_setMarginRegularization_float(self.as_raw_SVMSGD(), margin_regularization) }.into_result()
}
fn get_initial_step_size(&self) -> Result<f32> {
unsafe { sys::cv_ml_SVMSGD_getInitialStepSize_const(self.as_raw_SVMSGD()) }.into_result()
}
fn set_initial_step_size(&mut self, initial_step_size: f32) -> Result<()> {
unsafe { sys::cv_ml_SVMSGD_setInitialStepSize_float(self.as_raw_SVMSGD(), initial_step_size) }.into_result()
}
fn get_step_decreasing_power(&self) -> Result<f32> {
unsafe { sys::cv_ml_SVMSGD_getStepDecreasingPower_const(self.as_raw_SVMSGD()) }.into_result()
}
fn set_step_decreasing_power(&mut self, step_decreasing_power: f32) -> Result<()> {
unsafe { sys::cv_ml_SVMSGD_setStepDecreasingPower_float(self.as_raw_SVMSGD(), step_decreasing_power) }.into_result()
}
fn get_term_criteria(&self) -> Result<core::TermCriteria> {
unsafe { sys::cv_ml_SVMSGD_getTermCriteria_const(self.as_raw_SVMSGD()) }.into_result().map(|ptr| core::TermCriteria { ptr })
}
fn set_term_criteria(&mut self, val: &core::TermCriteria) -> Result<()> {
unsafe { sys::cv_ml_SVMSGD_setTermCriteria_TermCriteria(self.as_raw_SVMSGD(), val.as_raw_TermCriteria()) }.into_result()
}
}
impl dyn SVMSGD + '_ {
pub fn create() -> Result<types::PtrOfSVMSGD> {
unsafe { sys::cv_ml_SVMSGD_create() }.into_result().map(|ptr| types::PtrOfSVMSGD { ptr })
}
pub fn load(filepath: &str, node_name: &str) -> Result<types::PtrOfSVMSGD> {
string_arg!(filepath);
string_arg!(node_name);
unsafe { sys::cv_ml_SVMSGD_load_String_String(filepath.as_ptr(), node_name.as_ptr()) }.into_result().map(|ptr| types::PtrOfSVMSGD { ptr })
}
}
pub trait StatModel: core::Algorithm {
#[inline(always)] fn as_raw_StatModel(&self) -> *mut c_void;
fn get_var_count(&self) -> Result<i32> {
unsafe { sys::cv_ml_StatModel_getVarCount_const(self.as_raw_StatModel()) }.into_result()
}
fn empty(&self) -> Result<bool> {
unsafe { sys::cv_ml_StatModel_empty_const(self.as_raw_StatModel()) }.into_result()
}
fn is_trained(&self) -> Result<bool> {
unsafe { sys::cv_ml_StatModel_isTrained_const(self.as_raw_StatModel()) }.into_result()
}
fn is_classifier(&self) -> Result<bool> {
unsafe { sys::cv_ml_StatModel_isClassifier_const(self.as_raw_StatModel()) }.into_result()
}
fn train_with_data(&mut self, train_data: &types::PtrOfTrainData, flags: i32) -> Result<bool> {
unsafe { sys::cv_ml_StatModel_train_PtrOfTrainData_int(self.as_raw_StatModel(), train_data.as_raw_PtrOfTrainData(), flags) }.into_result()
}
fn train(&mut self, samples: &dyn core::ToInputArray, layout: i32, responses: &dyn core::ToInputArray) -> Result<bool> {
input_array_arg!(samples);
input_array_arg!(responses);
unsafe { sys::cv_ml_StatModel_train__InputArray_int__InputArray(self.as_raw_StatModel(), samples.as_raw__InputArray(), layout, responses.as_raw__InputArray()) }.into_result()
}
fn calc_error(&self, data: &types::PtrOfTrainData, test: bool, resp: &mut dyn core::ToOutputArray) -> Result<f32> {
output_array_arg!(resp);
unsafe { sys::cv_ml_StatModel_calcError_const_PtrOfTrainData_bool__OutputArray(self.as_raw_StatModel(), data.as_raw_PtrOfTrainData(), test, resp.as_raw__OutputArray()) }.into_result()
}
fn predict(&self, samples: &dyn core::ToInputArray, results: &mut dyn core::ToOutputArray, flags: i32) -> Result<f32> {
input_array_arg!(samples);
output_array_arg!(results);
unsafe { sys::cv_ml_StatModel_predict_const__InputArray__OutputArray_int(self.as_raw_StatModel(), samples.as_raw__InputArray(), results.as_raw__OutputArray(), flags) }.into_result()
}
}
pub trait TrainData {
#[inline(always)] fn as_raw_TrainData(&self) -> *mut c_void;
fn missing_value(&mut self) -> Result<f32> {
unsafe { sys::cv_ml_TrainData_missingValue(self.as_raw_TrainData()) }.into_result()
}
fn get_layout(&self) -> Result<i32> {
unsafe { sys::cv_ml_TrainData_getLayout_const(self.as_raw_TrainData()) }.into_result()
}
fn get_n_train_samples(&self) -> Result<i32> {
unsafe { sys::cv_ml_TrainData_getNTrainSamples_const(self.as_raw_TrainData()) }.into_result()
}
fn get_n_test_samples(&self) -> Result<i32> {
unsafe { sys::cv_ml_TrainData_getNTestSamples_const(self.as_raw_TrainData()) }.into_result()
}
fn get_n_samples(&self) -> Result<i32> {
unsafe { sys::cv_ml_TrainData_getNSamples_const(self.as_raw_TrainData()) }.into_result()
}
fn get_n_vars(&self) -> Result<i32> {
unsafe { sys::cv_ml_TrainData_getNVars_const(self.as_raw_TrainData()) }.into_result()
}
fn get_n_all_vars(&self) -> Result<i32> {
unsafe { sys::cv_ml_TrainData_getNAllVars_const(self.as_raw_TrainData()) }.into_result()
}
fn get_sample(&self, var_idx: &dyn core::ToInputArray, sidx: i32, buf: &mut f32) -> Result<()> {
input_array_arg!(var_idx);
unsafe { sys::cv_ml_TrainData_getSample_const__InputArray_int_float_X(self.as_raw_TrainData(), var_idx.as_raw__InputArray(), sidx, buf) }.into_result()
}
fn get_samples(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getSamples_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_missing(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getMissing_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_train_samples(&self, layout: i32, compress_samples: bool, compress_vars: bool) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getTrainSamples_const_int_bool_bool(self.as_raw_TrainData(), layout, compress_samples, compress_vars) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_train_responses(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getTrainResponses_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_train_norm_cat_responses(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getTrainNormCatResponses_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_test_responses(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getTestResponses_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_test_norm_cat_responses(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getTestNormCatResponses_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_responses(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getResponses_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_norm_cat_responses(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getNormCatResponses_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_sample_weights(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getSampleWeights_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_train_sample_weights(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getTrainSampleWeights_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_test_sample_weights(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getTestSampleWeights_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_var_idx(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getVarIdx_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_var_type(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getVarType_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_var_symbol_flags(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getVarSymbolFlags_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_response_type(&self) -> Result<i32> {
unsafe { sys::cv_ml_TrainData_getResponseType_const(self.as_raw_TrainData()) }.into_result()
}
fn get_train_sample_idx(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getTrainSampleIdx_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_test_sample_idx(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getTestSampleIdx_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_values(&self, vi: i32, sidx: &dyn core::ToInputArray, values: &mut f32) -> Result<()> {
input_array_arg!(sidx);
unsafe { sys::cv_ml_TrainData_getValues_const_int__InputArray_float_X(self.as_raw_TrainData(), vi, sidx.as_raw__InputArray(), values) }.into_result()
}
fn get_norm_cat_values(&self, vi: i32, sidx: &dyn core::ToInputArray, values: &mut i32) -> Result<()> {
input_array_arg!(sidx);
unsafe { sys::cv_ml_TrainData_getNormCatValues_const_int__InputArray_int_X(self.as_raw_TrainData(), vi, sidx.as_raw__InputArray(), values) }.into_result()
}
fn get_default_subst_values(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getDefaultSubstValues_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_cat_count(&self, vi: i32) -> Result<i32> {
unsafe { sys::cv_ml_TrainData_getCatCount_const_int(self.as_raw_TrainData(), vi) }.into_result()
}
fn get_class_labels(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getClassLabels_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_cat_ofs(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getCatOfs_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_cat_map(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getCatMap_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn set_train_test_split(&mut self, count: i32, shuffle: bool) -> Result<()> {
unsafe { sys::cv_ml_TrainData_setTrainTestSplit_int_bool(self.as_raw_TrainData(), count, shuffle) }.into_result()
}
fn set_train_test_split_ratio(&mut self, ratio: f64, shuffle: bool) -> Result<()> {
unsafe { sys::cv_ml_TrainData_setTrainTestSplitRatio_double_bool(self.as_raw_TrainData(), ratio, shuffle) }.into_result()
}
fn shuffle_train_test(&mut self) -> Result<()> {
unsafe { sys::cv_ml_TrainData_shuffleTrainTest(self.as_raw_TrainData()) }.into_result()
}
fn get_test_samples(&self) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getTestSamples_const(self.as_raw_TrainData()) }.into_result().map(|ptr| core::Mat { ptr })
}
fn get_names(&self, names: &mut types::VectorOfString) -> Result<()> {
unsafe { sys::cv_ml_TrainData_getNames_const_VectorOfString(self.as_raw_TrainData(), names.as_raw_VectorOfString()) }.into_result()
}
}
impl dyn TrainData + '_ {
pub fn get_sub_vector(vec: &core::Mat, idx: &core::Mat) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getSubVector_Mat_Mat(vec.as_raw_Mat(), idx.as_raw_Mat()) }.into_result().map(|ptr| core::Mat { ptr })
}
pub fn get_sub_matrix(matrix: &core::Mat, idx: &core::Mat, layout: i32) -> Result<core::Mat> {
unsafe { sys::cv_ml_TrainData_getSubMatrix_Mat_Mat_int(matrix.as_raw_Mat(), idx.as_raw_Mat(), layout) }.into_result().map(|ptr| core::Mat { ptr })
}
pub fn load_from_csv(filename: &str, header_line_count: i32, response_start_idx: i32, response_end_idx: i32, var_type_spec: &str, delimiter: i8, missch: i8) -> Result<types::PtrOfTrainData> {
string_arg!(filename);
string_arg!(var_type_spec);
unsafe { sys::cv_ml_TrainData_loadFromCSV_String_int_int_int_String_char_char(filename.as_ptr(), header_line_count, response_start_idx, response_end_idx, var_type_spec.as_ptr(), delimiter, missch) }.into_result().map(|ptr| types::PtrOfTrainData { ptr })
}
pub fn create(samples: &dyn core::ToInputArray, layout: i32, responses: &dyn core::ToInputArray, var_idx: &dyn core::ToInputArray, sample_idx: &dyn core::ToInputArray, sample_weights: &dyn core::ToInputArray, var_type: &dyn core::ToInputArray) -> Result<types::PtrOfTrainData> {
input_array_arg!(samples);
input_array_arg!(responses);
input_array_arg!(var_idx);
input_array_arg!(sample_idx);
input_array_arg!(sample_weights);
input_array_arg!(var_type);
unsafe { sys::cv_ml_TrainData_create__InputArray_int__InputArray__InputArray__InputArray__InputArray__InputArray(samples.as_raw__InputArray(), layout, responses.as_raw__InputArray(), var_idx.as_raw__InputArray(), sample_idx.as_raw__InputArray(), sample_weights.as_raw__InputArray(), var_type.as_raw__InputArray()) }.into_result().map(|ptr| types::PtrOfTrainData { ptr })
}
}