|
- *
- * Matching 01: ************************************************
- * Matching 01: BEGIN of generated code for model initialization
- * Matching 01: ************************************************
- set_system ('border_shape_models', 'false')
- *
- * Matching 01: Obtain the model image
- read_image (Image, 'C:/Users/thinger.cn/Desktop/第5章:Halcon快速入门及联合编程/5.24 Halcon创建模板参数说明/套环/1.BMP')
- *
- * Matching 01: Build the ROI from basic regions
- gen_circle (ModelRegion, 233.558, 483.037, 35.9314)
- *
- * Matching 01: Reduce the model template
- reduce_domain (Image, ModelRegion, TemplateImage)
- *
- * Matching 01: Create the shape model
- create_shape_model (TemplateImage, 3, rad(0), rad(360), rad(3.4478), ['none','no_pregeneration'], 'use_polarity', [10,11,4], 4, ModelID)
- *
- * Matching 01: Get the model contour for transforming it later into the image
- get_shape_model_contours (ModelContours, ModelID, 1)
- *
- * Matching 01: Get the reference position
- area_center (ModelRegion, ModelRegionArea, RefRow, RefColumn)
- *输出仿射变换矩阵 原始点X 原始点Y 原始点A 目标点X 目标点Y 目标点A 支持平移和旋转
- vector_angle_to_rigid (0, 0, 0, RefRow, RefColumn, 0, HomMat2D)
- *对Xld进行仿射变换
- affine_trans_contour_xld (ModelContours, TransContours, HomMat2D)
- *
- * Matching 01: Display the model contours
- dev_display (Image)
- dev_set_color ('green')
- dev_set_draw ('margin')
- dev_display (ModelRegion)
- dev_display (TransContours)
- stop ()
- *
- * Matching 01: END of generated code for model initialization
- * Matching 01: * * * * * * * * * * * * * * * * * * * * * * *
- * Matching 01: BEGIN of generated code for model application
- *
- * Matching 01: Loop over all specified test images
- TestImages := ['C:/Users/thinger.cn/Desktop/第5章:Halcon快速入门及联合编程/5.24 Halcon创建模板参数说明/套环/1.BMP']
- for T := 0 to 0 by 1
- *
- * Matching 01: Obtain the test image
- read_image (Image, TestImages[T])
- *
- * Matching 01: Find the model
- find_shape_model (Image, ModelID, rad(0), rad(360), 0.5, 27, 0.5, 'least_squares', [3,1], 0.75, Row, Column, Angle, Score)
-
-
- *
- * Matching 01: Transform the model contours into the detected positions
- dev_display (Image)
- for I := 0 to |Score| - 1 by 1
-
- *生成一个单元矩阵
- * hom_mat2d_identity (HomMat2D)
- *旋转
- * hom_mat2d_rotate (HomMat2D, Angle[I], 0, 0, HomMat2D)
- *平移
- *hom_mat2d_translate (HomMat2D, Row[I], Column[I], HomMat2D)
-
- *输出仿射变换矩阵 原始点X 原始点Y 原始点A 目标点X 目标点Y 目标点A 支持平移和旋转
- vector_angle_to_rigid (0, 0, 0, Row[I], Column[I], Angle[I], HomMat2D)
-
-
- *对xld仿射变换
- affine_trans_contour_xld (ModelContours, TransContours, HomMat2D)
-
- dev_set_color ('green')
- dev_display (TransContours)
- stop ()
- endfor
- endfor
- *
- * Matching 01: *******************************************
- * Matching 01: END of generated code for model application
- * Matching 01: *******************************************
- *
- *输出仿射变换矩阵 至少2个点 刚性仿射变换矩阵,支持旋转和平移
- vector_to_rigid (Column, Row, Column, Row, HomMat2D1)
- *柔性仿射变换矩阵,支持旋转和平移和缩放
- vector_to_similarity (Column, Row, Column, Row, HomMat2D2)
- *输出仿射变换矩阵 至少3个点 支持旋转和平移和缩放和斜切
- vector_to_hom_mat2d (Column, Row, Column, Row, HomMat2D3)
- *旋转 平移 缩放 斜切
- *仿射变换流程
- *1、获取特征点 坐标 角度
- *2、调用算子生成仿射变换矩阵
- *3、对图像、区域、Xld进行仿射变换
复制代码
|
|