Google Cloud Vision Client Library (PHP) Image Labels - Number of results?Latest Google PHP client library has no working autoloaderProblems with Google API Client Library for PHPGoogle APIs Client Library for PHP and Codeigniter 3Using the Google Cloud Vision API with a simple API keyHow to work Google Vision Api with Php library by using uri?I can't connect to google APIs with the PHP client libraryWhy is AWS Rekognition faster than Google Cloud Vision?Unknown error in PHP when using Google Cloud Vision ServiceHow To Convert Google Client Vision Library Response To JsonHow to handle efficiently Google Vision API Client Lib response?

Make assumption for function with variable argument

Struggling with cyclical dependancies in unit tests

Telling manager project isn't worth the effort?

Strange pattern-matching: is it correct?

How to include a table in the footnote environment

What do you call a flexible diving platform?

Why would anyone ever invest in a cash-only etf?

Examples of simultaneous independent breakthroughs

Can a US President, after impeachment and removal, be re-elected or re-appointed?

How to go ahead with methods that only one derived class implements from a common interface?

What is "aligned sequences" and "consensus sequence" in the context of sequence logo? How to compute these?

ECDSA: Why is SigningKey shorter than VerifyingKey

How can I kill my goat?

Why isn't there a serious attempt at creating a third mass-appeal party in the US?

To find islands of 1 and 0 in matrix

Did the Americans trade destroyers in the "destroyer deal" that they would later need themselves?

Does Wolfram Mathworld make a mistake describing a discrete probability distribution with a probability density function?

Is this photo showing a woman standing in the nude before teenagers real?

How to access HTML input values from Twig and vice versa

Why is the Apollo LEM ladder so far from the ground?

Summoning A Technology Based Demon

Why do they sell Cat 5 Ethernet splitters if you can’t split the signal?

Reset-ItemField failing silently

reconstruction filter - How does it actually work?



Google Cloud Vision Client Library (PHP) Image Labels - Number of results?


Latest Google PHP client library has no working autoloaderProblems with Google API Client Library for PHPGoogle APIs Client Library for PHP and Codeigniter 3Using the Google Cloud Vision API with a simple API keyHow to work Google Vision Api with Php library by using uri?I can't connect to google APIs with the PHP client libraryWhy is AWS Rekognition faster than Google Cloud Vision?Unknown error in PHP when using Google Cloud Vision ServiceHow To Convert Google Client Vision Library Response To JsonHow to handle efficiently Google Vision API Client Lib response?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am using the upper mentioned library (Google Cloud Vision Client Library v1) in PHP to assign labels to images... so far so good. It all works, except it returns fewer results than on the google test page... as far as I understand it has to do with a "max_results" parameter which defaults to 10, but I am not able to find where/how to set it manually...
There was a similar question here on Python and there it was as simple as passing it as a parameter - I have tried many options to do this in PHP, but apparently I am doing something wrong...



Here is a link to the documentation : https://googleapis.github.io/google-cloud-php/#/docs/cloud-vision/v0.19.3/vision/v1/imageannotatorclient?method=labelDetection
I am guessing I have to pass it to the "optionalArgs" parameter... but not exactly sure how to do this...



Here is more or less what my code is:



require __DIR__ . '/vendor/autoload.php';

use GoogleCloudVisionV1ImageAnnotatorClient;

$this->client = new ImageAnnotatorClient();
$response = $this->client->labelDetection(...THE IMAGE...);
$labels = $response->getLabelAnnotations();

if ($labels)
foreach ($labels as $label)
// do something with $label->getDescription()




Anyone got an idea how to get more results in the $labels array?










