zoukankan      html  css  js  c++  java
  • Halcon学习:静态车牌识别

    算法逻辑:原图转3通道并转为HSV控件,看哪个图更适合进行车牌识别,进行阈值分割,然后把获得的区域进行合并并且通过OCR识别库识别。

     1 dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
     2 dev_open_file_dialog ('read_image', 'default', 'default', Selection)
     3 read_image (Image, Selection)
     4 *图像反色
     5 invert_image (Image, ImageInvert)
     6 
     7 *转3通道并转为hsv空间
     8 decompose3 (ImageInvert, R, G, B)
     9 trans_from_rgb (R, G, B, H, S, V, 'hsv')
    10 *分割
    11 threshold (S, Regions, 130, 255)
    12 connection (Regions, ConnectedRegions)
    13 *获取
    14 select_shape (ConnectedRegions, SelectedRegions, ['area','row'], 'and', [70,135.73], [95,195.9])
    15 *整合
    16 union1 (SelectedRegions, RegionUnion)
    17 *包含
    18 shape_trans (RegionUnion, RegionTrans, 'rectangle2')
    19 
    20 *获得Phi
    21 orientation_region (RegionTrans, Phi)
    22 area_center (RegionTrans, Area, Row, Column)
    23 vector_angle_to_rigid (Row, Column, Phi, Row, Column, rad(180), HomMat2D)
    24 * vector_angle_to_rigid (Row, Column, Phi, Row, Column, 0, HomMat2D)
    25 *旋转图像
    26 affine_trans_image (Image, ImageAffinTrans, HomMat2D, 'constant', 'false')
    27 *旋转区域,让车牌摆正,以便于之后的识别
    28 affine_trans_region (RegionTrans, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
    29 * rotate_image (RegionAffineTrans, ImageRotate1, 180, 'constant')
    30 *获取区域图像
    31 reduce_domain (ImageAffinTrans, RegionAffineTrans, ImageReduced)
    32 * rotate_image (ImageReduced, ImageRotate2, 180, 'constant')
    33 *转灰度
    34 rgb1_to_gray (ImageReduced, GrayImage)
    35 *旋转180
    36 * rotate_image (GrayImage, ImageRotate3, 180, 'constant')
    37 
    38 threshold (GrayImage, Region1, 77, 252)
    39 *获取所有个体
    40 connection (Region1, ConnectedRegions1)
    41 select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 63.76, 500)
    42 
    43 sort_region (SelectedRegions1, SortedRegions, 'character', 'true', 'Column')
    44 *用OCR识别库识别
    45 read_ocr_class_mlp ('Industrial_0-9A-Z_NoRej.omc', OCRHandle)
    46 do_ocr_multi_class_mlp (SortedRegions, ImageInvert, OCRHandle, Class, Confidence)
    47 dev_display (Image)
    48 disp_message (WindowHandle, Class, 'window', 0, 0, 'black', 'true')

    流程图:

      

      

     

  • 相关阅读:
    ssh 配置
    c指针
    centos 配置
    mac terminal 配色
    【webrtc】coturn服务搭建(27)
    【webrtc】SDP(26)
    【webrtc】webrtc通过peerconnection进行音视频互通(25)
    【webrtc】媒体协商的过程(24)
    【webrtc】STUN协议(23)
    【webrtc】webrtc网络传输基本知识(22)
  • 原文地址:https://www.cnblogs.com/zxl971213/p/13691192.html
Copyright © 2011-2022 走看看