Guide to incorporating tesseract OCR into a Cordova/Phonegap application

My attempts to use Tesseract OCR with my app have been unsuccessful despite following the instructions provided here.

After inspecting the code using Google Chrome Dev console through the WebView, I encountered an error:

Uncaught SyntaxError: Unexpected token }

This error is located in tesseractPlugin.js:11 within

file:///android_asset/www/plugins/com.tesseract.phonegap/tesseractPlugin/tesseractPlugin.js

Additionally, another error appeared:

Uncaught Error: Module com.tesseract.phonegap.tesseractPlugin.TesseractPlugin does not exist.

This error occurs in cordova.js:1431

I suspect that Cordova is unable to find the plugin due to potential version compatibility issues.

I am frustrated as there seems to be no alternative solutions available online and I lack the knowledge to create my own Cordova plugin.

Furthermore, I followed the project setup instructions meticulously to avoid mistakes but still encountered difficulties. Strangely, I could not download the plugin from

https://github.com/engzhaowei/Tesseract-phonegap-android-example/tree/master/plugins/com.tesseract.phonegap.tesseractPlugin

Therefore, I had to download the full package and retrieve the plugin from

C:\xxx\plugins\com.tesseract.phonegap.tesseractPlugin

Answer №1

If you're looking for a powerful solution, check out tessaract js at . It's a handy javascript library that is compatible with phonegap and quite straightforward to implement. Simply add the cdn script in the header and execute the code snippet to get it up and running. Do keep in mind that tessaract can be a bit slow.

<script src='https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/tesseract.js'></script>

var myimage = document.getElementById("largeImage").src;

Tesseract.recognize(myimage)
.then(function(result){
// console.log(result);
document.getElementById("textarea1").value = result.text; // assign results to a textbox

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps should I take to have a button initiate an AJAX request?

One of the tasks on my list involves a textbox and a button for interaction. Once text is entered into the textbox, I intend to trigger an AJAX request by clicking the button. The purpose of this AJAX call is to extract the text input and incorporate it i ...

Embedding JSON data in a GSP page

My goal is to transfer JSON data to a GSP page and present it in a table format. The expected JSON structure: { "data": [ [ "Tiger Nixon", "System Architect", "Edinburgh" ] ]} I attempted to achieve this with the following co ...

Ensuring Proper Tabulator Width Adjustment Across All Browser Zoom Levels

<div id="wormGearTabulatorTable" style="max-height: 100%; max-width: 100%; position: relative;" class="tabulator" role="grid" tabulator-layout="fitDataTable"><div class="tabulator-header" role="rowgroup"><div class="tabulator-header-co ...

Tips for creating line breaks in Google Chart tooltips

I'm having trouble breaking a line in the code snippet below. Here is the complete code: <html> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script ...

JavaScript - What is the best way to add the same object value into an array?

After spending a few hours trying to figure out how to manage JSON data structured like this: [ { "value": "Osteonecrosis", "Diagnosis_Code": "DIAG002", "NamaCategory": "Primary Category", "FK_Diagnosis_Content_ID": 2 }, { "value ...

Using three.js inside Colab

Here are some examples showcasing bi-directional communications between Python and JavaScript in Google Colab: I'm trying to get this simple three.js demo to work in Colab. Any tips? Despite the seemingly straightforward source code, I'm facing ...

What could be causing BeautifulSoup to overlook certain elements on the page?

For practice, I am in the process of developing an Instagram web scraper. To handle dynamic webpages, I have opted to utilize Selenium. The webpage is loaded using: driver.execute_script("return document.documentElement.outerHTML") (Using this javascript ...

Long variable causing a Nullpointer exception

I'm encountering an issue with the code snippet below: private Long projectNumber; // with getters and setters When I try to check if projectNumber is null or not, I'm receiving a null pointer exception at the if condition. if(selected.getProj ...

Always make sure to call for files using their respective names in

Here is how my project structure looks like: . ├── node_modules ├── package.json ├── www │ ├── css │ ├── js │ ├── file.js │ ├── folder │ ├── file2.js │ ├─ ...

Is there a method to determine whether the user has granted permission for notifications to be enabled?

Once I have requested permission from the user of the website, I need to confirm if they have granted permission before triggering the send() function. What is the most sophisticated approach to achieve this? ...

Incorporating a Streamlit Application into an Established React.js Project via an iFrame

I am in the process of incorporating a Streamlit app into my existing React.js application to take advantage of its data analysis and visualization features. Can this integration be accomplished using an iFrame? Has anyone successfully embedded a Streamlit ...

Node.js web server operating on port 3000 is running a script

I have developed a Node.js script that extracts data from a database and saves it in a file. Additionally, I have set up a Node.js web server listening on port 3000 using forever to keep it running constantly. However, the script currently lacks a web inte ...

Attempting to implement Vue js extensions without relying on NPM or webpack

The issue Currently, I am trying to follow the jqWidgets guidelines provided in the link below to create a dropdown box. However, the challenge I'm facing is that their setup involves using the IMPORT functionality which is restricted by my tech lead ...

Error encountered on Windows 10 version 10.0.19044 during library installation with npm

I've encountered an error while trying to run or install libraries for a project within our organization. E:\GIT\bookshelf>npm install npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail= ...

Evolving characteristics of Bootstrap popover

I am currently working on a text field and button setup where I have implemented a popover feature using Bootstrap. This is the code snippet I am using: function displayPopover() { $("#text").popover("show"); } The popover appear ...

Ways to create a self-contained video viewer

Is it possible to create a self-contained video player similar to jwplayer or the YouTube video player using just HTML, CSS, and JavaScript? I know that I can build a video player by utilizing the video tag along with some custom javascript and css, but ho ...

Amcharts displays individual balloons for each graph instead of a single balloon for all graphs

My goal is to have a single balloon for all stacked graphs. I modified my code according to this guide. Unfortunately, the data for messages is not being displayed. https://i.sstatic.net/2MRhc.jpg Did I make an error in my implementation? function creat ...

Comparing values with Selenium's assertEqual method

I developed a test scenario in Selenium WebDriver utilizing the TestNG framework. I attempted to retrieve and print text using getText() and also incorporate it in Assert.assertEquals(). The issue that is arising is that upon executing this test, an error ...

Is there a way to make the hoverzoom effect only apply to a specific object instead of all objects?

I'm currently troubleshooting my code in order to implement a hover effect on Mui <cards> when a user hovers over the object. I have managed to make it work partially, but the issue is that the effect gets applied to all objects instead of just ...

How can I calculate the total sum of values in an array retrieved from an API call?

Within the array this.state.companiesIncome, I've got 50 objects each containing a {value and date}. However, when attempting to retrieve this.state.companiesIncome[2].value, I'm encountering an error stating: TypeError: Cannot read property &apo ...