void energy::Fitting::cleanup() { kernel_cleanup(); ///< disposes of static resources render_color.cleanup(); render_xyz.cleanup(); render_normals.cleanup(); sensor_depth.cleanup(); distance_transform.cleanup(); cudax::CublasHelper::cleanup(); cudax::CudaHelper::cleanup(); }
void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]){ mexPrintf("welcome to dtform!\n"); if( nrhs!=1 ) mexErrMsgTxt("This function requires 1 arguments\n"); if( !mxIsNumeric(prhs[0]) ) mexErrMsgTxt("varargin{0} must be a numeric image\n"); if( !(mxGetNumberOfDimensions(prhs[0])==2) ) mexErrMsgTxt("varargin{0} must be an image\n"); int num_rows = mxGetM(prhs[0]); int num_cols = mxGetN(prhs[0]); if( !mxIsDouble(prhs[0]) ) mexErrMsgTxt("varargin{0} must be a _double_ image\n"); mexPrintf("Processing size(I)=[%dx%d]\n", num_rows, num_cols); Scalar* image = (Scalar*) mxGetPr(prhs[0]); DistanceTransform dt; dt.init(num_rows, num_cols); dt.exec(image, Scalar(.5)); ///--- allocate & copy output (could be improved { Scalar* out_dt = dt.dsts_image_ptr(); plhs[0] = mxCreateDoubleMatrix(num_rows, num_cols, mxREAL); Scalar* out = (Scalar*) mxGetPr(plhs[0]); for(int i=0; i<(num_rows*num_cols); i++) out[i] = out_dt[i]; } ///--- Also save corresp (indexes) if(nlhs==2){ plhs[1] = mxCreateDoubleMatrix(num_rows, num_cols, mxREAL); Scalar* out = (Scalar*) mxGetPr(plhs[1]); int* out_dti = dt.idxs_image_ptr(); for(int i=0; i<(num_rows*num_cols); i++) out[i] = out_dti[i]; } dt.cleanup(); }