Skip to content

Resolve #29 form jmbuena #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions channels/private/convConst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,16 @@ void convMax( float *I, float *O, int h, int w, int d, int r ) {
// B=convConst(type,A,r,s); fast 2D convolutions (see convTri.m and convBox.m)
#ifdef MATLAB_MEX_FILE
void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) {
int *ns, ms[3], nDims, d, m, r, s; float *A, *B, p;
int nDims; float *A, *B, p;
mwSize ms[3]; mwSize *ns, d, m, r, s;;
mxClassID id; char type[1024];

// error checking on arguments
if(nrhs!=4) mexErrMsgTxt("Four inputs required.");
if(nlhs > 1) mexErrMsgTxt("One output expected.");
nDims = mxGetNumberOfDimensions(prhs[1]);
id = mxGetClassID(prhs[1]);
ns = (int*) mxGetDimensions(prhs[1]);
ns = (mwSize*) mxGetDimensions(prhs[1]);
d = (nDims == 3) ? ns[2] : 1;
m = (ns[0] < ns[1]) ? ns[0] : ns[1];
if( (nDims!=2 && nDims!=3) || id!=mxSINGLE_CLASS || m<4 )
Expand Down
18 changes: 10 additions & 8 deletions channels/private/gradientMex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ void fhog( float *M, float *O, float *H, int h, int w, int binSize,
/******************************************************************************/
#ifdef MATLAB_MEX_FILE
// Create [hxwxd] mxArray array, initialize to 0 if c=true
mxArray* mxCreateMatrix3( int h, int w, int d, mxClassID id, bool c, void **I ){
const int dims[3]={h,w,d}, n=h*w*d; int b; mxArray* M;
mxArray* mxCreateMatrix3( mwSize h, mwSize w, mwSize 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);
Expand All @@ -331,9 +331,9 @@ mxArray* mxCreateMatrix3( int h, int w, int d, mxClassID id, bool c, void **I ){

// 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 )
int nl1, int nr0, int nr1, mwSize *h, mwSize *w, mwSize *d, mxClassID id, void **I )
{
const int *dims; int nDims;
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]);
Expand All @@ -344,7 +344,7 @@ void checkArgs( int nl, mxArray *pl[], int nr, const mxArray *pr[], int nl0,

// [Gx,Gy] = grad2(I) - see gradient2.m
void mGrad2( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) {
int h, w, d; float *I, *Gx, *Gy;
mwSize h, w, d; float *I, *Gx, *Gy;
checkArgs(nl,pl,nr,pr,1,2,1,1,&h,&w,&d,mxSINGLE_CLASS,(void**)&I);
if(h<2 || w<2) mexErrMsgTxt("I must be at least 2x2.");
pl[0]= mxCreateMatrix3( h, w, d, mxSINGLE_CLASS, 0, (void**) &Gx );
Expand All @@ -354,7 +354,8 @@ void mGrad2( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) {

// [M,O] = gradMag( I, channel, full ) - see gradientMag.m
void mGradMag( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) {
int h, w, d, c, full; float *I, *M, *O=0;
mwSize h, w, d;
int c, full; float *I, *M, *O=0;
checkArgs(nl,pl,nr,pr,1,2,3,3,&h,&w,&d,mxSINGLE_CLASS,(void**)&I);
if(h<2 || w<2) mexErrMsgTxt("I must be at least 2x2.");
c = (int) mxGetScalar(pr[1]); full = (int) mxGetScalar(pr[2]);
Expand All @@ -366,7 +367,7 @@ void mGradMag( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) {

// gradMagNorm( M, S, norm ) - operates on M - see gradientMag.m
void mGradMagNorm( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) {
int h, w, d; float *M, *S, norm;
mwSize h, w, d; float *M, *S, norm;
checkArgs(nl,pl,nr,pr,0,0,3,3,&h,&w,&d,mxSINGLE_CLASS,(void**)&M);
if( mxGetM(pr[1])!=h || mxGetN(pr[1])!=w || d!=1 ||
mxGetClassID(pr[1])!=mxSINGLE_CLASS ) mexErrMsgTxt("M or S is bad.");
Expand All @@ -376,7 +377,8 @@ void mGradMagNorm( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) {

// H=gradHist(M,O,[...]) - see gradientHist.m
void mGradHist( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) {
int h, w, d, hb, wb, nChns, binSize, nOrients, softBin, useHog;
mwSize h, w, d, hb, wb;
int nChns, binSize, nOrients, softBin, useHog;
bool full; float *M, *O, *H, clipHog;
checkArgs(nl,pl,nr,pr,1,3,2,8,&h,&w,&d,mxSINGLE_CLASS,(void**)&M);
O = (float*) mxGetPr(pr[1]);
Expand Down
16 changes: 10 additions & 6 deletions channels/private/imPadMex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ template<class T> void imPad( T *A, T *B, int h, int w, int d, int pt, int pb,
// B = imPadMex(A,pad,type); see imPad.m for usage details
#ifdef MATLAB_MEX_FILE
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
int *ns, ms[3], nCh, nDims, pt, pb, pl, pr, flag, k; double *p;
int nCh, nDims, pt, pb, pl, pr, flag, k; double *p;
mwSize *ns, ms[3], *ns_out;
void *A, *B; mxClassID id; double val=0; char type[1024];

// Error checking on arguments
if( nrhs!=3 ) mexErrMsgTxt("Three inputs expected.");
if( nlhs>1 ) mexErrMsgTxt("One output expected.");
nDims=mxGetNumberOfDimensions(prhs[0]); id=mxGetClassID(prhs[0]);
ns = (int*) mxGetDimensions(prhs[0]); nCh=(nDims==2) ? 1 : ns[2];
ns = (mwSize*) mxGetDimensions(prhs[0]); nCh=(nDims==2) ? 1 : ns[2];
if( (nDims!=2 && nDims!=3) ||
(id!=mxSINGLE_CLASS && id!=mxDOUBLE_CLASS && id!=mxUINT8_CLASS) )
mexErrMsgTxt("A should be 2D or 3D single, double or uint8 array.");
Expand All @@ -102,10 +103,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
if( ns[0]==0 || ns[1]==0 ) flag=0;

// create output array
ms[0]=ns[0]+pt+pb; ms[1]=ns[1]+pl+pr; ms[2]=nCh;
if( ms[0]<0 || ns[0]<=-pt || ns[0]<=-pb ) ms[0]=0;
if( ms[1]<0 || ns[1]<=-pl || ns[1]<=-pr ) ms[1]=0;
plhs[0] = mxCreateNumericArray(3, (const mwSize*) ms, id, mxREAL);
ms[0]=ns[0]+mwSize(pt)+mwSize(pb);
ms[1]=ns[1]+mwSize(pl)+mwSize(pr);
ms[2]=mwSize(nCh);

if( ms[0]<0 || int(ns[0])<=-int(pt) || int(ns[0])<=-int(pb) ) ms[0]=0;
if( ms[1]<0 || int(ns[1])<=-int(pl) || int(ns[1])<=-int(pr) ) ms[1]=0;
plhs[0] = mxCreateNumericArray(3, ms, id, mxREAL);
if( ms[0]==0 || ms[1]==0 ) return;

// pad array
Expand Down
10 changes: 7 additions & 3 deletions channels/private/imResampleMex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ void resample( T *A, T *B, int ha, int hb, int wa, int wb, int d, T r ) {
if(ybd[0]==2) for(; y<hb; y++) { ya=yas[y*4]; B0[y]=U(0)+U(1); }
if(ybd[0]==3) for(; y<hb; y++) { ya=yas[y*4]; B0[y]=U(0)+U(1)+U(2); }
if(ybd[0]==4) for(; y<hb; y++) { ya=yas[y*4]; B0[y]=U(0)+U(1)+U(2)+U(3); }
if(ybd[0]>4) for(; y<hn; y++) { B0[ybs[y]] += C[yas[y]] * ywts[y]; }
if(ybd[0]>4) {
for(int i=0; i<hb; i++) { B0[i] = 0; }
for(; y<hn; y++) { B0[ybs[y]] += C[yas[y]] * ywts[y]; } }
#undef U
} else {
for(y=0; y<ybd[0]; y++) B0[y] = C[yas[y]]*ywts[y];
Expand All @@ -132,14 +134,16 @@ void resample( T *A, T *B, int ha, int hb, int wa, int wb, int d, T r ) {
// B = imResampleMex(A,hb,wb,nrm); see imResample.m for usage details
#ifdef MATLAB_MEX_FILE
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
int *ns, ms[3], n, m, nCh, nDims;
int n, m, nCh, nDims;
mwSize ms[3];
mwSize *ns;
void *A, *B; mxClassID id; double nrm;

// Error checking on arguments
if( nrhs!=4) mexErrMsgTxt("Four inputs expected.");
if( nlhs>1 ) mexErrMsgTxt("One output expected.");
nDims=mxGetNumberOfDimensions(prhs[0]); id=mxGetClassID(prhs[0]);
ns = (int*) mxGetDimensions(prhs[0]); nCh=(nDims==2) ? 1 : ns[2];
ns = (mwSize*) mxGetDimensions(prhs[0]); nCh=(nDims==2) ? 1 : ns[2];
if( (nDims!=2 && nDims!=3) ||
(id!=mxSINGLE_CLASS && id!=mxDOUBLE_CLASS && id!=mxUINT8_CLASS) )
mexErrMsgTxt("A should be 2D or 3D single, double or uint8 array.");
Expand Down
5 changes: 3 additions & 2 deletions channels/private/rgbConvertMex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,14 @@ oT* rgbConvert( iT *I, int n, int d, int flag, oT nrm ) {
// J = rgbConvertMex(I,flag,single); see rgbConvert.m for usage details
#ifdef MATLAB_MEX_FILE
void mexFunction(int nl, mxArray *pl[], int nr, const mxArray *pr[]) {
const int *dims; int nDims, n, d, dims1[3]; void *I; void *J; int flag;
const mwSize *dims; int nDims, n, d; void *I; void *J; int flag;
mwSize dims1[3];
bool single; mxClassID idIn, idOut;

// Error checking
if( nr!=3 ) mexErrMsgTxt("Three inputs expected.");
if( nl>1 ) mexErrMsgTxt("One output expected.");
dims = (const int*) mxGetDimensions(pr[0]); n=dims[0]*dims[1];
dims = (const mwSize*) mxGetDimensions(pr[0]); n=dims[0]*dims[1];
nDims = mxGetNumberOfDimensions(pr[0]);
d = 1; for( int i=2; i<nDims; i++ ) d*=dims[i];

Expand Down
Binary file modified detector/models/AcfInriaDetector.mat
Binary file not shown.
10 changes: 6 additions & 4 deletions images/private/histc2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ int findBin( double x, double *edges, int nBins ) {
* sub2ind(ind,sub,subMul,nd)
*******************************************************************************/
#define sub2ind(ind, sub, subMul, nd) ind=sub[0]; for(k=1;k<nd;k++) ind+=sub[k]*subMul[k];
int *sub2ind_init( const int*siz, const int nd ) {
int *sub2ind_init( const mwSize*siz, const int nd ) {
int i, *subMul;
subMul = (int*) mxCalloc( nd, sizeof(int));
subMul[0] = 1; for(i=1; i<nd; i++ ) subMul[i]=subMul[i-1]*siz[i-1];
return subMul;
}

/* construct the nd dimensional histogram */
void histcND( double* h, double* A, double* wtMask, int n, int nd, double**edges, int* nBins ) {
void histcND( double* h, double* A, double* wtMask, int n, int nd, double**edges, mwSize* nBins ) {
int i, j, k, inbounds; int *subMul, *sub, ind;
sub = (int *) mxMalloc( nd * sizeof(int) );
subMul = sub2ind_init( nBins, nd );
Expand All @@ -67,7 +67,9 @@ void histcND( double* h, double* A, double* wtMask, int n, int nd, double**edges
}

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
int i, n, nd, *nBins; double *A, *wtMask, **edges, *h;
int i, n, nd;
mwSize *nBins;
double *A, *wtMask, **edges, *h;

/* Error checking on arguments PRHS=[A1, wtMask, edges1, edges2, ...]; PLHS=[h] */
if( nrhs < 3) mexErrMsgTxt("At least three input arguments required.");
Expand All @@ -83,7 +85,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
/* extract arguments */
A = mxGetPr(prhs[0]);
wtMask = mxGetPr(prhs[1]);
nBins = (int*) mxMalloc( nd * sizeof(int) );
nBins = (mwSize*) mxMalloc( nd * sizeof(int) );
for( i=0; i<nd; i++) nBins[i] = mxGetN(prhs[i+2])-1;
edges = (double**) mxMalloc( nd * sizeof(double*) );
for( i=0; i<nd; i++) edges[i] = mxGetPr(prhs[i+2]);
Expand Down
3 changes: 2 additions & 1 deletion images/private/imtransform2_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ void homogToInds(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {

void applyTransform(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
/* J=applyTransform(I,rs,cs,is,flag); */
int flag, *nsI, nsJ[3], areaJ, areaI, nDims, i, k, id, *is;
mwSize nsJ[3];
int flag, *nsI, areaJ, areaI, nDims, i, k, id, *is;
double *I, *J, *I1, *J1, *rs, *cs, wr, wc, wrc, r, c;

/* extract inputs */
Expand Down
3 changes: 2 additions & 1 deletion videos/private/ktComputeW_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ void ktComputeW( double* w, uchar* B, double* q, double *p, int n, int nBits ) {

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
/* Declare variables. */
int n, nBits, dims[2];
int n, nBits;
mwSize dims[2];
uchar *B; double *q, *p, *w;

/* PRHS=[B, q, p, nBits]; PLHS=[w] */
Expand Down
4 changes: 3 additions & 1 deletion videos/private/ktHistcRgb_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ void ktHistcRgb( double* h, uchar* B, double* wtMask, int n, int nBits ) {
}

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
int n, nBits, dims[3]; uchar *B; double *wtMask, *h;
int n, nBits;
mwSize dims[3];
uchar *B; double *wtMask, *h;

/* PRHS=[B, wtMask, nBits]; PLHS=[h] */
if( nrhs != 3) mexErrMsgTxt("Three input arguments required.");
Expand Down