当前位置:网站首页>Halcon: discrete digital OCR recognition
Halcon: discrete digital OCR recognition
2022-06-27 16:47:00 【Aii parson】
* Function of the scatter character OCR distinguish
dev_clear_window ()
dev_open_window (0, 0, 640, 400, 'black', WindowHandle)
*1. Read images
read_image (Image, 'E:/03 CV( ancient )/Halcon/ Code / Superman enlightenment _ Topic enlightenment /OCR_SVM/ Images /1.bmp')
get_image_size (Image, Width, Height)
*2. Location and affine transformation
Classes:=['2','0','1','6','0','6','1','6','6','F','1','6','C','1','8','3','8','C']
Row1:=64.3375
Column1:=165.313
Row2:=218.713
Column2:=618.988
Px:=Column1+(Column2-Column1)/2
Py:=Row1+(Row2-Row1)/2
gen_rectangle1 (Rectangle,Row1,Column1,Row2,Column2 )
dev_display (Image)
dev_display (Rectangle)
* Affine transformation
text_line_orientation (Rectangle, Image, 25, -0.523599, 0.523599, OrientationAngle)# Will be based on gen_rectangle1 (Rectangle,,, ) Medium Rectangle Automatically obtain the rotation angle OrientationAngle
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_rotate (HomMat2DIdentity, -OrientationAngle, Px, Py, HomMat2DRotate)
affine_trans_image (Image, ImageAffineTrans, HomMat2DRotate, 'constant', 'false')
dev_display (Image)
dev_display (ImageAffineTrans)
*3. Dot extraction ( Dark spot )
dots_image (ImageAffineTrans, DotImage, 3, 'dark', 2)
gen_rectangle1 (ROI_0, 97.6825, 204.763, 205.128, 605.427)
reduce_domain (DotImage, ROI_0, ImageReduced)# tailoring ( The affine transformed image and the manual rectangular drawing area are cropped )
threshold (ImageReduced, Regions, 60, 255)# Manual binarization ( It is necessary to set the threshold value √, The channel is changed to 1)
connection (Regions, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 0, 50)
union1 (SelectedRegions, RegionUnion)
* Connect the scattered points of each number into a completely closed connected domain ( In the direction of expansion : The longitudinal --> The transverse -->45° Oblique -->145° Oblique )
closing_rectangle1 (RegionUnion, RegionClosing1, 1, 5)
closing_rectangle1 (RegionClosing1, RegionClosing2, 5, 1)
* Oblique expansion : High set to 0
gen_rectangle2 (ROI_0, 16, 16, rad(45), 3, 0)
closing (RegionClosing2, ROI_0, RegionClosing3)
gen_rectangle2 (ROI_0, 2, 2, rad(145), 2, 0)
closing (RegionClosing3, ROI_0, RegionClosing4)
dilation_circle (RegionClosing4, RegionDilation, 1)
connection (RegionDilation, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 145.41, 433.49)# Remove the colon :
partition_dynamic (SelectedRegions1, Partitioned, 30, 20)# Divide the area horizontally where the vertical range is small ), Prevent adhesion after corrosion and expansion
sort_region (Partitioned, SortedRegions, 'character', 'true', 'row')# Reading mode and direction
count_obj (SortedRegions, Number)
dev_display (ImageAffineTrans)
for i := 1 to Number by 1
dev_set_color ('red')
select_obj (SortedRegions, char, i)
dev_display (char)
intersection (char, Regions, RegionIntersection)# Extract the original figure number : Extract the connected numbers of the scatter graph and make the intersection with the original scatter graph , Get the public part
append_ocr_trainf (RegionIntersection, ImageAffineTrans, Classes[i-1], 'D:/svm.trf')
endfor
边栏推荐
- 基于 Nebula Graph 构建百亿关系知识图谱实践
- 等保2.0密码要求是什么?法律依据有哪些?
- 关于#mysql#的问题:问题遇到的现象和发生背景
- The time of localdatetime type (2019-11-19t15:16:17) is queried with the time range of Oracle
- LeetCode每日一练(主要元素)
- MySQL中符号@的作用
- 利用Redis实现订单30分钟自动取消
- Hierarchical clustering and case analysis
- 10 minutes to master the installation steps of MySQL
- 分布式Session解决方案
猜你喜欢
MySQL中符号@的作用
List to table
Mihayou sued Minmetals trust, which was exposed to product thunderstorms
【Pygame小遊戲】這款“吃掉一切”遊戲簡直奇葩了?通通都吃掉嘛?(附源碼免費領)
Redis Series 2: data persistence improves availability
A distribution fission activity is more than just a circle of friends!
【多线程】线程通信调度、等待集 wait() 、notify()
全面解析零知识证明:消解扩容难题 重新定义「隐私安全」
Etcd visualization tool: kstone deployment (I), rapid deployment based on Helm
关于#mysql#的问题:问题遇到的现象和发生背景
随机推荐
C語言教師工作量管理系統
Smart wind power | Tupu software digital twin wind turbine equipment, 3D visual intelligent operation and maintenance
Hierarchical clustering and case analysis
事务的隔离级别详解
3.1 simple condition judgment
Special function calculator
Oracle概念三
Hongmeng makes efforts! HDD Hangzhou station · offline salon invites you to build ecology
树莓派初步使用
What is RPC
MySQL中符号@的作用
C language teacher workload management system
LeetCode每日一练(杨辉三角)
Solving Poisson equation by tensorflow
Qt5 signal and slot mechanism (demonstrate the correlation between the control's own signal and slot function)
What should the ultimate LAN transmission experience be like
LeetCode每日一练(两数之和)
If you want to use DMS to handle database permissions, can you only use Alibaba cloud ram accounts (Alibaba cloud RDS)
EMQ helps Qingdao Yanbo build a smart water platform
Data center table reports realize customized statistics, overtime leave summary record sharing