HObject 型ho_Image转BYTE型的pImage

示意代码如下:

1 GetImagePointer1(ho_Image, &hv_Pointer, &hv_Type, &hv_Width, &hv_Height);
2 BYTE *p=(BYTE *)hv_Pointer[0].L();
3 int height= (Hlong)hv_Height; 
4 int width = (Hlong)hv_Width;
5 memcpy(pImage,p,width*height*sizeof(BYTE));

 

转载于:https://www.cnblogs.com/youngxin/p/4220418.html

void CHalconAndHmiDlg::OnBnClickedButton2() { HObject ho_Image, ho_R, ho_G, ho_B, ho_Regions; HObject ho_ConnectedRegions, ho_SelectedRegions, ho_Cross; HObject ho_Rectangle; // Local control variables HTuple hv_ImageFiles, hv_Index, hv_Number, hv_Area; HTuple hv_Row, hv_Column, hv_Phi, hv_Length1, hv_Length2; ho_Image = HO_IMAGE; ListFiles("./按钮图片", ((HTuple("files").Append("follow_links")).Append("recursive")), &hv_ImageFiles); TupleRegexpSelect(hv_ImageFiles, (HTuple("\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$").Append("ignore_case")), &hv_ImageFiles); { HTuple end_val3 = (hv_ImageFiles.TupleLength()) - 1; HTuple step_val3 = 1; for (hv_Index = 0; hv_Index.Continue(end_val3, step_val3); hv_Index += step_val3) { ReadImage(&ho_Image, HTuple(hv_ImageFiles[hv_Index])); Decompose3(ho_Image, &ho_R, &ho_G, &ho_B); Threshold(ho_R, &ho_Regions, 140, 255); Connection(ho_Regions, &ho_ConnectedRegions); SelectShape(ho_ConnectedRegions, &ho_SelectedRegions, "area", "and", 600, 1000); CountObj(ho_SelectedRegions, &hv_Number); if (HDevWindowStack::IsOpen()) DispObj(ho_Image, HDevWindowStack::GetActive()); AreaCenter(ho_SelectedRegions, &hv_Area, &hv_Row, &hv_Column); GenCrossContourXld(&ho_Cross, hv_Row, hv_Column, 20, 0.785398); //根据筛选区域生成矩形框 SmallestRectangle2(ho_SelectedRegions, &hv_Row, &hv_Column, &hv_Phi, &hv_Length1, &hv_Length2); //根据矩形框的参数生成矩形框 GenRectangle2(&ho_Rectangle, hv_Row, hv_Column, hv_Phi, hv_Length1, hv_Length2); m_HalconWin.dispObj(ho_Image); m_HalconWin.setWndColor("red"); m_HalconWin.setLineWidth(2); m_HalconWin.dispObj(ho_Cross); m_HalconWin.setDraw( L"margin"); m_HalconWin.dispObj(ho_Rectangle); m_HalconWin.dispMessage("红色按钮数量:" + hv_Number, "image", 0, 0, "black", "true"); // stop(); only in hdevelop } } }
06-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值