added keras support
This commit is contained in:
@@ -175,6 +175,10 @@ class OCRController extends ApiController
|
||||
$data['ocr']['pixelate'] = $result;
|
||||
imagedestroy($imgcreate);
|
||||
|
||||
// keras
|
||||
$cmd = "python3 scripts/keras.py " . base64_encode(file_get_contents($tmpfname));
|
||||
$command = escapeshellcmd($cmd); #no special characters it will work
|
||||
$data['ocr']['keras'] = shell_exec($command);
|
||||
|
||||
unlink($tmpfname);
|
||||
return $this->respondJson($data);
|
||||
@@ -203,28 +207,4 @@ class OCRController extends ApiController
|
||||
|
||||
// // Do something with the text from Tesseract
|
||||
// echo $text;
|
||||
|
||||
|
||||
// function is_ani($filename) {
|
||||
// if(!($fh = @fopen($filename, 'rb')))
|
||||
// return false;
|
||||
// $count = 0;
|
||||
// //an animated gif contains multiple "frames", with each frame having a
|
||||
// //header made up of:
|
||||
// // * a static 4-byte sequence (\x00\x21\xF9\x04)
|
||||
// // * 4 variable bytes
|
||||
// // * a static 2-byte sequence (\x00\x2C) (some variants may use \x00\x21 ?)
|
||||
|
||||
// // We read through the file til we reach the end of the file, or we've found
|
||||
// // at least 2 frame headers
|
||||
// $chunk = false;
|
||||
// while(!feof($fh) && $count < 2) {
|
||||
// //add the last 20 characters from the previous string, to make sure the searched pattern is not split.
|
||||
// $chunk = ($chunk ? substr($chunk, -20) : "") . fread($fh, 1024 * 100); //read 100kb at a time
|
||||
// $count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s', $chunk, $matches);
|
||||
// }
|
||||
|
||||
// fclose($fh);
|
||||
// return $count > 1;
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user