Halcon 模板匹配+跟随定位
图片组下载地址:这里
* 读取模板图片
dev_close_window ()
read_image (Image, './image/board-01.png')
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
dev_display (Image)
* 设置绘制方式
dev_set_draw ('margin')
* 获取用户绘制 模板区域 矩形
* draw_rectangle2 (WindowHandle, Row, Column, Phi, Length1, Length2)
Row:=273.0
Column:=236.0
Phi:=-0.0227234
Length1:=44.0114
Length2:=11.7015
* 生成矩形
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
reduce_domain (Image, Rectangle, ImageReduced)
* 创建形状模型
create_shape_model (ImageReduced, 'auto', 0, rad(360), rad(1), 'auto', 'use_polarity', 'auto', 'auto', ModelID)
* 搜索模板
find_shape_model (ImageReduced, ModelID, 0, rad(360), 0.4, 1, 0, 'least_squares', 0, 0.9, Row1, Column1, Angle, Score)
* 获取模板
get_shape_model_contours (ShapeModel, ModelID, 1)
stop()
***********************************定义测试窗口***************<