ocr_wafer_semi_font.hdev圆晶上semi字符提取 相关例程学习

Index:.../Applications/OCR/ocr_wafer_semi_font.hdev



* This example describes one step from the semiconductor product chain.
* In the front-end-of-line step, the ICs are printed on the wafer. To
* tag a single wafer from the production life line, each wafer receives
* an ID number, printed with the SEMI font. This ID number is read here.

dev_update_off ()
dev_close_window ()
read_image (Image, 'ocr/wafer_semi_font_01')
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
dev_set_draw ('margin')
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_line_width (2)
dev_set_colored (12)

设置的颜色挺多的

read_ocr_class_mlp ('SEMI', OCRHandle)

用的是semi训练模板
NumImages := 10
for Index := 1 to NumImages by 1
    * 
    * Segment characters
    read_image (Image, 'ocr/wafer_semi_font_' + Index$'02')
    * Characters must be black-on-white, i.e., dark characters on a light background
    invert_image (Image, ImageInvert)
    mean_image (Image, ImageMean, 31, 31)
    dyn_threshold (Image, ImageMean, RegionDynThresh, 7, 'light')

dynthreshold提取字符
    * Characters are often dotted. Therefore, we first merge close dots
    * that belong to the same character just before calling the operator connection
    closing_circle (RegionDynThresh, RegionClosing, 2.0)

但字符各种点,做了closing闭操作,很常用要熟悉
    connection (RegionClosing, ConnectedRegions)
    * Filter out characters based on two facts:
    * 1. Characters are printed in SEMI-12. Therefore we can make strong assumptions
    *    on the dimensions of the characters
    * 2. Characters are printed along a straight line
    select_shape (ConnectedRegions, SelectedRegions1, ['height','width'], 'and', [29,15], [60,40])

提取方法比较固定,想必因为这一系列图的字符所占像素点差不多大小
    area_center (SelectedRegions1, Area, RowCh, ColumnCh)
    MedianRow := median(RowCh)

中位数,这里很有意义,我们都学过统计,当出现这种一串稳定数据,里面有几个不稳定值时,该用哪种统计方法解决问题?

虽然大家都会,但解决问题时能不能想出来,则是关键了
    select_shape (SelectedRegions1, Chars, 'row', 'and', MedianRow - 30, MedianRow + 30)

用中位数(坐标)来提取字符就很稳定了

    * 

    * Read out segmented characters
    sort_region (Chars, CharsSorted, 'character', 'true', 'column')
    shape_trans (CharsSorted, Characters, 'rectangle1')

排序后把字符外接矩阵做出来,shape-trans
    do_ocr_multi_class_mlp (Characters, ImageInvert, OCRHandle, Class, Confidence)

做匹配,关键还是halcon匹配算法太牛了,虽然实际用慢多了,但例程都快狠准
    * 

下面全是显示代码
    dev_display (ImageInvert)
    dilation_rectangle1 (Characters, RegionDilation, 7, 7)
    dev_display (RegionDilation)
    area_center (CharsSorted, Area1, Row, Column)
    MeanRow := mean(Row)
    for IndexL := 0 to |Class| - 1 by 1
        disp_message (WindowHandle, Class[IndexL], 'image', MeanRow + 40, Column[IndexL] - 20, 'black', 'true')
    endfor
    if (Index != NumImages)
        disp_continue_message (WindowHandle, 'black', 'true')
        stop ()
    endif
endfor
clear_ocr_class_mlp (OCRHandle)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值