
用halcon形状模版匹配,红色矩形框是搜索范围ROI 矩形框中间的是我训练的模版,按理说应该只会匹配到ROI中中间的那个 为什么会搜到搜索区域之外的部分,而且匹配分数还很高,这个设置set_system ('border_shape_models', 'false'),不是可以决定是否可以匹配出图像边界的地方吗?
set_system ('border_shape_models', 'false')*该句设置了无效
read_image (Image, 'P6')
rgb1_to_gray (Image, GrayImage)
gen_rectangle1 (ROI_0, 155.824, 338.831, 821.65, 959.427)
reduce_domain (GrayImage, ROI_0, ImageReduced)
threshold (ImageReduced, Region, 128, 255)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 108833, 200000)
fill_up (SelectedRegions, RegionFillUp)
gen_contour_region_xld (RegionFillUp, Contours, 'border')
*create_ncc_model (ImageReduced, 'auto', -0.39, 0.79, 'auto', 'use_polarity', ModelID)
create_shape_model_xld (Contours, 'auto', -0.39, 0.79, 'auto', 'auto', 'ignore_local_polarity', 5, ModelID)
determine_shape_model_params (ImageReduced, 'auto', -0.39, 0.79, 0.9, 1.1, 'auto', 'use_polarity', 'auto', 'auto', 'all', ParameterName, ParameterValue)
inspect_shape_model (ImageReduced, ModelImages, ModelRegions, 7, 60)
dev_clear_window ()
read_image (Image1, 'P6')
draw_rectangle1 (3600, Row1, Column1, Row2, Column2)
gen_rectangle1 (ROI_0, Row1, Column1, Row2, Column2)
reduce_domain (Image1, ROI_0, ImageReduced1)
*find_ncc_model (ImageReduced1, ModelID, -0.39, 0.78, 0.8, 1, 0.5, 'true', 0, Row, Column, Angle, Score)
find_shape_model (ImageReduced1, ModelID, -0.39, 0.78, 0.8, 1, 0.5, 'least_squares', 4, 0.9, Row, Column, Angle, Score)
dev_display_shape_matching_results (ModelID, 'red', Row, Column, Angle, 1, 1, 0)
disp_message (3600, 'Score:' + Score, 'window', 15, 15, 'red', 'false')