PHP code example of onepointhub / laravel_ocr

1. Go to this page and download the library: Download onepointhub/laravel_ocr library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

onepointhub / laravel_ocr example snippets


use Ntoufoudis\LaravelOcr\Facades\Ocr;

Ocr::scan($imagePath);



namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Ntoufoudis\LaravelOcr\Facades\Ocr;

class OcrController extends Controller
{
    public function index()
    {
        return view('upload_image');
    }
    
    public function readImage()
    {
        $image = request('image');
        
        if (isset($image) && $image->getPathName()) {
            $parsedText = Ocr::scan($image->getPathName());
            
            return view('parsed_image', compact('parsedText'));
        }
    }
}

//routes/web.php

Route::get('/upload_image', [App\Http\Controllers\OcrController::class, 'index'])->name('home');
Route::post('/upload_image', [App\Http\Controllers\OcrController::class, 'readImage'])->name('read-image');
shell
php artisan vendor:publish --provider=Ntoufoudis\\LaravelOcr\\LaravelOcrServiceProvider
shell
php artisan tesseract:check
shell
php artisan image:parse {imagePaths}