【每天一个Halcon例程】20240130

halcon例程:point_line_to_hom_mat2d.hdev 

* This example program shows how to align images based on point-to-line
* correspondences. HALCON's metrology model and point_line_to_hom_mat2d are used
* to detect the position and angle of the print in the images. The found position
* and angle are used to transform the images to the reference position (the
* position of the print in the first image in this example).
* From the aligned images of correct prints, a variation model is constructed.
* This variation model is then used to check and classify images of correct and
* incorrect prints.
dev_update_off ()
read_image (Image, 'pen/pen-01')//读入图像
get_image_size (Image, Width, Height)//获得图像宽高
dev_close_window ()//关闭窗口
dev_open_window (0, Width + 12, Width, Height, 'black', WindowHandle)
dev_open_window (0, 0, Width, Height, 'black', WindowHandleAlign)//打开窗口
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
set_display_font (WindowHandleAlign, 14, 'mono', 'true', 'false')//设置显示文本的字体大小和文本类型
dev_set_color ('red')//设置窗口显示的object对象的颜色
dev_display (Image)//显示图像
* Note: the checking of the print will be restricted to the region of the clip.
* Sometimes the print is also in an incorrect position of the clip.  This will lead
* to erroneous regions at the top or bottom border of the clip and hence can
* be detected easily.
threshold (Image, Region, 100, 255)//图像阈值分割
fill_up (Region, RegionFillUp)//填充孔洞
erosion_rectangle1 (RegionFillUp, RegionROI, 1, 15)//腐蚀
* Set up the metrology model with four lines.  Four lines are used since this is
* the minimum number of point-to-line correspondences that results in a unique rigid
* transformation.
create_metrology_model (MetrologyHandle)//创建测量模型句柄
set_metrology_model_image_size (MetrologyHandle, Width, Height)//设置要测量的图像的大小,必须调用
add_metrology_object_line_measure (MetrologyHandle, [208,137,213,90], [49,327,139,307], [100,201,214,89], [82,318,56,375], 40, 5, 1, 30, ['measure_transition','min_score'], ['negative',0.5], Index)//添加直线测量对象到模型。
set_metrology_object_param (MetrologyHandle, 'all', 'num_measures', 50)//设置测量模型参数
* Apply the metrology model to the reference image and read out the results.
apply_
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值