基于Tesseract的带位置离线OCR

基于Tesseract的带位置离线OCR


DrGraph QQ:282397369

过年哪里也去不了,尝试研究一下自己的文字识别需求。东折腾西折腾,居然用Tesseract达到一定效果。随便拿一张App Store的屏幕图像进行测试。
AppStore测试图片
识别耗时1334毫秒,本地的速度比网络速度还是要快些。具体含位置的识别结果为:

<OcrResult elapse="1840" height="1334" method="DrGraph" number="41" width="750">
	<item h="23" rect="12, 9, 136, 23" text="吧中 中国联通" w="136" x="12" y="9"/>
	<item h="23" rect="327, 9, 102, 23" text="上午9:58" w="102" x="327" y="9"/>
	<item h="23" rect="531, 9, 209, 23" text="盒 国 10096 国宝,4" w="209" x="531" y="9"/>
	<item h="32" rect="56, 66, 215, 32" text="Q 多多自走棋" w="215" x="56" y="66"/>
	<item h="32" rect="642, 66, 63, 32" text="取消" w="63" x="642" y="66"/>
	<item h="32" rect="572, 68, 32, 32" text="(null)" w="32" x="572" y="68"/>
	<item h="32" rect="187, 180, 168, 32" text="多多自走棋" w="168" x="187" y="180"/>
	<item h="28" rect="606, 226, 59, 28" text="获取" w="59" x="606" y="226"/>
	<item h="24" rect="188, 227, 259, 24" text="自走棋就是多多自走棋" w="259" x="188" y="227"/>
	<item h="20" rect="184, 272, 116, 20" text="寅席寅诬交" w="116" x="184" y="272"/>
	<item h="22" rect="322, 272, 77, 22" text="5.93万" w="77" x="322" y="272"/>
	<item h="16" rect="577, 281, 115, 16" text="App 内购买项目" w="115" x="577" y="281"/>
	<item h="19" rect="516, 588, 114, 19" text="虽“we" w="114" x="516" y="588"/>
	<item h="24" rect="591, 591, 62, 24" text="。 。。 |" w="62" x="591" y="591"/>
	<item h="12" rect="521, 608, 16, 12" text="辑" w="16" x="521" y="608"/>
	<item h="39" rect="305, 643, 264, 39" text="注国面重制:" w="264" x="305" y="643"/>
	<item h="15" rect="343, 693, 191, 15" text="汪1 八以山癌大风头全一亲朋" w="191" x="343" y="693"/>
	<item h="32" rect="186, 805, 133, 32" text="皇家骑士" w="133" x="186" y="805"/>
	<item h="28" rect="606, 851, 59, 28" text="获取" w="59" x="606" y="851"/>
	<item h="24" rect="185, 852, 156, 24" text="二次元自走棋" w="156" x="185" y="852"/>
	<item h="24" rect="185, 896, 51, 24" text="预订" w="51" x="185" y="896"/>
	<item h="16" rect="577, 906, 115, 16" text="App 内购买项目" w="115" x="577" y="906"/>
	<item h="12" rect="498, 965, 53, 12" text="ASSSZ" w="53" x="498" y="965"/>
	<item h="21" rect="528, 978, 51, 21" text="站" w="51" x="528" y="978"/>
	<item h="28" rect="71, 1117, 30, 28" text="(null)" w="30" x="71" y="1117"/>
	<item h="25" rect="675, 1147, 35, 25" text="ZE" w="35" x="675" y="1147"/>
	<item h="60" rect="57, 1174, 141, 60" text="“有枕歼" w="141" x="57" y="1174"/>
	<item h="54" rect="451, 1182, 204, 54" text="醒JESYY肥" w="204" x="451" y="1182"/>
	<item h="22" rect="679, 1183, 31, 22" text="虱" w="31" x="679" y="1183"/>
	<item h="15" rect="225, 1192, 20, 15" text="* 有" w="20" x="225" y="1192"/>
	<item h="29" rect="323, 1207, 103, 29" text=",,关电克" w="103" x="323" y="1207"/>
	<item h="46" rect="505, 1249, 38, 46" text="(null)" w="38" x="505" y="1249"/>
	<item h="46" rect="203, 1251, 43, 46" text="多" w="43" x="203" y="1251"/>
	<item h="44" rect="56, 1252, 36, 44" text="(null)" w="36" x="56" y="1252"/>
	<item h="44" rect="653, 1252, 42, 44" text="Q" w="42" x="653" y="1252"/>
	<item h="43" rect="354, 1253, 43, 43" text="个" w="43" x="354" y="1253"/>
	<item h="19" rect="205, 1310, 38, 19" text="游戏" w="38" x="205" y="1310"/>
	<item h="19" rect="505, 1310, 38, 19" text="更新" w="38" x="505" y="1310"/>
	<item h="19" rect="655, 1310, 38, 19" text="搜索" w="38" x="655" y="1310"/>
	<item h="19" rect="46, 1312, 56, 19" text="Today" w="56" x="46" y="1312"/>
	<item h="18" rect="356, 1313, 37, 18" text="pp" w="37" x="356" y="1313"/>
</OcrResult>

把识别结果和原图对比一下,就直观很多
识别结果与原图比对飞速
总的来说,该对的地方都差不多对了。也算是2020年的做第一个小工作。
先自己用,测试得差不多之后再做成一个小工具。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值