I am using OpenCV and I need to convert Iplimage->ID to char[ ] so that I can send it using TCP and then reconvert it to int on the server.
Here is the Iplimage header:
typedef struct _IplImage
{
int nSize;
int ID; //<--- ID of type INT
int nChannels;
int alphaChannel;
int depth;
char colorModel[4];
char channelSeq[4];
int dataOrder;
int origin;
int align;
int width;
int height;
struct _IplROI *roi;
struct _IplImage *maskROI;
void *imageId;
struct _IplTileInfo *tileInfo;
int imageSize;
char *imageData;
int widthStep;
int BorderMode[4];
int BorderConst[4];
char *imageDataOrigin;
}
IplImage;
this is my code:
char IDbuffer[10];
snprintf(IDbuffer,10,"%e",frame->ID);//where frame is of type IplImage*
printf("frame->ID= %a\n",IDbuffer);
and this what I got printed:
frame->ID= 0x0.0000000037d0cp-1022
even trying
printf("frame->ID= %a\n",frame->ID);
give me the same output.
Is this an integer format ?? and if yes how could I convert the char * of this format to an int??
Thanks in advance.
Use the
%dformat specifier sinceframe->IDis an integer:And then use the
%sformat specifier to print the buffer:There’s more information about the format specifiers in printf man page.