<?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; iOS</title>
	<atom:link href="http://lois.di-qual.net/blog/category/ios/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>
		<item>
		<title>Compile tesseract for iOS SDK 6.0</title>
		<link>http://lois.di-qual.net/blog/compile-tesseract-for-ios-sdk-6-0/</link>
		<comments>http://lois.di-qual.net/blog/compile-tesseract-for-ios-sdk-6-0/#comments</comments>
		<pubDate>Fri, 21 Sep 2012 19:00:34 +0000</pubDate>
		<dc:creator>Loïs Di Qual</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[ios6.0]]></category>
		<category><![CDATA[iphone-sdk]]></category>
		<category><![CDATA[ocr]]></category>

		<guid isPermaLink="false">http://lois.di-qual.net/blog/?p=141</guid>
		<description><![CDATA[Update 10/25/12 Added instructions to integrate an armv7s slice in liblept.a and libtesseract_all.a. Update 09/24/12 To make the iOS integration easier, I made a Github repo containing an Objective-C wrapper for Tesseract. It relies on an other repo containing tesseract &#038; leptonica libs. Feel free to improve them ! Objective-C wrapper: https://github.com/ldiqual/tesseract-ios Compiled libraries: https://github.com/ldiqual/tesseract-ios-lib [...]]]></description>
				<content:encoded><![CDATA[<h3>Update 10/25/12</h3>
<p>Added instructions to integrate an armv7s slice in <code class="codecolorer text default"><span class="text">liblept.a</span></code> and <code class="codecolorer text default"><span class="text">libtesseract_all.a</span></code>.</p>
<h3>Update 09/24/12</h3>
<p>To make the iOS integration easier, I made a Github repo containing an Objective-C wrapper for Tesseract. It relies on an other repo containing tesseract &#038; leptonica libs. Feel free to improve them !</p>
<ul>
<li>Objective-C wrapper: <a href="https://github.com/ldiqual/tesseract-ios">https://github.com/ldiqual/tesseract-ios</a></li>
<li>Compiled libraries: <a href="https://github.com/ldiqual/tesseract-ios-lib">https://github.com/ldiqual/tesseract-ios-lib</a></li>
</ul>
<p>More informations about these repos on my <a href="http://lois.di-qual.net/blog/install-and-use-tesseract-on-ios-with-tesseract-ios/">next article</a>.</p>
<h2>Introduction</h2>
<p>I had troubles while following the compiling guide from this blog: <a href="http://tinsuke.wordpress.com/2011/11/01/how-to-compile-and-use-tesseract-3-01-on-ios-sdk-5/">http://tinsuke.wordpress.com/2011/11/01/how-to-compile-and-use-tesseract-3-01-on-ios-sdk-5/</a>. Some dependencies are missing on a fresh Mountain Lion with Xcode 4.5, and more importantly: the <code class="codecolorer text default"><span class="text">build_dependencies.sh</span></code> won&#8217;t work.</p>
<p>Here is why: Xcode 4.5 and iOS SDK 6.0 don&#8217;t support armv6 anymore.</p>
<p>So here are the steps to build <a href="http://code.google.com/p/tesseract-ocr/">tesseract-ocr</a> for iOS SDK 6.0.</p>
<p><span id="more-141"></span></p>
<h2>Requirements</h2>
<p>If you don&#8217;t have HomeBrew already, that&#8217;s a shame. Run to <a href="http://mxcl.github.com/homebrew/">this website</a> and install it.</p>
<p>Then, install libtool and automake:</p>
<div class="codecolorer-container text 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 /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ brew install libtool automake</div></td></tr></tbody></table></div>
<p>You should have installed &#8216;Command Line Tools&#8217; after the Homebrew installation, but if you forgot: Open Xcode&#8217;s preferences, and install them from the &#8216;Downloads&#8217; tab.</p>
<p>The build process will need <code class="codecolorer text default"><span class="text">libtoolize</span></code>. Just make a symlink to <code class="codecolorer text default"><span class="text">glibtoolize</span></code>:</p>
<div class="codecolorer-container text 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 /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize</div></td></tr></tbody></table></div>
<p>We&#8217;re good to go.</p>
<h2>Sources and compilation</h2>
<p>The steps will more or less follow the tinsuke&#8217;s article, except for one thing: the build script.</p>
<p>Get the following sources:</p>
<ul>
<li>tesseract: <a href="http://code.google.com/p/tesseract-ocr/downloads/detail?name=tesseract-3.01.tar.gz">http://code.google.com/p/tesseract-ocr/downloads/detail?name=tesseract-3.01.tar.gz</a></li>
<li>leptonica: <a href="http://www.leptonica.com/source/leptonica-1.69.tar.gz">http://www.leptonica.com/source/leptonica-1.69.tar.gz</a></li>
<li>build_dependencies.sh: <a href="https://gist.github.com/3763217">https://gist.github.com/3763217</a> (click on &#8220;raw&#8221; and save it to your computer)</li>
</ul>
<p>Then, organize your folder with the following structure:</p>
<div class="codecolorer-container text 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="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">./build/<br />
&nbsp; dependencies/ <br />
&nbsp; leptonica-1.69/<br />
&nbsp; tesseract-3.01/<br />
&nbsp; build_dependencies.sh</div></td></tr></tbody></table></div>
<p>You might want to modify <code class="codecolorer text default"><span class="text">build_dependencies.sh</span></code> to make <code class="codecolorer text default"><span class="text">LEPTON_LIB</span></code> and <code class="codecolorer text default"><span class="text">TESSERACT_LIB</span></code> match the proper folders.</p>
<p>Now, you can build the libraries:</p>
<div class="codecolorer-container text 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 /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ chmod +x ./build_dependencies.sh<br />
$ ./build_dependencies</div></td></tr></tbody></table></div>
<p>In <code class="codecolorer text default"><span class="text">dependencies/lib/</span></code>, you&#8217;ll find <code class="codecolorer text default"><span class="text">liblept.a</span></code> and <code class="codecolorer text default"><span class="text">libtesseract_all.a</span></code>, these are the only libraries you need so you can remove other ones. Both contain armv7 and i386 slices only, but many iOS 5 projects require an armv7s slice.</p>
<p>Just <a href="http://www.galloway.me.uk/2012/09/hacking-up-an-armv7s-library/">follow this Matt Galloway&#8217;s blog post</a> to generate and put an armv7s slice into the libs.</p>
<p>Now you just have to copy <code class="codecolorer text default"><span class="text">dependencies/</span></code> in your Xcode Project, and follow <a href="http://lois.di-qual.net/blog/install-and-use-tesseract-on-ios-with-tesseract-ios/">my next article</a> on how to use tesseract.</p>
]]></content:encoded>
			<wfw:commentRss>http://lois.di-qual.net/blog/compile-tesseract-for-ios-sdk-6-0/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>
