Skip to content

Commit

Permalink
Add a helper for product search (#1414)
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashi Matsuo authored and dwsupplee committed Nov 9, 2018
1 parent e71766d commit f7b1aba
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Vision/src/V1/ImageAnnotatorClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,41 @@ public function objectLocalization($image, $optionalArgs = [])
);
}

/**
* Run product search for an image.
*
* Example:
* ```
* $imageContent = file_get_contents('path/to/image.jpg');
* $response = $imageAnnotatorClient->productSearch($imageContent);
* ```
*
* @param resource|string|Image $image The image to be processed.
* @param array $optionalArgs {
* Configuration Options.
*
* @type ImageContext $imageContext Additional context that may accompany the image.
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a
* {@see Google\ApiCore\RetrySettings} object, or an associative array
* of retry settings parameters. See the documentation on
* {@see Google\ApiCore\RetrySettings} for example usage.
* }
*
* @return AnnotateImageResponse
*
* @throws ApiException if the remote call fails
* @experimental
*/
public function productSearch($image, $optionalArgs = [])
{
return $this->annotateSingleFeature(
$image,
Type::PRODUCT_SEARCH,
$optionalArgs
);
}

/**
* @param Image $image
* @param Feature|int $featureType
Expand Down
1 change: 1 addition & 0 deletions Vision/tests/Snippet/V1/ImageAnnotatorClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public function detectionMethodSnippetDataProvider()
['cropHintsDetection'],
['webDetection'],
['objectLocalization'],
['productSearch'],
];
}

Expand Down
1 change: 1 addition & 0 deletions Vision/tests/Unit/V1/ImageAnnotatorClientExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public function detectionMethodDataProvider()
['cropHintsDetection', Feature_Type::CROP_HINTS],
['webDetection', Feature_Type::WEB_DETECTION],
['objectLocalization', Feature_Type::OBJECT_LOCALIZATION],
['productSearch', Feature_Type::PRODUCT_SEARCH],
];
$data = [];
foreach ($items as $item) {
Expand Down

0 comments on commit f7b1aba

Please sign in to comment.