例程:variation_model_illumination.hdev
* This example demonstrates the print inspection using
* a variation model. The variation model is trained
* using a single model image. Before applying the print inspection,
* the images are scaled to the same gray value range like the model.
*
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, 12, 'courier', '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', 5, 10, 'green', 'false')
* 创建形状模型
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)
* 对XLD轮廓(contour)进行一个任意二维仿射变换。
affine_trans_contour_xld (ModelContours, ModelContoursAffinTrans, HomMat2DTr