总结:
(1)inspect_shape_model(Image : ModelImages, ModelRegions : NumLevels, Contrast : ) 用于确定create_shape_model的Contrast和NumLevels参数,并显示图像效果,因此一般在create_shape_model之前使用。
(2)create_shape_model : 创建模板,其中参数MinContrast来过滤find_shape_models中找到的目标的中对比度小于阈值的目标,而使其忽略匹配
(3)get_shape_model_contours:用于观察create_shape_model模板的轮廓,生成位置在0点
(4)find_shape_model:查找模板,如果NumLevels参数设置为0则使用create_shape_model 中设置的NumLevels值。
(5)clear_shape_model (ModelID):关闭模板句柄
(6)dev_display_shape_matching_results:外部函数,展示所有查找到的目标的轮廓,但仅显示在底层金字塔的图像
(7)get_hom_mat2d_from_matching_result:外部函数,获取从模板轮廓初始生成位置移动到定位目标位置的变换矩阵
(8)write_shape_model:将模板写入文件
(9)其他:
read_shape_model;
create_scaled_shape_model;
create_shape_model_xld;
create_scaled_shape_model_xld;
set_shape_model_param;
get_shape_model_param;
find_shape_models;
find_scaled_shape_models;
案例一、align_measurements
* ------------------------------------------------------------------------------------------------
* This example program uses shape-based matching to align ROIs for the measure
* tool, which then inspects individual razor blades.
* The program can be run in two modes: (1) with the full affine transformation
* (2) using translate_measure
* Modify the next line to switch between the modes.
USING_TRANSLATE_MEASURE := 0
* ------------------------------------------------------------------------------------------------
* general configuration of HDevelopS
dev_update_window ('off')
* image acquisition and window size
read_image (ModelImage, 'razors1')
get_image_pointer1 (ModelImage, Pointer, Type, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'white', WindowHandle)
dev_set_part (0, 0, Height - 1, Width - 1)
dev_display (ModelImage)
* colors and other settings for the visualization
dev_set_color ('cyan')
dev_set_draw ('margin')
dev_set_line_width (2)
stop ()
* ------------------- start of the application ----------------
* -> select the model object
Row1 := 46
Column1 := 57
Row2 := 79
Column2 := 94
gen_rectangle1 (ROIPart1, Row1, Column1, Row2, Column2)
gen_rectangle1 (ROIPart2, Row1 + 364, Column1 + 13, Row2 + 364, Column2 + 13)
union2 (ROIPart1, ROIPart2, ModelROI)
area_center (ModelROI, Area, CenterROIRow, CenterROI