35.4、仿射变换实例一
目标:通过仿射变换根据定位find_***_model输出的参数把模板轮廓贴合到实时图像上
read_image (Image11, '1-1.bmp')
dev_set_draw ('margin')
draw_rectangle1 (3600, Row1, Column1, Row2, Column2)
gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
reduce_domain (Image11, 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 (Image11, ModelID, rad(-180), rad(360), 0.5, 1, 0.5, 'least_squares', 0, 0.9, Row, Column, Angle, Score)
if (|Score|>0)
*方法一
* dev_display_shape_matching_results (ModelID, 'red', Row, Column, Angle, 1, 1, 0)
*方法二
* hom_mat2d_identity (HomMat2DIdentity)
* hom_mat2d_scale (HomMat2DIdentity, 1, 1, 0, 0, HomMat2DScale)
* hom_mat2d_rotate (HomMat2DScale, Angle, 0, 0, HomMat2DRotate)
* hom_mat2d_translate (HomMat2DRotate, Row, Column, HomMat2DTranslate)
* affine_trans_contour_xld (ModelContours, ContoursAffinTrans, HomMat2DTranslate)
* dev_display (ContoursAffinTrans)
*方法三
vector_angle_to_rigid (0, 0, 0, Row, Column, Angle, HomMat2D)
hom_mat2d_scale(HomMat2D, 1, 1, 0, 0, HomMat2DScale1)
affine_trans_contour_xld (ModelContours, ContoursAffinTrans1, HomMat2DScale1)
endif