Halcon基础入门:识别车牌

摘要

  功能

提取并识别车牌号,注意:不识别汉字

  基本步骤如下

1.加载图像
2.预处理
3.分割提取
(1)分割
(2)旋转
(3)抠图
4.识别
5.显示

Halcon代码:识别车牌


*1 加载图像
read_image (Image, '微信图片_20190401160631.jpg')
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
dev_display (Image)

*2 预处理
decompose3 (Image, R, G, B)
trans_from_rgb (R,G,B,H, S, V, 'hsv')
threshold (S, Regions, 216, 255)
opening_rectangle1 (Regions, RegionOpening, 3, 3)

*3 分割提取(分割-旋转-抠图)
*分割
connection (RegionOpening, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, ['area','row','column'], 'and', [0,546.75,342.69], [8506.1,770.33,575.15])
union1 (SelectedRegions, RegionUnion)
shape_trans (RegionUnion, RegionTrans, 'rectangle2')

* area_center (RegionTrans, Area, Row, Column)
* orientation_region (RegionTrans, Phi)
* vector_angle_to_rigid (Row, Column, Phi, Row, Column,rad(180), HomMat2D)
* affine_trans_image (Image, ImageAffinTrans, HomMat2D, 'constant', 'false')
* affine_trans_region (RegionTrans, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
*旋转
smallest_rectangle2 (RegionTrans, Row, Col, Phi, Length1, Length2)
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_rotate (HomMat2DIdentity, -Phi, Col, Row, HomMat2D)
affine_trans_image (Image, ImageAffinTrans, HomMat2D, 'constant', 'false')
affine_trans_region (RegionTrans, RegionAffineTrans, HomMat2D, 'nearest_neighbor')

*抠图
reduce_domain (ImageAffinTrans, RegionAffineTrans, ImageReduced)
rgb1_to_gray (ImageReduced, GrayImage)
invert_image (GrayImage, ImageInvert)
threshold (GrayImage, Regions1, 158, 255)
opening_rectangle1 (Regions1, RegionOpening1, 3, 3)
connection (RegionOpening1, ConnectedRegions2)
select_shape (ConnectedRegions2, SelectedRegions1, 'area', 'and', 300, 660.04)

*4 识别
sort_region (SelectedRegions1, SortedRegions, 'character', 'true', 'column')
read_ocr_class_mlp ('Industrial_0-9A-Z_NoRej.omc', OCRHandle)
do_ocr_multi_class_mlp (SortedRegions, ImageInvert, OCRHandle, Class, Confidence)

*5 显示
dev_display (ImageAffinTrans)
disp_message (WindowHandle, Class, 'image', Row, Col, 'black', 'true')

在这里插入图片描述

更多详情了解:https://blog.csdn.net/qq_32015315/article/details/141663063

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值