1
我有两个问题。首先是为什么ncluster在火车功能后从10转换到80。第二:我将我的代码从C传递到C++与OpenCV,但它似乎有一些问题。我有一个例外,当我试图让我的模型的COVS,这是代码:期望最大化得到covs功能不能在OpenCV 2.4.6和火车功能后集群数量变化
int nclusters = 10; // Here nclusters is 10
EM em_model(nclusters, EM::COV_MAT_GENERIC);
bool isTrained = em_model.train(samples);
// Here nclusters is 80
Mat means = em_model.get<Mat>("means");
Mat weights = em_model.get<Mat>("weights");
const vector<Mat>& covs = em_model.get<vector<Mat>>("covs"); // Here I have the exception. I have tried with and without &.
调试它之后,最后一行后错误显示。系统显示一个窗口,myprogram.exe触发了一个断点,如果单击继续,我将Microsoft Visual C++调试库窗口与文件相关联:f:\ dd \ vctools \ crt_bld \ self_x86 \ crt \ src \ dbgheap.c;线路:1322;表达式:_CrtIsValidHeapPointer(pUserData)。
几乎相同的代码适用于这个家伙:How to use the CV::EM class in OpenCV 2.4.2?