本文整理汇总了C++中ObjectHandle::to_mex_handle方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectHandle::to_mex_handle方法的具体用法?C++ ObjectHandle::to_mex_handle怎么用?C++ ObjectHandle::to_mex_handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectHandle
的用法示例。
在下文中一共展示了ObjectHandle::to_mex_handle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mexFunction
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
int nD;
const int *rND;
MyClass *mine=0;
if (nrhs == 0)
{
mexErrMsgTxt("Need at least one input argument.");
return;
}
if ( nlhs == 0 && nrhs == 1 )
{
//release memory
ObjectHandle<MyClass>* handle = ObjectHandle<MyClass>::from_mex_handle(prhs[0]);
delete handle;
return;
}
// Get image size
nD=mxGetNumberOfDimensions(I_IN);
rND=mxGetDimensions(I_IN);
if ((nD != 3) || (rND[2] != 3))
{
mexErrMsgTxt("Need RGB image");
return;
}
if (nlhs == 1 && nrhs == 1)
{
//create structure
//RGB image is provoded
mine = new MyClass(rND[0],rND[1]);
//mexPrintf("Pointer before: %#x, ", mine);
ObjectHandle<MyClass> *handle = new ObjectHandle<MyClass>(mine);
//mexPrintf("Pointer after: %#x\n", mine);
plhs[0] = handle->to_mex_handle();
}
else if (nlhs == 1 && nrhs == 2 )
{
//update background
MyClass& mine = get_object<MyClass>(PDATA_IN);
// Create a matrix for the return argument
I_OUT = mxCreateNumericArray(2,rND,mxUINT8_CLASS, mxREAL);
/* Assign pointers to the various parameters */
unsigned char* imageout = (unsigned char*) mxGetData(I_OUT);
unsigned char* imagein = (unsigned char*) mxGetData(I_IN);
mine.process(imagein,imageout);
}
else if ( nlhs == 0 && nrhs == 3 )
{
//change settings -to do
MyClass& mine = get_object<MyClass>(PDATA_IN);
double* pars = (double*) mxGetData(PARS_IN);
mine.setParameters(pars);
}
else mexErrMsgTxt("Bad input.");
}