google-apiclient icon indicating copy to clipboard operation
google-apiclient copied to clipboard

Issue using Google Vision

Open davidpaulalbert opened this issue 8 years ago • 5 comments

From what I can tell, Google Cloud Vision is included in the API services. I've got everything setup but when I try to run a basic test (using an example from the Google Cloud Client PHP Library for Google Vision), I get an undefined method error. Here's my code:

$vision = Google::make('vision');
$familyPhotoResource = fopen('images/1e5a7f132d42540feae50b187233676b/592e338a86913-071616-098-1700x1152.jpg', 'r');

$image = $vision->image($familyPhotoResource, ['FACE_DETECTION']);
		
$result = $vision->annotate($image);
return $result;

I'm adding use Google at the top of my controller and I've tried both $vision = Google::make('vision'); and $vision = \Google::make('vision');

When I run the function it returns "Call to undefined method Google_Service_Vision::image()"

It references this line for the error:

$image = $vision->image($familyPhotoResource, ['FACE_DETECTION']);

Any ideas? Any help would be greatly appreciated.

davidpaulalbert avatar Jun 01 '17 03:06 davidpaulalbert

I think it's ->images instead of ->image.

https://github.com/google/google-api-php-client-services/blob/master/src/Google/Service/Vision.php

The constructor outlines the methods available for that service.

Sent from my iPhone

On 1 Jun 2017, at 04:03, davidpaulalbert [email protected] wrote:

From what I can tell, Google Cloud Vision is included in the API services. I've got everything setup but when I try to run a basic test (using an example from the Google Cloud Client PHP Library for Google Vision, I get an undefined method error. Here's my code: ` $vision = Google::make('vision');

$familyPhotoResource = fopen('images/1e5a7f132d42540feae50b187233676b/592e338a86913-071616-098-1700x1152.jpg', 'r');

$image = $vision->image($familyPhotoResource, [ 'FACE_DETECTION' ]);

$result = $vision->annotate($image); return $result;` I'm adding use Google at the top of my controller and I've tried both $vision = Google::make('vision'); and $vision = \Google::make('vision');

When I run the function it returns "Call to undefined method Google_Service_Vision::image()" Any ideas? Any help would be greatly appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

pulkitjalan avatar Jun 01 '17 04:06 pulkitjalan

Thanks--I actually tried that before posting. Same error but returns "Call to undefined method Google_Service_Vision::images()"

Any other ideas?

davidpaulalbert avatar Jun 01 '17 13:06 davidpaulalbert

FWIW, I don't think the proper library of Google Cloud Vision is loading with your package. Not your fault obviously as I know you're just loading the Google APIs and your package is just a wrapper. I ended up just installing the Google Cloud lib for PHP and calling the class directly without issues.

davidpaulalbert avatar Jun 01 '17 21:06 davidpaulalbert

Right ok, thanks for letting me know. Do u Ming leaving a snippet of what you did below to get it working please. It may be the wrapper can be updated to support it properly in case things have changed on the google client api?

Sent from my iPhone

On 1 Jun 2017, at 22:39, davidpaulalbert [email protected] wrote:

FWIW, I don't think the proper library of Google Cloud Vision is loading with your package. Not your fault obviously as I know you're just loading the Google APIs and your package is just a wrapper. I ended up just installing the Google Cloud lib for PHP and calling the class directly without issues.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

pulkitjalan avatar Jun 02 '17 03:06 pulkitjalan