halcon两区域的有无角度要求的最小距离

1.不带角度的两区域的最小距离

read_image (Image151325S132787556058004751, 'C:/Users/Administrator/Desktop/测试.png')
draw_rectangle2_mod (3600, 308, 413, 1.54, 165, 75, Row1, Column1, Phi1, Length11, Length21)
gen_rectangle2 (Rectangle, Row1, Column1, Phi1, Length11, Length21)
reduce_domain (Image151325S132787556058004751, Rectangle, ImageReduced)
dev_close_window ()
dev_open_window (Row1, Column1, 512, 512, 'black', WindowHandle)
dev_display (ImageReduced)
*二值化处理
threshold (ImageReduced, Region, 0, 100)
*分割
connection (Region, ConnectedRegions)
select_obj (ConnectedRegions, ObjectSelected1, 1)
select_obj (ConnectedRegions, ObjectSelected2, 2)
*求两个区域的最短距离
distance_rr_min (ObjectSelected1, ObjectSelected2, MinDistance, Row11, Column11, Row2, Column2)
dev_set_color ('black')
gen_cross_contour_xld (Cross1, Row11, Column11, 20, 0)
gen_cross_contour_xld (Cross2, Row2, Column2, 20, 0)
gen_contour_polygon_xld (Contour, [Row11,Row2], [Column11,Column2])

2.带角度的两区域最小距离

read_image (Image151325S132787556058004751, 'C:/Users/Administrator/Desktop/测试.png')
draw_rectangle2_mod (3600, 308, 413, 1.54, 165, 75, Row1, Column1, Phi1, Length11, Length21)
gen_rectangle2 (Rectangle, Row1, Column1, Phi1, Length11, Length21)
reduce_domain (Image151325S132787556058004751, Rectangle, ImageReduced)
dev_close_window ()
dev_open_window (Row1, Column1, 512, 512, 'black', WindowHandle)
dev_display (ImageReduced)
*二值化处理
threshold (ImageReduced, Region, 0, 100)
*分割
connection (Region, ConnectedRegions)
select_obj (ConnectedRegions, ObjectSelected1, 1)
select_obj (ConnectedRegions, ObjectSelected2, 2)
*求两个区域的最短距离
distance_rr_min (ObjectSelected1, ObjectSelected2, MinDistance, Row11, Column11, Row2, Column2)
dev_set_color ('black')
gen_cross_contour_xld (Cross1, Row11, Column11, 20, 0)
gen_cross_contour_xld (Cross2, Row2, Column2, 20, 0)
gen_contour_polygon_xld (Contour, [Row11,Row2], [Column11,Column2])

*带有角度的最小距离
angle := 20
angle := (angle * 3.14) /360
Row12 := Row11 - 100*sin(angle)
Col12 := Column11 + 100*cos(angle)
gen_contour_polygon_xld (Contour, [Row11,Row12], [Column11,Col12])
distance_pl (Row2, Column2,Row11, Column11, Row12, Col12,  Distance)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱搞事的程小猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值