gdevilbat/google-cloud-vision-php
Composer 安装命令:
composer require gdevilbat/google-cloud-vision-php
包简介
A simple php library for the google cloud vision API
README 文档
README
Overview
Performs Label detection, face detection, Logo detection, explicit content detection, landmark detection, optical character recogition and web detection on images. You can read more about Google cloud vision here https://cloud.google.com/vision/
Getting Started
You will need a google account to use this API so if you do not already have an account with google, head over there and create one
Installation
composer require wapnen/google-cloud-vision-php
Enable the API
To start using the google cloud vision api, follow the instructions here to enable the api for your google account https://cloud.google.com/vision/docs/before-you-begin
Authentication
You must set up an Api key to authenticate your requests. Follow the instructions here https://support.google.com/cloud/answer/6158862?hl=en to set up an API key for your project on google cloud platform console
Usage
<?php
include "vendor/autoload.php";
use GoogleCloudVision\GoogleCloudVision;
use GoogleCloudVision\Request\AnnotateImageRequest;
use GoogleCloudVision\Request\Request;
$annotateImageRequest1 = new AnnotateImageRequest();
$annotateImageRequest1->setImageUri("https://cdn.pixabay.com/photo/2016/02/19/11/25/supreme-court-building-1209701_960_720.jpg");
$annotateImageRequest1->setFeature('IMAGE_PROPERTIES');
$annotateImageRequest1->setFeature('LABEL_DETECTION');
$annotateImageRequest1->setFeature('WEB_DETECTION');
$gcvRequest = new GoogleCloudVision([$annotateImageRequest1], "Your_api_key");
$response = $gcvRequest->annotate();
echo json_encode($response);
?>
Note : You can create as many as 16 Annotate image requests to be sent with the request object
The function setImageUri(); takes a Google Cloud Storage image location, or publicly-accessible image URL. Alternatively you can use setImage(); which takes a base64 encoded image string.
You can set as many features as are available to the annotateImageRequest by calling the setFeature(); function on the annotateImageRequest which takes any of the following enum parameters ; TYPE_UNSPECIFIED, FACE_DETECTION, LANDMARK_DETECTION, LOGO_DETECTION, LABEL_DETECTION, TEXT_DETECTION, DOCUMENT_TEXT_DETECTION, SAFE_SEARCH_DETECTION, IMAGE_PROPERTIES, CROP_HINTS, WEB_DETECTION.
Optionally, you can set the image context for each annotateImageRequest object like so
$annotateImageRequest1 = new AnnotateImageRequest()
$annotateImageRequest1->setImageContext();
$annotateImageRequest1->getImageContext()->setCropHintsParams([1.333]); //array
$annotateImageRequest1->getImageContext()->setWebDetectionParams(false); //boolean
$annotateImageRequest1->getImageContext()->setLanguageHints([]); //array
Finally, the GoogleCloudVision request object takes an array of AnnotateImageRequest objects as the first parameter and the api key as the second parameter
Response object
If successful, you will receive a json object response in the format below;
{
"responses": [
{
object(AnnotateImageResponse)
}
]
}
gdevilbat/google-cloud-vision-php 适用场景与选型建议
gdevilbat/google-cloud-vision-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 77 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 01 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「machine learning」 「Computer Vision」 「google cloud vision api」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gdevilbat/google-cloud-vision-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gdevilbat/google-cloud-vision-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gdevilbat/google-cloud-vision-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Doctrine implementation of the MetaborStd (Statemachine) for PHP 8.2+
Automatically translate and review your content via Lokalise.
Simple and elegant tools for build web application.
Phwoolcon Finite State Machine
2020 PHP: A showcase and classroom for the cutting edge features of PHP 8
An introduction to machine learning in Rubix ML using the famous Iris dataset and the K Nearest Neighbors classifier.
统计信息
- 总下载量: 77
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-03