参考halcon案例check_blister
1、检测
*加载模板图片
dev_close_window ()
dev_update_off ()
read_image (ImageOrig, 'blister/blister_reference')
dev_open_window_fit_image (ImageOrig, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
dev_set_draw ('margin')
dev_set_line_width (3)
dev_display(ImageOrig)
*
*提取底板->转正
access_channel (ImageOrig, Image, 1)
threshold (Image, Regions, 79, 255)
area_center (Regions, Area, Row, Column)
orientation_region (Regions, Phi)
vector_angle_to_rigid (Row, Column, Phi, Row, Column, 0, HomMat2D)
affine_trans_region (Regions, RegionAffineTrans, HomMat2D, 'constant')
*以底板为基准 在底板区域上创建网格提取工具ROI
gen_empty_obj (Chambers)
for I := 0 to 4 by 1
Row := 88 + I * 70
for J := 0 to 2 by 1
Column := 163 + J * 150
gen_rectangle2 (Rectangle, Row, Column, 0, 64, 30)
concat_obj (Chambers, Rectangle, Chambers)
endf