• 大小: 36.82MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-29
  • 语言: 其他
  • 标签: OCR  

资源简介

基于端到端的深度学习的车牌、验证码、文档等字符识别,可以基于此进行样本生成和模型训练。

资源截图

代码片段和文件信息

#coding=utf-8
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
import cv2;
import numpy as np;
import os;
from math import *


# font = ImageFont.truetype(“Arial-Bold.ttf“14)

index = {“京“: 0 “沪“: 1 “津“: 2 “渝“: 3 “冀“: 4 “晋“: 5 “蒙“: 6 “辽“: 7 “吉“: 8 “黑“: 9 “苏“: 10 “浙“: 11 “皖“: 12
         “闽“: 13 “赣“: 14 “鲁“: 15 “豫“: 16 “鄂“: 17 “湘“: 18 “粤“: 19 “桂“: 20 “琼“: 21 “川“: 22 “贵“: 23 “云“: 24
         “藏“: 25 “陕“: 26 “甘“: 27 “青“: 28 “宁“: 29 “新“: 30 “0“: 31 “1“: 32 “2“: 33 “3“: 34 “4“: 35 “5“: 36
         “6“: 37 “7“: 38 “8“: 39 “9“: 40 “A“: 41 “B“: 42 “C“: 43 “D“: 44 “E“: 45 “F“: 46 “G“: 47 “H“: 48
         “J“: 49 “K“: 50 “L“: 51 “M“: 52 “N“: 53 “P“: 54 “Q“: 55 “R“: 56 “S“: 57 “T“: 58 “U“: 59 “V“: 60
         “W“: 61 “X“: 62 “Y“: 63 “Z“: 64};

chars = [“京“ “沪“ “津“ “渝“ “冀“ “晋“ “蒙“ “辽“ “吉“ “黑“ “苏“ “浙“ “皖“ “闽“ “赣“ “鲁“ “豫“ “鄂“ “湘“ “粤“ “桂“
             “琼“ “川“ “贵“ “云“ “藏“ “陕“ “甘“ “青“ “宁“ “新“ “0“ “1“ “2“ “3“ “4“ “5“ “6“ “7“ “8“ “9“ “A“
             “B“ “C“ “D“ “E“ “F“ “G“ “H“ “J“ “K“ “L“ “M“ “N“ “P“ “Q“ “R“ “S“ “T“ “U“ “V“ “W“ “X“
             “Y“ “Z“
             ];

def AddSmudginess(img Smu):
    rows = r(Smu.shape[0] - 50)

    cols = r(Smu.shape[1] - 50)
    adder = Smu[rows:rows + 50 cols:cols + 50];
    adder = cv2.resize(adder (50 50));
    #   adder = cv2.bitwise_not(adder)
    img = cv2.resize(img(5050))
    img = cv2.bitwise_not(img)
    img = cv2.bitwise_and(adder img)
    img = cv2.bitwise_not(img)
    return img

def rot(imgangelshapemax_angel):
    “““ 使图像轻微的畸变

        img 输入图像
        factor 畸变的参数
        size 为图片的目标尺寸

    “““
    size_o = [shape[1]shape[0]]

    size = (shape[1]+ int(shape[0]*cos((float(max_angel )/180) * 3.14))shape[0])


    interval = abs( int( sin((float(angel) /180) * 3.14)* shape[0]));

    pts1 = np.float32([[00]         [0size_o[1]][size_o[0]0][size_o[0]size_o[1]]])
    if(angel>0):

        pts2 = np.float32([[interval0][0size[1]  ][size[0]0  ][size[0]-intervalsize_o[1]]])
    else:
        pts2 = np.float32([[00][intervalsize[1]  ][size[0]-interval0  ][size[0]size_o[1]]])

    M  = cv2.getPerspectiveTransform(pts1pts2);
    dst = cv2.warpPerspective(imgMsize);

    return dst;

def rotRandrom(img factor size):
    shape = size;
    pts1 = np.float32([[0 0] [0 shape[0]] [shape[1] 0] [shape[1] shape[0]]])
    pts2 = np.float32([[r(factor) r(factor)] [ r(factor) shape[0] - r(factor)] [shape[1] - r(factor)  r(factor)]
                       [shape[1] - r(factor) shape[0] - r(factor)]])
    M = cv2.getPerspectiveTransform(pts1 pts2);
    dst = cv2.warpPerspective(img M size);
    return dst;



def tfactor(img):
    hsv = cv2.cvtColor(imgcv2.COLOR_BGR2HSV);

    hsv[::0] = hsv[::0]*(0.8+ np.random.random()*0.2);
    hsv[::1] = hsv[::1]*(0.3+ np.random.random()*0.7);
    hsv[::2] = hsv[::2]*(0.2

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\
     目录           0  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\.idea\
     目录           0  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\.idea\dictionaries\
     文件          86  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\.idea\dictionaries\yujinke.xml
     文件         159  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\.idea\encodings.xml
     文件         459  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\.idea\end-to-end-for-chinese-plate-recognition.iml
     文件        1520  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\.idea\misc.xml
     文件         332  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\.idea\modules.xml
     文件         180  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\.idea\vcs.xml
     文件       18212  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\.idea\workspace.xml
     目录           0  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\
     文件        3896  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A01_N84E28_1.jpg
     文件        3598  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A01_N84E28_2.jpg
     文件        2579  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A01_NMV802_1.jpg
     文件        3377  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A01_NMV802_2.jpg
     文件        2873  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A02_NBD719_1.jpg
     文件        3067  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A02_NBD719_2.jpg
     文件        2486  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A05F26_1.jpg
     文件        3576  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A137U8_1.jpg
     文件        3607  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A137U8_2.jpg
     文件        3676  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A137U8_3.jpg
     文件        2783  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A19Z80_0.jpg
     文件        2740  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A19Z80_1.jpg
     文件        3383  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A19Z80_2.jpg
     文件        3209  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A19Z80_3.jpg
     文件        2900  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A19Z80_4.jpg
     文件        3085  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A19Z80_5.jpg
     文件        2558  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A19Z80_7.jpg
     文件        2844  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A19Z80_8.jpg
     文件        2508  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A1L828_0.jpg
     文件        2811  2017-02-17 20:18  end-to-end-for-chinese-plate-recognition-master\NoPlates\A03_A1L828_1.jpg
............此处省略175个文件信息

评论

共有 条评论