我使用OpenCV的EM算法来获得GMM型号的示例代码OpenCV的文档中的帮助下,如下所示:
cv::Mat capturedFrame
const int N = 5;
int nsamples = 100;
cv::Mat samples ( nsamples, 2, CV_32FC1 );
samples = samples.reshape ( 2, 0 );
cv::Mat sample ( 1, 2, CV_32FC1 );
CvEM em_model;
CvEMParams params;
for ( i = 0; i < N; i++ )
{
//from the training samples
cv::Mat samples_part = samples.rowRange ( i*nsamples/N, (i+1)*nsamples/N);
cv::Scalar mean (((i%N)+1)*img.rows/(N1+1),((i/N1)+1)*img.rows/(N1+1));
cv::Scalar sigma (30,30);
cv::randn(samples_part,mean,sigma);
}
samples = samples.reshape ( 1, 0 );
//initialize model parameters
params.covs = NULL;
params.means = NULL;
params.weights = NULL;
params.probs = NULL;
params.nclusters = N;
params.cov_mat_type = CvEM::COV_MAT_SPHERICAL;
params.start_step = CvEM::START_AUTO_STEP;
params.term_crit.max_iter = 300;
params.term_crit.epsilon = 0.1;
params.term_crit.type = CV_TERMCRIT_ITER|CV_TERMCRIT_EPS;
//cluster the data
em_model.train ( samples, Mat(), params, &labels );
作为一个新的以GMM和OpenCV,现在我有一些问题:
首先 ,在执行上面的代码后,我能得到像probs:
cv::Mat probs = em_model.getProbs();
然后,我怎样才能得到这些具有最多和最少的元件模型,也就是最大的和最小的车型?
其次 ,我的样本数据只有100这里,为的OpenCV的示例代码,但我读一帧大小为600×800,我想品尝所有这些像素吧,这是480000.但是这需要大约10毫秒这100个样本,这意味着这将是太缓慢,如果我设置:
int nsamples = 480000;
我现在在这里的路吗?