话不多说直接看代码
*在创建模版模版匹配之前要先把要用的模版图片给单独的抠出来
*获取想要创建模版的图像后进行创建模版
create_scaled_shape_model (ImageReduced, 'auto', rad(0), rad(360), 'auto', 0.9, 1.1, 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID)
*获取模版的坐标 其中RegionDilation为模版图片
area_center (RegionDilation, Area, Row, Column)
get_shape_model_contours (ModelContours, ModelID, 1)
*把轮廓进行平移旋转之类的 变成一个矩阵
vector_angle_to_rigid (0, 0, 0, Row, Column, 0, HomMat2D)
*把矩阵显示到窗口中
affine_trans_contour_xld (ModelContours, ContoursAffineTrans, HomMat2D)
*在上面以及把模版创建好了,下面进行寻找
find_scaled_shape_model (ImageMean2, ModelID, rad(0), rad(360), 0.9, 1.1, 0.5, 0, 0.5, 'least_squares', 0, 0.9, Row1, Column1, Angle1, Scale, Score)
*找到后显示
*先创建图片的矩阵
hom_mat2d_identity (HomMat2DIdentity)
*平移
hom_mat2d_translate (HomMat2DIdentity, Row1, Column1, HomMat2DTranslate)
*旋转
hom_mat2d_rotate (HomMat2DTranslate, Angle1, Row1, Column1, HomMat2DRotate)
*缩放
hom_mat2d_scale (HomMat2DRotate, Scale, Scale, Row1, Column1, HomMat2DScale)
*显示
affine_trans_contour_xld (ModelContours, ContoursAffineTrans1, HomMat2DScale)