31.7、几何定位---实例二(不支持缩放)
例子一
read_image (Capture2013922111946109, 'C:/ww/Capture2013-9-22 11-19-46-109.jpg')
draw_rectangle2 (3600, Row, Column, Phi, Length1, Length2)
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
reduce_domain (Capture2013922111946109, Rectangle, ImageReduced)
create_shape_model (ImageReduced, 'auto', rad(-180), rad(360), 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID)
get_shape_model_contours (ModelContours, ModelID, 1)
find_shape_model (ImageReduced, ModelID, rad(-180), rad(360), 0.5, 1, 0.5, 'least_squares', 0, 0.9, Row1, Column1, Angle, Score)
dev_display_shape_matching_results (ModelID, 'red', Row1, Column1, Angle, 1, 1, 0)
* Code generated by Image Acquisition 01
list_files ('C:/ww', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima)$','ignore_case'], ImageFiles)
for Index := 0 to |ImageFiles| - 1 by 1
read_image (Image, ImageFiles[Index])
find_shape_model (Image, ModelID, rad(-180), rad(360), 0.5, 1, 0.5, 'least_squares', 0, 0.9, Row1, Column1, Angle, Score)
if (|Score|>0)
dev_display_shape_matching_results (ModelID, 'red', Row1, Column1, Angle, 1, 1, 0)
endif
endfor
clear_shape_model (ModelID)
ModelID:=-1
注:可以通过gen_cross_contour_xld算子产生一个十字架标注中心
例子二
read_image (Image1, 'C:/1.BMP')
dev_set_draw ('margin')
draw_rectangle2 (3600, Row, Column, Phi, Length1, Length2)
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
reduce_domain (Image1, Rectangle, ImageReduced)
*rad(-90), rad(180)----> rad(-180), rad(360)
create_shape_model (ImageReduced, 'auto', rad(-180), rad(360), 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID)
get_shape_model_contours (ModelContours, ModelID, 1)
find_shape_model (Image1, ModelID, rad(-180), rad(360), 0.5, 30, 0.5, 'least_squares', 0, 0.9, Row1, Column1, Angle, Score)
if(|Score|>0)
dev_display_shape_matching_results (ModelID, 'red', Row1, Column1, Angle, 1, 1, 0)
endif
clear_shape_model (ModelID)