Created
November 28, 2016 10:55
-
-
Save ytakky2014/447c3e0caf636d5680e18425a3699937 to your computer and use it in GitHub Desktop.
Use Google Cloud Vision Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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