STAY TUNED

~ COMING SOON ~

~ NIT Network Solution ~

Management, Controller, Security, Application, Architecture, Setup and Deploy

~ NIT Cyber Security Solution ~

Prevent security breaches starts with exploits detection and build up protection before you connect.

~ NIT Arduino Hacks ~

Digital controller had been applied widely in this era. It playing maih role in IoT handling sensors and actuators with programmable decision making as well as Artificial Intelligence.

HIDDEN_SEO

CSS_OVERWRITE

HIDDEN_MUSIC

Showing posts with label OCR. Show all posts
Showing posts with label OCR. Show all posts

OCR API Setup & Deploy with PHP

OCR.Space is a free OCR API which allow parsing images and PDF documents to extract the text in JSON format. Since, it's an API, it could be apply the OCR functions by using GET and POST parameter with any languages in development.


Let's get started by signup an FREE tier OCR.Space API key, this acts as a token for service authentication and initialisation, if no access key is attached in a GET or POST parameter, the return results are usually NULL. Kindly, fill in the signup form at here. Once the request is successful, the API key will be sent to your email inbox.


To use the OCR API, the endpoint for POST had been provided as below and support HTTPS and HTTP protocols.
https://api.ocr.space/parse/image To apply the very basic image parsing via URL and reveal the OCR results, the image below is attached in this demonstration.


(IMAGE URL: COPY HERE )

Simply append the parameter of "apikey" and "url" at the end of the API address:
The result of OCR parsed will be as below:
As you can see, the parsing will results a JSON output and from what we can observed, we could extract or export the value we required where param at "ParsedText".

To decode the JSON or extract the value out of this structure, we will suggest a PHP scripting as below:


<?php
$gateway = 'https://api.ocr.space/parse/imageurl';
$key = 'helloworld'; //input your API KEY, this is test key
$img = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZN1vlbHxOM6J01rScGR_4J-s3MwLbseE-qEiH8KxarHe0M06RjugEknQKpyKMJBDzqPnT77D1sGi20SAbOl7MJLN2OeeSCJh5VcgEXKSC7iAHMxyzpuJY01Ko7Pz4yHSeCtBfwNrPv80/s1600/TEXT01.png';

$url = $gateway."?"."apikey=".$key."&url=".$img; //establish the url
$data = file_get_contents($url); // fetch content to variable array
$txt = json_decode($data, true); // decode the JSON feed

echo "<h1> OCR.SPACE API DEMONSTRATION </h1>";
echo "<h2> LOADED IMAGE </h2>"; //show fetch image

echo "<img border=\"0\" data-original-height=\"739\" data-original-width=\"962\" height=\"306\" width=\"400\" src=\"".$img."\"/>";
echo "<h2> OUTPUT </h2>"; //display image text
echo $txt["ParsedResults"][0]["ParsedText"]; //output the ocr text
?>


Simply deploy the codes and edit the highlighted source with any web server, I'm using APACHE and save it to FILENAME.php 


The result will show as below:

The above demonstration is by default OCR options which the interpretation is in ENGLISH OCR. If you wish to perform an OCR applied with different language, simply modify the parameter of API parsing as below:

Simply append the parameter of "apikey" + "url" "language" at the end of the API address:
Let's try with a image with Chinese characters.


(IMAGE URL: COPY HERE)


Edit the PHP coding and append with the parameter.
<?php
$gateway = 'https://api.ocr.space/parse/imageurl';
$key = 'helloworld'; //input your API KEY, this is test key
$img='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5trq6LDiAKgR_FavIeEI5y4iPlxdvYDKW58iZFowgm8JHmSkTsPsqOme4aqsIkxtLuBVYNCMxR_kxjqRmENPiuQusQ5mm-106ezXTr7AzMmOCdPP4oc-VbBuIlxQ4ZVs4WGMjDVsotZ4/s400/cccc.png';
$lang = 'chs';

$url = $gateway."?"."apikey=".$key."&url=".$img."&language=".$lang; //establish the url

?>


The results are perfect!

Note that the OCR language parameter's parsing option as below, simply change the $lang parameter with any of the below validated with the text appeared in the parsed image.

Arabic=ara
Bulgarian=bul
Chinese(Simplified)=chs
Chinese(Traditional)=cht
Croatian = hrv
Czech = cze
Danish = dan
Dutch = dut
English = eng
Finnish = fin
French = fre
German = ger
Greek = gre
Hungarian = hun
Korean = kor
Italian = ita
Japanese = jpn
Norwegian = nor
Polish = pol
Portuguese = por
Russian = rus
Slovenian = slv
Spanish = spa
Swedish = swe
Turkish = tur

The application of OCR is widely applied in automated processing invalided images to text or to obtain valid values from pictures. The OCR is working in AI, integrated environment or to be a part of a processing node in a system to perform text extraction from provided inputs. Happy Explore & Have a nice day, do leave us any comments and we will reply you shortly.



NIT FOR ALL - FACEBOOK
Feel free to share this article around and do like & follow at our Facebook page. We would like to talk about IoT applications in the next post, stay tune.
OCR API Setup & Deploy with PHP

OCR ~ Optical Character Recognition & API Introduction

Optical Character Recognition @ Optical Character Reader which abbreviate as OCR is a technology that applying in printed or written text delivered in an image format to be converted or extract the contained text.

What is OCR

The application of OCR is not limited for only character recognition, it can be a middle man whom process the input and trigger next action from the results after the virtual decision making. It is useful when you are an educator or student and frequently obtain information from books that need to be extract and compile into assignments. OCR also provide business solutions in banking for example reading of the cheque, PDF parsing, LaTex parsing and etc.

WHAT IS API

API had been widely applied in the modern development trends. The API allows heavy processing at server-side and return results or data with authenticated inputs from user side. API makes development easier by integrating all building blocks from one end to the other end. API usually is a gateway which allow information to be parse and output data in JSON, XML, CSV, plain text and etc. formats.

OCR.SPCAE API

The integration of the existing OCR functions with API is to provide an easy way of parsing images and PDF documents to proceed text extractions returned in a JSON format via any nodes over the internet. OCR.Space provide the realtime API for developer for different usage based on different tier, the limitations are input file size, monthly requests, rate limits, page limits and etc. The API provider usually offer a light version of processing for developers for free. Alternatively, if want to integrate the whole functions fully, it charges for maintenance fees and usage tiers.


NIT FOR ALL - FACEBOOK
Please stay with us, the demonstrations and practically applying OCR.Space API will be publish in the coming post. Feel free to share this article around and do like & follow at our Facebook page. 
OCR ~ Optical Character Recognition & API Introduction