zw版【转发·台湾nvp系列Delphi例程】HALCON color_fuses2

zw版【转发·台湾nvp系列Delphi例程】HALCON color_fuses2

 

 

 


procedure TForm1.Button1Click(Sender: TObject);
var
w, h : OleVariant;
hv_Fuse, hv_i : Integer;
begin
ho_Image.ReadImage(Tuple.TupleAdd('color/color_fuses_0', hv_Count));
w := ho_Image.GetImageSize(h);
hv_WH.SetPart(0, 0, h - 1, w - 1);
hv_WH.DispObj(ho_Image as IHObjectX);
hv_WH.SetTposition(12, 512);
hv_WH.WriteString(Tuple.TupleAdd(Tuple.TupleAdd('color/color_fuses0', hv_Count), '.png'));

ho_Red := ho_Image.Decompose3(ho_Green, ho_Blue);
ho_Hue := ho_Red.TransFromRgb(ho_Green, ho_Blue, ho_Saturation, ho_Intensity, 'hsv');
ho_Saturated := ho_Saturation.Threshold(60, 255);
ho_HueSaturated := ho_Hue.ReduceDomain(ho_Saturated);
for hv_Fuse := 0 to Tuple.TupleSub(Tuple.TupleLength(hv_FuseTypes), 1) do
begin
ho_CurrentFuse := ho_HueSaturated.Threshold(Tuple.TupleSelect(hv_HueRanges, Tuple.TupleMult(hv_Fuse, 2)), Tuple.TupleSelect(hv_HueRanges, Tuple.TupleAdd(Tuple.TupleMult(hv_Fuse, 2), 1)));
ho_CurrentFuseConn := ho_CurrentFuse.Connection;
ho_CurrentFuseFill:= ho_CurrentFuseConn.FillUp;
ho_CurrentFuseSel := ho_CurrentFuseFill.SelectShape('area', 'and', 6000, 20000);
hv_FuseArea := ho_CurrentFuseSel.AreaCenter(hv_Row1, hv_Column1);
hv_WH.SetColor('magenta');
for hv_i := 0 to Tuple.TupleSub(Tuple.TupleLength(hv_FuseArea), 1) do
begin
hv_WH.SetTposition(Tuple.TupleSelect(hv_Row1, hv_i), Tuple.TupleSelect(hv_Column1, hv_i));
hv_WH.WriteString(Tuple.TupleAdd(Tuple.TupleAdd(Tuple.TupleAdd(Tuple.TupleSelect(hv_FuseColors, hv_Fuse), ' '), Tuple.TupleSelect(hv_FuseTypes, hv_Fuse)), ' Ampere'));
end;
hv_WH.SetTposition(Tuple.TupleMult(24, Tuple.TupleAdd(hv_Fuse, 1)), 12);
hv_WH.SetColor('slate blue');
hv_WH.WriteString(Tuple.TupleAdd(Tuple.TupleAdd(Tuple.TupleSelect(hv_FuseColors, hv_Fuse), ' Fuses: '), Tuple.TupleLength(hv_FuseArea)));
end;
hv_Count := hv_Count + 1;
if (hv_Count > 4) then
hv_Count := 0;
end;

转载于:https://www.cnblogs.com/ziwang/p/4851175.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值