halcon求区域角度

read_image (Image, ‘C:/Users/Public/Documents/MVTec/HALCON-12.0/examples/images/clip.png’)
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, ‘black’, WindowHandle)
dev_display (Image)
dev_set_color (‘black’)
RowA1:=255
ColA1:=10
RowA2:=255
ColA2:=500
disp_line (WindowHandle, RowA1, ColA1, RowA2, ColA2)
RowB1:=255
ColB1:=255
for i:=1 to 360 by 1
RowB2:=255+sin(rad(i))*200
ColB2:=255+cos(rad(i))*200
disp_line (WindowHandle, RowB1, ColB1, RowB2, ColB2)
gen_region_line (RegionLines, RowB1, ColB1, RowB2, ColB2)
*计算区域的方向-3.14~6.28
orientation_region (RegionLines, Phi)
*计算直线的方向-1.57~1.57
line_orientation (RowB1, ColB1, RowB2, ColB2, Phi1)
*计算线段的中心,长度和方向
line_position (RowB1, ColB1, RowB2, ColB2, RowCenter, ColCenter, Length, Phi2)
*计算两直线的夹角0~3.14
angle_ll ( RowA1, ColA1, RowA2, ColA2, RowB1, ColB1, RowB2, ColB2, Angle)

endfor
stop ()

在这里插入图片描述
threshold (Image, Dark, 0, 70)
connection (Dark, ConnectedRegions)
*dev_clear_window ()
select_shape (ConnectedRegions, SelectedRegions, ‘area’, ‘and’, 5000, 10000)
orientation_region (SelectedRegions, Phi3)
area_center (SelectedRegions, Area, Row, Column)
dev_set_color (‘red’)
dev_set_draw (‘margin’)
dev_set_line_width (7)
length :=80
disp_arrow (WindowHandle, Row, Column, Row+cos((Phi3+1.57))*length, Column+sin((Phi3+1.57))*length, 3)

在这里插入图片描述

  • 3
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值