Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use Google Cloud Vision Sample
<?php
use Curl\Curl;
$api_url = env('GOOGLE_CLOUDVISION_API_URL');
$api_key = env('GOOGLE_CLOUDVISION_API_KEY');
$curl = new Curl();
$curl_url = $api_url . $api_key;
$curl->setHeader('Content-Type', 'application/json');
$image_path = 'image_path';
$file = file_get_contents($image_path);
$send_json = json_encode([
"requests" => [
"image" => [
"content" => base64_encode($file)
],
"features" => [
// 物体認識
[
"type" => "LABEL_DETECTION",
"maxResults" => 5
],
],
"imageContext" => [
"languageHints" => "ja"
]
]
]);
$curl->post($curl_url, $send_json);
$response = $curl->response;
var_dump($response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.