-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
justinlguo
committed
Jun 17, 2024
1 parent
bdd828c
commit 43a91c2
Showing
21 changed files
with
1,747 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
require dirname(__FILE__, 2) . '/vendor/autoload.php'; | ||
|
||
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, | ||
'scheme' => 'https', // 审核时必须为https | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey))); | ||
try { | ||
//本接口用于创建一个数据集(Dataset),数据集是由文件元数据构成的集合,用于存储和管理元数据。 | ||
$result = $cosClient->CreateDataset(array( | ||
'AppId' => 'AppId', // 其中 APPID 获取参考 https://console.cloud.tencent.com/developer | ||
'Headers' => array( | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json', | ||
), | ||
'DatasetName'=> 'test', // 数据集名称,同一个账户下唯一。命名规则如下: 长度为1~32字符。 只能包含小写英文字母,数字,短划线(-)。 必须以英文字母和数字开头。;是否必传:是 | ||
'Description'=> 'test', // 数据集描述信息。长度为1~256个英文或中文字符,默认值为空。;是否必传:否 | ||
'TemplateId'=> 'Official:COSBasicMeta', // 指模板,在建立元数据索引时,后端将根据模板来决定收集哪些元数据。每个模板都包含一个或多个算子,不同的算子表示不同的元数据。目前支持的模板: Official:DefaultEmptyId:默认为空的模板,表示不进行元数据的采集。 Official:COSBasicMeta:基础信息模板,包含 COS 文件基础元信息算子,表示采集 COS 文件的名称、类型、ACL等基础元信息数据。 Official:FaceSearch:人脸检索模板,包含人脸检索、COS 文件基础元信息算子。Official:ImageSearch:图像检索模板,包含图像检索、COS 文件基础元信息算子。;是否必传:否 | ||
|
||
)); | ||
// 请求成功 | ||
print_r($result); | ||
} catch (\Exception $e) { | ||
// 请求失败 | ||
echo($e); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
require dirname(__FILE__, 2) . '/vendor/autoload.php'; | ||
|
||
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, | ||
'scheme' => 'https', // 审核时必须为https | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey))); | ||
try { | ||
//本文档介绍创建数据集(Dataset)和对象存储(COS)Bucket 的绑定关系,绑定后将使用创建数据集时所指定算子对文件进行处理。绑定关系创建后,将对 COS 中新增的文件进行准实时的增量追踪扫描,使用创建数据集时所指定算子对文件进行处理,抽取文件元数据信息进行索引。通过此方式为文件建立索引后,您可以使用元数据查询API对元数据进行查询、管理和统计。 | ||
$result = $cosClient->CreateDatasetBinding(array( | ||
'AppId' => 'AppId', // 其中 APPID 获取参考 https://console.cloud.tencent.com/developer | ||
'Headers' => array( | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json', | ||
), | ||
'DatasetName'=> 'test', // 数据集名称,同一个账户下唯一。;是否必传:是 | ||
'URI'=> 'cos://examplebucket-1250000000', // 资源标识字段,表示需要与数据集绑定的资源,当前仅支持COS存储桶,字段规则:cos://<BucketName>,其中BucketName表示COS存储桶名称,例如:cos://examplebucket-1250000000;是否必传:是 | ||
|
||
)); | ||
// 请求成功 | ||
print_r($result); | ||
} catch (\Exception $e) { | ||
// 请求失败 | ||
echo($e); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
require dirname(__FILE__, 2) . '/vendor/autoload.php'; | ||
|
||
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, | ||
'scheme' => 'https', // 审核时必须为https | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey))); | ||
try { | ||
//提取一个 COS 文件的元数据,在数据集中建立索引。会根据数据集中的算子提取不同的元数据建立索引,也支持建立自定义的元数据索引。 | ||
$result = $cosClient->CreateFileMetaIndex(array( | ||
'AppId' => 'AppId', // 其中 APPID 获取参考 https://console.cloud.tencent.com/developer | ||
'Headers' => array( | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json', | ||
), | ||
'DatasetName'=> 'test001', // 数据集名称,同一个账户下唯一。;是否必传:是 | ||
// 用于建立索引的文件信息。;是否必传:是 | ||
'File'=> array( | ||
'CustomId'=> '001', // 自定义ID。该文件索引到数据集后,作为该行元数据的属性存储,用于和您的业务系统进行关联、对应。您可以根据业务需求传入该值,例如将某个URI关联到您系统内的某个ID。推荐传入全局唯一的值。在查询时,该字段支持前缀查询和排序,详情请见字段和操作符的支持列表。 ;是否必传:否 | ||
'CustomLabels'=> array('age' => '18','level' => '18',) | ||
, // 自定义标签。您可以根据业务需要自定义添加标签键值对信息,用于在查询时可以据此为筛选项进行检索,详情请见字段和操作符的支持列表。 ;是否必传:否 | ||
'MediaType'=> 'image', // 可选项,文件媒体类型,枚举值: image:图片。 other:其他。 document:文档。 archive:压缩包。 video:视频。 audio:音频。 ;是否必传:否 | ||
'ContentType'=> 'image/jpeg', // 可选项,文件内容类型(MIME Type),如image/jpeg。 ;是否必传:否 | ||
'URI'=> 'cos://examplebucket-1250000000/test.jpg', // 资源标识字段,表示需要建立索引的文件地址,当前仅支持COS上的文件,字段规则:cos:///,其中BucketName表示COS存储桶名称,ObjectKey表示文件完整路径,例如:cos://examplebucket-1250000000/test1/img.jpg。 注意: 1、仅支持本账号内的COS文件 2、不支持HTTP开头的地址;是否必传:是 | ||
'MaxFaceNum'=> 20, // 输入图片中检索的人脸数量,默认值为20,最大值为20。(仅当数据集模板 ID 为 Official:FaceSearch 有效)。;是否必传:否 | ||
), | ||
|
||
)); | ||
// 请求成功 | ||
print_r($result); | ||
} catch (\Exception $e) { | ||
// 请求失败 | ||
echo($e); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
require dirname(__FILE__, 2) . '/vendor/autoload.php'; | ||
|
||
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, | ||
'scheme' => 'https', // 审核时必须为https | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey))); | ||
try { | ||
//从数据集中搜索与指定图片最相似的前N张图片并返回人脸坐标可对数据集内文件进行一个或多个人员的人脸识别。 | ||
$result = $cosClient->DatasetFaceSearch(array( | ||
'AppId' => 'AppId', // 其中 APPID 获取参考 https://console.cloud.tencent.com/developer | ||
'Headers' => array( | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json', | ||
), | ||
'DatasetName'=> 'test', // 数据集名称,同一个账户下唯一。;是否必传:是 | ||
'URI'=> 'cos://examplebucket-1250000000/test.jpg', // 资源标识字段,表示需要建立索引的文件地址。;是否必传:是 | ||
'MaxFaceNum'=> 1, // 输入图片中检索的人脸数量,默认值为1(传0或不传采用默认值),最大值为10。;是否必传:否 | ||
'Limit'=> 10, // 检索的每张人脸返回相关人脸数量,默认值为10,最大值为100。;是否必传:否 | ||
'MatchThreshold'=> 10, // 出参 Score 中,只有超过 MatchThreshold 值的结果才会返回。范围:1-100,默认值为0,推荐值为80。;是否必传:否 | ||
|
||
)); | ||
// 请求成功 | ||
print_r($result); | ||
} catch (\Exception $e) { | ||
// 请求失败 | ||
echo($e); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
require dirname(__FILE__, 2) . '/vendor/autoload.php'; | ||
|
||
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, | ||
'scheme' => 'https', // 审核时必须为https | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey))); | ||
try { | ||
//可以根据已提取的文件元数据(包含文件名、标签、路径、自定义标签、文本等字段)查询和统计数据集内文件,支持逻辑关系表达方式。 | ||
$result = $cosClient->DatasetSimpleQuery(array( | ||
'AppId' => 'AppId', // 其中 APPID 获取参考 https://console.cloud.tencent.com/developer | ||
'Headers' => array( | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json', | ||
), | ||
'DatasetName'=> 'test', // 数据集名称,同一个账户下唯一。;是否必传:是 | ||
// 简单查询参数条件,可自嵌套。;是否必传:是 | ||
'Query'=> array( | ||
'Operation'=> 'and', // 操作运算符。枚举值: not:逻辑非。 or:逻辑或。 and:逻辑与。 lt:小于。 lte:小于等于。 gt:大于。 gte:大于等于。 eq:等于。 exist:存在性查询。 prefix:前缀查询。 match-phrase:字符串匹配查询。 nested:字段为数组时,其中同一对象内逻辑条件查询。;是否必传:是 | ||
), | ||
'MaxResults'=> 100, // 返回文件元数据的最大个数,取值范围为0200。 使用聚合参数时,该值表示返回分组的最大个数,取值范围为02000。 不设置此参数或者设置为0时,则取默认值100。;是否必传:否 | ||
'Sort'=> 'CustomId', // 排序字段列表。请参考字段和操作符的支持列表。 多个排序字段可使用半角逗号(,)分隔,例如:Size,Filename。 最多可设置5个排序字段。 排序字段顺序即为排序优先级顺序。;是否必传:是 | ||
'Order'=> 'desc', // 排序字段的排序方式。取值如下: asc:升序; desc(默认):降序。 多个排序方式可使用半角逗号(,)分隔,例如:asc,desc。 排序方式不可多于排序字段,即参数Order的元素数量需小于等于参数Sort的元素数量。例如Sort取值为Size,Filename时,Order可取值为asc,desc或asc。 排序方式少于排序字段时,未排序的字段默认取值asc。例如Sort取值为Size,Filename,Order取值为asc时,Filename默认排序方式为asc,即升序排列;是否必传:是 | ||
// 聚合字段信息列表。 当您使用聚合查询时,仅返回聚合结果,不再返回匹配到的元信息列表。;是否必传:是 | ||
'Aggregations'=> array( | ||
), | ||
|
||
)); | ||
// 请求成功 | ||
print_r($result); | ||
} catch (\Exception $e) { | ||
// 请求失败 | ||
echo($e); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
require dirname(__FILE__, 2) . '/vendor/autoload.php'; | ||
|
||
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, | ||
'scheme' => 'https', // 审核时必须为https | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey))); | ||
try { | ||
//删除一个数据集(Dataset)。 | ||
$result = $cosClient->DeleteDataset(array( | ||
'AppId' => 'AppId', // 其中 APPID 获取参考 https://console.cloud.tencent.com/developer | ||
'Headers' => array( | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json', | ||
), | ||
'DatasetName'=> 'test', // 数据集名称,同一个账户下唯一。;是否必传:是 | ||
|
||
)); | ||
// 请求成功 | ||
print_r($result); | ||
} catch (\Exception $e) { | ||
// 请求失败 | ||
echo($e); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
require dirname(__FILE__, 2) . '/vendor/autoload.php'; | ||
|
||
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, | ||
'scheme' => 'https', // 审核时必须为https | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey))); | ||
try { | ||
//解绑数据集和对象存储(COS)Bucket ,解绑会导致 COS Bucket新增的变更不会同步到数据集,请谨慎操作。 | ||
$result = $cosClient->DeleteDatasetBinding(array( | ||
'AppId' => 'AppId', // 其中 APPID 获取参考 https://console.cloud.tencent.com/developer | ||
'Headers' => array( | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json', | ||
), | ||
'DatasetName'=> 'test', // 数据集名称,同一个账户下唯一。;是否必传:是 | ||
'URI'=> 'cos://examplebucket-1250000000', // 资源标识字段,表示需要与数据集绑定的资源,当前仅支持COS存储桶,字段规则:cos://<BucketName>,其中BucketName表示COS存储桶名称,例如:cos://examplebucket-1250000000;是否必传:是 | ||
|
||
)); | ||
// 请求成功 | ||
print_r($result); | ||
} catch (\Exception $e) { | ||
// 请求失败 | ||
echo($e); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
require dirname(__FILE__, 2) . '/vendor/autoload.php'; | ||
|
||
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, | ||
'scheme' => 'https', // 审核时必须为https | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey))); | ||
try { | ||
//从数据集内删除一个文件的元信息。无论该文件的元信息是否在数据集内存在,均会返回删除成功。 | ||
$result = $cosClient->DeleteFileMetaIndex(array( | ||
'AppId' => 'AppId', // 其中 APPID 获取参考 https://console.cloud.tencent.com/developer | ||
'Headers' => array( | ||
'Content-Type' => 'application/json', | ||
), | ||
'DatasetName'=> 'test', // 数据集名称,同一个账户下唯一。;是否必传:是 | ||
'URI'=> 'cos://examplebucket-1250000000/test.jpg', // 资源标识字段,表示需要建立索引的文件地址。;是否必传:是 | ||
|
||
)); | ||
// 请求成功 | ||
print_r($result); | ||
} catch (\Exception $e) { | ||
// 请求失败 | ||
echo($e); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
require dirname(__FILE__, 2) . '/vendor/autoload.php'; | ||
|
||
$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi | ||
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket | ||
$cosClient = new Qcloud\Cos\Client( | ||
array( | ||
'region' => $region, | ||
'scheme' => 'https', // 审核时必须为https | ||
'credentials'=> array( | ||
'secretId' => $secretId , | ||
'secretKey' => $secretKey))); | ||
try { | ||
//查询一个数据集(Dataset)信息。 | ||
$result = $cosClient->DescribeDataset(array( | ||
'AppId' => 'AppId', // 其中 APPID 获取参考 https://console.cloud.tencent.com/developer | ||
'Headers' => array( | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json', | ||
), | ||
'datasetname' => '', // 数据集名称,同一个账户下唯一。 | ||
'statistics' => false, // 是否需要实时统计数据集中文件相关信息。有效值: false:不统计,返回的文件的总大小、数量信息可能不正确也可能都为0。 true:需要统计,返回数据集中当前的文件的总大小、数量信息。 默认值为false。 | ||
|
||
)); | ||
// 请求成功 | ||
print_r($result); | ||
} catch (\Exception $e) { | ||
// 请求失败 | ||
echo($e); | ||
} |
Oops, something went wrong.