How to get the GMM co-variance matrix?

asked 2017-01-12 02:48:39 -0600

lcmai gravatar image

updated 2017-01-13 01:46:27 -0600

berak gravatar image

I am using cv::EM to train the GMMs. Everything works fine except when I want to get the co-variance matrix I got a Debug Assertion Failed.

The code is:

cout << "Test the EM algorithm in Opencv" << endl;
cv::EM em(5);
em.train(training_set);
if (em.isTrained())
{
    cout << "Finished trainging EM" << endl;
    const cv::Mat &weights =  em.get<cv::Mat>("weights");
    const cv::Mat &Means = em.get<cv::Mat>("means");
    const vector<cv::Mat> &Covs = em.get<vector<cv::Mat>>("covs");
}

system("pause");

and the error message is:

Debug Assertion Failed!

Program: D:\Kinect test\GMM\GMM\x64\Debug\GMM.exe File: f:\dd\vctools\crt\crtw32\misc\dbgheap.c Line: 1424

Expression: _pFirstBlock == pHead

For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.

The complete call stack is:

 ntdll.dll!NtWaitForSingleObject() Unknown

ntdll.dll!LdrpDrainWorkQueue()  Unknown

ntdll.dll!LdrpLoadDllInternal() Unknown

ntdll.dll!LdrpLoadDll() Unknown

ntdll.dll!LdrLoadDll()  Unknown

KernelBase.dll!LoadLibraryExW()    Unknown

SogouPY.ime!00007ff89b27daf8()  Unknown

SogouPY.ime!00007ff89b1186ce()  Unknown

SogouPY.ime!00007ff89b11873a()  Unknown

SogouPY.ime!00007ff89b1f7a02()  Unknown

SogouPY.ime!00007ff89b1f7b68()  Unknown

SogouPY.ime!00007ff89b2212e7()  Unknown

SogouPY.ime!00007ff89b228965()  Unknown

SogouPY.ime!00007ff89b2b6a85()  Unknown

SogouPY.ime!00007ff89b227437()  Unknown

SogouPY.ime!00007ff89b22759f()  Unknown

SogouPY.ime!00007ff89b227638()  Unknown

user32.dll!UserCallWinProcCheckWow()   Unknown

user32.dll!DispatchClientMessage() Unknown

user32.dll!__fnINLPCREATESTRUCT()  Unknown

ntdll.dll!KiUserCallbackDispatcherContinue()   Unknown

win32u.dll!NtUserCreateWindowEx()  Unknown

user32.dll!VerNtUserCreateWindowEx()   Unknown

user32.dll!CreateWindowInternal()  Unknown

user32.dll!CreateWindowExW()   Unknown

SogouTSF.ime!00007ff89b7fceae() Unknown

SogouTSF.ime!00007ff89b7e9dd5() Unknown

msctf.dll!CTip::Activate()  Unknown

msctf.dll!CThreadInputMgr::_ActivateTip()   Unknown

msctf.dll!CThreadInputMgr::ActivateInputProfile()   Unknown

msctf.dll!CThreadInputMgr::OnActiveProfileChange(void)  Unknown

msctf.dll!CThreadInputMgr::TimerProc(struct HWND__ *,unsigned int,unsigned __int64,unsigned long)   Unknown

user32.dll!UserCallWinProc()   Unknown

user32.dll!DispatchMessageWorker() Unknown

user32.dll!DialogBox2()    Unknown

user32.dll!InternalDialogBox() Unknown

user32.dll!SoftModalMessageBox()   Unknown

user32.dll!MessageBoxWorker()  Unknown

user32.dll!MessageBoxTimeoutW()    Unknown

user32.dll!MessageBoxW()   Unknown

msvcr120d.dll!__crtMessageBoxW(const wchar_t * lpText=0x0000008d4ddc2260, const wchar_t * lpCaption=0x00007ff877265140, unsigned int uType=73746) Line 250  C

