- gen_region_runs (ROI_0, [104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249], [163,160,156,153,150,146,143,140,136,133,130,126,123,120,116,113,110,106,103,101,101,102,102,102,103,103,103,104,104,105,105,105,106,106,106,107,107,107,108,108,108,109,109,109,110,110,110,111,111,112,112,112,113,113,113,114,114,114,115,115,115,116,116,116,117,117,117,118,118,119,119,119,120,120,120,121,121,121,122,122,122,123,123,123,124,124,124,125,125,126,126,126,127,127,127,128,128,130,132,134,136,138,140,143,145,147,149,151,153,156,158,160,162,164,166,169,171,173,175,177,179,181,184,186,188,190,192,194,197,199,201,203,205,207,210,212,214,216,218,220,223,225,227,229,231,233], [164,163,162,164,165,167,169,170,172,173,175,177,178,180,181,183,184,186,188,189,191,192,194,195,197,199,200,202,203,205,207,208,210,211,213,214,216,218,219,221,222,224,225,227,229,230,232,233,235,237,238,240,241,243,244,246,248,249,251,252,254,255,257,259,260,262,263,265,267,268,270,271,271,270,270,269,269,268,268,267,267,266,266,265,265,264,264,263,263,262,262,261,261,260,260,259,259,258,258,257,257,256,256,255,255,254,254,253,253,252,252,251,251,250,250,249,249,248,248,247,247,246,246,245,245,244,244,243,243,242,242,241,241,240,240,239,239,238,238,237,237,236,236,235,235,234])
- *平移
- hom_mat2d_identity (HomMat2DIdentity)
- hom_mat2d_translate (HomMat2DIdentity, 164, 164, HomMat2DTranslate)
- affine_trans_region (ROI_0, RegionAffineTrans, HomMat2DTranslate, 'nearest_neighbor')
- *缩放
- hom_mat2d_identity (HomMat2DIdentity1)
- area_center (ROI_0, Area, Row, Column)
- hom_mat2d_scale (HomMat2DIdentity1, 2, 2, Row, Column, HomMat2DScale)
- affine_trans_region (ROI_0, RegionAffineScale, HomMat2DScale, 'nearest_neighbor')
- *旋转
- hom_mat2d_identity (HomMat2DIdentity2)
- area_center (ROI_0, Area1, Row1, Column1)
- hom_mat2d_rotate (HomMat2DIdentity2, -0.78, Row1, Column1, HomMat2DRotate)
- affine_trans_region (ROI_0, RegionAffineRotate, HomMat2DRotate, 'nearest_neighbor')
复制代码- *
- * 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)
- vector_angle_to_rigid (0, 0, 0, RefRow, RefColumn, 0, HomMat2D)
- 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, 0, 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)
-
- vector_angle_to_rigid (0, 0, 0, Row[I], Column[I], Angle[I], HomMat2D1)
-
-
- affine_trans_contour_xld (ModelContours, TransContours, HomMat2D1)
- dev_set_color ('green')
- dev_display (TransContours)
- stop ()
- endfor
- endfor
- *
- * Matching 01: *******************************************
- * Matching 01: END of generated code for model application
- * Matching 01: *******************************************
- *
复制代码
|