接着上个月写的一篇发送IplImage结构的来说,因为Socket发送结构的部分上一篇写过了,所以不再多写了。
CvMat的结构如下:
typedef struct CvMat
{
int type;
int step;
/* for internal use only */
int* refcount;
int hdr_refcount;
union
{
uchar* ptr;
short* s;
int* i;
float* fl;
double* db;
} data;
#ifdef __cplusplus
union
{
int rows;
int height;
};
union
{
int cols;
int width;
};
#else
int rows;
int cols;
#endif
}
CvMat;
这里其实和传送IpIlmage一样,需要先传送CvMat的header。需要特别说明的是,CvMat中的矩阵元素的类型和IplImage是不一样的,有可能是uchar,short,float或者double。所以在接受的过程中可能需要知道它的type。使用以下代码:
int a_type = CV_MAT_TYPE(mat->type);
CV_MAT_TYPE是core文件夹下的types_c.h里定义的一个宏。用这个