图像进行缺陷检测
*检测所有测试图像上的纹理缺陷。
NumImages := 7
for Index := 1 to NumImages by 1
read_image (TestImage, 'carpet/carpet_' + Index$'02')
*
*检测当前图像
apply_texture_inspection_model (TestImage, NoveltyRegion, TextureInspectionModel, TextureInspectionResultID)
*得到新颖性图像和区域
get_texture_inspection_result_object (NovScoreImage, TextureInspectionResultID, 'novelty_score_image')
get_texture_inspection_result_object (NovRegion, TextureInspectionResultID, 'novelty_region')
* 显示单个金字塔层数的结果
count_obj (NovScoreImage, Number)
for Level := 1 to Number by 1
CurrentWindow := WindowHandles[Level - 1]
dev_set_window (CurrentWindow)
dev_clear_window ()
select_obj (NovScoreImage, NovScoreImageL, Level)
select_obj (NovRegion, NovRegionL, Level)
get_image_size (NovScoreImageL, Width, Height)
dev_set_part (0, 0, Height - 1, Width - 1)
dev_display (NovScoreImageL)
Legend := 'Novelty region (level ' + Levels[Level - 1] + ')'
dev_set_color ('red')
大林上位机机器视觉,_常州电工培训_常州PLC培训_常州机器视觉培训_常州上位机培训_常州工业机器人培训,最适合电工及plc编程人员学习的上位机机器视觉课程 大林老师:15861139266(微信同号)
dev_set_line_width (2)
*
dev_display (NovRegionL)
dev_disp_text (['Novelty score image (level ' + Levels[Level - 1] + ')','Novelty threshold: ' + NoveltyThreshold[Level - 1]$'.1f'], 'window', 12, 12, 'black', [], [])
dev_disp_text (Legend, 'window', WindowHeight - 50, 12, ['red','white'], ['box_color','shadow'], ['black','false'])
endfor
* 显示结果
dev_set_window (WindowHandle4)
dev_display (TestImage)
dev_set_line_width (2)
dev_set_color ('red')
dev_display (NoveltyRegion)
area_center (NoveltyRegion, Area, Row, Column)
if (Area > 100)
dev_disp_text ('Not OK', 'window', 12, 12, 'white', 'box_color', 'red')
else
dev_disp_text ('OK', 'window', 12, 12, 'white', 'box_color', 'forest green')
endif
if (Index < NumImages)
dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', [], [])
stop ()
endif
endfor