Halcon几何定位
作者:互联网
H a l c o n 几 何 定 位 Halcon几何定位 Halcon几何定位
read_image (Image, '1.BMP')
*
* Matching 02: ************************************************
* Matching 02: BEGIN of generated code for model initialization
* Matching 02: ************************************************
set_system ('border_shape_models', 'false')
*
* Matching 02: Obtain the model image
* Matching 02: *************
* Matching 02: * ATTENTION *
* Matching 02: *************
* Matching 02: The image from the graphics window is not available. At this point,
* Matching 02: it is necessary to ensure an image is stored in the variable 'Image'
*
* Matching 02: Build the ROI from basic regions
gen_rectangle1 (ModelRegion, 198.514, 448.541, 267.264, 514.813)
*
* Matching 02: Reduce the model template
reduce_domain (Image, ModelRegion, TemplateImage)
*
* Matching 02: Create the shape model
create_scaled_shape_model (TemplateImage, 3, rad(0), rad(360), rad(3.5798), 0.89, 1.1, 0.0312, ['none','no_pregeneration'], 'use_polarity', [10,11,4], 4, ModelID)
*
* Matching 02: Get the model contour for transforming it later into the image
get_shape_model_contours (ModelContours, ModelID, 1)
*
* Matching 02: 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 02: Display the model contours
dev_display (Image)
dev_set_color ('green')
dev_set_draw ('margin')
dev_display (ModelRegion)
dev_display (TransContours)
stop ()
*
* Matching 02: END of generated code for model initialization
* Matching 02: * * * * * * * * * * * * * * * * * * * * * * *
* Matching 02: BEGIN of generated code for model application
*
* Matching 02: Loop over all specified test images
TestImages := ['1.BMP']
for T := 0 to 0 by 1
*
* Matching 02: Obtain the test image
read_image (Image, TestImages[T])
*
* Matching 02: Find the model
find_scaled_shape_model (Image, ModelID, rad(0), rad(360), 0.89, 1.1, 0.8, 27, 0.5, 'least_squares', [3,1], 0.4, Row, Column, Angle, Scale, Score)
*
* Matching 02: 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_scale (HomMat2D, Scale[I], Scale[I], 0, 0, HomMat2D)
hom_mat2d_rotate (HomMat2D, Angle[I], 0, 0, HomMat2D)
hom_mat2d_translate (HomMat2D, Row[I], Column[I], HomMat2D)
affine_trans_contour_xld (ModelContours, TransContours, HomMat2D)
dev_set_color ('green')
dev_display (TransContours)
stop ()
endfor
endfor
*
* Matching 02: *******************************************
* Matching 02: END of generated code for model application
* Matching 02: *******************************************
*
标签:02,定位,HomMat2D,Image,dev,Halcon,几何,model,Matching 来源: https://blog.csdn.net/qq_41375318/article/details/120455222