OCR Wrapper Library

by onezero
4 years ago
1959 Views

Table of Contents


Voodoo OCR Wrapper Library

Voodoo RPA EDEnvrionment enables the user to develop and integrate everything into their robotic process automation projects. The Voodoo Native OCR Wrapper can be used in EDE environment and provides a single point of contact for OCR works. Below is a sample EDE design to OCR image set to return into Voodoo Data Storage.

To use, you add this OCRLoader library into Voodoo File References in EDE. Also you need Newtonsoft.Json library to deserialize JSON responses.

namespace VoodooImplementation {
    using System;
    using VooDooCommonData.CommonInterface;
    using VooDooCommonData.InstanceData;
    using OCRLoader;
    using Newtonsoft.Json;
    
    public class ComputationEvaluator : System.MarshalByRefObject, IPlugInComputation {
        
        private bool result_;
        
        private VooDooCommonData.InstanceData.PlanDataInstanceManager planDataInstanceManager_;

        public ComputationEvaluator() {
        }
        
        public bool result {
            get {
                return result_;
            }
        }
        
        public virtual VooDooCommonData.InstanceData.PlanDataInstanceManager planDataInstanceManager {
            get {
                return planDataInstanceManager_;
            }
            set {
                planDataInstanceManager_ = value;
            }
        }
        
        public virtual void ExecuteComputation() {
            OCR OCRObj = new OCR();
            string text = OCRObj.ocrSpace(@"C:\Users\oz\Desktop\simple-text-captcha.png", "helloworld");
            dynamic stuff = JsonConvert.DeserializeObject(text);
            string captcha = stuff.ParsedResults[0]["ParsedText"];
            string mcaptcha = captcha.Replace(" ", "").Trim();
            
            /* This Code Is Not Important. Just Set Return OCR Resut Into Voodoo Data Storage*/
            planDataInstanceManager_.SetDataTableValueFromCurrentDataRowIndex(4,"search", "Voodoo");
            planDataInstanceManager_.SetDataTableValueFromCurrentDataRowIndex(4,"captcha", mcaptcha);

            result_ = true;
        }
    }
}

OCR Class

Methods

Property Description
string ocrSpace(string path, string apikey, string isOverlayRequired) OCR given local image and return result as JSON string.

path: Local file path to be OCR. That file can jpg, png or pdf

apikey: Ocr.space api key. You can apply https://ocr.space/OCRAPI

isOverlayRequired: That is a boolean value (true/false). Default = false If true, returns the coordinates of the bounding boxes for each word. If false, the OCR’ed text is returned only as a text block (this makes the JSON reponse smaller)

string text = OCRObj.ocrSpace(@"C:\Users\oz\Desktop\captcha.png", "helloworld");

Real Life Example Video