Download the PHP package ahmadmayahi/php-google-vision without Composer
On this page you can find all versions of the php package ahmadmayahi/php-google-vision. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ahmadmayahi/php-google-vision
More information about ahmadmayahi/php-google-vision
Files in ahmadmayahi/php-google-vision
Package php-google-vision
Short Description An elegant wrapper around Google Vision
License MIT
Homepage https://github.com/ahmadmayahi/php-google-vision
Informations about the package php-google-vision

[](https://packagist.org/packages/ahmadmayahi/php-google-vision) [](https://packagist.org/packages/ahmadmayahi/php-google-vision) [](https://github.com/ahmadmayahi/php-google-vision/actions/workflows/run-tests.yml) [](https://github.com/ahmadmayahi/php-google-vision/actions/workflows/php-cs-fixer.yml)
[](https://codecov.io/gh/ahmadmayahi/php-google-vision) [](https://scrutinizer-ci.com/g/ahmadmayahi/php-google-vision/?branch=main) [](https://scrutinizer-ci.com/code-intelligence)
Requires PHP 8.0+
For feedback, please contact me.
This package provides an elegant wrapper around Google Vision API and more.
It's an effort to make Google Vision API easy and fun to work with.
Contents
- Installation
- Creating Google Service Account
- Configuration
- Original Responses
- Integration with Laravel
- Image Text Detection (OCR)
- Get Plain Text
- Get Document
- Handwriting
- PDF and Tiff
- Crop Hints Detection
- Detect Crop Hints
- Draw box around hints
- Crop Image
- Face Detection
- Draw box around faces
- Detect Image Properties
- Label Detection
- Landmark Detection
- Logo Detection
- Object Localizer
- Detect Objects
- Draw Box Around Objects
- Draw Box Around Objects With Text
- Web Detection
Installation
You may install the package via composer:
Creating Google Service Account
First, you must create a Google service account and setup the configuration object.
Configuration
Original Responses
All the features come with getOriginalResponse()
method which returns the original response that's returned by PHP Google Vision Package:
The file()
method accepts the following types:
- Local file path:
path/to/your/file
. - Google Storage path:
gs://path/to/file
. - File resource, such as
fopen()
. SplFileInfo
.SplFileObject
.
Integration with Laravel
Open up the AppServiceProvider
and add the following lines:
Using Dependency Injection:
You may also resolve the object using the app
helper as follows:
Image Text Detection (OCR)
Get plain text
The plain()
method returns an object of type AhmadMayahi\Vision\Data\ImageText
.
Both plain()
and document()
methods return null
if no text will be detected.
You may also get the plain text using __toString()
magic method:
Get Document
The getDocument
returns an object of type AhmadMayahi\Vision\Data\ImageText
.
The difference between
plain()
anddocuemnt()
is that the first one only retrieves the plain text (no bullets, signs, etc...), whereas the latter one tries to retrieve the entire document (including bullets, symbols, etc...).
Handwriting
The document
method can also be used to detect handwriting in an image.
PDF and Tiff
Coming soon.
Crop Hints Detection
Crop Hints suggests vertices for a crop region on an image.
Detect Crop Hints
Draw box around hints
You may use the drawBoxAroundHints
method as follows:
Crop Image
You may export the cropped image as follows:
Original Image:
Cropped Image:
Face Detection
Face Detection detects multiple faces within an image along with the associated key facial attributes such as emotional state or wearing headwear
.
The detect
method returns a Generator
of AhmadMayahi\Vision\Data\Face
:
The anger
, surprise
and joy
etc... return likelihoods ratings which are expressed as six different values:
UNKNOWN
.VERY_UNLIKELY
.UNLIKELY
.POSSIBLE
.LIKELY
.VERY_LIKELY
.
See Likelihood.
You may get the results as array:
Or as JSON:
asArray
andasJson
is supported in all the features that returnGenerator
.
Draw box around faces
All the drawing methods return an object of type
AhmadMayahi\Vision\Support\Image
.
This feature doesn't support Google Storage yet.
Image Properties Detection
The Image Properties feature detects general attributes of the image, such as dominant color.
The detect
method returns a Generator
of AhmadMayahi\Vision\Data\ImageProperties
:
Landmark Detection
Landmark Detection detects popular natural and human-made structures within an image.
Safe Search Detection
SafeSearch Detection detects explicit content such as adult content or violent content within an image.
The detect
method returns an object of type AhmadMayahi\Vision\Data\SafeSearch
:
Label Detection
Detect and extract information about entities in an image, across a broad group of categories.
The detect
method returns an a Generator
of labels:
Logo Detection
Detect and extract information about entities in an image, across a broad group of categories.
The detect
method returns an Generator
of logos:
Object Localizer
Object Localizer detects and extract multiple objects in an image with Object Localization.
Detect Objects
The detect
method returns a Generator
of AhmadMayahi\Vision\Data\LocalizedObjectData
:
Draw Box Around Objects
You may draw box around objects using the drawBoxAroundObjects
method:
The drawBoxAroundObjects()
takes an optionalcallback
as a second parameter:
This feature doesn't support Google Storage yet.
Draw Box Around Objects With Text
You may want to draw box around objects and include the object's text as well:
This feature doesn't support Google Storage yet.
Web Detection
Web Detection detects Web references to an image.
The detect
method returns either an object of tupe AhmadMayahi\Vision\Data\WebData
or null
value.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Ahmad Mayahi
- All Contributors
License
The MIT License (MIT). Please see License File for more information.