K
kkirtac
Hi, i have a void pointer and i cast it to an appropriate known type
before using. The types which i cast this void* to are, from the
Intel's open source computer vision library. Here is my piece of non-
working code:
CvMat *rowVect = cvCreateMat(1,nfeatures,CV_MAKETYPE(images[0]-
cvReshape( images[0], rowVect, 0, 1 ); //vectorize the image; readrow
is a 1xN matrix(vector)
void* ptr;
switch (images[0]->depth)
{
case IPL_DEPTH_8U :
ptr = (unsigned char *) rowVect->data.ptr ; //ptr is defined as an
unsigned char pointer
break; //
data is 'union' type
case IPL_DEPTH_8S :
ptr = (signed char *) rowVect->data.ptr ;
break;
case IPL_DEPTH_16S :
ptr = (unsigned short *) rowVect->data.ptr ;
break;
case IPL_DEPTH_32S :
ptr = (int *) rowVect->data.i ; // i is defined as an int pointer
break;
case IPL_DEPTH _32F :
ptr = (float *) rowVect->data.fl ; // fl is defined as float
pointer
break;
case IPL_DEPTH_64F :
ptr = (double *) rowVect->data.db ; // db is a double
break;
}
int i=0, k;
while(i<nsamples)
{
cvReshape( images, readrow, 0, 1 );
for(k=0; k<nfeatures; k++)
Data->data.db[i*(Data->width)+k] = (double) ptr[k]; // errors occur
here
//fill the Data matrix
i++;
}
Error : 1) 'void*' : unknown size
2) 'typecast' : cannot convert from void to double
i m sorry if it is illegal to point a 3rd party library here, but it
has also been written in standard C. But my problem is a pure "C
language" problem i think. I cast a void pointer but then i cant use
it...
Regards
before using. The types which i cast this void* to are, from the
Intel's open source computer vision library. Here is my piece of non-
working code:
CvMat *rowVect = cvCreateMat(1,nfeatures,CV_MAKETYPE(images[0]-
//rowVect is a pointer to CvMat typedepth,1));
cvReshape( images[0], rowVect, 0, 1 ); //vectorize the image; readrow
is a 1xN matrix(vector)
void* ptr;
switch (images[0]->depth)
{
case IPL_DEPTH_8U :
ptr = (unsigned char *) rowVect->data.ptr ; //ptr is defined as an
unsigned char pointer
break; //
data is 'union' type
case IPL_DEPTH_8S :
ptr = (signed char *) rowVect->data.ptr ;
break;
case IPL_DEPTH_16S :
ptr = (unsigned short *) rowVect->data.ptr ;
break;
case IPL_DEPTH_32S :
ptr = (int *) rowVect->data.i ; // i is defined as an int pointer
break;
case IPL_DEPTH _32F :
ptr = (float *) rowVect->data.fl ; // fl is defined as float
pointer
break;
case IPL_DEPTH_64F :
ptr = (double *) rowVect->data.db ; // db is a double
break;
}
int i=0, k;
while(i<nsamples)
{
cvReshape( images, readrow, 0, 1 );
for(k=0; k<nfeatures; k++)
Data->data.db[i*(Data->width)+k] = (double) ptr[k]; // errors occur
here
//fill the Data matrix
i++;
}
Error : 1) 'void*' : unknown size
2) 'typecast' : cannot convert from void to double
i m sorry if it is illegal to point a 3rd party library here, but it
has also been written in standard C. But my problem is a pure "C
language" problem i think. I cast a void pointer but then i cant use
it...
Regards