ハルコンサークル検索

円検索機能
本質的に、円検索機能は、ほとんどの場合に発生するテンプレート マッチングの精度が低く、実際の座標から部分的にずれが生じるためです。このとき、測定長方形の形状を確立できます
。推定点に対して複数の計算を行う より正確な輪郭を求める測定
円探索の他に、楕円探索、直線探索、角度を付けた長方形探索の4つの方法があります。

*创建测量模板
create_metrology_model (MetrologyHandle)
*向计量模型中添加计量对象。
*其中需要注意的是:'circle'*halcon的这个算子允许对4种计量对象:'circle'(圆形)ellipse(椭圆形)line(直线)rectangle2(带角度的矩形)
*[Row3, Column3, 195]对计量模型创建特征。当我们选择圆形的时候就会需要圆的中心XY坐标和半径
*50(高斯滤波的值)
*test1计量模型识别码
add_metrology_object_generic (MetrologyHandle, 'circle', [Row3, Column3, 195], 50, 5, 5, 30, [], [], test1)
*将句柄添加在图像中
apply_metrology_model (Image1, MetrologyHandle)
*获取到计量模型的结果
*输出不同类型'used_edges'(提取边缘) 'angle_direction'(提取角度) 'result_type'(结果类型)
*'row'(获取行坐标)【输出多种不同类型的数值】(实质上可以获取到测量举行的拟合中点)
get_metrology_object_result (MetrologyHandle, 'all', 'all', 'used_edges', 'row', UsedRow)
get_metrology_object_result (MetrologyHandle, 'all', 'all', 'used_edges', 'column', UsedColumn)
*生成测量矩形
get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row1, Column1)
*创建测量矩形中点
gen_cross_contour_xld (UsedEdges, UsedRow, UsedColumn, 10, Angle)
*创建圆形
get_metrology_object_result_contour (ResultContours, MetrologyHandle, 'all', 'all', 1.5)
dev_display (Image1)
dev_display (UsedEdges)
dev_display (ResultContours)
*对结果类型进行获取,获取角度,中心X值和Y值
*RadiusC1角度值,Row9行坐标,column9纵坐标
get_metrology_object_result (MetrologyHandle, test1, 'all', 'result_type', 'radius', RadiusC1)
get_metrology_object_result (MetrologyHandle, test1, 'all', 'result_type', 'row', Row9)
get_metrology_object_result (MetrologyHandle, test1, 'all', 'result_type', 'column', column9)
*创建圆形轮廓
gen_circle_contour_xld (ContCircle2, Row9, column9, RadiusC1, rad(180), rad(360), 'positive', 1)
gen_circle_contour_xld (ContCircle3, Row9, column9, RadiusC1, rad(0), rad(-180), 'positive', 1)
gen_cross_contour_xld (Cross, Row9, column9, 100, Angle)

ここに画像の説明を挿入

おすすめ

転載: blog.csdn.net/m0_51559565/article/details/128368683