Expectation Maximization get covs function not working on OpenCV 2.4.6 and number of cluster change after train function

荒凉一梦 提交于 2019-12-11 13:13:47

问题


I have two questions. First one is why ncluster switch from 10 to 80 after the train function. Second: I am passing my code from C to C++ with OpenCV but it seems there are some problems with it. I am having an exception when I try to get the covs of my model, this is the code:

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 &.

After debugging it the error shows after that last line. The system shows a window with myprogram.exe has triggered a breakpoint, and if I click continue I have the Microsoft Visual C++ Debug Library window with file: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c; Line: 1322; Expression: _CrtIsValidHeapPointer(pUserData).

Almost the same code works for this guy: How to use the CV::EM class in OpenCV 2.4.2?


回答1:


I already fixed it. I compiled the source libraries of OpenCV 2.4.6 with using VS2012 and it worked. It seems like there is a few bugs in the compiled one.



来源:https://stackoverflow.com/questions/19171607/expectation-maximization-get-covs-function-not-working-on-opencv-2-4-6-and-numbe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!