Created
March 13, 2021 00:32
-
-
Save symisc/ce43b075da7e91b05f9dee954ffbcfce to your computer and use it in GitHub Desktop.
Given an image with human readable characters. Detect input language & extract text content from there using the PixLab API - https://pixlab.io/cmd?id=ocr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* PixLab PHP Client which is just a single class PHP file without any dependency that you can get from Github | |
* https://github.com/symisc/pixlab-php | |
*/ | |
require_once "pixlab.php"; | |
# Given an image with human readable characters. Detect input language & extract text content from there. | |
# https://pixlab.io/cmd?id=ocr for additional information. | |
/* Target image with human readable text input */ | |
$img = 'http://quotesten.com/wp-content/uploads/2016/06/Confucius-Quote.jpg'; | |
# Your PixLab API Key. Get yours from https://pixlab.io/dashboard | |
$key = 'PIXLAB_API_KEY'; | |
/* Process */ | |
$pix = new Pixlab($key); | |
if( !$pix->get('ocr',array('img' => $img, 'orientation' => true, 'nl' => true)) ){ | |
echo $pix->get_error_message()."\n"; | |
die; | |
} | |
echo "Input language: ".$pix->json->lang; | |
echo "\nText Output: ".$pix->json->output."\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment