private function parseContent($fileUri, $language)
 {
     if (!File::exists($fileUri)) {
         throw new Exception('Document parsing job #' . $this->job->getJobId() . ' received a uri to a file that does not seem to exist.');
     }
     $tesseract = new TesseractOCR($fileUri);
     $tesseract->setTempDir(Config::get('paperwork.tesseractTempDirectory'));
     if (isset($language)) {
         $tesseract->setLanguage($language);
     }
     return $tesseract->recognize();
 }
Example #2
-1
 public function getOCR()
 {
     require_once base_path() . '/vendor/thiagoalessio/tesseract_ocr/TesseractOCR/TesseractOCR.php';
     $tesseract = new TesseractOCR(public_path() . '/assets/img/social/fb_login.png');
     $tesseract->setTempDir(storage_path());
     $tesseract->setLanguage('eng');
     //same 3-letters code as tesseract training data packages
     echo $tesseract->recognize();
 }
Example #3
-1
 function ocr($img, $lng = 'fre')
 {
     $t = new \TesseractOCR($img);
     $t->setTempDir(CACHE_PATH);
     // $t->setLanguage($lng);
     return $t->recognize();
 }
 /**
  * Get Ocr uploaded Image Text.
  *
  * @return with Success with Text Extracted or Error
  */
 public function postUpload()
 {
     // Build the input for our validation
     $input = array('image' => Input::file('image'));
     // Within the ruleset, make sure we let the validator know that this
     // file should be an image
     $rules = array('image' => 'required|mimes:jpeg,png,pdf');
     // Now pass the input and rules into the validator
     $validator = Validator::make($input, $rules);
     // Check to see if validation fails or passes
     if ($validator->fails()) {
         // Redirect with a helpful message to inform the user that
         // the provided file was not an adequate type
         return Redirect::back()->with('message', 'Error: The provided file was not an image');
     } else {
         $file = Input::file('image');
         $destinationPath = 'uploads/photos';
         $image = $file->getClientOriginalName();
         Input::file('image')->move($destinationPath, $image);
         require_once base_path() . '/vendor/thiagoalessio/tesseract_ocr/TesseractOCR/TesseractOCR.php';
         $tesseract = new TesseractOCR(public_path() . '/' . $destinationPath . '/' . $image);
         $tesseract->setTempDir(storage_path());
         $tesseract->setLanguage('eng');
         //same 3-letters code as tesseract training data packages
         $ocr = $tesseract->recognize();
         return Redirect::route('upload-form')->with('message', 'Success: File upload was successful')->with('ocr', $ocr);
     }
     return Redirect::back()->with('error', 'An error occured');
 }