2012年1月17日 星期二

calling matlab from c

* matlab array is column-major. C array and openCV mat are row-major.

* mxArray *engGetVariable(Engine *ep, const char *name);

Returns

Pointer to a newly allocated mxArray structure, or NULL if the attempt fails.
engGetVariable reads the named mxArray from the MATLAB engine session associated with ep. engGetVariable allocates memory for mxArray. Use mxDestroyArray to destroy the mxArray created by this routine when you are finished with it.


* Avoid "server busy" message box, add three lines to InitInstance as shown below.


    // Initialize OLE libraries
    if (!AfxOleInit())
    {
        AfxMessageBox(IDP_OLE_INIT_FAILED);
        return FALSE;
    }

    // for Matlab
    // The following three lines eliminate the Server busy message
    COleMessageFilter* pFilter = AfxOleGetMessageFilter();
    ASSERT_VALID(pFilter);
    pFilter->EnableNotRespondingDialog(FALSE);

1 則留言: