function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shruti NigamShruti Nigam 

Error in using OCR(Optical Character Recognition)

Hi All,

I am using tessract.js for converting images to text but it is giving error in lightning component.


I have also tried to use as a static resource but it is still giving error.

Anyone know how to convert images to text in lightning component.
Below is my code.

Component
<aura:component implements="lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">


    <ltng:require scripts="https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/tesseract.js"/>
    
    
    
    
    <lightning:layout>
        <lightning:layoutItem padding="around-small" size ="12">
            <div aria-labelledby="newexpenseform">

                <fieldset class="slds-box slds-theme--default background" size ="12">
					
                  
                    <div class="slds-align_absolute-center slds-p-top_x-large">

                        <lightning:input type="file" 
                                         aura:id="file" 
                                         variant="label-inline" 
                                         name="file" 
                                         onchange="{!c.hulk }"/>  
                    </div>

                   
                    
                    
                </fieldset>
            </div>
        </lightning:layoutItem>
    </lightning:layout>
</aura:component>

Controller
({
	 hulk: function (component, event,helper) 
    {
         var files = event.getSource().get("v.files");
         alert(files);


         console.log(files);
		
         Tesseract.recognize(files).then(function(result)
         {
             console.log(result.text);
             alert(result.text);
         });
  		
        $A.enqueueAction(action);
	}
})

Thanks in advance
 
Oshin AgrawalOshin Agrawal
Hey,

Did you get this resolved?
I am looking for something similar.