*此示例演示了使用变体模型的打印检查。 *变异模型使用单个模型图像进行训练。在应用打印检测之前,图像将缩放到与模型相同的灰度值范围。 dev_update_off () dev_close_window () * * Read model image and init visualization *读取模型图像并初始化可视化 read_image (ModelImage, 'cap_illumination/cap_illumination_01') get_image_size (ModelImage, Width, Height) dev_open_window (0, 0, Width / 2, Height / 2, 'black', WindowHandle) set_display_font (WindowHandle, 14, 'mono', 'true', 'false') * * Segment model region *分割模型区域 dev_display (ModelImage) get_model_region (ModelImage, RegionROI, ImageReduced) area_center (RegionROI, Area, RowModel, ColumnModel) dev_set_draw ('margin') dev_set_color ('green') dev_display (RegionROI) * * Create model for shape-based-matching *创建模型 disp_message (WindowHandle, 'Model generation...', 'window', 12, 12, 'black', 'true') create_scaled_shape_model (ImageReduced, 'auto', 0, rad(360), 'auto', 0.8, 1.2, 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID) get_shape_model_contours (ModelContours, ModelID, 1) * Transform model contours from the original position for visualization *从原始位置变换模型轮廓以进行可视化 hom_mat2d_identity (HomMat2DIdentity) hom_mat2d_translate (HomMat2DIdentity, RowModel, ColumnModel, HomMat2DTranslate) affine_trans_contour_xld (ModelContours, ModelContoursAffineTrans, HomMat2DTranslate) * * Create variation model for print inspection *创建用于打印检测的变异模型 create_variation_model (Width, Height, 'byte', 'direct', VariationID) * Generate variation image sobel_amp (ModelImage, VarImage, 'sum_abs', 5) prepare_direct_variation_model (ModelImage, VarImage, VariationID, [20,25], [1.6,1.6]) * * Get gray value range of the variation model *获取变异模型的灰度值范围 get_grayval_range (ModelImage, RegionROI, RegionForeground, RegionBackground, BackgroundGVModel, ForegroundGVModel) * * Perform print inspection *执行印刷检测 for I := 1 to 9 by 1 read_image (rImage, 'cap_illumination/cap_illumination_' + I$'.2') inspect_cap (rImage, RegionROI, WindowHandle, ModelID, VariationID, RowModel, ColumnModel, BackgroundGVModel, ForegroundGVModel) if (I < 9) disp_continue_message (WindowHandle, 'black', 'true') stop () endif endfor * clear_shape_model (ModelID) clear_variation_model (VariationID)
标签:印刷,检测,模型,dev,variation,auto,视觉,model,ModelImage From: https://www.cnblogs.com/echo-efun/p/18073294