Mat转Hobject:
void Mat_2_HImage(Mat img, Hobject & HImage)
{
int height = img.rows;
int width = img.cols;
uchar *dataGray = new uchar[width*height];
for(int i = 0; i<height; i++)
{
memcpy(dataGray + width*i,img.data + img.step*i, width);
}
gen_image1(&HImage,"byte",width,height,(Hlong)(dataGray));
delete[] dataGray;
}
Hobject转Mat:
void HImage_2_Mat(Hobject *HImage, Mat *dst)
{
HTuple hv_Pointer, hv_byte;
int W = 0, H = 0;
cout<<"get_image_pointer1 before"<<endl;
uchar* pdata =NULL;
char type[128] ={0};
Hlong width =0;
Hlong height =0;
Herror err_ =get_image_pointer1(*HImage, (Hlong*)&pdata, type, &width, &height);
W =width;
H =height;
memcpy(dst->data, pdata, W*H);
}