This package makes working with Google Vision a breeze. Once it has been set up you can do these things:
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->text($imagePath);
// statically
use Pkboom\GoogleVision\Facades\GoogleVision;
GoogleVision::face($imagePath);
You can install the package via composer:
composer require pkboom/google-vision
You must publish the configuration with this command:
php artisan vendor:publish --provider="Pkboom\GoogleVision\GoogleVisionServiceProvider"
This will publish a file called google-vision.php in your config-directory with these contents:
return [
/*
* Path to the json file containing the credentials.
*/
'service_account_credentials_json' => storage_path('app/service-account/credentials.json'),
];
how to obtain the credentials to communicate with google calendar
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->text($imagePath);
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->logo($imagePath);
// with extension
$result = $googleVision->logo($imagePath, $imageExtension);
// with file output
$result = $googleVision
->output($outputFilePath);
->logo($imagePath);
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->cropHints($imagePath);
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->document($imagePath);
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->face($imagePath, $extension, $outputPath);
// with extension
$result = $googleVision->face($imagePath, $imageExtension);
// with file output
$result = $googleVision
->output($outputFilePath);
->face($imagePath);
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->imageProperty($imagePath);
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->label($imagePath);
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->landmark($imagePath);
// with extension
$result = $googleVision->landmark($imagePath, $imageExtension);
// with file output
$result = $googleVision
->output($outputFilePath);
->landmark($imagePath);
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->object($imagePath);
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->safeSearch($imagePath);
use Pkboom\GoogleVision\GoogleVisionFactory;
$googleVision = GoogleVisionFactory::create();
$result = $googleVision->web($imagePath);
// with geo results
$result = $googleVision
->includeGeoResult()
->web($imagePath);
You can detect pdf and store it as Json on Google Cloud Storage. Destination is set to gs://your-bucket/results
by default.
use Pkboom\GoogleVision\GoogleVisionFactory;
$path = 'gs://your-bucket/file.pdf';
$output = 'gs://your-bucket/any/';
$googleVision = GoogleVisionFactory::create();
$googleStorage->pdf($path, $output);
// with destination
$googleStorage
->to($output)
->pdf($path, $output);