Exemplo n.º 1
1
function numbersForFileNamed($fileName)
{
    $tesseract = new \TesseractOCR(BASE_PATH . 'inbox/' . $fileName);
    $tesseract->setWhitelist(range(0, 9));
    return preg_split('/[ \\n]/', $tesseract->recognize());
}
Exemplo n.º 2
0
<?php

require_once 'vendor/autoload.php';
for ($i = 1; $i <= 10; $i++) {
    $tesseract = new TesseractOCR("img/image{$i}.jpg");
    $tesseract->setLanguage('eng');
    $tesseract->setWhitelist(range('a', 'z'), range(0, 9));
    echo $tesseract->recognize() . "\r";
}
 public function testInducedRecognition()
 {
     $tesseract = new TesseractOCR("{$this->imagesDir}gotz.png");
     $tesseract->setWhitelist(range(0, 9));
     $this->assertThat($tesseract->recognize(), $this->LogicalOr($this->equalTo(6012), $this->equalTo(6017)));
 }
Exemplo n.º 4
0
 public function testInducedRecognition()
 {
     $tesseract = new TesseractOCR("{$this->imagesDir}gotz.png");
     $tesseract->setWhitelist(range(0, 9));
     $this->assertEquals(6012, $tesseract->recognize());
 }
Exemplo n.º 5
-1
 public function recognizeText($imageFile)
 {
     require_once "TesseractOCR/TesseractOCR.php";
     require_once "Repositories/CR_File.php";
     // Recognize text from image
     $tesseract = new TesseractOCR($imageFile->filePath);
     $tesseract->setWhitelist(range('A', 'Z'), range('a', 'z'), range(0, 9), '_-.,;"#<>()%{}[]= ');
     $txt = $tesseract->recognize();
     // Save text file
     // public/output/code_filename.ext
     $codeFilePath = "public/output/code_" . $imageFile->fileName . $this->LANGUAGES[$this->language];
     $recognizedCodeFile = new CR_File($codeFilePath);
     $recognizedCodeFile->write($txt);
     return $recognizedCodeFile;
 }