我正在使用 cvEm 对 2D 数据进行高斯混合建模。调用 train 函数后,它返回 True(签署成功的训练)和分类结果(具有不同颜色的不同集群)似乎是合理的,但是在获取集群的协方差矩阵时出现访问冲突错误!
以下是相关的代码行:
CvEMParams params;
params.covs = NULL;
params.means = NULL;
params.weights = NULL;
params.probs = NULL;
params.nclusters = NrGMMComponents;
params.cov_mat_type = CvEM::COV_MAT_GENERIC; // DIAGONAL, GENERIC, SPHERICAL
params.start_step = CvEM::START_AUTO_STEP;
params.term_crit.max_iter = 300;
params.term_crit.epsilon = 0.001;
params.term_crit.type = CV_TERMCRIT_ITER|CV_TERMCRIT_EPS;
//params.term_crit.type = CV_TERMCRIT_ITER;
// 2.2 Estimate GMM params for all <NrGMMComponents> Gaussian Mixture Components
CvEM em_model;
bool result = em_model.train( samples, Mat(), params, &labels);
vector<cv::Mat> covs;
em_model.getCovs(covs); ////////////Access Violation here! :(