share|improve this question






























    0















    I am using the upper mentioned library (Google Cloud Vision Client Library v1) in PHP to assign labels to images... so far so good. It all works, except it returns fewer results than on the google test page... as far as I understand it has to do with a "max_results" parameter which defaults to 10, but I am not able to find where/how to set it manually...
    There was a similar question here on Python and there it was as simple as passing it as a parameter - I have tried many options to do this in PHP, but apparently I am doing something wrong...



    Here is a link to the documentation : https://googleapis.github.io/google-cloud-php/#/docs/cloud-vision/v0.19.3/vision/v1/imageannotatorclient?method=labelDetection
    I am guessing I have to pass it to the "optionalArgs" parameter... but not exactly sure how to do this...



    Here is more or less what my code is:



    require __DIR__ . '/vendor/autoload.php';

    use GoogleCloudVisionV1ImageAnnotatorClient;

    $this->client = new ImageAnnotatorClient();
    $response = $this->client->labelDetection(...THE IMAGE...);
    $labels = $response->getLabelAnnotations();

    if ($labels)
    foreach ($labels as $label)
    // do something with $label->getDescription()




    Anyone got an idea how to get more results in the $labels array?










    share|improve this question


























      0












      0








      0


      1






      I am using the upper mentioned library (Google Cloud Vision Client Library v1) in PHP to assign labels to images... so far so good. It all works, except it returns fewer results than on the google test page... as far as I understand it has to do with a "max_results" parameter which defaults to 10, but I am not able to find where/how to set it manually...
      There was a similar question here on Python and there it was as simple as passing it as a parameter - I have tried many options to do this in PHP, but apparently I am doing something wrong...



      Here is a link to the documentation : https://googleapis.github.io/google-cloud-php/#/docs/cloud-vision/v0.19.3/vision/v1/imageannotatorclient?method=labelDetection
      I am guessing I have to pass it to the "optionalArgs" parameter... but not exactly sure how to do this...



      Here is more or less what my code is:



      require __DIR__ . '/vendor/autoload.php';

      use GoogleCloudVisionV1ImageAnnotatorClient;

      $this->client = new ImageAnnotatorClient();
      $response = $this->client->labelDetection(...THE IMAGE...);
      $labels = $response->getLabelAnnotations();

      if ($labels)
      foreach ($labels as $label)
      // do something with $label->getDescription()




      Anyone got an idea how to get more results in the $labels array?










      share|improve this question
















      I am using the upper mentioned library (Google Cloud Vision Client Library v1) in PHP to assign labels to images... so far so good. It all works, except it returns fewer results than on the google test page... as far as I understand it has to do with a "max_results" parameter which defaults to 10, but I am not able to find where/how to set it manually...
      There was a similar question here on Python and there it was as simple as passing it as a parameter - I have tried many options to do this in PHP, but apparently I am doing something wrong...



      Here is a link to the documentation : https://googleapis.github.io/google-cloud-php/#/docs/cloud-vision/v0.19.3/vision/v1/imageannotatorclient?method=labelDetection
      I am guessing I have to pass it to the "optionalArgs" parameter... but not exactly sure how to do this...



      Here is more or less what my code is:



      require __DIR__ . '/vendor/autoload.php';

      use GoogleCloudVisionV1ImageAnnotatorClient;

      $this->client = new ImageAnnotatorClient();
      $response = $this->client->labelDetection(...THE IMAGE...);
      $labels = $response->getLabelAnnotations();

      if ($labels)
      foreach ($labels as $label)
      // do something with $label->getDescription()




      Anyone got an idea how to get more results in the $labels array?







      php google-api google-api-php-client google-vision






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 21 at 10:13







      Виктор Иванов

















      asked Mar 21 at 8:34









      Виктор ИвановВиктор Иванов

      3391 silver badge11 bronze badges




      3391 silver badge11 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          1





          +50









          New Method



          Since the other answer I provided seems to be deprecated, I am going to provide a sample that uses the setMaxResults method on the Feature object.



          $imageAnnotatorClient = new ImageAnnotatorClient();
          $gcsImageUri = 'some/image.jpg';
          $source = new ImageSource();
          $source->setGcsImageUri($gcsImageUri);
          $image = new Image();
          $image->setSource($source);
          $type = Feature_Type::FACE_DETECTION;
          $featuresElement = new Feature();
          $featuresElement->setType($type);
          $featuresElement->setMaxResults(100); // SET MAX RESULTS HERE
          $features = [$featuresElement];
          $requestsElement = new AnnotateImageRequest();
          $requestsElement->setImage($image);
          $requestsElement->setFeatures($features);
          $requests = [$requestsElement];
          $imageAnnotatorClient->batchAnnotateImages($requests);



          Deprecated Method



          The maxResults value gets specified in the Image constructor



          An example of this code can be found in the source code for the Image object.



           $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
          $image = new Image($imageResource, [
          'FACE_DETECTION',
          'LOGO_DETECTION'
          ], [
          'maxResults' => [
          'FACE_DETECTION' => 1
          ],
          'imageContext' => [
          ....
          ]
          ]
          ]);





          share|improve this answer

























          • Hello craigts, Thank you for the reply. I have seen this in the docs and dependency files, but this just creates an object that "Represents an image to be annotated".... I can successfully do that... but how do I actually get the labels I need from here? If I pass this object to the ImageAnnotatorClient-> labelDetection() it doesn't work... as far as I understand you are not supposed to do that. So any ideas?

            – Виктор Иванов
            Mar 26 at 9:39



















          0














          OK, so for anybody who still may need this here is a working example



           use GoogleCloudVisionImage;
          use GoogleCloudVisionVisionClient;

          $imageResource = fopen(__DIR__ .'/'. $fileIMG, 'r');

          $thePic = new Image($imageResource, [
          'LABEL_DETECTION',
          'LOGO_DETECTION',
          'TEXT_DETECTION'
          ], [
          'maxResults' => [
          'LABEL_DETECTION' => 20,
          'LOGO_DETECTION' => 20,
          'TEXT_DETECTION' => 20
          ],
          'imageContext' => []
          ]);


          $vision = new VisionClient();
          $result = $vision->annotate($thePic);

          $finalLabels = array();

          // do the same for $results->text(), $results->logos()
          if($result->labels())
          foreach ($result->labels() as $key => $annonObj)
          $tmp = $annonObj->info();
          $finalLabels[] = $tmp['description'];




          But... as it says in the official documentation



          • Please note this client will be deprecated in our next release. In order

          • to receive the latest features and updates, please take

          • the time to familiarize yourself with @see GoogleCloudVisionV1ImageAnnotatorClient.

          So I still need a way to do this using the ImageAnnotatorClient class... any ideas anyone?






          share|improve this answer























          • I have updated my answer with the new method for setting maxResults. Happy coding!

            – craigts
            Mar 26 at 19:39













          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55276425%2fgoogle-cloud-vision-client-library-php-image-labels-number-of-results%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1





          +50









          New Method



          Since the other answer I provided seems to be deprecated, I am going to provide a sample that uses the setMaxResults method on the Feature object.



          $imageAnnotatorClient = new ImageAnnotatorClient();
          $gcsImageUri = 'some/image.jpg';
          $source = new ImageSource();
          $source->setGcsImageUri($gcsImageUri);
          $image = new Image();
          $image->setSource($source);
          $type = Feature_Type::FACE_DETECTION;
          $featuresElement = new Feature();
          $featuresElement->setType($type);
          $featuresElement->setMaxResults(100); // SET MAX RESULTS HERE
          $features = [$featuresElement];
          $requestsElement = new AnnotateImageRequest();
          $requestsElement->setImage($image);
          $requestsElement->setFeatures($features);
          $requests = [$requestsElement];
          $imageAnnotatorClient->batchAnnotateImages($requests);



          Deprecated Method



          The maxResults value gets specified in the Image constructor



          An example of this code can be found in the source code for the Image object.



           $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
          $image = new Image($imageResource, [
          'FACE_DETECTION',
          'LOGO_DETECTION'
          ], [
          'maxResults' => [
          'FACE_DETECTION' => 1
          ],
          'imageContext' => [
          ....
          ]
          ]
          ]);





          share|improve this answer

























          • Hello craigts, Thank you for the reply. I have seen this in the docs and dependency files, but this just creates an object that "Represents an image to be annotated".... I can successfully do that... but how do I actually get the labels I need from here? If I pass this object to the ImageAnnotatorClient-> labelDetection() it doesn't work... as far as I understand you are not supposed to do that. So any ideas?

            – Виктор Иванов
            Mar 26 at 9:39
















          1





          +50









          New Method



          Since the other answer I provided seems to be deprecated, I am going to provide a sample that uses the setMaxResults method on the Feature object.



          $imageAnnotatorClient = new ImageAnnotatorClient();
          $gcsImageUri = 'some/image.jpg';
          $source = new ImageSource();
          $source->setGcsImageUri($gcsImageUri);
          $image = new Image();
          $image->setSource($source);
          $type = Feature_Type::FACE_DETECTION;
          $featuresElement = new Feature();
          $featuresElement->setType($type);
          $featuresElement->setMaxResults(100); // SET MAX RESULTS HERE
          $features = [$featuresElement];
          $requestsElement = new AnnotateImageRequest();
          $requestsElement->setImage($image);
          $requestsElement->setFeatures($features);
          $requests = [$requestsElement];
          $imageAnnotatorClient->batchAnnotateImages($requests);



          Deprecated Method



          The maxResults value gets specified in the Image constructor



          An example of this code can be found in the source code for the Image object.



           $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
          $image = new Image($imageResource, [
          'FACE_DETECTION',
          'LOGO_DETECTION'
          ], [
          'maxResults' => [
          'FACE_DETECTION' => 1
          ],
          'imageContext' => [
          ....
          ]
          ]
          ]);





          share|improve this answer

























          • Hello craigts, Thank you for the reply. I have seen this in the docs and dependency files, but this just creates an object that "Represents an image to be annotated".... I can successfully do that... but how do I actually get the labels I need from here? If I pass this object to the ImageAnnotatorClient-> labelDetection() it doesn't work... as far as I understand you are not supposed to do that. So any ideas?

            – Виктор Иванов
            Mar 26 at 9:39














          1





          +50







          1





          +50



          1




          +50





          New Method



          Since the other answer I provided seems to be deprecated, I am going to provide a sample that uses the setMaxResults method on the Feature object.



          $imageAnnotatorClient = new ImageAnnotatorClient();
          $gcsImageUri = 'some/image.jpg';
          $source = new ImageSource();
          $source->setGcsImageUri($gcsImageUri);
          $image = new Image();
          $image->setSource($source);
          $type = Feature_Type::FACE_DETECTION;
          $featuresElement = new Feature();
          $featuresElement->setType($type);
          $featuresElement->setMaxResults(100); // SET MAX RESULTS HERE
          $features = [$featuresElement];
          $requestsElement = new AnnotateImageRequest();
          $requestsElement->setImage($image);
          $requestsElement->setFeatures($features);
          $requests = [$requestsElement];
          $imageAnnotatorClient->batchAnnotateImages($requests);



          Deprecated Method



          The maxResults value gets specified in the Image constructor



          An example of this code can be found in the source code for the Image object.



           $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
          $image = new Image($imageResource, [
          'FACE_DETECTION',
          'LOGO_DETECTION'
          ], [
          'maxResults' => [
          'FACE_DETECTION' => 1
          ],
          'imageContext' => [
          ....
          ]
          ]
          ]);





          share|improve this answer















          New Method



          Since the other answer I provided seems to be deprecated, I am going to provide a sample that uses the setMaxResults method on the Feature object.



          $imageAnnotatorClient = new ImageAnnotatorClient();
          $gcsImageUri = 'some/image.jpg';
          $source = new ImageSource();
          $source->setGcsImageUri($gcsImageUri);
          $image = new Image();
          $image->setSource($source);
          $type = Feature_Type::FACE_DETECTION;
          $featuresElement = new Feature();
          $featuresElement->setType($type);
          $featuresElement->setMaxResults(100); // SET MAX RESULTS HERE
          $features = [$featuresElement];
          $requestsElement = new AnnotateImageRequest();
          $requestsElement->setImage($image);
          $requestsElement->setFeatures($features);
          $requests = [$requestsElement];
          $imageAnnotatorClient->batchAnnotateImages($requests);



          Deprecated Method



          The maxResults value gets specified in the Image constructor



          An example of this code can be found in the source code for the Image object.



           $imageResource = fopen(__DIR__ . '/assets/family-photo.jpg', 'r');
          $image = new Image($imageResource, [
          'FACE_DETECTION',
          'LOGO_DETECTION'
          ], [
          'maxResults' => [
          'FACE_DETECTION' => 1
          ],
          'imageContext' => [
          ....
          ]
          ]
          ]);






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 26 at 19:38

























          answered Mar 25 at 17:00









          craigtscraigts

          1,99118 silver badges19 bronze badges




          1,99118 silver badges19 bronze badges












          • Hello craigts, Thank you for the reply. I have seen this in the docs and dependency files, but this just creates an object that "Represents an image to be annotated".... I can successfully do that... but how do I actually get the labels I need from here? If I pass this object to the ImageAnnotatorClient-> labelDetection() it doesn't work... as far as I understand you are not supposed to do that. So any ideas?

            – Виктор Иванов
            Mar 26 at 9:39


















          • Hello craigts, Thank you for the reply. I have seen this in the docs and dependency files, but this just creates an object that "Represents an image to be annotated".... I can successfully do that... but how do I actually get the labels I need from here? If I pass this object to the ImageAnnotatorClient-> labelDetection() it doesn't work... as far as I understand you are not supposed to do that. So any ideas?

            – Виктор Иванов
            Mar 26 at 9:39

















          Hello craigts, Thank you for the reply. I have seen this in the docs and dependency files, but this just creates an object that "Represents an image to be annotated".... I can successfully do that... but how do I actually get the labels I need from here? If I pass this object to the ImageAnnotatorClient-> labelDetection() it doesn't work... as far as I understand you are not supposed to do that. So any ideas?

          – Виктор Иванов
          Mar 26 at 9:39






          Hello craigts, Thank you for the reply. I have seen this in the docs and dependency files, but this just creates an object that "Represents an image to be annotated".... I can successfully do that... but how do I actually get the labels I need from here? If I pass this object to the ImageAnnotatorClient-> labelDetection() it doesn't work... as far as I understand you are not supposed to do that. So any ideas?

          – Виктор Иванов
          Mar 26 at 9:39














          0














          OK, so for anybody who still may need this here is a working example



           use GoogleCloudVisionImage;
          use GoogleCloudVisionVisionClient;

          $imageResource = fopen(__DIR__ .'/'. $fileIMG, 'r');

          $thePic = new Image($imageResource, [
          'LABEL_DETECTION',
          'LOGO_DETECTION',
          'TEXT_DETECTION'
          ], [
          'maxResults' => [
          'LABEL_DETECTION' => 20,
          'LOGO_DETECTION' => 20,
          'TEXT_DETECTION' => 20
          ],
          'imageContext' => []
          ]);


          $vision = new VisionClient();
          $result = $vision->annotate($thePic);

          $finalLabels = array();

          // do the same for $results->text(), $results->logos()
          if($result->labels())
          foreach ($result->labels() as $key => $annonObj)
          $tmp = $annonObj->info();
          $finalLabels[] = $tmp['description'];




          But... as it says in the official documentation



          • Please note this client will be deprecated in our next release. In order

          • to receive the latest features and updates, please take

          • the time to familiarize yourself with @see GoogleCloudVisionV1ImageAnnotatorClient.

          So I still need a way to do this using the ImageAnnotatorClient class... any ideas anyone?






          share|improve this answer























          • I have updated my answer with the new method for setting maxResults. Happy coding!

            – craigts
            Mar 26 at 19:39















          0














          OK, so for anybody who still may need this here is a working example



           use GoogleCloudVisionImage;
          use GoogleCloudVisionVisionClient;

          $imageResource = fopen(__DIR__ .'/'. $fileIMG, 'r');

          $thePic = new Image($imageResource, [
          'LABEL_DETECTION',
          'LOGO_DETECTION',
          'TEXT_DETECTION'
          ], [
          'maxResults' => [
          'LABEL_DETECTION' => 20,
          'LOGO_DETECTION' => 20,
          'TEXT_DETECTION' => 20
          ],
          'imageContext' => []
          ]);


          $vision = new VisionClient();
          $result = $vision->annotate($thePic);

          $finalLabels = array();

          // do the same for $results->text(), $results->logos()
          if($result->labels())
          foreach ($result->labels() as $key => $annonObj)
          $tmp = $annonObj->info();
          $finalLabels[] = $tmp['description'];




          But... as it says in the official documentation



          • Please note this client will be deprecated in our next release. In order

          • to receive the latest features and updates, please take

          • the time to familiarize yourself with @see GoogleCloudVisionV1ImageAnnotatorClient.

          So I still need a way to do this using the ImageAnnotatorClient class... any ideas anyone?






          share|improve this answer























          • I have updated my answer with the new method for setting maxResults. Happy coding!

            – craigts
            Mar 26 at 19:39













          0












          0








          0







          OK, so for anybody who still may need this here is a working example



           use GoogleCloudVisionImage;
          use GoogleCloudVisionVisionClient;

          $imageResource = fopen(__DIR__ .'/'. $fileIMG, 'r');

          $thePic = new Image($imageResource, [
          'LABEL_DETECTION',
          'LOGO_DETECTION',
          'TEXT_DETECTION'
          ], [
          'maxResults' => [
          'LABEL_DETECTION' => 20,
          'LOGO_DETECTION' => 20,
          'TEXT_DETECTION' => 20
          ],
          'imageContext' => []
          ]);


          $vision = new VisionClient();
          $result = $vision->annotate($thePic);

          $finalLabels = array();

          // do the same for $results->text(), $results->logos()
          if($result->labels())
          foreach ($result->labels() as $key => $annonObj)
          $tmp = $annonObj->info();
          $finalLabels[] = $tmp['description'];




          But... as it says in the official documentation



          • Please note this client will be deprecated in our next release. In order

          • to receive the latest features and updates, please take

          • the time to familiarize yourself with @see GoogleCloudVisionV1ImageAnnotatorClient.

          So I still need a way to do this using the ImageAnnotatorClient class... any ideas anyone?






          share|improve this answer













          OK, so for anybody who still may need this here is a working example



           use GoogleCloudVisionImage;
          use GoogleCloudVisionVisionClient;

          $imageResource = fopen(__DIR__ .'/'. $fileIMG, 'r');

          $thePic = new Image($imageResource, [
          'LABEL_DETECTION',
          'LOGO_DETECTION',
          'TEXT_DETECTION'
          ], [
          'maxResults' => [
          'LABEL_DETECTION' => 20,
          'LOGO_DETECTION' => 20,
          'TEXT_DETECTION' => 20
          ],
          'imageContext' => []
          ]);


          $vision = new VisionClient();
          $result = $vision->annotate($thePic);

          $finalLabels = array();

          // do the same for $results->text(), $results->logos()
          if($result->labels())
          foreach ($result->labels() as $key => $annonObj)
          $tmp = $annonObj->info();
          $finalLabels[] = $tmp['description'];




          But... as it says in the official documentation



          • Please note this client will be deprecated in our next release. In order

          • to receive the latest features and updates, please take

          • the time to familiarize yourself with @see GoogleCloudVisionV1ImageAnnotatorClient.

          So I still need a way to do this using the ImageAnnotatorClient class... any ideas anyone?







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 10:33









          Виктор ИвановВиктор Иванов

          3391 silver badge11 bronze badges




          3391 silver badge11 bronze badges












          • I have updated my answer with the new method for setting maxResults. Happy coding!

            – craigts
            Mar 26 at 19:39

















          • I have updated my answer with the new method for setting maxResults. Happy coding!

            – craigts
            Mar 26 at 19:39
















          I have updated my answer with the new method for setting maxResults. Happy coding!

          – craigts
          Mar 26 at 19:39





          I have updated my answer with the new method for setting maxResults. Happy coding!

          – craigts
          Mar 26 at 19:39

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55276425%2fgoogle-cloud-vision-client-library-php-image-labels-number-of-results%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해