msvcr120d.dll!__crtMessageWindowW(int nRptType=2, void * returnAddress=0x00007ff8771f0829, const wchar_t * szFile=0x00007ff877288a80, const wchar_t * szLine=0x0000008d4ddc5350, const wchar_t * szModule=0x0000000000000000, const wchar_t * szUserMessage=0x0000008d4ddca350) Line 391    C++

msvcr120d.dll!_VCrtDbgReportW(int nRptType=2, void * returnAddress=0x00007ff8771f0829, const wchar_t * szFile=0x00007ff877288a80, int nLine=1424, const wchar_t * szModule=0x0000000000000000, const wchar_t * szFormat=0x00007ff877263a3c, char * arglist=0x0000008d4ddcc448) Line 672 C

msvcr120d.dll!_CrtDbgReportWV(int nRptType=2, void * returnAddress=0x00007ff8771f0829, const wchar_t * szFile=0x00007ff877288a80, int nLine=1424, const wchar_t * szModule=0x0000000000000000, const wchar_t * szFormat=0x00007ff877263a3c, char * arglist=0x0000008d4ddcc448) Line 263 C++

msvcr120d.dll!_CrtDbgReportW(int nRptType=2, const wchar_t * szFile=0x00007ff877288a80, int nLine=1424, const wchar_t * szModule=0x0000000000000000, const wchar_t * szFormat=0x00007ff877263a3c, ...) Line 279 C++

msvcr120d.dll!_free_dbg_nolock(void * pUserData=0x000001a3b4141ca0, int nBlockUse=1) Line 1424  C++

msvcr120d.dll!_free_dbg(void * pUserData=0x000001a3b4141ca0, int nBlockUse=1) Line 1265 C++

msvcr120d.dll!operator delete(void * pUserData=0x000001a3b4141ca0) Line 54  C++

opencv_core2413d.dll!00007ff8773146a2() Unknown

opencv_core2413d.dll!00007ff87731449c() Unknown

opencv_core2413d.dll!00007ff87730f20d() Unknown

opencv_core2413d.dll!00007ff87730ac61() Unknown

opencv_core2413d.dll!00007ff87730b16c() Unknown

opencv_core2413d.dll!00007ff87731756b ...
(more)
edit retag flag offensive close merge delete

Comments

Can you post the call stack of the error? That would help a lot for figuring out exactly what caused the error.

Tetragramm gravatar imageTetragramm ( 2017-01-12 07:47:20 -0600 )edit

The call stack of the error is: > GMM.exe! cv::Algorithm::get<std::vector<cv::mat,std::allocator<cv::mat> > >(const char * _name) Line 4095

lcmai gravatar imagelcmai ( 2017-01-12 19:42:43 -0600 )edit

That's not a complete call stack. I would expect lines and method names for everything from main() down to the exact location of the error.

Tetragramm gravatar imageTetragramm ( 2017-01-12 20:15:06 -0600 )edit
1

The call stack is very long, can I just post it as an answer tomorrow? As I just created my account yesterday, I am not all allow to post answers within two days after the account created. Sorry for the delay.

lcmai gravatar imagelcmai ( 2017-01-12 21:25:37 -0600 )edit

You should be able to edit your question.

Tetragramm gravatar imageTetragramm ( 2017-01-12 21:29:34 -0600 )edit

I already update the call stack, thank you.

lcmai gravatar imagelcmai ( 2017-01-13 00:33:36 -0600 )edit

is that running in debug mode ? (stacktrace shows, it's using debug dll's)

berak gravatar imageberak ( 2017-01-13 02:14:29 -0600 )edit

Yes, it runs in debug mode.

lcmai gravatar imagelcmai ( 2017-01-13 02:22:55 -0600 )edit

ok, ignore, then. (was suspecting a problem with "mixed" dlls)

berak gravatar imageberak ( 2017-01-13 02:24:26 -0600 )edit

That is unfortunate. The part I wanted is all unknown. I don't suppose you could upgrade to 3.2 and make the few changes it would take? It's much nicer as far as getting data.

Tetragramm gravatar imageTetragramm ( 2017-01-13 17:32:20 -0600 )edit