public class EM extends StatModel
Modifier and Type | Field and Description |
---|---|
static int |
COV_MAT_DEFAULT |
static int |
COV_MAT_DIAGONAL |
static int |
COV_MAT_GENERIC |
static int |
COV_MAT_SPHERICAL |
static int |
DEFAULT_MAX_ITERS |
static int |
DEFAULT_NCLUSTERS |
static int |
START_AUTO_STEP |
static int |
START_E_STEP |
static int |
START_M_STEP |
COMPRESSED_INPUT, PREPROCESSED_INPUT, RAW_OUTPUT, UPDATE_MODEL
Modifier | Constructor and Description |
---|---|
protected |
EM(long addr) |
Modifier and Type | Method and Description |
---|---|
static EM |
__fromPtr__(long addr) |
static EM |
create()
Creates empty %EM model.
|
protected void |
finalize() |
int |
getClustersNumber()
SEE: setClustersNumber
|
int |
getCovarianceMatrixType()
SEE: setCovarianceMatrixType
|
void |
getCovs(List<Mat> covs)
Returns covariation matrices
Returns vector of covariation matrices.
|
Mat |
getMeans()
Returns the cluster centers (means of the Gaussian mixture)
Returns matrix with the number of rows equal to the number of mixtures and number of columns
equal to the space dimensionality.
|
TermCriteria |
getTermCriteria()
SEE: setTermCriteria
|
Mat |
getWeights()
Returns weights of the mixtures
Returns vector with the number of elements equal to the number of mixtures.
|
static EM |
load(String filepath)
Loads and creates a serialized EM from a file
Use EM::save to serialize and store an EM to disk.
|
static EM |
load(String filepath,
String nodeName)
Loads and creates a serialized EM from a file
Use EM::save to serialize and store an EM to disk.
|
float |
predict(Mat samples)
Returns posterior probabilities for the provided samples
|
float |
predict(Mat samples,
Mat results)
Returns posterior probabilities for the provided samples
|
float |
predict(Mat samples,
Mat results,
int flags)
Returns posterior probabilities for the provided samples
|
double[] |
predict2(Mat sample,
Mat probs)
Returns a likelihood logarithm value and an index of the most probable mixture component
for the given sample.
|
void |
setClustersNumber(int val)
getClustersNumber SEE: getClustersNumber
|
void |
setCovarianceMatrixType(int val)
getCovarianceMatrixType SEE: getCovarianceMatrixType
|
void |
setTermCriteria(TermCriteria val)
getTermCriteria SEE: getTermCriteria
|
boolean |
trainE(Mat samples,
Mat means0)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainE(Mat samples,
Mat means0,
Mat covs0)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainE(Mat samples,
Mat means0,
Mat covs0,
Mat weights0)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainE(Mat samples,
Mat means0,
Mat covs0,
Mat weights0,
Mat logLikelihoods)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainE(Mat samples,
Mat means0,
Mat covs0,
Mat weights0,
Mat logLikelihoods,
Mat labels)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainE(Mat samples,
Mat means0,
Mat covs0,
Mat weights0,
Mat logLikelihoods,
Mat labels,
Mat probs)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainEM(Mat samples)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainEM(Mat samples,
Mat logLikelihoods)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainEM(Mat samples,
Mat logLikelihoods,
Mat labels)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainEM(Mat samples,
Mat logLikelihoods,
Mat labels,
Mat probs)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainM(Mat samples,
Mat probs0)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainM(Mat samples,
Mat probs0,
Mat logLikelihoods)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainM(Mat samples,
Mat probs0,
Mat logLikelihoods,
Mat labels)
Estimate the Gaussian mixture parameters from a samples set.
|
boolean |
trainM(Mat samples,
Mat probs0,
Mat logLikelihoods,
Mat labels,
Mat probs)
Estimate the Gaussian mixture parameters from a samples set.
|
calcError, empty, getVarCount, isClassifier, isTrained, train, train, train
clear, getDefaultName, getNativeObjAddr, save
public static final int DEFAULT_NCLUSTERS
public static final int DEFAULT_MAX_ITERS
public static final int START_E_STEP
public static final int START_M_STEP
public static final int START_AUTO_STEP
public static final int COV_MAT_SPHERICAL
public static final int COV_MAT_DIAGONAL
public static final int COV_MAT_GENERIC
public static final int COV_MAT_DEFAULT
public static EM __fromPtr__(long addr)
public Mat getMeans()
public Mat getWeights()
public static EM create()
public static EM load(String filepath, String nodeName)
filepath
- path to serialized EMnodeName
- name of node containing the classifierpublic static EM load(String filepath)
filepath
- path to serialized EMpublic TermCriteria getTermCriteria()
public double[] predict2(Mat sample, Mat probs)
sample
- A sample for classification. It should be a one-channel matrix of
\(1 \times dims\) or \(dims \times 1\) size.probs
- Optional output matrix that contains posterior probabilities of each component
given the sample. It has \(1 \times nclusters\) size and CV_64FC1 type.
The method returns a two-element double vector. Zero element is a likelihood logarithm value for
the sample. First element is an index of the most probable mixture component for the given
sample.public boolean trainE(Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods, Mat labels, Mat probs)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.means0
- Initial means \(a_k\) of mixture components. It is a one-channel matrix of
\(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
converted to the inner matrix of such type for the further computing.covs0
- The vector of initial covariance matrices \(S_k\) of mixture components. Each of
covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
do not have CV_64F type they will be converted to the inner matrices of such type for the
further computing.weights0
- Initial weights \(\pi_k\) of mixture components. It should be a one-channel
floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.logLikelihoods
- The optional output matrix that contains a likelihood logarithm value for
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.labels
- The optional output "class label" for each sample:
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.probs
- The optional output matrix that contains posterior probabilities of each Gaussian
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainE(Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods, Mat labels)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.means0
- Initial means \(a_k\) of mixture components. It is a one-channel matrix of
\(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
converted to the inner matrix of such type for the further computing.covs0
- The vector of initial covariance matrices \(S_k\) of mixture components. Each of
covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
do not have CV_64F type they will be converted to the inner matrices of such type for the
further computing.weights0
- Initial weights \(\pi_k\) of mixture components. It should be a one-channel
floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.logLikelihoods
- The optional output matrix that contains a likelihood logarithm value for
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.labels
- The optional output "class label" for each sample:
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainE(Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.means0
- Initial means \(a_k\) of mixture components. It is a one-channel matrix of
\(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
converted to the inner matrix of such type for the further computing.covs0
- The vector of initial covariance matrices \(S_k\) of mixture components. Each of
covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
do not have CV_64F type they will be converted to the inner matrices of such type for the
further computing.weights0
- Initial weights \(\pi_k\) of mixture components. It should be a one-channel
floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.logLikelihoods
- The optional output matrix that contains a likelihood logarithm value for
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainE(Mat samples, Mat means0, Mat covs0, Mat weights0)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.means0
- Initial means \(a_k\) of mixture components. It is a one-channel matrix of
\(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
converted to the inner matrix of such type for the further computing.covs0
- The vector of initial covariance matrices \(S_k\) of mixture components. Each of
covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
do not have CV_64F type they will be converted to the inner matrices of such type for the
further computing.weights0
- Initial weights \(\pi_k\) of mixture components. It should be a one-channel
floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainE(Mat samples, Mat means0, Mat covs0)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.means0
- Initial means \(a_k\) of mixture components. It is a one-channel matrix of
\(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
converted to the inner matrix of such type for the further computing.covs0
- The vector of initial covariance matrices \(S_k\) of mixture components. Each of
covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
do not have CV_64F type they will be converted to the inner matrices of such type for the
further computing.
floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainE(Mat samples, Mat means0)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.means0
- Initial means \(a_k\) of mixture components. It is a one-channel matrix of
\(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
converted to the inner matrix of such type for the further computing.
covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
do not have CV_64F type they will be converted to the inner matrices of such type for the
further computing.
floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainEM(Mat samples, Mat logLikelihoods, Mat labels, Mat probs)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.logLikelihoods
- The optional output matrix that contains a likelihood logarithm value for
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.labels
- The optional output "class label" for each sample:
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.probs
- The optional output matrix that contains posterior probabilities of each Gaussian
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainEM(Mat samples, Mat logLikelihoods, Mat labels)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.logLikelihoods
- The optional output matrix that contains a likelihood logarithm value for
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.labels
- The optional output "class label" for each sample:
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainEM(Mat samples, Mat logLikelihoods)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.logLikelihoods
- The optional output matrix that contains a likelihood logarithm value for
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainEM(Mat samples)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainM(Mat samples, Mat probs0, Mat logLikelihoods, Mat labels, Mat probs)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.probs0
- the probabilitieslogLikelihoods
- The optional output matrix that contains a likelihood logarithm value for
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.labels
- The optional output "class label" for each sample:
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.probs
- The optional output matrix that contains posterior probabilities of each Gaussian
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainM(Mat samples, Mat probs0, Mat logLikelihoods, Mat labels)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.probs0
- the probabilitieslogLikelihoods
- The optional output matrix that contains a likelihood logarithm value for
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.labels
- The optional output "class label" for each sample:
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainM(Mat samples, Mat probs0, Mat logLikelihoods)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.probs0
- the probabilitieslogLikelihoods
- The optional output matrix that contains a likelihood logarithm value for
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public boolean trainM(Mat samples, Mat probs0)
samples
- Samples from which the Gaussian mixture model will be estimated. It should be a
one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
it will be converted to the inner matrix of such type for the further computing.probs0
- the probabilities
each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
\(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
mixture component given the each sample. It has \(nsamples \times nclusters\) size and
CV_64FC1 type.public float predict(Mat samples, Mat results, int flags)
predict
in class StatModel
samples
- The input samples, floating-point matrixresults
- The optional output \( nSamples \times nClusters\) matrix of results. It contains
posterior probabilities for each sample from the inputflags
- This parameter will be ignoredpublic float predict(Mat samples, Mat results)
public float predict(Mat samples)
public int getClustersNumber()
public int getCovarianceMatrixType()
public void getCovs(List<Mat> covs)
covs
- automatically generatedpublic void setClustersNumber(int val)
val
- automatically generatedpublic void setCovarianceMatrixType(int val)
val
- automatically generatedpublic void setTermCriteria(TermCriteria val)
val
- automatically generatedGenerated on Wed Oct 9 2019 23:24:43 UTC / OpenCV 4.1.2