haocon找圆_基于Halcon圆拟合提取学习

1.本文主要围绕Halcon圆拟合提取的学习心得总结,主要围绕halcon算子shape_trans,small_circle,fit_circle_contour_xld,hough_circles,add_metrology_object_circle_measure展开

2.Shape_trans

该算子检测图像变换区域中被广泛应用;

Signature

shape_trans(Region : RegionTrans : Type : )

Region (input_object)  region(-array) →object

Regions to be transformed.

RegionTrans (output_object)  region(-array) →object

Transformed regions.

Type (input_control)  string →(string)

Type of transformation.

Default value: 'convex'

List of values: 'convex', 'ellipse', 'inner_center', 'inner_circle', 'inner_rectangle1','outer_circle', 'rectangle1', 'rectangle2'

Halcon例程1:

提取前图片                                提取后图片

Halcon code

threshold (Image, Region, 0, 100)

closing_circle (Region, Region, 3.5)

connection (Region, ConnectedRegions)

select_shape (ConnectedRegions, Ring, ['width','height'], 'and', [550,550], [750,750])

shape_trans (Ring, OuterCircle, 'outer_circle')

3.smallest_circle

该算子主要是拟合一个区域的小围绕圆

Signature

smallest_circle(Regions : : : Row, Column, Radius)

Regions (input_object)  region(-array) →object

Regions to be examined.

Row (output_control)  circle.center.y(-array) →(real)

Line index of the center.

Column (output_control)  circle.center.x(-array) →(real)

Column index of the center.

Radius (output_control)  circle.radius(-array) →(real)

Radius of the surrounding circle.

Assertion: Radius >= 0

Halcon例程2:

提取前图片                              提取后图片

Halcon code

read_image (Image, 'circular_barcode')

get_image_size (Image, Width, Height)

threshold (Image, Region, 0, 100)

closing_circle (Region, Region, 3.5)

connection (Region, ConnectedRegions)

select_shape (ConnectedRegions, Ring, ['width','height'], 'and', [550,550], [75

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Halcon是一款图像处理软件,可以用于图像识别、字符识别、物体检测等多种领域。基于Halcon的字符识别可以通过以下步骤实现: 1. 装载图像:使用Halcon的read_image函数读取图像。 2. 预处理图像:使用Halcon的preprocessing函数对图像进行预处理,例如灰度化、二值化等。 3. 定位字符:使用Halcon的find_text函数对字符进行定位。 4. 分割字符:根据字符的位置信息,使用Halcon的crop_rectangle函数将字符从原图像中分割出来。 5. 特征提取:对分割出来的字符进行特征提取,例如使用Halcon的moments函数计算Hu不变矩。 6. 训练分类器:使用Halcon的svm_train函数训练分类器。 7. 字符识别:使用Halcon的svm_classify函数对新的字符进行识别。 下面是一个基于Halcon的字符识别的示例代码: ```python read_image(Image, 'characters.png') preprocessing(Image, Image, 'gray') threshold(Image, BinaryImage, 128, 255) reduce_domain(BinaryImage, Region, 100, 100, 200, 200) find_text(Region, TextRegions, 'auto', 'black', ['lines_gaps'], [30, 10], [30, 10]) num_chars := number_of_text(TextRegions) for i := 1 to num_chars crop_rectangle(Image, CharImage, TextRegions[i]) moments(CharImage, Moments) hu_moments(Moments, HuMoments) svm_classify(HuMoments, 'trained_classifier.svm', Result) write_string(Result) endfor ``` 在该代码中,首先读取图像并进行预处理,然后使用find_text函数定位字符并分割出来。接着,对每个字符进行特征提取,并使用svm_classify函数进行识别。最终输出识别结果。 需要注意的是,该示例代码仅供参考,实际应用中还需要根据具体情况进行调整和优化。同时,也需要准备好训练数据集,以便训练分类器。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值