原图
建模图
识别图
代码
封装函数
***** dev_display_ncc_matching_results (ModelIds, ClassColors, Row, Column, Angle, Model)
*
NumMatches := |Row|
if (NumMatches > 0)
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_ncc_model_region (ModelRegion, ModelID[Index])
gen_contour_region_xld (ModelRegion, ModelContours, 'border_holes')
dev_set_color (Color[Index % |Color|])
for Match := 0 to NumMatches - 1 by 1
if (Index == Model[Match])
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_rotate (HomMat2DIdentity, Angle[Match], 0, 0, HomMat2DRotate)
hom_mat2d_translate (HomMat2DRotate, Row[Match], Column[Match], HomMat2DTranslate)
affine_trans_contour_xld (ModelContours, ContoursAffinTrans, HomMat2DTranslate)
dev_display (ContoursAffinTrans)
affine_trans_pixel (HomMat2DTranslate, 0, 0, RowTrans, ColTrans)
gen_cross_contour_xld (Cross, RowTrans, ColTrans, 6, Angle[Match])
dev_display (Cross)
endif
endfor
endfor
endif
return ()
***analyze_result (ModelIds, Model, ClassLabels, Text, TextColors)
CableTypeFound := false
for I := 0 to |ModelIds| - 1 by 1
* 类型1、2确定
if (I < 2)
if (CableTypeFound)
continue
endif
if (find(Model,I) != -1)
Text := 'Cable is of ' + ClassLabels[I]
TextColors := 'black'
CableTypeFound := true
else
Text := '没找到此类型'
TextColors := 'red'
endif
else
*标签1、2、3、4确定
if (find(Model,I) == -1)
Text := [Text,ClassLabels[I] + ' 标签没有 ']
TextColors := [TextColors,'red']
else
Text := [Text,ClassLabels[I] + ' 标签存在']
TextColors := [TextColors,'black']
endif
endif
endfor
return (