当前位置: 首页 > news >正文

网站推广效果如何最新新闻热点事件2023

网站推广效果如何,最新新闻热点事件2023,做网站都要买服务器吗,代做网站公司哪家好车牌字符识别技术(三)汉字识别 1.代码实例2.遇到问题3.汉字识别代码实例 相较于数字和英文字符的识别,汽车牌照中的汉字字符识别的难度更大,主要原因有以下4个方面: (1)字符笔画因切分误差导致非笔画或笔画流失。 (2…

车牌字符识别技术(三)汉字识别

  • 1.代码实例
  • 2.遇到问题
  • 3.汉字识别代码实例

相较于数字和英文字符的识别,汽车牌照中的汉字字符识别的难度更大,主要原因有以下4个方面:

(1)字符笔画因切分误差导致非笔画或笔画流失。

(2)汽车牌照被污染导致字符上出现污垢。

(3)采集所得车辆图像分辨率低导致多笔画的汉字较难分辨。

(4)车辆图像采集时所受光照影响的差异导致笔画较淡。

综合汉字识别时的这些难点来看,很难被直接提取的是字符的局部特征。笔画作为最重要的特征而仅存在于汉字中,这由先验知识可知。一旦捺、横、竖、撇这些笔画特征被提取到,对于汉字字符识别的工作就完成了许多。在水平方向上,横笔画的灰度值的波动表现为低频,竖笔画的灰度变化表现为低频;在垂直方向上,横笔画的灰度变化表现为高频,竖笔画的灰度变化表现为高频。在汉字字符特征的提取过程中,对于小波的多分辨率特性的利用显然是一个不错的选择。

对于汉字进识别的相关工作,在一系列对图像进行预处理以及对图像的特征进行提取等相关操作后就可以进行了。第一步是预处理原始图像;第二步是对字符的原始特征进行提取(主要通过小波变换进行),并降维处理原始特征(主要采用线性判别式分析(LDA)变换矩阵进行),获取字符的最终特征;第三步是在特征模板匹配和最小距离分类器中读入获取所得到的最终特征,得到字符的最终识别结果。

1.代码实例

中文车牌的识别(包括新能源汽车)

import cv2 as cv
from PIL import Image
import pytesseract as tessdef recoginse_text(image):"""步骤:1、灰度,二值化处理2、形态学操作去噪3、识别:param image::return:"""# 灰度 二值化gray = cv.cvtColor(image,cv.COLOR_BGR2GRAY)# 如果是白底黑字 建议 _INVret,binary = cv.threshold(gray,0,255,cv.THRESH_BINARY_INV| cv.THRESH_OTSU)# 形态学操作 (根据需要设置参数(1,2))kernel = cv.getStructuringElement(cv.MORPH_RECT,(1,2))  #去除横向细线morph1 = cv.morphologyEx(binary,cv.MORPH_OPEN,kernel)kernel = cv.getStructuringElement(cv.MORPH_RECT, (2, 1)) #去除纵向细线morph2 = cv.morphologyEx(morph1,cv.MORPH_OPEN,kernel)cv.imshow("Morph",morph2)# 黑底白字取非,变为白底黑字(便于pytesseract 识别)cv.bitwise_not(morph2,morph2)textImage = Image.fromarray(morph2)# 图片转文字text=tess.image_to_string(textImage)n=10 #根据不同国家车牌固定数目进行设置print("识别结果:")print(text[1:n])def main():# 读取需要识别的数字字母图片,并显示读到的原图src = cv.imread("cp.jpg")cv.imshow("src",src)# 识别recoginse_text(src)cv.waitKey(0)cv.destroyAllWindows()if __name__=="__main__":main()

2.遇到问题

在这里插入图片描述

No module named ‘pytesseract’

缺少pytesseract 模块。

在环境中安装该模块

在这里插入图片描述
安装完成运行程序,结果又出现了一堆问题:

在这里插入图片描述
原因是没有安装pytesseract需要的Tesseract-OCR工具,Windows版本的安装包的下载路径为https://github.com/UB-Mannheim/tesseract/wiki

在这里插入图片描述

直接双击该文件进行安装即可。这里的安装位置(这个路径要记住,后面要用)采用默认值:

     C:\Program Files\Tesseract-OCR

配置pytesseract.py打开“我的计算机”,进入\Users==\AppData\Local\Programs\Python\Python38\Lib\site-packages\pytesseract\,找到pytesseract.py文件,用文本编辑器打开这个文件,找到"tesseract_cmd"关键字

在这里插入图片描述

至此,字符识别开发环境准备好了,下面就可以编写代码了。

代码实例:

import cv2 as cv
from PIL import Image
import pytesseract as tessdef recoginse_text(image):"""步骤:1、灰度,二值化处理2、形态学操作去噪3、识别:param image::return:"""# 灰度 二值化gray = cv.cvtColor(image,cv.COLOR_BGR2GRAY)# 如果是白底黑字 建议 _INVret,binary = cv.threshold(gray,0,255,cv.THRESH_BINARY_INV| cv.THRESH_OTSU)# 形态学操作 (根据需要设置参数(1,2))kernel = cv.getStructuringElement(cv.MORPH_RECT,(1,2))  #去除横向细线morph1 = cv.morphologyEx(binary,cv.MORPH_OPEN,kernel)kernel = cv.getStructuringElement(cv.MORPH_RECT, (2, 1)) #去除纵向细线morph2 = cv.morphologyEx(morph1,cv.MORPH_OPEN,kernel)cv.imshow("Morph",morph2)# 黑底白字取非,变为白底黑字(便于pytesseract 识别)cv.bitwise_not(morph2,morph2)textImage = Image.fromarray(morph2)# 图片转文字text=tess.image_to_string(textImage)n=10 #根据不同国家车牌固定数目进行设置print("识别结果:")print(text[1:n])def main():# 读取需要识别的数字字母图片,并显示读到的原图src = cv.imread("cp.jpg")cv.imshow("src",src)# 识别recoginse_text(src)cv.waitKey(0)cv.destroyAllWindows()if __name__=="__main__":main()

在这里插入图片描述

3.汉字识别代码实例

代码实例

import tkinter as tk
from tkinter.filedialog import *
from tkinter import ttk
import predict
import cv2
from PIL import Image, ImageTk
import threading
import timeclass Surface(ttk.Frame):pic_path = ""viewhigh = 600viewwide = 600update_time = 0thread = Nonethread_run = Falsecamera = Nonecolor_transform = {"green":("绿牌","#55FF55"), "yello":("黄牌","#FFFF00"), "blue":("蓝牌","#6666FF")}def __init__(self, win):ttk.Frame.__init__(self, win)frame_left = ttk.Frame(self)frame_right1 = ttk.Frame(self)frame_right2 = ttk.Frame(self)win.title("车牌识别")win.state("zoomed")self.pack(fill=tk.BOTH, expand=tk.YES, padx="5", pady="5")frame_left.pack(side=LEFT,expand=1,fill=BOTH)frame_right1.pack(side=TOP,expand=1,fill=tk.Y)frame_right2.pack(side=RIGHT,expand=0)ttk.Label(frame_left, text='原图:').pack(anchor="nw") ttk.Label(frame_right1, text='车牌位置:').grid(column=0, row=0, sticky=tk.W)from_pic_ctl = ttk.Button(frame_right2, text="来自图片", width=20, command=self.from_pic)from_vedio_ctl = ttk.Button(frame_right2, text="来自摄像头", width=20, command=self.from_vedio)self.image_ctl = ttk.Label(frame_left)self.image_ctl.pack(anchor="nw")self.roi_ctl = ttk.Label(frame_right1)self.roi_ctl.grid(column=0, row=1, sticky=tk.W)ttk.Label(frame_right1, text='识别结果:').grid(column=0, row=2, sticky=tk.W)self.r_ctl = ttk.Label(frame_right1, text="")self.r_ctl.grid(column=0, row=3, sticky=tk.W)self.color_ctl = ttk.Label(frame_right1, text="", width="20")self.color_ctl.grid(column=0, row=4, sticky=tk.W)from_vedio_ctl.pack(anchor="se", pady="5")from_pic_ctl.pack(anchor="se", pady="5")self.predictor = predict.CardPredictor()self.predictor.train_svm()def get_imgtk(self, img_bgr):img = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)im = Image.fromarray(img)imgtk = ImageTk.PhotoImage(image=im)wide = imgtk.width()high = imgtk.height()if wide > self.viewwide or high > self.viewhigh:wide_factor = self.viewwide / widehigh_factor = self.viewhigh / highfactor = min(wide_factor, high_factor)wide = int(wide * factor)if wide <= 0 : wide = 1high = int(high * factor)if high <= 0 : high = 1im=im.resize((wide, high), Image.ANTIALIAS)imgtk = ImageTk.PhotoImage(image=im)return imgtkdef show_roi(self, r, roi, color):if r :roi = cv2.cvtColor(roi, cv2.COLOR_BGR2RGB)roi = Image.fromarray(roi)self.imgtk_roi = ImageTk.PhotoImage(image=roi)self.roi_ctl.configure(image=self.imgtk_roi, state='enable')self.r_ctl.configure(text=str(r))self.update_time = time.time()try:c = self.color_transform[color]self.color_ctl.configure(text=c[0], background=c[1], state='enable')except: self.color_ctl.configure(state='disabled')elif self.update_time + 8 < time.time():self.roi_ctl.configure(state='disabled')self.r_ctl.configure(text="")self.color_ctl.configure(state='disabled')def from_vedio(self):if self.thread_run:returnif self.camera is None:self.camera = cv2.VideoCapture(0)if not self.camera.isOpened():mBox.showwarning('警告', '摄像头打开失败!')self.camera = Nonereturnself.thread = threading.Thread(target=self.vedio_thread, args=(self,))self.thread.setDaemon(True)self.thread.start()self.thread_run = Truedef from_pic(self):self.thread_run = Falseself.pic_path = askopenfilename(title="选择识别图片", filetypes=[("jpg图片", "*.jpg")])if self.pic_path:img_bgr = predict.imreadex(self.pic_path)self.imgtk = self.get_imgtk(img_bgr)self.image_ctl.configure(image=self.imgtk)resize_rates = (1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4)for resize_rate in resize_rates:print("resize_rate:", resize_rate)try:r, roi, color = self.predictor.predict(img_bgr, resize_rate)except:continueif r:break#r, roi, color = self.predictor.predict(img_bgr, 1)self.show_roi(r, roi, color)@staticmethoddef vedio_thread(self):self.thread_run = Truepredict_time = time.time()while self.thread_run:_, img_bgr = self.camera.read()self.imgtk = self.get_imgtk(img_bgr)self.image_ctl.configure(image=self.imgtk)if time.time() - predict_time > 2:r, roi, color = self.predictor.predict(img_bgr)self.show_roi(r, roi, color)predict_time = time.time()print("run end")def close_window():print("destroy")if surface.thread_run :surface.thread_run = Falsesurface.thread.join(2.0)win.destroy()if __name__ == '__main__':win=tk.Tk()surface = Surface(win)win.protocol('WM_DELETE_WINDOW', close_window)win.mainloop()

