composer require malong/productai
The code and arguments in the tests
directory are NOT examples but unit testing only. Please set the arguments according to your usage scenarios.
use ProductAI;
$product_ai = new ProductAI\API($access_key_id, $secret_key);
$result = $product_ai->searchImage($service_type, $service_id, $url, $loc, $tags, $count, $threshold);
$loc
: Optional, default is the entire image. An area of the image which you want to search. The format is [$x, $y, $w, $h]
.
$tags
: Optional, default is []
. The keywords which you want to search.
$count
: Optional, default is 20. The number of results that between 0 and 100. Public services do NOT support this argument.
$threshold
: Optional, default is 0. A threshold value that between 0 and 1. Set up this argument is NOT recommended.
$result = $product_ai->searchImage($service_type, $service_id, '@'.$filename, $loc, $tags, $count, $threshold);
$result = $product_ai->searchImage($service_type, $service_id, file_get_contents($filename), $loc, $tags, $count, $threshold);
$result = $product_ai->searchImage($service_type, $service_id, '#'.$form_name, $loc, $tags, $count, $threshold);
$result = $product_ai->classifyImage($service_type, $service_id, $image, $loc);
The $image
argument accepts the same type as the image search.
$result = $product_ai->detectImage($service_type, $service_id, $image, $loc);
The $image
argument accepts the same type as the image search.
$result = $product_ai->addImageToSet($set_id, $image_url, 'optional meta', [
'optional tag 1',
'optional tag 2',
]);
$result = $product_ai->addImagesToSet($set_id, [
[
$image_url_1,
'optional meta 1',
[
'optional tag 1',
'optional tag 2',
],
],
[
$image_url_2,
'optional meta 2',
[
'optional tag 3',
'optional tag 4',
],
],
]);
$result = $product_ai->addImagesToSet($set_id, $filename);
$result = $product_ai->removeImagesFromSet($set_id, [
$image_url_1,
$image_url_2,
]);
$result = $product_ai->removeImagesFromSet($set_id, $filename);
tests
目录里的代码及相关参数仅用于单元测试,不是示例,请根据使用场景设置相关参数。
composer require malong/productai
use ProductAI;
$product_ai = new ProductAI\API($access_key_id, $secret_key);
$result = $product_ai->searchImage($service_type, $service_id, $url, $loc, $tags, $count, $threshold);
$loc
: 可选,默认为整张图片。用于搜索的图片区域,格式为 [$x, $y, $w, $h]
.
$tags
: 可选,默认为 []
。用于筛选搜索结果的标签。
$count
: 可选,默认为 20。 设置返回结果的数量,值为 0 到 100,公共服务不支持此参数。
$threshold
: 可选,默认为 0。设置返回结果的阈值, 值为 0 到 1,不建议设置此参数。
$result = $product_ai->searchImage($service_type, $service_id, '@'.$filename, $loc, $tags, $count, $threshold);
$result = $product_ai->searchImage($service_type, $service_id, file_get_contents($filename), $loc, $tags, $count, $threshold);
$result = $product_ai->searchImage($service_type, $service_id, '#'.$form_name, $loc, $tags, $count, $threshold);
$result = $product_ai->classifyImage($service_type, $service_id, $image, $loc);
$image
参数接受的类型与图像搜索一致。
$result = $product_ai->detectImage($service_type, $service_id, $image, $loc);
$image
参数接受的类型与图像搜索一致。
$result = $product_ai->addImageToSet($set_id, $image_url, 'optional meta', [
'optional tag 1',
'optional tag 2',
]);
$result = $product_ai->addImagesToSet($set_id, [
[
$image_url_1,
'optional meta 1',
[
'optional tag 1',
'optional tag 2',
],
],
[
$image_url_2,
'optional meta 2',
[
'optional tag 3',
'optional tag 4',
],
],
]);
$result = $product_ai->addImagesToSet($set_id, $filename);
$result = $product_ai->removeImagesFromSet($set_id, [
$image_url_1,
$image_url_2,
]);
$result = $product_ai->removeImagesFromSet($set_id, $filename);