Skip to content

Commit 668cfbd

Browse files
nic12347franktguo
and
franktguo
authored
严格签名 (#342)
* 补充文档转码参数 * 人脸特效拆分URL方式 * x-ci-*header写入签名 * ci补充参数 --------- Co-authored-by: franktguo <[email protected]>
1 parent 17b973a commit 668cfbd

File tree

6 files changed

+105
-38
lines changed

6 files changed

+105
-38
lines changed

sample/CreateDataset.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
'DatasetName'=> 'test', // 数据集名称,同一个账户下唯一。命名规则如下: 长度为1~32字符。 只能包含小写英文字母,数字,短划线(-)。 必须以英文字母和数字开头。;是否必传:是
2424
'Description'=> 'test', // 数据集描述信息。长度为1~256个英文或中文字符,默认值为空。;是否必传:否
2525
'TemplateId'=> 'Official:COSBasicMeta', // 指模板,在建立元数据索引时,后端将根据模板来决定收集哪些元数据。每个模板都包含一个或多个算子,不同的算子表示不同的元数据。目前支持的模板: Official:DefaultEmptyId:默认为空的模板,表示不进行元数据的采集。 Official:COSBasicMeta:基础信息模板,包含 COS 文件基础元信息算子,表示采集 COS 文件的名称、类型、ACL等基础元信息数据。 Official:FaceSearch:人脸检索模板,包含人脸检索、COS 文件基础元信息算子。Official:ImageSearch:图像检索模板,包含图像检索、COS 文件基础元信息算子。;是否必传:否
26-
26+
'Version' => 'basic', // 数据集版本。basic、standard,默认为basic。
27+
'Volume' => 0, // Version为basic时为50w。Version为standard时,默认为500w,可设置1-10000,单位w。传0采用默认值。
28+
'TrainingMode' => 1, // 训练数据的来源模式。
29+
'TrainingDataset' => '', // 训练数据的数据集名称。仅在TrainingMode为0时生效。
30+
'TrainingURI' => '', // 训练数据的资源路径。仅在TrainingMode为1时生效。
2731
));
2832
// 请求成功
2933
print_r($result);

