我有两个问题。第一个是为什么在训练功能后 ncluster 从 10 切换到 80。第二:我正在使用 OpenCV 将我的代码从 C 传递到 C++,但它似乎存在一些问题。当我尝试获取模型的 covs 时出现异常,这是代码:
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?