Blob分析之bottle.hdev

* 分割读取啤酒瓶子上的数字
* bottle.hdev: Segment and read numbers on a beer bottle
* 第0步
* Step 0: Preparations
*定义字体名称,用来读取瓶子上的数据/或者可以这么理解,定义瓶子上数据的字体
* Specify the name of the font to use for reading the date on the bottle.
*用训练好的0-9通用字体是最简单的。如果已经运行过这个程序,你可以第二行名称,是用这个项目训练的字体
* It is easiest to use the pre-trained font Universal_0-9_NoRej. If you
* have run the program bottlet.hdev in this directory, you can activate
* the second line to use the font trained with this program.
FontName := 'Universal_0-9_NoRej'
* FontName := 'bottle'
* 第一步,分割
* Step 1: Segmentation
*关闭窗体更新
dev_update_window ('off')
*读取图像
read_image (Bottle, 'bottle2')
*获取图像尺寸
get_image_size (Bottle, Width, Height)
*关闭窗体
dev_close_window ()
*打开窗体
dev_open_window (0, 0, 2 * Width, 2 * Height, 'black', WindowID)
*设置显示字体
set_display_font (WindowID, 16, 'mono', 'true', 'false')
*显示图像
dev_display (Bottle)
*显示'Press F5 to continiue'这个信息
disp_continue_message (WindowID, 'black', 'true')
stop ()
* 创建自动文字读取器以及设置一些参数
* Create Automatic Text Reader and set some parameters
*创建文字读取器
create_text_model_reader ('auto', FontName, TextModel)
* The printed date has a significantly higher stroke width
*设置文字读取参数的最小宽度
set_text_model_param (TextModel, 'min_stroke_width', 6)
*最佳日期(表示多级之前引用是最佳的)有一个特殊和已知的结构
* The "best before" date has a particular and known structure
*设置文字组成格式,'2 2 2'便是由三段数字构成,中间由空白或者分隔符分开 '19'表示没有分隔符或者空白
set_text_model_param (TextModel, 'text_line_structure', '2 2 2')
* 读取最佳日期
* Read the "best before" date
find_text (Bottle, TextModel, TextResultID)
* 获取最佳日期文字并显示
* Display the segmentation results
get_text_object (Characters, TextResultID, 'all_lines')
*显示瓶子图像
dev_display (Bottle)
*显示读取到的字符
dev_display (Characters)
stop ()
*显示读取到的结果
* Display the reading results
*获取文字结果
get_text_result (TextResultID, 'class', Classes)
*求区域面积和中心坐标
area_center (Characters, Area, Row, Column)
*显示读取到的文字信息
disp_message (WindowID, Classes, 'image', 80, Column - 3, 'green', 'false')
* 释放内存
* Free memory
*清楚文字结果
clear_text_result (TextResultID)
*清楚Text模型
clear_text_model (TextModel)

posted @ 2020-07-30 22:23  懒树懒  阅读(220)  评论(0编辑  收藏  举报