sample/imageFaceEffect.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
'secretId' => $secretId,
1414
'secretKey' => $secretKey)));
1515
try {
16-
// 人脸特效 https://cloud.tencent.com/document/product/460/47197
17-
$result = $cosClient->ImageFaceEffect(array(
16+
// 人脸特效
17+
// 桶文件
18+
$result = $cosClient->imageFaceEffect(array(
1819
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
19-
'Key' => '', // ObjectKey
20+
'Key' => 'xxx.jpg', // ObjectKey
2021
'type' => 'face-beautify', // 人脸特效类型。人脸美颜:face-beautify;人脸性别转换:face-gender-transformation;人脸年龄变化:face-age-transformation;人像分割:face-segmentation
2122
'whitening' => 30,
2223
'smoothing' => 10,
@@ -26,6 +27,20 @@
2627
'age' => 18,
2728
));
2829
print_r($result);
30+
31+
// 第三方URL
32+
$result = $cosClient->imageUrlFaceEffect(array(
33+
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
34+
'type' => 'face-beautify', // 人脸特效类型。人脸美颜:face-beautify;人脸性别转换:face-gender-transformation;人脸年龄变化:face-age-transformation;人像分割:face-segmentation
35+
'whitening' => 30,
36+
'smoothing' => 10,
37+
'faceLifting' => 70,
38+
'eyeEnlarging' => 70,
39+
'gender' => 1,
40+
'age' => 18,
41+
'detectUrl' => 'https://xxx.com/xxx.jpg',
42+
));
43+
print_r($result);
2944
} catch (\Exception $e) {
3045
// 请求失败
3146
echo($e);

src/Client.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
* @method object CloseOriginProtect(array $args) 关闭原图保护
193193
* @method object ImageDetectFace(array $args) 人脸检测
194194
* @method object ImageFaceEffect(array $args) 人脸特效
195+
* @method object ImageUrlFaceEffect(array $args) 人脸特效
195196
* @method object IDCardOCR(array $args) 身份证识别
196197
* @method object IDCardOCRByUpload(array $args) 身份证识别-上传时处理
197198
* @method object GetLiveCode(array $args) 获取数字验证码

src/Descriptions.php

Lines changed: 77 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static function CreateMediaTranscodeJobs() {
2929
'Bucket' => array( 'required' => true, 'type' => 'string', 'location' => 'uri', ),
3030
'Tag' => array( 'location' => 'xml', 'type' => 'string', ),
3131
'QueueId' => array( 'location' => 'xml', 'type' => 'string', ),
32+
'QueueType' => array( 'location' => 'xml', 'type' => 'string', ),
3233
'CallBack' => array( 'location' => 'xml', 'type' => 'string', ),
3334
'CallBackFormat' => array( 'location' => 'xml', 'type' => 'string', ),
3435
'CallBackType' => array( 'location' => 'xml', 'type' => 'string', ),
@@ -271,6 +272,33 @@ public static function CreateMediaTranscodeJobs() {
271272
'State' => array( 'type' => 'string', 'location' => 'xml', ),
272273
),
273274
),
275+
'Subtitles' => array(
276+
'type' => 'object',
277+
'location' => 'xml',
278+
'properties' => array(
279+
'Subtitle' => array(
280+
'type' => 'array',
281+
'location' => 'xml',
282+
'data' => array(
283+
'xmlFlattened' => true,
284+
),
285+
'items' => array(
286+
'type' => 'object',
287+
'name' => 'Subtitle',
288+
'sentAs' => 'Subtitle',
289+
'properties' => array(
290+
'Url' => array( 'type' => 'string', 'location' => 'xml', ),
291+
'Embed' => array( 'type' => 'string', 'location' => 'xml', ),
292+
'FontType' => array( 'type' => 'string', 'location' => 'xml', ),
293+
'FontSize' => array( 'type' => 'string', 'location' => 'xml', ),
294+
'FontColor' => array( 'type' => 'string', 'location' => 'xml', ),
295+
'OutlineColor' => array( 'type' => 'string', 'location' => 'xml', ),
296+
'VMargin' => array( 'type' => 'string', 'location' => 'xml', ),
297+
),
298+
),
299+
),
300+
),
301+
),
274302
),
275303
),
276304
'CallBackMqConfig' => array(
@@ -282,6 +310,15 @@ public static function CreateMediaTranscodeJobs() {
282310
'MqName' => array( 'type' => 'string', 'location' => 'xml', ),
283311
),
284312
),
313+
'CallBackKafkaConfig' => array(
314+
'type' => 'object',
315+
'location' => 'xml',
316+
'properties' => array(
317+
'Region' => array( 'type' => 'string', 'location' => 'xml', ),
318+
'InstanceId' => array( 'type' => 'string', 'location' => 'xml', ),
319+
'Topic' => array( 'type' => 'string', 'location' => 'xml', ),
320+
),
321+
),
285322
),
286323
);
287324
}
@@ -2145,7 +2182,7 @@ public static function DetectVideo() {
21452182
'type' => 'object',
21462183
'properties' => array(
21472184
'Mode' => array( 'type' => 'string', 'location' => 'xml', ),
2148-
'Count' => array( 'type' => 'string', 'location' => 'xml', ),
2185+
'Count' => array( 'type' => 'integer', 'location' => 'xml', ),
21492186
'TimeInterval' => array( 'type' => 'numeric', 'location' => 'xml', ),
21502187
),
21512188
),
@@ -3485,39 +3522,19 @@ public static function CreateDocProcessJobs() {
34853522
'type' => 'object',
34863523
'location' => 'xml',
34873524
'properties' => array(
3488-
'SrcType' => array(
3489-
'type' => 'string',
3490-
),
3491-
'TgtType' => array(
3492-
'type' => 'string',
3493-
),
3494-
'SheetId' => array(
3495-
'type' => 'integer',
3496-
),
3497-
'StartPage' => array(
3498-
'type' => 'integer',
3499-
),
3500-
'EndPage' => array(
3501-
'type' => 'integer',
3502-
),
3503-
'ImageParams' => array(
3504-
'type' => 'string',
3505-
),
3506-
'DocPassword' => array(
3507-
'type' => 'string',
3508-
),
3509-
'Comments' => array(
3510-
'type' => 'integer',
3511-
),
3512-
'PaperDirection' => array(
3513-
'type' => 'integer',
3514-
),
3515-
'Quality' => array(
3516-
'type' => 'integer',
3517-
),
3518-
'Zoom' => array(
3519-
'type' => 'integer',
3520-
),
3525+
'SrcType' => array( 'type' => 'string', 'location' => 'xml', ),
3526+
'TgtType' => array( 'type' => 'string', 'location' => 'xml', ),
3527+
'StartPage' => array( 'type' => 'integer', 'location' => 'xml', ),
3528+
'EndPage' => array( 'type' => 'integer', 'location' => 'xml', ),
3529+
'SheetId' => array( 'type' => 'integer', 'location' => 'xml', ),
3530+
'PaperDirection' => array( 'type' => 'integer', 'location' => 'xml', ),
3531+
'PaperSize' => array( 'type' => 'integer', 'location' => 'xml', ),
3532+
'ImageParams' => array( 'type' => 'string', 'location' => 'xml', ),
3533+
'Quality' => array( 'type' => 'integer', 'location' => 'xml', ),
3534+
'Zoom' => array( 'type' => 'integer', 'location' => 'xml', ),
3535+
'ImageDpi' => array( 'type' => 'integer', 'location' => 'xml', ),
3536+
'DocPassword' => array( 'type' => 'string', 'location' => 'xml', ),
3537+
'Comments' => array( 'type' => 'integer', 'location' => 'xml', ),
35213538
),
35223539
),
35233540
),
@@ -12927,6 +12944,27 @@ public static function ImageFaceEffect() {
1292712944
),
1292812945
);
1292912946
}
12947+
12948+
public static function ImageUrlFaceEffect() {
12949+
return array(
12950+
'httpMethod' => 'GET',
12951+
'uri' => '/{Bucket}?ci-process=face-effect',
12952+
'class' => 'Qcloud\\Cos\\Command',
12953+
'responseClass' => 'ImageFaceEffectOutput',
12954+
'responseType' => 'model',
12955+
'parameters' => array(
12956+
'Bucket' => array( 'required' => true, 'type' => 'string', 'location' => 'uri', ),
12957+
'type' => array( 'type' => 'string', 'location' => 'query', ),
12958+
'whitening' => array( 'type' => 'integer', 'location' => 'query', ),
12959+
'smoothing' => array( 'type' => 'integer', 'location' => 'query', ),
12960+
'faceLifting' => array( 'type' => 'integer', 'location' => 'query', ),
12961+
'eyeEnlarging' => array( 'type' => 'integer', 'location' => 'query', ),
12962+
'gender' => array( 'type' => 'integer', 'location' => 'query', ),
12963+
'age' => array( 'type' => 'integer', 'location' => 'query', ),
12964+
'detectUrl' => array('type' => 'string', 'location' => 'query', 'sentAs' => 'detect-url'),
12965+
),
12966+
);
12967+
}
1293012968
public static function ImageFaceEffectOutput() {
1293112969
return array(
1293212970
'type' => 'object',
@@ -19289,6 +19327,11 @@ public static function CreateDataset() {
1928919327
'DatasetName' => array( 'location' => 'json', 'type' => 'string', ),
1929019328
'Description' => array( 'location' => 'json', 'type' => 'string', ),
1929119329
'TemplateId' => array( 'location' => 'json', 'type' => 'string', ),
19330+
'Version' => array( 'location' => 'json', 'type' => 'string', ),
19331+
'Volume' => array( 'location' => 'json', 'type' => 'integer', ),
19332+
'TrainingMode' => array( 'location' => 'json', 'type' => 'integer', ),
19333+
'TrainingDataset' => array( 'location' => 'json', 'type' => 'string', ),
19334+
'TrainingURI' => array( 'location' => 'json', 'type' => 'string', ),
1929219335
),
1929319336

1929419337
);

src/Service.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,6 +3787,7 @@ public static function getService() {
37873787
'CloseOriginProtect' => Descriptions::CloseOriginProtect(), // 关闭原图保护
37883788
'ImageDetectFace' => Descriptions::ImageDetectFace(), // 人脸检测
37893789
'ImageFaceEffect' => Descriptions::ImageFaceEffect(), // 人脸特效
3790+
'ImageUrlFaceEffect' => Descriptions::ImageUrlFaceEffect(), // 人脸特效
37903791
'IDCardOCR' => Descriptions::IDCardOCR(), // 身份证识别
37913792
'IDCardOCRByUpload' => Descriptions::IDCardOCRByUpload(), // 身份证识别-上传时处理
37923793
'GetLiveCode' => Descriptions::GetLiveCode(), // 获取数字验证码

src/Signature.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public function needCheckHeader( $header ) {
5353
if ( startWith( $header, 'x-cos-' ) ) {
5454
return true;
5555
}
56+
if ( startWith( $header, 'x-ci-' ) ) {
57+
return true;
58+
}
5659
if ( in_array( $header, $this->signHeader ) ) {
5760
return true;
5861
}

0 commit comments

Comments
 (0)