Struct opencv::ml::EM

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

The class implements the Expectation Maximization algorithm.

See also

[ml_intro_em]

Implementations§

source§

impl EM

source

pub fn create() -> Result<Ptr<EM>>

Creates empty %EM model. The model should be trained then using StatModel::train(traindata, flags) method. Alternatively, you can use one of the EM::train* methods or load it from file using Algorithm::load<EM>(filename).

source

pub fn load(filepath: &str, node_name: &str) -> Result<Ptr<EM>>

Loads and creates a serialized EM from a file

Use EM::save to serialize and store an EM to disk. Load the EM from this file again, by calling this function with the path to the file. Optionally specify the node for the file containing the classifier

Parameters
  • filepath: path to serialized EM
  • nodeName: name of node containing the classifier
C++ default parameters
  • node_name: String()
source

pub fn load_def(filepath: &str) -> Result<Ptr<EM>>

Loads and creates a serialized EM from a file

Use EM::save to serialize and store an EM to disk. Load the EM from this file again, by calling this function with the path to the file. Optionally specify the node for the file containing the classifier

Parameters
  • filepath: path to serialized EM
  • nodeName: name of node containing the classifier
Note

This alternative version of EM::load function uses the following default values for its arguments:

  • node_name: String()

Trait Implementations§

source§

impl AlgorithmTrait for EM

source§

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

source§

fn clear(&mut self) -> Result<()>

Clears the algorithm state
source§

fn read(&mut self, fn_: &FileNode) -> Result<()>

Reads algorithm parameters from a file storage
source§

impl AlgorithmTraitConst for EM

source§

fn as_raw_Algorithm(&self) -> *const c_void

source§

fn write(&self, fs: &mut FileStorage) -> Result<()>

Stores algorithm parameters in a file storage
source§

fn write_1(&self, fs: &mut FileStorage, name: &str) -> Result<()>

Stores algorithm parameters in a file storage Read more
source§

fn write_with_name(&self, fs: &Ptr<FileStorage>, name: &str) -> Result<()>

@deprecated Read more
source§

fn write_with_name_def(&self, fs: &Ptr<FileStorage>) -> Result<()>

👎Deprecated:

Note

Deprecated: ## Note This alternative version of AlgorithmTraitConst::write_with_name function uses the following default values for its arguments: Read more
source§

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

Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
source§

fn save(&self, filename: &str) -> Result<()>

Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).
source§

fn get_default_name(&self) -> Result<String>

Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.
source§

impl Boxed for EM

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 Debug for EM

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for EM

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl EMTrait for EM

source§

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

source§

fn set_clusters_number(&mut self, val: i32) -> Result<()>

The number of mixture components in the Gaussian mixture model. Default value of the parameter is EM::DEFAULT_NCLUSTERS=5. Some of %EM implementation could determine the optimal number of mixtures within a specified value range, but that is not the case in ML yet. Read more
source§

fn set_covariance_matrix_type(&mut self, val: i32) -> Result<()>

Constraint on covariance matrices which defines type of matrices. See EM::Types. Read more
source§

fn set_term_criteria(&mut self, val: TermCriteria) -> Result<()>

The termination criteria of the %EM algorithm. The %EM algorithm can be terminated by the number of iterations termCrit.maxCount (number of M-steps) or when relative change of likelihood logarithm is less than termCrit.epsilon. Default maximum number of iterations is EM::DEFAULT_MAX_ITERS=100. Read more
source§

fn train_em( &mut self, samples: &impl ToInputArray, log_likelihoods: &mut impl ToOutputArray, labels: &mut impl ToOutputArray, probs: &mut impl ToOutputArray ) -> Result<bool>

Estimate the Gaussian mixture parameters from a samples set. Read more
source§

fn train_em_def(&mut self, samples: &impl ToInputArray) -> Result<bool>

Estimate the Gaussian mixture parameters from a samples set. Read more
source§

fn train_e( &mut self, samples: &impl ToInputArray, means0: &impl ToInputArray, covs0: &impl ToInputArray, weights0: &impl ToInputArray, log_likelihoods: &mut impl ToOutputArray, labels: &mut impl ToOutputArray, probs: &mut impl ToOutputArray ) -> Result<bool>

Estimate the Gaussian mixture parameters from a samples set. Read more
source§

fn train_e_def( &mut self, samples: &impl ToInputArray, means0: &impl ToInputArray ) -> Result<bool>

