Open pythonpanda-beep opened 3 years ago
@pythonpanda-beep Did you solve the issue?
Here is a quick fix:
mxArray* mxCreateMatrix3( int h, int w, int d, mxClassID id, bool c, void **I ){
const mwSize dims[3]={h,w,d}, n=h*w*d; int b; mxArray* M;
if( id==mxINT32_CLASS ) b=sizeof(int);
else if( id==mxDOUBLE_CLASS ) b=sizeof(double);
else if( id==mxSINGLE_CLASS ) b=sizeof(float);
else mexErrMsgTxt("Unknown mxClassID.");
*I = c ? mxCalloc(n,b) : mxMalloc(n*b);
M = mxCreateNumericMatrix(0,0,id,mxREAL);
mxSetData(M,*I); mxSetDimensions(M,dims,3); return M;
}
// Check inputs and outputs to mex, retrieve first input I
void checkArgs( int nl, mxArray *pl[], int nr, const mxArray *pr[], int nl0,
int nl1, int nr0, int nr1, int *h, int *w, int *d, mxClassID id, void **I )
{
const mwSize *dims; int nDims;
if( nl<nl0 || nl>nl1 ) mexErrMsgTxt("Incorrect number of outputs.");
if( nr<nr0 || nr>nr1 ) mexErrMsgTxt("Incorrect number of inputs.");
nDims = mxGetNumberOfDimensions(pr[0]); dims = mxGetDimensions(pr[0]);
*h=dims[0]; *w=dims[1]; *d=(nDims==2) ? 1 : dims[2]; *I = mxGetPr(pr[0]);
if( nDims!=2 && nDims!=3 ) mexErrMsgTxt("I must be a 2D or 3D array.");
if( mxGetClassID(pr[0])!=id ) mexErrMsgTxt("I has incorrect type.");
}
Here is a quick fix:
mxArray* mxCreateMatrix3( int h, int w, int d, mxClassID id, bool c, void **I ){ const mwSize dims[3]={h,w,d}, n=h*w*d; int b; mxArray* M; if( id==mxINT32_CLASS ) b=sizeof(int); else if( id==mxDOUBLE_CLASS ) b=sizeof(double); else if( id==mxSINGLE_CLASS ) b=sizeof(float); else mexErrMsgTxt("Unknown mxClassID."); *I = c ? mxCalloc(n,b) : mxMalloc(n*b); M = mxCreateNumericMatrix(0,0,id,mxREAL); mxSetData(M,*I); mxSetDimensions(M,dims,3); return M; } // Check inputs and outputs to mex, retrieve first input I void checkArgs( int nl, mxArray *pl[], int nr, const mxArray *pr[], int nl0, int nl1, int nr0, int nr1, int *h, int *w, int *d, mxClassID id, void **I ) { const mwSize *dims; int nDims; if( nl<nl0 || nl>nl1 ) mexErrMsgTxt("Incorrect number of outputs."); if( nr<nr0 || nr>nr1 ) mexErrMsgTxt("Incorrect number of inputs."); nDims = mxGetNumberOfDimensions(pr[0]); dims = mxGetDimensions(pr[0]); *h=dims[0]; *w=dims[1]; *d=(nDims==2) ? 1 : dims[2]; *I = mxGetPr(pr[0]); if( nDims!=2 && nDims!=3 ) mexErrMsgTxt("I must be a 2D or 3D array."); if( mxGetClassID(pr[0])!=id ) mexErrMsgTxt("I has incorrect type."); }
hello,I use your code to fix the problem. However, I face a new bug:
MEX 已成功完成。 使用 'MinGW64 Compiler (C++)' 编译。 错误使用 mex In file included from D:\multimodal_identification\DCF\csr-dcf-master\mex_src\segmentation\mex_extractforeground.cpp:4:0: D:\multimodal_identification\DCF\csr-dcf-master\mex_src\segmentation\mex_utils.hpp: In function 'cv::Mat toMat(const mxArray*, int, bool)': D:\multimodal_identification\DCF\csr-dcf-master\mex_src\segmentation\mex_utils.hpp:141:19: error: invalid operands of types 'int' and 'void' to binary 'operator==' depth = (depth==CV_USRTYPE1) ? DepthOf[classID] : depth;
出错 compile (line 26) eval(['mex mex_extractforeground.cpp src\segment.cpp -Isrc\ -I' opencv_include ' -L' opencv_libpath ' ' lib]);
Here is a quick fix:
mxArray* mxCreateMatrix3( int h, int w, int d, mxClassID id, bool c, void **I ){ const mwSize dims[3]={h,w,d}, n=h*w*d; int b; mxArray* M; if( id==mxINT32_CLASS ) b=sizeof(int); else if( id==mxDOUBLE_CLASS ) b=sizeof(double); else if( id==mxSINGLE_CLASS ) b=sizeof(float); else mexErrMsgTxt("Unknown mxClassID."); *I = c ? mxCalloc(n,b) : mxMalloc(n*b); M = mxCreateNumericMatrix(0,0,id,mxREAL); mxSetData(M,*I); mxSetDimensions(M,dims,3); return M; } // Check inputs and outputs to mex, retrieve first input I void checkArgs( int nl, mxArray *pl[], int nr, const mxArray *pr[], int nl0, int nl1, int nr0, int nr1, int *h, int *w, int *d, mxClassID id, void **I ) { const mwSize *dims; int nDims; if( nl<nl0 || nl>nl1 ) mexErrMsgTxt("Incorrect number of outputs."); if( nr<nr0 || nr>nr1 ) mexErrMsgTxt("Incorrect number of inputs."); nDims = mxGetNumberOfDimensions(pr[0]); dims = mxGetDimensions(pr[0]); *h=dims[0]; *w=dims[1]; *d=(nDims==2) ? 1 : dims[2]; *I = mxGetPr(pr[0]); if( nDims!=2 && nDims!=3 ) mexErrMsgTxt("I must be a 2D or 3D array."); if( mxGetClassID(pr[0])!=id ) mexErrMsgTxt("I has incorrect type."); }
hello,I use your code to fix the problem. However, I face a new bug:
MEX 已成功完成。 使用 'MinGW64 Compiler (C++)' 编译。 错误使用 mex In file included from D:\multimodal_identification\DCF\csr-dcf-master\mex_src\segmentation\mex_extractforeground.cpp:4:0: D:\multimodal_identification\DCF\csr-dcf-master\mex_src\segmentation\mex_utils.hpp: In function 'cv::Mat toMat(const mxArray*, int, bool)': D:\multimodal_identification\DCF\csr-dcf-master\mex_src\segmentation\mex_utils.hpp:141:19: error: invalid operands of types 'int' and 'void' to binary 'operator==' depth = (depth==CV_USRTYPE1) ? DepthOf[classID] : depth;
出错 compile (line 26) eval(['mex mex_extractforeground.cpp src\segment.cpp -Isrc\ -I' opencv_include ' -L' opencv_libpath ' ' lib]);
I am facing exactly the same issue and don't know how to solve it. If anyone has some idea plz guide me through it.
/home/ubuntu/csr-dcf-master/mex_src/hog/gradientMex.cpp: In function ‘mxArray* mxCreateMatrix3(int, int, int, mxClassID, bool, void)’: /home/ubuntu/csr-dcf-master/mex_src/hog/gradientMex.cpp:329:44: error: cannot convert ‘const int’ to ‘const mwSize {aka const long unsigned int}’ for argument ‘2’ to ‘int mxSetDimensions_730(mxArray, const mwSize, mwSize)’ mxSetData(M,I); mxSetDimensions(M,dims,3); return M; ^ /home/ubuntu/csr-dcf-master/mex_src/hog/gradientMex.cpp: In function ‘void checkArgs(int, mxArray, int, const mxArray*, int, int, int, int, int, int, int, mxClassID, void*)’: /home/ubuntu/csr-dcf-master/mex_src/hog/gradientMex.cpp:339:71: error: cannot convert ‘const mwSize {aka const long unsigned int}’ to ‘const int’ in assignment nDims = mxGetNumberOfDimensions(pr[0]); dims = mxGetDimensions(pr[0]); ^
error compile (line 9) mex gradientMex.cpp
How can I solve this problem?