HALCON_根据XLD轮廓 把图像摆正

*求取图形的角度,并且进行旋转,生成旋转矩阵
*在RegionErosion  这个的基础上

reduce_domain(ImageScaled,  SelectedRegion, ImageErosion)
dev_clear_window()
dev_display(ImageErosion)
dev_set_draw('margin')

gen_contour_region_xld (ImageErosion, Contours, 'border')
dev_set_color('red')
dev_display(Contours)

*截取区域,求取线段的角度
stop ()
*注意参数 'false'  ,旋转不闭合
**裁剪XLD轮廓

draw_rectangle1 (3600, Row1, Column1, Row2, Column2)
***裁剪出XLD轮廓
crop_contours_xld(Contours, CroppedContours1, Row1, Column1, Row2, Column2, 'false')

** 裁剪出XLD轮廓CroppedContours1
** 输出结果为拟合出来后直线的起点和终点

fit_line_contour_xld(CroppedContours1, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin,\
                     RowEnd, ColEnd, Nr, Nc, Dist)


*计算出来的角度是弧度值  RowEnd小的数值放在前面 作为起点
*直线与X轴的夹角
if(RowBegin > RowEnd)
    angle_lx(  RowEnd, ColEnd, RowBegin, ColBegin, Angle)
else
    angle_lx( RowBegin, ColBegin, RowEnd, ColEnd, Angle)
endif


tuple_deg(Angle, Deg)
gen_contour_polygon_xld(C
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值