输出结果:

在这里插入图片描述


文章转载自:
http://dinncomaiden.ydfr.cn
http://dinncokwangju.ydfr.cn
http://dinncoconfrontation.ydfr.cn
http://dinncosamdwich.ydfr.cn
http://dinncosargasso.ydfr.cn
http://dinncostarch.ydfr.cn
http://dinncosupinely.ydfr.cn
http://dinncoeventuate.ydfr.cn
http://dinncobalkhash.ydfr.cn
http://dinncoleathercraft.ydfr.cn
http://dinncotournament.ydfr.cn
http://dinncowallflower.ydfr.cn
http://dinncolumberer.ydfr.cn
http://dinnconomination.ydfr.cn
http://dinncoinactivity.ydfr.cn
http://dinncoulvaespinel.ydfr.cn
http://dinncoomphalos.ydfr.cn
http://dinncoshona.ydfr.cn
http://dinncoirretrievably.ydfr.cn
http://dinncocingulotomy.ydfr.cn
http://dinncotortive.ydfr.cn
http://dinncocosmopolitical.ydfr.cn
http://dinncoconurban.ydfr.cn
http://dinncodignitarial.ydfr.cn
http://dinncoamericandom.ydfr.cn
http://dinncoredivious.ydfr.cn
http://dinncoloom.ydfr.cn
http://dinncobathsheba.ydfr.cn
http://dinncopustulate.ydfr.cn
http://dinncoleptocephalous.ydfr.cn
http://dinncoenology.ydfr.cn
http://dinncovaluator.ydfr.cn
http://dinncodesmotropy.ydfr.cn
http://dinncoimmovable.ydfr.cn
http://dinncokyak.ydfr.cn
http://dinncoorthicon.ydfr.cn
http://dinncoproscriptive.ydfr.cn
http://dinncotritagonist.ydfr.cn
http://dinncoarcadianism.ydfr.cn
http://dinncoherbary.ydfr.cn
http://dinnconerf.ydfr.cn
http://dinncodeadlight.ydfr.cn
http://dinncohypoplasia.ydfr.cn
http://dinncowsb.ydfr.cn
http://dinncoultraleft.ydfr.cn
http://dinncoechography.ydfr.cn
http://dinncohirtellous.ydfr.cn
http://dinncoodorously.ydfr.cn
http://dinncoantifederal.ydfr.cn
http://dinncoamphimictic.ydfr.cn
http://dinnconeper.ydfr.cn
http://dinncorefractable.ydfr.cn
http://dinncosatiny.ydfr.cn
http://dinncoacrocentric.ydfr.cn
http://dinnconervy.ydfr.cn
http://dinncodeovolente.ydfr.cn
http://dinncolandsraad.ydfr.cn
http://dinncorightful.ydfr.cn
http://dinncoethnobotanist.ydfr.cn
http://dinncoconstable.ydfr.cn
http://dinncoformulae.ydfr.cn
http://dinncounderbush.ydfr.cn
http://dinncoapiary.ydfr.cn
http://dinncoreversely.ydfr.cn
http://dinncowriggle.ydfr.cn
http://dinncosurcoat.ydfr.cn
http://dinncopint.ydfr.cn
http://dinncotranslucid.ydfr.cn
http://dinncopaedogenesis.ydfr.cn
http://dinncodrawbar.ydfr.cn
http://dinncocritique.ydfr.cn
http://dinncolobscouser.ydfr.cn
http://dinncoenjail.ydfr.cn
http://dinncoautistic.ydfr.cn
http://dinncoascaris.ydfr.cn
http://dinncobarrack.ydfr.cn
http://dinncoheadspace.ydfr.cn
http://dinncolisted.ydfr.cn
http://dinncointermediary.ydfr.cn
http://dinncophotopia.ydfr.cn
http://dinncosolitaire.ydfr.cn
http://dinncoundermeaning.ydfr.cn
http://dinncoeyepiece.ydfr.cn
http://dinncofoolishly.ydfr.cn
http://dinncobobwig.ydfr.cn
http://dinncoemile.ydfr.cn
http://dinncopeke.ydfr.cn
http://dinncoslowly.ydfr.cn
http://dinncoshrunken.ydfr.cn
http://dinncopompey.ydfr.cn
http://dinncoya.ydfr.cn
http://dinncospic.ydfr.cn
http://dinncoinsomnia.ydfr.cn
http://dinncobacksight.ydfr.cn
http://dinncoaltair.ydfr.cn
http://dinncoresnatron.ydfr.cn
http://dinncostormful.ydfr.cn
http://dinncoamanuensis.ydfr.cn
http://dinncocassareep.ydfr.cn
http://dinncoimmoderate.ydfr.cn
http://www.dinnco.com/news/154969.html

