<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://itecfun.com/extern.php?action=feed&amp;tid=3375&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[个人知识管理站 / python3.6  + tesseract-orc 4.0 + pillow 5.1图片识别（中文识别）(源码 可执行）【原创】]]></title>
		<link>http://www.itecfun.com/viewtopic.php?id=3375</link>
		<description><![CDATA[python3.6  + tesseract-orc 4.0 + pillow 5.1图片识别（中文识别）(源码 可执行）【原创】 最近发表的帖子。]]></description>
		<lastBuildDate>Mon, 26 Nov 2018 02:50:59 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[python3.6  + tesseract-orc 4.0 + pillow 5.1图片识别（中文识别）(源码 可执行）【原创】]]></title>
			<link>http://www.itecfun.com/viewtopic.php?pid=3648#p3648</link>
			<description><![CDATA[<p>tesseract4.0安装参考<a href="https://blog.csdn.net/a745233700/article/details/80108652" rel="nofollow">链接进入</a></p><p>以下代码保存文件名为trans2Chi_sim.py</p><div class="codebox"><pre class="vscroll"><code>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from PIL import Image
import pytesseract

import argparse

#命令行执行 添加图片目录和结果保存路径
ap = argparse.ArgumentParser()

ap.add_argument(&quot;-i&quot;,&quot;--image&quot;,required=True,help=&quot;path to input image&quot;)
#结果保存的文件可以不设置，默认保存到当前目录下的result.txt文件中
ap.add_argument(&quot;-r&quot;,&quot;--result&quot;,required=False,help=&quot;the name of the result txt file save name&quot;)

args = vars(ap.parse_args())

#获取图片
img_path = args[&quot;image&quot;]
print(&#039;image path : %s&#039;%img_path)

#识别结果默认保存到当前目录result.txt文件中
res_path =&#039;result&#039;
if args[&quot;result&quot;] is not None:
	res_path = args[&quot;result&quot;]

#print(&#039;result path : %s&#039;%res_path)

image = Image.open(img_path)
#使用tessdata chi_sim简体中文训练数据进行识别
text = pytesseract.image_to_string(image, lang=&#039;chi_sim&#039;)

filename = res_path
if &#039;.txt&#039; not in res_path:
	filename = res_path+&quot;.txt&quot;
#结果保存
with open(filename,&#039;w&#039;) as f:
	f.write(text.replace(&#039; &#039;,&#039;&#039;))  #识别后每个字之间有空格，需要去掉空格

print(&#039;识别内容已保存到文件：%s&#039;%filename)</code></pre></div><br /><p>命令号执行如下：<br />python trans2Chi_sim.py -i imagename.jpg [ -r result.txt]</p><p>非手写字体识别率非常高，很不错</p>]]></description>
			<author><![CDATA[dummy@example.com (xuyg)]]></author>
			<pubDate>Mon, 26 Nov 2018 02:50:59 +0000</pubDate>
			<guid>http://www.itecfun.com/viewtopic.php?pid=3648#p3648</guid>
		</item>
	</channel>
</rss>
