<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/tesseract-4-is-here-state-of-the-art-ocr-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://ropensci.org/technotes/2018/11/06/tesseract-40/"> rOpenSci - open tools for open science</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p> <img alt="cover image" src="https://i0.wp.com/upload.wikimedia.org/wikipedia/commons/d/d7/8-cell.gif?w=456&ssl=1" data-recalc-dims="1"></p>
<p>Last week Google and friends released the new major version of their OCR system: <a rel="nofollow" href="https://github.com/tesseract-ocr/tesseract/releases" target="_blank">Tesseract 4</a>. This release builds upon 2+ years of hard work and has completely overhauled the internal OCR engine. From the <a rel="nofollow" href="https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00" target="_blank">tesseract wiki</a>:</p>
<blockquote>
<p>Tesseract 4.0 includes a new neural network-based recognition engine that delivers significantly higher accuracy (on document images) than the previous versions, in return for a significant increase in required compute power. On complex languages however, it may actually be faster than base Tesseract.</p>
</blockquote>
<p>We have now also updated the R package <a rel="nofollow" href="https://cloud.r-project.org/web/packages/tesseract/index.html" target="_blank">tesseract</a> to ship with the new Tesseract 4 on MacOS and Windows. It uses the new engine by default, and the results are extremely impressive! Recognition is much more accurate then before, even without manually enhancing the image quality.</p>
<h2>Updating</h2>
<p>The binary R package for Windows and MacOS can be installed directly from CRAN:</p>
<pre><code>install.packages(&quot;tesseract&quot;)
</code></pre>
<p>Tesseract 4 uses a new training data format, so if you had previously installed custom training data you might need to redownload these as well:</p>
<pre><code># If you want to OCR french text:
library(tesseract)
tesseract_download('fra')
</code></pre>
<p>Training data for <code>eng</code> (default) is included with the R package already.</p>
<h2>Testing</h2>
<p>Let’s take a simple example from last month’s <a rel="nofollow" href="https://ropensci.org/blog/2018/08/28/birds-ocr/" target="_blank">blog post</a> about ocr’ing bird drawings from the natural history collection. We use the magick package to preprocess the image (crop the area of interest). The <code>image_ocr()</code> function is a magick wrapper for <code>tesseract::ocr()</code>.</p>
<p><img alt="birds" src="https://i2.wp.com/jeroen.github.io/images/birds.jpg?w=456&ssl=1" data-recalc-dims="1"></p>
<pre><code>library(magick)
image_read(&quot;https://jeroen.github.io/images/birds.jpg&quot;) %>%
  image_crop('1200x300+100+1700') %>%
  image_ocr() %>%
  cat()
</code></pre>
<pre><code>H Grenveld. del Watherby &amp; 0°
CLIMACTERIS PICUMNUS.
(BROWN TREE CREEPER).
</code></pre>
<p>Tesseract has perfectly detected the hand-written species name (both the Latin and English name), and has also found and nearly perfectly predicted the tiny author names. These results would be a very good basis for post-processing and automatic classification. For example we could match these results against known species and authors as illustrated explained in the original <a rel="nofollow" href="https://ropensci.org/blog/2018/08/28/birds-ocr/" target="_blank">blog post</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://ropensci.org/technotes/2018/11/06/tesseract-40/"> rOpenSci - open tools for open science</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/UzVlmmGLo4k" height="1"></a></div>