Estimate the Gaussian mixture parameters from a samples set. Read more
source§

fn train_m( &mut self, samples: &impl ToInputArray, probs0: &impl ToInputArray, log_likelihoods: &mut impl ToOutputArray, labels: &mut impl ToOutputArray, probs: &mut impl ToOutputArray ) -> Result<bool>

Estimate the Gaussian mixture parameters from a samples set. Read more
source§

fn train_m_def( &mut self, samples: &impl ToInputArray, probs0: &impl ToInputArray ) -> Result<bool>

Estimate the Gaussian mixture parameters from a samples set. Read more
source§

impl EMTraitConst for EM

source§

fn as_raw_EM(&self) -> *const c_void

source§

fn get_clusters_number(&self) -> Result<i32>

The number of mixture components in the Gaussian mixture model. Default value of the parameter is EM::DEFAULT_NCLUSTERS=5. Some of %EM implementation could determine the optimal number of mixtures within a specified value range, but that is not the case in ML yet. Read more
source§

fn get_covariance_matrix_type(&self) -> Result<i32>

Constraint on covariance matrices which defines type of matrices. See EM::Types. Read more
source§

fn get_term_criteria(&self) -> Result<TermCriteria>

The termination criteria of the %EM algorithm. The %EM algorithm can be terminated by the number of iterations termCrit.maxCount (number of M-steps) or when relative change of likelihood logarithm is less than termCrit.epsilon. Default maximum number of iterations is EM::DEFAULT_MAX_ITERS=100. Read more
source§

fn get_weights(&self) -> Result<Mat>

Returns weights of the mixtures Read more
source§

fn get_means(&self) -> Result<Mat>

Returns the cluster centers (means of the Gaussian mixture) Read more
source§

fn get_covs(&self, covs: &mut Vector<Mat>) -> Result<()>

Returns covariation matrices Read more
source§

fn predict( &self, samples: &impl ToInputArray, results: &mut impl ToOutputArray, flags: i32 ) -> Result<f32>

Returns posterior probabilities for the provided samples Read more
source§

fn predict_def(&self, samples: &impl ToInputArray) -> Result<f32>

Returns posterior probabilities for the provided samples Read more
source§

fn predict2( &self, sample: &impl ToInputArray, probs: &mut impl ToOutputArray ) -> Result<Vec2d>

Returns a likelihood logarithm value and an index of the most probable mixture component for the given sample. Read more
source§

impl From<EM> for Algorithm

source§

fn from(s: EM) -> Self

Converts to this type from the input type.
source§

impl From<EM> for StatModel

source§

fn from(s: EM) -> Self

Converts to this type from the input type.
source§

impl StatModelTrait for EM

source§

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

source§

fn train_with_data( &mut self, train_data: &Ptr<TrainData>, flags: i32 ) -> Result<bool>

Trains the statistical model Read more
source§

fn train_with_data_def(&mut self, train_data: &Ptr<TrainData>) -> Result<bool>

Trains the statistical model Read more
source§

fn train( &mut self, samples: &impl ToInputArray, layout: i32, responses: &impl ToInputArray ) -> Result<bool>

Trains the statistical model Read more
source§

impl StatModelTraitConst for EM

source§

fn as_raw_StatModel(&self) -> *const c_void

source§

fn get_var_count(&self) -> Result<i32>

Returns the number of variables in training samples
source§

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

source§

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

Returns true if the model is trained
source§

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

Returns true if the model is classifier
source§

fn calc_error( &self, data: &Ptr<TrainData>, test: bool, resp: &mut impl ToOutputArray ) -> Result<f32>

Computes error on the training or test dataset Read more
source§

fn predict( &self, samples: &impl ToInputArray, results: &mut impl ToOutputArray, flags: i32 ) -> Result<f32>

Predicts response(s) for the provided sample(s) Read more
source§

fn predict_def(&self, samples: &impl ToInputArray) -> Result<f32>

Predicts response(s) for the provided sample(s) Read more
source§

impl TryFrom<StatModel> for EM

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(s: StatModel) -> Result<Self>

Performs the conversion.
source§

impl Send for EM

Auto Trait Implementations§

§

impl RefUnwindSafe for EM

§

impl !Sync for EM

§

impl Unpin for EM

§

impl UnwindSafe for EM

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.