31.7.1、改进dev_display_shape_matching_results
dev_display_shape_matching_results使用于显示定位结果的,但它只是把轮廓区域显示出来,并没有变量来保存这个轮廓。
改进方法:修改函数内部让内部保存再输出变量。
dev_display_shape_matching_results函数原型
* This procedure displays the results of Shape-Based Matching.
*
NumMatches := |Row|
if (NumMatches>0)
if (|ScaleR|=1)
tuple_gen_const (NumMatches, ScaleR, ScaleR)
endif
if (|ScaleC|=1)
tuple_gen_const (NumMatches, ScaleC, ScaleC)
endif
if (|Model|=0)
tuple_gen_const (NumMatches, 0, Model)
elseif (|Model|=1)
tuple_gen_const (NumMatches, Model, Model)
endif
for Index := 0 to |ModelID|-1 by 1
get_shape_model_contours (ModelContours, ModelID[Index], 1)
dev_set_color (Color[Index%|Color|])
for Match := 0 to NumMatches-1 by 1
if (Index=Model[Match])
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_scale (HomMat2DIdentity, ScaleR[Match], ScaleC[Match], 0, 0, HomMat2DScale)
hom_mat2d_rotate (HomMat2DScale, Angle[Match], 0, 0, HomMat2DRotate)
hom_mat2d_translate (HomMat2DRotate, Row[Match], Column[Match], HomMat2DTranslate)
affine_trans_contour_xld (ModelContours, ContoursAffinTrans, HomMat2DTranslate)
dev_display (ContoursAffinTrans)
endif
endfor
endfor
endif
return ()
修改后
* This procedure displays the results of Shape-Based Matching.
*
NumMatches := |Row|
if (NumMatches>0)
if (|ScaleR|=1)
tuple_gen_const (NumMatches, ScaleR, ScaleR)
endif
if (|ScaleC|=1)
tuple_gen_const (NumMatches, ScaleC, ScaleC)
endif
if (|Model|=0)
tuple_gen_const (NumMatches, 0, Model)
elseif (|Model|=1)
tuple_gen_const (NumMatches, Model, Model)
endif
for Index := 0 to |ModelID|-1 by 1
get_shape_model_contours (ModelContours, ModelID[Index], 1)
dev_set_color (Color[Index%|Color|])
for Match := 0 to NumMatches-1 by 1
if (Index=Model[Match])
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_scale (HomMat2DIdentity, ScaleR[Match], ScaleC[Match], 0, 0, HomMat2DScale)
hom_mat2d_rotate (HomMat2DScale, Angle[Match], 0, 0, HomMat2DRotate)
hom_mat2d_translate (HomMat2DRotate, Row[Match], Column[Match], HomMat2DTranslate)
*******************************************************************************
affine_trans_contour_xld (ModelContours, Out_countours, HomMat2DTranslate)
dev_display (Out_countours)
*******************************************************************************
endif
endfor
endfor
endif
return ()