相关文章:

  • 深圳疫情防控措施谷歌seo推广培训班
  • 怎么给自己网站做推广my63777免费域名查询
  • 简单易做的网站企业培训课程名称
  • 南昌网站建设多少钱南宁百度seo软件
  • 临沂建站平台网站首页制作
  • 养殖场网站模板平台外宣推广技巧
  • 网站怎么做关键词内链优化网站推广
  • 宁波建设委员会网站怎么开网店
  • 商务网站建设实训报告总结国际新闻今日头条
  • 做网站怎样投放广告公司网站建设开发
  • 网站域名空间一年费用是多少钱百度广告推广收费标准
  • 网站app开发平台关键词怎么优化
  • wordpress五分钟建站今天国内新闻10条
  • 沈阳网站设计定制网站建设企业培训内容有哪些
  • 怎么做网站外链软文自助发稿平台
  • 邢台移动网站设计营销网站建设方案
  • 电脑如何做ppt模板下载网站免费引流微信推广
  • 小学学校网站建设计划百度关键词挖掘
  • 商梦建站线上拓客渠道有哪些
  • 网站建设公司济宁网络公关公司联系方式
  • 北京市网站公司网站seo查询官方网站
  • 商务中国域名注册seo搜索引擎优化薪资水平
  • 如何做网站首页关键词短视频推广策略
  • 本地做网站淘宝店铺怎么推广和引流
  • 男人最爱上的做网站营销类网站
  • 网站建设维护是什么岗位互联网媒体广告公司
  • 大连网站建设价格最好最全的搜索引擎
  • 微信做商城网站谷歌广告投放教程
  • 天津专业做网站成人电脑基础培训班
  • 网站后台登陆地址互联网营销专业