<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code-It &#187; tesseract</title>
	<atom:link href="http://lois.di-qual.net/blog/tag/tesseract/feed/" rel="self" type="application/rss+xml" />
	<link>http://lois.di-qual.net/blog</link>
	<description></description>
	<lastBuildDate>Tue, 30 Oct 2012 19:19:29 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Install and use tesseract on iOS with tesseract-ios</title>
		<link>http://lois.di-qual.net/blog/install-and-use-tesseract-on-ios-with-tesseract-ios/</link>
		<comments>http://lois.di-qual.net/blog/install-and-use-tesseract-on-ios-with-tesseract-ios/#comments</comments>
		<pubDate>Mon, 08 Oct 2012 21:56:02 +0000</pubDate>
		<dc:creator>Loïs Di Qual</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[lib]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[tesseract]]></category>

		<guid isPermaLink="false">http://lois.di-qual.net/blog/?p=159</guid>
		<description><![CDATA[Update 10/10/12 I updated tesseract-ios-lib with a (fake) armv7s slice. There is no need to remove armv7s from build architectures anymore. More informations about this change on my previous post. Introduction In my last article about how to compile tesseract for iOS SDK 6, I quickly posted two links to my github repos: tesseract-ios: an [...]]]></description>
				<content:encoded><![CDATA[<h3>Update 10/10/12</h3>
<p>I updated <code class="codecolorer text default"><span class="text">tesseract-ios-lib</span></code> with a (fake) armv7s slice. There is no need to remove armv7s from build architectures anymore. More informations about this change on <a href="http://lois.di-qual.net/blog/compile-tesseract-for-ios-sdk-6-0/">my previous post</a>.</p>
<h2>Introduction</h2>
<p>In my last article about <a href="http://lois.di-qual.net/blog/compile-tesseract-for-ios-sdk-6-0/">how to compile tesseract for iOS SDK 6</a>, I quickly posted two links to my github repos:</p>
<ul>
<li><a href="https://github.com/ldiqual/tesseract-ios">tesseract-ios</a>: an Objective-C wrapper for tesseract</a></li>
<li><a href="https://github.com/ldiqual/tesseract-ios-lib">tesseract-ios-lib</a>: the tesseract library compiled for iOS (universal armv7/i386 library)</a>
</ul>
<p>Some comments complained about the lack of guide to install and use this wrapper. I&#8217;m going to show you how to build a new iOS project with tesseract, from scratch.</p>
<p><span id="more-159"></span></p>
<h2>Create the project</h2>
<p>Create a simple Single View Application from XCode:</p>
<p><a href="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_create_project.png"><img src="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_create_project-1024x628.png" alt="" title="ts_create_project" width="1024" height="628" class="alignnone size-large wp-image-188" /></a></p>
<p>Name it whatever you want:</p>
<p><a href="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_create_project2.png"><img src="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_create_project2-1024x628.png" alt="" title="ts_create_project2" width="1024" height="628" class="alignnone size-large wp-image-189" /></a></p>
<h2>Project structure</h2>
<p>Download <a href="https://github.com/ldiqual/tesseract-ios">tesseract-ios</a>, <a href="https://github.com/ldiqual/tesseract-ios-lib">tesseract-ios-lib</a>, and <a href="http://code.google.com/p/tesseract-ocr/downloads/list">your language trained data</a>.</p>
<p>Then, open your project folder in Finder, and organise it like this:</p>
<p><a href="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_folder_structure.png"><img src="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_folder_structure.png" alt="" title="ts_folder_structure" width="528" height="542" class="alignnone size-full wp-image-190" /></a></p>
<p>Add &#8220;tesseract-ios&#8221; and &#8220;tesseract-ios-lib&#8221; in your project by creating groups:</p>
<p><a href="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_add_libs.png"><img src="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_add_libs-1024x628.png" alt="" title="ts_add_libs" width="1024" height="628" class="alignnone size-large wp-image-184" /></a></p>
<p>Then, add &#8220;tessdata&#8221; <strong>by reference</strong>:</p>
<p><a href="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_add_tessdata.png"><img src="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_add_tessdata-1024x628.png" alt="" title="ts_add_tessdata" width="1024" height="628" class="alignnone size-large wp-image-185" /></a></p>
<p>This step is extremely important, double check that you&#8217;re adding it by reference or your application will crash.</p>
<h2>Project settings</h2>
<p>Go to your project configuration, select your target, and click on &#8220;Build Settings&#8221;. Then, set the C++ compiler to default:</p>
<p><a href="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_change_compiler.png"><img src="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_change_compiler.png" alt="" title="ts_change_compiler" width="826" height="313" class="alignnone size-full wp-image-187" /></a></p>
<p>And set the build architecture to &#8220;armv7&#8243; (instead of &#8220;armv7 armv7s&#8221;, as tesseract-ios-lib doesn&#8217;t contain an armv7s slice for now):</p>
<p><a href="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_change_arch.png"><img src="http://lois.di-qual.net/blog/wp-content/uploads/2012/10/ts_change_arch.png" alt="" title="ts_change_arch" width="772" height="487" class="alignnone size-full wp-image-186" /></a></p>
<p>We&#8217;re ready to use tesseract.</p>
<h2>Usage</h2>
<p>Add an image called &#8220;image_sample.jpg&#8221; to your project. </p>
<p>Then, in <code class="codecolorer text default"><span class="text">ViewController.m</span></code>, add <code class="codecolorer text default"><span class="text">#import tesseract.h</span></code> and put the following lines in <code class="codecolorer text default"><span class="text">-viewDidLoad</span></code>:</p>
<div class="codecolorer-container objc twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Tesseract<span style="color: #002200;">*</span> tesseract <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>Tesseract alloc<span style="color: #002200;">&#93;</span> initWithDataPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;tessdata&quot;</span> language<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;eng&quot;</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#91;</span>tesseract setImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;image_sample.jpg&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#91;</span>tesseract recognize<span style="color: #002200;">&#93;</span>;<br />
<br />
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@&quot;</span>, <span style="color: #002200;">&#91;</span>tesseract recognizedText<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>Methods reference is available <a href="https://github.com/ldiqual/tesseract-ios">on the project repo</a>.</p>
<p>You should get the image-extracted text in your console.</p>
<h2>Project code</h2>
<p>You can download the tutorial source code right here: <a href='http://lois.di-qual.net/blog/wp-content/uploads/2012/10/TesseractSample.zip'>TesseractSample</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lois.di-qual.net/blog/install-and-use-tesseract-on-ios-with-tesseract-ios/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
	</channel>
</rss>
