facebody-20191230/main.tea (6,462 lines of code) (raw):
/**
*
*/
import Util;
import OSS;
import OpenPlatform;
import OSSUtil;
import FileForm;
import Number;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;
extends OpenApi;
init(config: OpenApi.Config){
super(config);
@endpointRule = 'regional';
checkConfig(config);
@endpoint = getEndpoint('facebody', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}
function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
if (!Util.empty(endpoint)) {
return endpoint;
}
if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
return endpointMap[regionId];
}
return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model AddFaceRequest {
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='U1'),
extraData?: string(name='ExtraData'),
imageUrl?: string(name='ImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test/imgsearch/demo/1.png'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='50.0'),
similarityScoreThresholdBetweenEntity?: float(name='SimilarityScoreThresholdBetweenEntity', example='50.0'),
similarityScoreThresholdInEntity?: float(name='SimilarityScoreThresholdInEntity', example='50.0'),
}
model AddFaceAdvanceRequest {
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='U1'),
extraData?: string(name='ExtraData'),
imageUrlObject?: readable(name='ImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test/imgsearch/demo/1.png'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='50.0'),
similarityScoreThresholdBetweenEntity?: float(name='SimilarityScoreThresholdBetweenEntity', example='50.0'),
similarityScoreThresholdInEntity?: float(name='SimilarityScoreThresholdInEntity', example='50.0'),
}
model AddFaceResponseBody = {
data?: {
faceId?: string(name='FaceId', example='5'),
qualitieScore?: float(name='QualitieScore', example='99.79581'),
}(name='Data'),
requestId?: string(name='RequestId', example='2B93C43A-F824-40C8-AF79-844342B0F43A'),
}
model AddFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: AddFaceResponseBody(name='body'),
}
async function addFaceWithOptions(request: AddFaceRequest, runtime: Util.RuntimeOptions): AddFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.dbName)) {
body['DbName'] = request.dbName;
}
if (!Util.isUnset(request.entityId)) {
body['EntityId'] = request.entityId;
}
if (!Util.isUnset(request.extraData)) {
body['ExtraData'] = request.extraData;
}
if (!Util.isUnset(request.imageUrl)) {
body['ImageUrl'] = request.imageUrl;
}
if (!Util.isUnset(request.qualityScoreThreshold)) {
body['QualityScoreThreshold'] = request.qualityScoreThreshold;
}
if (!Util.isUnset(request.similarityScoreThresholdBetweenEntity)) {
body['SimilarityScoreThresholdBetweenEntity'] = request.similarityScoreThresholdBetweenEntity;
}
if (!Util.isUnset(request.similarityScoreThresholdInEntity)) {
body['SimilarityScoreThresholdInEntity'] = request.similarityScoreThresholdInEntity;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'AddFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function addFace(request: AddFaceRequest): AddFaceResponse {
var runtime = new Util.RuntimeOptions{};
return addFaceWithOptions(request, runtime);
}
async function addFaceAdvance(request: AddFaceAdvanceRequest, runtime: Util.RuntimeOptions): AddFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var addFaceReq = new AddFaceRequest{};
OpenApiUtil.convert(request, addFaceReq);
if(!Util.isUnset(request.imageUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
addFaceReq.imageUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var addFaceResp = addFaceWithOptions(addFaceReq, runtime);
return addFaceResp;
}
model AddFaceEntityRequest {
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='mm2'),
labels?: string(name='Labels'),
}
model AddFaceEntityResponseBody = {
requestId?: string(name='RequestId', example='DA7CAFEB-0A37-4496-9CDF-E3DBB6309CB2'),
}
model AddFaceEntityResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: AddFaceEntityResponseBody(name='body'),
}
async function addFaceEntityWithOptions(request: AddFaceEntityRequest, runtime: Util.RuntimeOptions): AddFaceEntityResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.dbName)) {
body['DbName'] = request.dbName;
}
if (!Util.isUnset(request.entityId)) {
body['EntityId'] = request.entityId;
}
if (!Util.isUnset(request.labels)) {
body['Labels'] = request.labels;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'AddFaceEntity',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function addFaceEntity(request: AddFaceEntityRequest): AddFaceEntityResponse {
var runtime = new Util.RuntimeOptions{};
return addFaceEntityWithOptions(request, runtime);
}
model AddFaceImageTemplateRequest {
imageURL?: string(name='ImageURL', example='https://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/img_facefusion/template/sucai1.jpg'),
}
model AddFaceImageTemplateAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='https://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/img_facefusion/template/sucai1.jpg'),
}
model AddFaceImageTemplateResponseBody = {
data?: {
faceInfos?: [
{
faceRect?: {
height?: string(name='Height', example='94'),
width?: string(name='Width', example='89'),
x?: string(name='X', example='254'),
y?: string(name='Y', example='318'),
}(name='FaceRect'),
templateFaceID?: string(name='TemplateFaceID', example='string 6cd509ea-54fa-4730-8e9d-c94cadcda048_0'),
}
](name='FaceInfos'),
templateId?: string(name='TemplateId', example='6cd509ea-54fa-4730-8e9d-c94cadcda048'),
}(name='Data'),
requestId?: string(name='RequestId', example='798A721D-7C7F-4D87-A125-1D04B3055C2C'),
}
model AddFaceImageTemplateResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: AddFaceImageTemplateResponseBody(name='body'),
}
async function addFaceImageTemplateWithOptions(request: AddFaceImageTemplateRequest, runtime: Util.RuntimeOptions): AddFaceImageTemplateResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'AddFaceImageTemplate',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function addFaceImageTemplate(request: AddFaceImageTemplateRequest): AddFaceImageTemplateResponse {
var runtime = new Util.RuntimeOptions{};
return addFaceImageTemplateWithOptions(request, runtime);
}
async function addFaceImageTemplateAdvance(request: AddFaceImageTemplateAdvanceRequest, runtime: Util.RuntimeOptions): AddFaceImageTemplateResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var addFaceImageTemplateReq = new AddFaceImageTemplateRequest{};
OpenApiUtil.convert(request, addFaceImageTemplateReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
addFaceImageTemplateReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var addFaceImageTemplateResp = addFaceImageTemplateWithOptions(addFaceImageTemplateReq, runtime);
return addFaceImageTemplateResp;
}
model BatchAddFacesRequest {
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='U1'),
faces?: [
{
extraData?: string(name='ExtraData'),
imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test/imgsearch/demo/1.png'),
}
](name='Faces'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='50.0'),
similarityScoreThresholdBetweenEntity?: float(name='SimilarityScoreThresholdBetweenEntity', example='50.0'),
similarityScoreThresholdInEntity?: float(name='SimilarityScoreThresholdInEntity', example='50.0'),
}
model BatchAddFacesAdvanceRequest {
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='U1'),
faces?: [
{
extraData?: string(name='ExtraData'),
imageURLObject?: readable(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test/imgsearch/demo/1.png'),
}
](name='Faces'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='50.0'),
similarityScoreThresholdBetweenEntity?: float(name='SimilarityScoreThresholdBetweenEntity', example='50.0'),
similarityScoreThresholdInEntity?: float(name='SimilarityScoreThresholdInEntity', example='50.0'),
}
model BatchAddFacesShrinkRequest {
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='U1'),
facesShrink?: string(name='Faces'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='50.0'),
similarityScoreThresholdBetweenEntity?: float(name='SimilarityScoreThresholdBetweenEntity', example='50.0'),
similarityScoreThresholdInEntity?: float(name='SimilarityScoreThresholdInEntity', example='50.0'),
}
model BatchAddFacesResponseBody = {
data?: {
failedFaces?: [
{
code?: string(name='Code', example='ClientError.IllegalArgument'),
imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test/imgsearch/demo/xxxx.png'),
message?: string(name='Message', example='not found the db=test'),
}
](name='FailedFaces'),
insertedFaces?: [
{
faceId?: string(name='FaceId', example='16350536'),
imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test/imgsearch/demo/xxxx.png'),
qualitieScore?: float(name='QualitieScore', example='99.79581'),
}
](name='InsertedFaces'),
}(name='Data'),
requestId?: string(name='RequestId', example='C46A46D0-3263-181A-A1EE-0901E4595390'),
}
model BatchAddFacesResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: BatchAddFacesResponseBody(name='body'),
}
async function batchAddFacesWithOptions(tmpReq: BatchAddFacesRequest, runtime: Util.RuntimeOptions): BatchAddFacesResponse {
Util.validateModel(tmpReq);
var request = new BatchAddFacesShrinkRequest{};
OpenApiUtil.convert(tmpReq, request);
if (!Util.isUnset(tmpReq.faces)) {
request.facesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.faces, 'Faces', 'json');
}
var body : map[string]any = {};
if (!Util.isUnset(request.dbName)) {
body['DbName'] = request.dbName;
}
if (!Util.isUnset(request.entityId)) {
body['EntityId'] = request.entityId;
}
if (!Util.isUnset(request.facesShrink)) {
body['Faces'] = request.facesShrink;
}
if (!Util.isUnset(request.qualityScoreThreshold)) {
body['QualityScoreThreshold'] = request.qualityScoreThreshold;
}
if (!Util.isUnset(request.similarityScoreThresholdBetweenEntity)) {
body['SimilarityScoreThresholdBetweenEntity'] = request.similarityScoreThresholdBetweenEntity;
}
if (!Util.isUnset(request.similarityScoreThresholdInEntity)) {
body['SimilarityScoreThresholdInEntity'] = request.similarityScoreThresholdInEntity;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'BatchAddFaces',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function batchAddFaces(request: BatchAddFacesRequest): BatchAddFacesResponse {
var runtime = new Util.RuntimeOptions{};
return batchAddFacesWithOptions(request, runtime);
}
async function batchAddFacesAdvance(request: BatchAddFacesAdvanceRequest, runtime: Util.RuntimeOptions): BatchAddFacesResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var batchAddFacesReq = new BatchAddFacesRequest{};
OpenApiUtil.convert(request, batchAddFacesReq);
if(!Util.isUnset(request.faces)) {
var i0 : integer = 0;
for (var item0 : request.faces) {
if(!Util.isUnset(item0.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = item0.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
var tmp : BatchAddFacesRequest.faces = batchAddFacesReq.faces[i0];
tmp.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
i0 = Number.ltoi(Number.add(Number.itol(i0), Number.itol(1)));
}
}
}
var batchAddFacesResp = batchAddFacesWithOptions(batchAddFacesReq, runtime);
return batchAddFacesResp;
}
model BeautifyBodyRequest {
ageRange?: {
ageMax?: long(name='AgeMax'),
ageMinimum?: long(name='AgeMinimum'),
}(name='AgeRange'),
bodyBoxes?: [
{
height?: float(name='Height'),
width?: float(name='Width'),
x?: float(name='X'),
y?: float(name='Y'),
}
](name='BodyBoxes', example='[{\\"X\\":824,\\"Y\\":284,\\"Height\\":670,\\"Width\\":283},{\\"X\\":419,\\"Y\\":291,\\"Height\\":663,\\"Width\\":522}]'),
custom?: long(name='Custom', example='1'),
faceList?: [
{
age?: long(name='Age'),
faceBox?: {
height?: float(name='Height'),
width?: float(name='Width'),
x?: float(name='X'),
y?: float(name='Y'),
}(name='FaceBox'),
gender?: long(name='Gender'),
}
](name='FaceList', example='[{"age":24,"gender":0,"faceBox":{"x":887,"y":293,"width":81,"height":94}},{"age":24,"gender":0,"faceBox":{"x":695,"y":385,"width":65,"height":75}}]'),
femaleLiquifyDegree?: float(name='FemaleLiquifyDegree', example='1'),
imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/jin/BeautifyBody/BeautifyBody1.jpg'),
isPregnant?: boolean(name='IsPregnant', example='false'),
lengthenDegree?: float(name='LengthenDegree', example='1'),
maleLiquifyDegree?: float(name='MaleLiquifyDegree', example='1'),
originalHeight?: long(name='OriginalHeight', example='1000'),
originalWidth?: long(name='OriginalWidth', example='1500'),
poseList?: [
{
pose?: [
{
score?: float(name='Score'),
x?: long(name='X'),
y?: long(name='Y'),
}
](name='Pose'),
}
](name='PoseList', example='[{"pose":[{"x":715.33203125,"y":424.31640625,"score":0.8786243796348572},{"x":735.83984375,"y":415.52734375,"score":0.8847978115081787},{"x":703.61328125,"y":410.64453125,"score":0.8813298344612122}]},{"pose":[{"x":926.26953125,"y":342.28515625,"score":0.8721742630004883},{"x":938.96484375,"y":325.68359375,"score":0.8899118900299072},{"x":907.71484375,"y":332.51953125,"score":0.8997631072998047}]}]'),
}
model BeautifyBodyAdvanceRequest {
ageRange?: {
ageMax?: long(name='AgeMax'),
ageMinimum?: long(name='AgeMinimum'),
}(name='AgeRange'),
bodyBoxes?: [
{
height?: float(name='Height'),
width?: float(name='Width'),
x?: float(name='X'),
y?: float(name='Y'),
}
](name='BodyBoxes', example='[{\\"X\\":824,\\"Y\\":284,\\"Height\\":670,\\"Width\\":283},{\\"X\\":419,\\"Y\\":291,\\"Height\\":663,\\"Width\\":522}]'),
custom?: long(name='Custom', example='1'),
faceList?: [
{
age?: long(name='Age'),
faceBox?: {
height?: float(name='Height'),
width?: float(name='Width'),
x?: float(name='X'),
y?: float(name='Y'),
}(name='FaceBox'),
gender?: long(name='Gender'),
}
](name='FaceList', example='[{"age":24,"gender":0,"faceBox":{"x":887,"y":293,"width":81,"height":94}},{"age":24,"gender":0,"faceBox":{"x":695,"y":385,"width":65,"height":75}}]'),
femaleLiquifyDegree?: float(name='FemaleLiquifyDegree', example='1'),
imageURLObject?: readable(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/jin/BeautifyBody/BeautifyBody1.jpg'),
isPregnant?: boolean(name='IsPregnant', example='false'),
lengthenDegree?: float(name='LengthenDegree', example='1'),
maleLiquifyDegree?: float(name='MaleLiquifyDegree', example='1'),
originalHeight?: long(name='OriginalHeight', example='1000'),
originalWidth?: long(name='OriginalWidth', example='1500'),
poseList?: [
{
pose?: [
{
score?: float(name='Score'),
x?: long(name='X'),
y?: long(name='Y'),
}
](name='Pose'),
}
](name='PoseList', example='[{"pose":[{"x":715.33203125,"y":424.31640625,"score":0.8786243796348572},{"x":735.83984375,"y":415.52734375,"score":0.8847978115081787},{"x":703.61328125,"y":410.64453125,"score":0.8813298344612122}]},{"pose":[{"x":926.26953125,"y":342.28515625,"score":0.8721742630004883},{"x":938.96484375,"y":325.68359375,"score":0.8899118900299072},{"x":907.71484375,"y":332.51953125,"score":0.8997631072998047}]}]'),
}
model BeautifyBodyShrinkRequest {
ageRangeShrink?: string(name='AgeRange'),
bodyBoxesShrink?: string(name='BodyBoxes', example='[{\\"X\\":824,\\"Y\\":284,\\"Height\\":670,\\"Width\\":283},{\\"X\\":419,\\"Y\\":291,\\"Height\\":663,\\"Width\\":522}]'),
custom?: long(name='Custom', example='1'),
faceListShrink?: string(name='FaceList', example='[{"age":24,"gender":0,"faceBox":{"x":887,"y":293,"width":81,"height":94}},{"age":24,"gender":0,"faceBox":{"x":695,"y":385,"width":65,"height":75}}]'),
femaleLiquifyDegree?: float(name='FemaleLiquifyDegree', example='1'),
imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/jin/BeautifyBody/BeautifyBody1.jpg'),
isPregnant?: boolean(name='IsPregnant', example='false'),
lengthenDegree?: float(name='LengthenDegree', example='1'),
maleLiquifyDegree?: float(name='MaleLiquifyDegree', example='1'),
originalHeight?: long(name='OriginalHeight', example='1000'),
originalWidth?: long(name='OriginalWidth', example='1500'),
poseListShrink?: string(name='PoseList', example='[{"pose":[{"x":715.33203125,"y":424.31640625,"score":0.8786243796348572},{"x":735.83984375,"y":415.52734375,"score":0.8847978115081787},{"x":703.61328125,"y":410.64453125,"score":0.8813298344612122}]},{"pose":[{"x":926.26953125,"y":342.28515625,"score":0.8721742630004883},{"x":938.96484375,"y":325.68359375,"score":0.8899118900299072},{"x":907.71484375,"y":332.51953125,"score":0.8997631072998047}]}]'),
}
model BeautifyBodyResponseBody = {
data?: {
action?: string(name='Action'),
XFlowURL?: string(name='XFlowURL'),
YFlowURL?: string(name='YFlowURL'),
}(name='Data', description='Id of the request'),
requestId?: string(name='RequestId', example='ECC9587C-C06A-4350-9BF6-2DA6314D39D7'),
}
model BeautifyBodyResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: BeautifyBodyResponseBody(name='body'),
}
async function beautifyBodyWithOptions(tmpReq: BeautifyBodyRequest, runtime: Util.RuntimeOptions): BeautifyBodyResponse {
Util.validateModel(tmpReq);
var request = new BeautifyBodyShrinkRequest{};
OpenApiUtil.convert(tmpReq, request);
if (!Util.isUnset(tmpReq.ageRange)) {
request.ageRangeShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.ageRange, 'AgeRange', 'json');
}
if (!Util.isUnset(tmpReq.bodyBoxes)) {
request.bodyBoxesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.bodyBoxes, 'BodyBoxes', 'json');
}
if (!Util.isUnset(tmpReq.faceList)) {
request.faceListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.faceList, 'FaceList', 'json');
}
if (!Util.isUnset(tmpReq.poseList)) {
request.poseListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.poseList, 'PoseList', 'json');
}
var body : map[string]any = {};
if (!Util.isUnset(request.ageRangeShrink)) {
body['AgeRange'] = request.ageRangeShrink;
}
if (!Util.isUnset(request.bodyBoxesShrink)) {
body['BodyBoxes'] = request.bodyBoxesShrink;
}
if (!Util.isUnset(request.custom)) {
body['Custom'] = request.custom;
}
if (!Util.isUnset(request.faceListShrink)) {
body['FaceList'] = request.faceListShrink;
}
if (!Util.isUnset(request.femaleLiquifyDegree)) {
body['FemaleLiquifyDegree'] = request.femaleLiquifyDegree;
}
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.isPregnant)) {
body['IsPregnant'] = request.isPregnant;
}
if (!Util.isUnset(request.lengthenDegree)) {
body['LengthenDegree'] = request.lengthenDegree;
}
if (!Util.isUnset(request.maleLiquifyDegree)) {
body['MaleLiquifyDegree'] = request.maleLiquifyDegree;
}
if (!Util.isUnset(request.originalHeight)) {
body['OriginalHeight'] = request.originalHeight;
}
if (!Util.isUnset(request.originalWidth)) {
body['OriginalWidth'] = request.originalWidth;
}
if (!Util.isUnset(request.poseListShrink)) {
body['PoseList'] = request.poseListShrink;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'BeautifyBody',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function beautifyBody(request: BeautifyBodyRequest): BeautifyBodyResponse {
var runtime = new Util.RuntimeOptions{};
return beautifyBodyWithOptions(request, runtime);
}
async function beautifyBodyAdvance(request: BeautifyBodyAdvanceRequest, runtime: Util.RuntimeOptions): BeautifyBodyResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var beautifyBodyReq = new BeautifyBodyRequest{};
OpenApiUtil.convert(request, beautifyBodyReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
beautifyBodyReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var beautifyBodyResp = beautifyBodyWithOptions(beautifyBodyReq, runtime);
return beautifyBodyResp;
}
model BlurFaceRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/BlurFace/BlurFace1.png'),
}
model BlurFaceAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/BlurFace/BlurFace1.png'),
}
model BlurFaceResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://viapi-cn-shanghai-dha-segmenter.oss-cn-shanghai.aliyuncs.com/upload/result_FaceBlur/2020-8-5/invi_FaceBlur_015966077063461060948_IBdDsq.jpg?Expires=1596609506&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=x8n3jq1X91Sq7BKWE4vRHSu6g9****'),
maskURL?: string(name='MaskURL'),
}(name='Data'),
requestId?: string(name='RequestId', example='4C6080B0-64C4-488E-BBA6-245749CA11AD'),
}
model BlurFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: BlurFaceResponseBody(name='body'),
}
async function blurFaceWithOptions(request: BlurFaceRequest, runtime: Util.RuntimeOptions): BlurFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'BlurFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function blurFace(request: BlurFaceRequest): BlurFaceResponse {
var runtime = new Util.RuntimeOptions{};
return blurFaceWithOptions(request, runtime);
}
async function blurFaceAdvance(request: BlurFaceAdvanceRequest, runtime: Util.RuntimeOptions): BlurFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var blurFaceReq = new BlurFaceRequest{};
OpenApiUtil.convert(request, blurFaceReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
blurFaceReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var blurFaceResp = blurFaceWithOptions(blurFaceReq, runtime);
return blurFaceResp;
}
model BodyPostureRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/BodyPosture/BodyPosture4.jpg'),
}
model BodyPostureAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/BodyPosture/BodyPosture4.jpg'),
}
model BodyPostureResponseBody = {
data?: {
metaObject?: {
height?: int32(name='Height', example='500'),
width?: int32(name='Width', example='500'),
}(name='MetaObject'),
outputs?: [
{
humanCount?: int32(name='HumanCount', example='1'),
results?: [
{
bodies?: [
{
confident?: float(name='Confident', example='0.91309475898742676'),
label?: string(name='Label', example='nose'),
positions?: [
{
points?: [ float ](name='Points'),
}
](name='Positions'),
}
](name='Bodies'),
}
](name='Results'),
}
](name='Outputs'),
}(name='Data'),
requestId?: string(name='RequestId', example='B854094B-9231-4A54-89AB-C377CB0D237D'),
}
model BodyPostureResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: BodyPostureResponseBody(name='body'),
}
async function bodyPostureWithOptions(request: BodyPostureRequest, runtime: Util.RuntimeOptions): BodyPostureResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'BodyPosture',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function bodyPosture(request: BodyPostureRequest): BodyPostureResponse {
var runtime = new Util.RuntimeOptions{};
return bodyPostureWithOptions(request, runtime);
}
async function bodyPostureAdvance(request: BodyPostureAdvanceRequest, runtime: Util.RuntimeOptions): BodyPostureResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var bodyPostureReq = new BodyPostureRequest{};
OpenApiUtil.convert(request, bodyPostureReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
bodyPostureReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var bodyPostureResp = bodyPostureWithOptions(bodyPostureReq, runtime);
return bodyPostureResp;
}
model CompareFaceRequest {
imageDataA?: string(name='ImageDataA', example='/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgK****'),
imageDataB?: string(name='ImageDataB', example='/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgQ****'),
imageURLA?: string(name='ImageURLA', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/CompareFace/CompareFace-right1.png'),
imageURLB?: string(name='ImageURLB', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/CompareFace/CompareFace-left1.png'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='75.12'),
}
model CompareFaceAdvanceRequest {
imageDataA?: string(name='ImageDataA', example='/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgK****'),
imageDataB?: string(name='ImageDataB', example='/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgQ****'),
imageURLAObject?: readable(name='ImageURLA', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/CompareFace/CompareFace-right1.png'),
imageURLBObject?: readable(name='ImageURLB', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/CompareFace/CompareFace-left1.png'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='75.12'),
}
model CompareFaceResponseBody = {
data?: {
confidence?: float(name='Confidence'),
isMaskA?: long(name='IsMaskA'),
isMaskB?: long(name='IsMaskB'),
landmarksAList?: [ long ](name='LandmarksAList'),
landmarksBList?: [ long ](name='LandmarksBList'),
messageTips?: string(name='MessageTips', example='imageB quality score less threshold'),
qualityScoreA?: float(name='QualityScoreA', example='75.16'),
qualityScoreB?: float(name='QualityScoreB', example='75.20'),
rectAList?: [ int32 ](name='RectAList', description='1'),
rectBList?: [ int32 ](name='RectBList', description='1'),
thresholds?: [ float ](name='Thresholds', description='1'),
}(name='Data'),
requestId?: string(name='RequestId'),
}
model CompareFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: CompareFaceResponseBody(name='body'),
}
async function compareFaceWithOptions(request: CompareFaceRequest, runtime: Util.RuntimeOptions): CompareFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageDataA)) {
body['ImageDataA'] = request.imageDataA;
}
if (!Util.isUnset(request.imageDataB)) {
body['ImageDataB'] = request.imageDataB;
}
if (!Util.isUnset(request.imageURLA)) {
body['ImageURLA'] = request.imageURLA;
}
if (!Util.isUnset(request.imageURLB)) {
body['ImageURLB'] = request.imageURLB;
}
if (!Util.isUnset(request.qualityScoreThreshold)) {
body['QualityScoreThreshold'] = request.qualityScoreThreshold;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'CompareFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function compareFace(request: CompareFaceRequest): CompareFaceResponse {
var runtime = new Util.RuntimeOptions{};
return compareFaceWithOptions(request, runtime);
}
async function compareFaceAdvance(request: CompareFaceAdvanceRequest, runtime: Util.RuntimeOptions): CompareFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var compareFaceReq = new CompareFaceRequest{};
OpenApiUtil.convert(request, compareFaceReq);
if(!Util.isUnset(request.imageURLAObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLAObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
compareFaceReq.imageURLA = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.imageURLBObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLBObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
compareFaceReq.imageURLB = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var compareFaceResp = compareFaceWithOptions(compareFaceReq, runtime);
return compareFaceResp;
}
model CompareFaceWithMaskRequest {
imageURLA?: string(name='ImageURLA'),
imageURLB?: string(name='ImageURLB'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='97.0'),
}
model CompareFaceWithMaskAdvanceRequest {
imageURLAObject?: readable(name='ImageURLA'),
imageURLBObject?: readable(name='ImageURLB'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='97.0'),
}
model CompareFaceWithMaskResponseBody = {
data?: {
confidence?: float(name='Confidence'),
isMaskA?: long(name='IsMaskA'),
isMaskB?: long(name='IsMaskB'),
landmarksAList?: [ long ](name='LandmarksAList'),
landmarksBList?: [ long ](name='LandmarksBList'),
messageTips?: string(name='MessageTips', example='imageB quality score less threshold'),
qualityScoreA?: float(name='QualityScoreA'),
qualityScoreB?: float(name='QualityScoreB'),
rectAList?: [ long ](name='RectAList'),
rectBList?: [ long ](name='RectBList'),
thresholds?: [ long ](name='Thresholds'),
}(name='Data'),
requestId?: string(name='RequestId', example='C6499918-E932-41B3-96F5-A18F50D262DD'),
}
model CompareFaceWithMaskResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: CompareFaceWithMaskResponseBody(name='body'),
}
async function compareFaceWithMaskWithOptions(request: CompareFaceWithMaskRequest, runtime: Util.RuntimeOptions): CompareFaceWithMaskResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURLA)) {
body['ImageURLA'] = request.imageURLA;
}
if (!Util.isUnset(request.imageURLB)) {
body['ImageURLB'] = request.imageURLB;
}
if (!Util.isUnset(request.qualityScoreThreshold)) {
body['QualityScoreThreshold'] = request.qualityScoreThreshold;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'CompareFaceWithMask',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function compareFaceWithMask(request: CompareFaceWithMaskRequest): CompareFaceWithMaskResponse {
var runtime = new Util.RuntimeOptions{};
return compareFaceWithMaskWithOptions(request, runtime);
}
async function compareFaceWithMaskAdvance(request: CompareFaceWithMaskAdvanceRequest, runtime: Util.RuntimeOptions): CompareFaceWithMaskResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var compareFaceWithMaskReq = new CompareFaceWithMaskRequest{};
OpenApiUtil.convert(request, compareFaceWithMaskReq);
if(!Util.isUnset(request.imageURLAObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLAObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
compareFaceWithMaskReq.imageURLA = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.imageURLBObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLBObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
compareFaceWithMaskReq.imageURLB = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var compareFaceWithMaskResp = compareFaceWithMaskWithOptions(compareFaceWithMaskReq, runtime);
return compareFaceWithMaskResp;
}
model CreateFaceDbRequest {
name?: string(name='Name', example='default'),
}
model CreateFaceDbResponseBody = {
requestId?: string(name='RequestId', example='818D24A6-E368-46B3-99C5-3CF36D98CCA3'),
}
model CreateFaceDbResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: CreateFaceDbResponseBody(name='body'),
}
async function createFaceDbWithOptions(request: CreateFaceDbRequest, runtime: Util.RuntimeOptions): CreateFaceDbResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.name)) {
body['Name'] = request.name;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'CreateFaceDb',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function createFaceDb(request: CreateFaceDbRequest): CreateFaceDbResponse {
var runtime = new Util.RuntimeOptions{};
return createFaceDbWithOptions(request, runtime);
}
model DeepfakeFaceRequest {
tasks?: [
{
imageData?: string(name='ImageData', example='/9j/4AAQSkZJRgABAQAAAQABAAD/2****'),
imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DeepfakeFace/DeepfakeFace1.jpg'),
}
](name='Tasks'),
}
model DeepfakeFaceAdvanceRequest {
tasks?: [
{
imageData?: string(name='ImageData', example='/9j/4AAQSkZJRgABAQAAAQABAAD/2****'),
imageURLObject?: readable(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DeepfakeFace/DeepfakeFace1.jpg'),
}
](name='Tasks'),
}
model DeepfakeFaceResponseBody = {
data?: {
elements?: [
{
faceNumber?: long(name='FaceNumber', example='1'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DeepfakeFace/DeepfakeFace1.jpg'),
results?: [
{
confidence?: float(name='Confidence', example='36.6455'),
label?: string(name='Label', example='normalface'),
messageTips?: string(name='MessageTips', example='blurred, occluded or large angle face, please check.'),
rect?: {
height?: long(name='Height', example='284'),
left?: long(name='Left', example='373'),
top?: long(name='Top', example='111'),
width?: long(name='Width', example='207'),
}(name='Rect'),
}
](name='Results'),
taskId?: string(name='TaskId', example='8E6F65D5-62A1-1E5B-BC0B-00508034AC92'),
}
](name='Elements'),
}(name='Data'),
requestId?: string(name='RequestId', example='8E6F65D5-62A1-1E5B-BC0B-00508034AC92'),
}
model DeepfakeFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DeepfakeFaceResponseBody(name='body'),
}
async function deepfakeFaceWithOptions(request: DeepfakeFaceRequest, runtime: Util.RuntimeOptions): DeepfakeFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.tasks)) {
body['Tasks'] = request.tasks;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DeepfakeFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function deepfakeFace(request: DeepfakeFaceRequest): DeepfakeFaceResponse {
var runtime = new Util.RuntimeOptions{};
return deepfakeFaceWithOptions(request, runtime);
}
async function deepfakeFaceAdvance(request: DeepfakeFaceAdvanceRequest, runtime: Util.RuntimeOptions): DeepfakeFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var deepfakeFaceReq = new DeepfakeFaceRequest{};
OpenApiUtil.convert(request, deepfakeFaceReq);
if(!Util.isUnset(request.tasks)) {
var i0 : integer = 0;
for (var item0 : request.tasks) {
if(!Util.isUnset(item0.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = item0.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
var tmp : DeepfakeFaceRequest.tasks = deepfakeFaceReq.tasks[i0];
tmp.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
i0 = Number.ltoi(Number.add(Number.itol(i0), Number.itol(1)));
}
}
}
var deepfakeFaceResp = deepfakeFaceWithOptions(deepfakeFaceReq, runtime);
return deepfakeFaceResp;
}
model DeleteFaceRequest {
dbName?: string(name='DbName', example='default'),
faceId?: string(name='FaceId', example='001'),
}
model DeleteFaceResponseBody = {
requestId?: string(name='RequestId', example='FAC90D32-2F04-5AD4-B94B-BAA163AB3724'),
}
model DeleteFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DeleteFaceResponseBody(name='body'),
}
async function deleteFaceWithOptions(request: DeleteFaceRequest, runtime: Util.RuntimeOptions): DeleteFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.dbName)) {
body['DbName'] = request.dbName;
}
if (!Util.isUnset(request.faceId)) {
body['FaceId'] = request.faceId;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DeleteFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function deleteFace(request: DeleteFaceRequest): DeleteFaceResponse {
var runtime = new Util.RuntimeOptions{};
return deleteFaceWithOptions(request, runtime);
}
model DeleteFaceDbRequest {
name?: string(name='Name', example='default'),
}
model DeleteFaceDbResponseBody = {
requestId?: string(name='RequestId', example='203AE658-CFE1-507D-B105-F88CD1F1F71B'),
}
model DeleteFaceDbResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DeleteFaceDbResponseBody(name='body'),
}
async function deleteFaceDbWithOptions(request: DeleteFaceDbRequest, runtime: Util.RuntimeOptions): DeleteFaceDbResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.name)) {
body['Name'] = request.name;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DeleteFaceDb',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function deleteFaceDb(request: DeleteFaceDbRequest): DeleteFaceDbResponse {
var runtime = new Util.RuntimeOptions{};
return deleteFaceDbWithOptions(request, runtime);
}
model DeleteFaceEntityRequest {
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='wood'),
}
model DeleteFaceEntityResponseBody = {
requestId?: string(name='RequestId', example='DA7CAFEB-0A37-4496-9CDF-E3DBB6309CB2'),
}
model DeleteFaceEntityResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DeleteFaceEntityResponseBody(name='body'),
}
async function deleteFaceEntityWithOptions(request: DeleteFaceEntityRequest, runtime: Util.RuntimeOptions): DeleteFaceEntityResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.dbName)) {
body['DbName'] = request.dbName;
}
if (!Util.isUnset(request.entityId)) {
body['EntityId'] = request.entityId;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DeleteFaceEntity',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function deleteFaceEntity(request: DeleteFaceEntityRequest): DeleteFaceEntityResponse {
var runtime = new Util.RuntimeOptions{};
return deleteFaceEntityWithOptions(request, runtime);
}
model DeleteFaceImageTemplateRequest {
templateId?: string(name='TemplateId', example='6cd509ea-54fa-4730-8e9d-c94cadcda048'),
}
model DeleteFaceImageTemplateResponseBody = {
requestId?: string(name='RequestId', example='F9E76786-3A85-43C3-B79C-3175B4536252'),
}
model DeleteFaceImageTemplateResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DeleteFaceImageTemplateResponseBody(name='body'),
}
async function deleteFaceImageTemplateWithOptions(request: DeleteFaceImageTemplateRequest, runtime: Util.RuntimeOptions): DeleteFaceImageTemplateResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.templateId)) {
body['TemplateId'] = request.templateId;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DeleteFaceImageTemplate',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function deleteFaceImageTemplate(request: DeleteFaceImageTemplateRequest): DeleteFaceImageTemplateResponse {
var runtime = new Util.RuntimeOptions{};
return deleteFaceImageTemplateWithOptions(request, runtime);
}
model DetectBodyCountRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectBodyCount/DetectBodyCount3.jpg'),
}
model DetectBodyCountAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectBodyCount/DetectBodyCount3.jpg'),
}
model DetectBodyCountResponseBody = {
data?: {
personNumber?: int32(name='PersonNumber', example='6'),
}(name='Data'),
requestId?: string(name='RequestId', example='1C709078-8886-4C91-AEDE-4E04EED0A689'),
}
model DetectBodyCountResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DetectBodyCountResponseBody(name='body'),
}
async function detectBodyCountWithOptions(request: DetectBodyCountRequest, runtime: Util.RuntimeOptions): DetectBodyCountResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DetectBodyCount',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function detectBodyCount(request: DetectBodyCountRequest): DetectBodyCountResponse {
var runtime = new Util.RuntimeOptions{};
return detectBodyCountWithOptions(request, runtime);
}
async function detectBodyCountAdvance(request: DetectBodyCountAdvanceRequest, runtime: Util.RuntimeOptions): DetectBodyCountResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var detectBodyCountReq = new DetectBodyCountRequest{};
OpenApiUtil.convert(request, detectBodyCountReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
detectBodyCountReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var detectBodyCountResp = detectBodyCountWithOptions(detectBodyCountReq, runtime);
return detectBodyCountResp;
}
model DetectCelebrityRequest {
imageURL?: string(name='ImageURL', example='https://viapi-oss.oss-cn-shanghai.aliyuncs.com/doc/facebody/xxx.jpg'),
}
model DetectCelebrityAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='https://viapi-oss.oss-cn-shanghai.aliyuncs.com/doc/facebody/xxx.jpg'),
}
model DetectCelebrityResponseBody = {
data?: {
faceRecognizeResults?: [
{
faceBoxes?: [ float ](name='FaceBoxes', description='1'),
name?: string(name='Name'),
}
](name='FaceRecognizeResults'),
height?: int32(name='Height', example='1000'),
width?: int32(name='Width', example='1000'),
}(name='Data'),
requestId?: string(name='RequestId', example='4E92C0D4-BB0F-4F25-AD13-E87D02FAA205'),
}
model DetectCelebrityResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DetectCelebrityResponseBody(name='body'),
}
async function detectCelebrityWithOptions(request: DetectCelebrityRequest, runtime: Util.RuntimeOptions): DetectCelebrityResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DetectCelebrity',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function detectCelebrity(request: DetectCelebrityRequest): DetectCelebrityResponse {
var runtime = new Util.RuntimeOptions{};
return detectCelebrityWithOptions(request, runtime);
}
async function detectCelebrityAdvance(request: DetectCelebrityAdvanceRequest, runtime: Util.RuntimeOptions): DetectCelebrityResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var detectCelebrityReq = new DetectCelebrityRequest{};
OpenApiUtil.convert(request, detectCelebrityReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
detectCelebrityReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var detectCelebrityResp = detectCelebrityWithOptions(detectCelebrityReq, runtime);
return detectCelebrityResp;
}
model DetectChefCapRequest {
imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xuhan/facebody/DetectChefCap/ChefCap1.png'),
}
model DetectChefCapAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xuhan/facebody/DetectChefCap/ChefCap1.png'),
}
model DetectChefCapResponseBody = {
data?: {
elements?: [
{
box?: [ float ](name='Box'),
category?: string(name='Category', example='chefcap'),
confidence?: float(name='Confidence', example='0.6817094683647156'),
}
](name='Elements'),
}(name='Data'),
requestId?: string(name='RequestId', example='ADA2A7FD-6A97-4D5F-8781-FEC2DEF28418'),
}
model DetectChefCapResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DetectChefCapResponseBody(name='body'),
}
async function detectChefCapWithOptions(request: DetectChefCapRequest, runtime: Util.RuntimeOptions): DetectChefCapResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DetectChefCap',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function detectChefCap(request: DetectChefCapRequest): DetectChefCapResponse {
var runtime = new Util.RuntimeOptions{};
return detectChefCapWithOptions(request, runtime);
}
async function detectChefCapAdvance(request: DetectChefCapAdvanceRequest, runtime: Util.RuntimeOptions): DetectChefCapResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var detectChefCapReq = new DetectChefCapRequest{};
OpenApiUtil.convert(request, detectChefCapReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
detectChefCapReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var detectChefCapResp = detectChefCapWithOptions(detectChefCapReq, runtime);
return detectChefCapResp;
}
model DetectFaceRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectFace/DetectFace1.png'),
landmark?: boolean(name='Landmark', example='true'),
maxFaceNumber?: long(name='MaxFaceNumber', example='1'),
pose?: boolean(name='Pose', example='true'),
quality?: boolean(name='Quality', example='true'),
}
model DetectFaceAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectFace/DetectFace1.png'),
landmark?: boolean(name='Landmark', example='true'),
maxFaceNumber?: long(name='MaxFaceNumber', example='1'),
pose?: boolean(name='Pose', example='true'),
quality?: boolean(name='Quality', example='true'),
}
model DetectFaceResponseBody = {
data?: {
faceCount?: int32(name='FaceCount', example='1'),
faceProbabilityList?: [ float ](name='FaceProbabilityList', description='1'),
faceRectangles?: [ int32 ](name='FaceRectangles', description='1'),
landmarkCount?: int32(name='LandmarkCount', example='105'),
landmarkScore?: [ float ](name='LandmarkScore'),
landmarks?: [ float ](name='Landmarks', description='1'),
poseList?: [ float ](name='PoseList', description='1'),
pupils?: [ double ](name='Pupils', description='1'),
qualities?: {
blurList?: [ float ](name='BlurList', description='1'),
fnfList?: [ float ](name='FnfList', description='1'),
glassList?: [ float ](name='GlassList', description='1'),
illuList?: [ float ](name='IlluList', description='1'),
maskList?: [ float ](name='MaskList', description='1'),
noiseList?: [ float ](name='NoiseList', description='1'),
poseList?: [ float ](name='PoseList', description='1'),
scoreList?: [ float ](name='ScoreList', description='1'),
}(name='Qualities'),
}(name='Data'),
requestId?: string(name='RequestId'),
}
model DetectFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DetectFaceResponseBody(name='body'),
}
async function detectFaceWithOptions(request: DetectFaceRequest, runtime: Util.RuntimeOptions): DetectFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.landmark)) {
body['Landmark'] = request.landmark;
}
if (!Util.isUnset(request.maxFaceNumber)) {
body['MaxFaceNumber'] = request.maxFaceNumber;
}
if (!Util.isUnset(request.pose)) {
body['Pose'] = request.pose;
}
if (!Util.isUnset(request.quality)) {
body['Quality'] = request.quality;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DetectFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function detectFace(request: DetectFaceRequest): DetectFaceResponse {
var runtime = new Util.RuntimeOptions{};
return detectFaceWithOptions(request, runtime);
}
async function detectFaceAdvance(request: DetectFaceAdvanceRequest, runtime: Util.RuntimeOptions): DetectFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var detectFaceReq = new DetectFaceRequest{};
OpenApiUtil.convert(request, detectFaceReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
detectFaceReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var detectFaceResp = detectFaceWithOptions(detectFaceReq, runtime);
return detectFaceResp;
}
model DetectInfraredLivingFaceRequest {
tasks?: [
{
imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectInfraredLivingFace/DetectInfraredLivingFace.jpeg'),
}
](name='Tasks'),
}
model DetectInfraredLivingFaceAdvanceRequest {
tasks?: [
{
imageURLObject?: readable(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectInfraredLivingFace/DetectInfraredLivingFace.jpeg'),
}
](name='Tasks'),
}
model DetectInfraredLivingFaceResponseBody = {
data?: {
elements?: [
{
faceNumber?: long(name='FaceNumber', example='1'),
imageURL?: string(name='ImageURL', example='http://viapi-demo.oss-cn-shanghai.aliyuncs.com/viapi-demo/images/SegmentCommonImage/segmentimage-src-hu.jpeg'),
results?: [
{
label?: string(name='Label', example='liveness'),
messageTips?: string(name='MessageTips', example='blurred, occluded or large angle face, please check.'),
rate?: float(name='Rate', example='83.3848'),
rect?: {
height?: long(name='Height', example='20'),
left?: long(name='Left', example='60'),
top?: long(name='Top', example='50'),
width?: long(name='Width', example='30'),
}(name='Rect'),
suggestion?: string(name='Suggestion', example='review'),
}
](name='Results'),
}
](name='Elements'),
}(name='Data'),
requestId?: string(name='RequestId', example='68DF6EC7-3B1D-11EE-9FA7-1122F1AE92DD'),
}
model DetectInfraredLivingFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DetectInfraredLivingFaceResponseBody(name='body'),
}
async function detectInfraredLivingFaceWithOptions(request: DetectInfraredLivingFaceRequest, runtime: Util.RuntimeOptions): DetectInfraredLivingFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.tasks)) {
body['Tasks'] = request.tasks;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DetectInfraredLivingFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function detectInfraredLivingFace(request: DetectInfraredLivingFaceRequest): DetectInfraredLivingFaceResponse {
var runtime = new Util.RuntimeOptions{};
return detectInfraredLivingFaceWithOptions(request, runtime);
}
async function detectInfraredLivingFaceAdvance(request: DetectInfraredLivingFaceAdvanceRequest, runtime: Util.RuntimeOptions): DetectInfraredLivingFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var detectInfraredLivingFaceReq = new DetectInfraredLivingFaceRequest{};
OpenApiUtil.convert(request, detectInfraredLivingFaceReq);
if(!Util.isUnset(request.tasks)) {
var i0 : integer = 0;
for (var item0 : request.tasks) {
if(!Util.isUnset(item0.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = item0.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
var tmp : DetectInfraredLivingFaceRequest.tasks = detectInfraredLivingFaceReq.tasks[i0];
tmp.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
i0 = Number.ltoi(Number.add(Number.itol(i0), Number.itol(1)));
}
}
}
var detectInfraredLivingFaceResp = detectInfraredLivingFaceWithOptions(detectInfraredLivingFaceReq, runtime);
return detectInfraredLivingFaceResp;
}
model DetectLivingFaceRequest {
tasks?: [
{
imageData?: string(name='ImageData'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectLivingFace/DetectLivingFace4.jpg'),
}
](name='Tasks'),
}
model DetectLivingFaceAdvanceRequest {
tasks?: [
{
imageData?: string(name='ImageData'),
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectLivingFace/DetectLivingFace4.jpg'),
}
](name='Tasks'),
}
model DetectLivingFaceResponseBody = {
data?: {
elements?: [
{
faceNumber?: long(name='FaceNumber', example='1'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectLivingFace/DetectLivingFace4.jpg'),
results?: [
{
frames?: [
{
rate?: float(name='Rate', example='84.83'),
url?: string(name='Url', example='http://aligreen-shanghai.oss-cn-shanghai.aliyuncs.com/prod/hammal/26210da42/28118541_TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png?Expires=1582703593&OSSAccessKeyId=H4sp5QfNbuDg****&Signature=%2B8iUkb5YjomYR8ujV2c8wMAavs****&x-oss-process=image%2Fcrop%2Cx_0%2Cw_288%2Fauto-orient%2C0'),
}
](name='Frames'),
label?: string(name='Label', example='liveness'),
messageTips?: string(name='MessageTips', example='blurred, occluded or large angle face, please check.'),
rate?: float(name='Rate', example='76.22'),
rect?: {
height?: long(name='Height', example='60'),
left?: long(name='Left', example='20'),
top?: long(name='Top', example='30'),
width?: long(name='Width', example='50'),
}(name='Rect'),
suggestion?: string(name='Suggestion', example='review'),
}
](name='Results'),
taskId?: string(name='TaskId', example='img1owc8WGskNm78OEAPJTZal-1****'),
}
](name='Elements'),
}(name='Data'),
requestId?: string(name='RequestId', example='2EEA0396-BD84-5729-B8BD-D60776FCEF2B'),
}
model DetectLivingFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DetectLivingFaceResponseBody(name='body'),
}
async function detectLivingFaceWithOptions(request: DetectLivingFaceRequest, runtime: Util.RuntimeOptions): DetectLivingFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.tasks)) {
body['Tasks'] = request.tasks;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DetectLivingFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function detectLivingFace(request: DetectLivingFaceRequest): DetectLivingFaceResponse {
var runtime = new Util.RuntimeOptions{};
return detectLivingFaceWithOptions(request, runtime);
}
async function detectLivingFaceAdvance(request: DetectLivingFaceAdvanceRequest, runtime: Util.RuntimeOptions): DetectLivingFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var detectLivingFaceReq = new DetectLivingFaceRequest{};
OpenApiUtil.convert(request, detectLivingFaceReq);
if(!Util.isUnset(request.tasks)) {
var i0 : integer = 0;
for (var item0 : request.tasks) {
if(!Util.isUnset(item0.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = item0.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
var tmp : DetectLivingFaceRequest.tasks = detectLivingFaceReq.tasks[i0];
tmp.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
i0 = Number.ltoi(Number.add(Number.itol(i0), Number.itol(1)));
}
}
}
var detectLivingFaceResp = detectLivingFaceWithOptions(detectLivingFaceReq, runtime);
return detectLivingFaceResp;
}
model DetectPedestrianRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectPedestrian/DetectPedestrian8.jpg'),
}
model DetectPedestrianAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectPedestrian/DetectPedestrian8.jpg'),
}
model DetectPedestrianResponseBody = {
data?: {
elements?: [
{
boxes?: [ int32 ](name='Boxes', description='1'),
score?: float(name='Score', example='0.999'),
type?: string(name='Type', example='person'),
}
](name='Elements'),
height?: int32(name='Height', example='599'),
width?: int32(name='Width', example='899'),
}(name='Data'),
requestId?: string(name='RequestId', example='45DBA494-6250-42C4-80D1-7CF19BDD2CB1'),
}
model DetectPedestrianResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DetectPedestrianResponseBody(name='body'),
}
async function detectPedestrianWithOptions(request: DetectPedestrianRequest, runtime: Util.RuntimeOptions): DetectPedestrianResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DetectPedestrian',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function detectPedestrian(request: DetectPedestrianRequest): DetectPedestrianResponse {
var runtime = new Util.RuntimeOptions{};
return detectPedestrianWithOptions(request, runtime);
}
async function detectPedestrianAdvance(request: DetectPedestrianAdvanceRequest, runtime: Util.RuntimeOptions): DetectPedestrianResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var detectPedestrianReq = new DetectPedestrianRequest{};
OpenApiUtil.convert(request, detectPedestrianReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
detectPedestrianReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var detectPedestrianResp = detectPedestrianWithOptions(detectPedestrianReq, runtime);
return detectPedestrianResp;
}
model DetectPedestrianIntrusionRequest {
detectRegion?: [
{
line?: {
x1?: long(name='X1', example='0'),
x2?: long(name='X2', example='300'),
y1?: long(name='Y1', example='0'),
y2?: long(name='Y2', example='300'),
}(name='Line'),
rect?: {
bottom?: long(name='Bottom', example='300'),
left?: long(name='Left', example='0'),
right?: long(name='Right', example='300'),
top?: long(name='Top', example='0'),
}(name='Rect'),
}
](name='DetectRegion'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectPedestrianIntrusion/DetectPedestrianIntrusion2.jpg'),
regionType?: string(name='RegionType', example='rectangle'),
}
model DetectPedestrianIntrusionAdvanceRequest {
detectRegion?: [
{
line?: {
x1?: long(name='X1', example='0'),
x2?: long(name='X2', example='300'),
y1?: long(name='Y1', example='0'),
y2?: long(name='Y2', example='300'),
}(name='Line'),
rect?: {
bottom?: long(name='Bottom', example='300'),
left?: long(name='Left', example='0'),
right?: long(name='Right', example='300'),
top?: long(name='Top', example='0'),
}(name='Rect'),
}
](name='DetectRegion'),
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectPedestrianIntrusion/DetectPedestrianIntrusion2.jpg'),
regionType?: string(name='RegionType', example='rectangle'),
}
model DetectPedestrianIntrusionShrinkRequest {
detectRegionShrink?: string(name='DetectRegion'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectPedestrianIntrusion/DetectPedestrianIntrusion2.jpg'),
regionType?: string(name='RegionType', example='rectangle'),
}
model DetectPedestrianIntrusionResponseBody = {
data?: {
elements?: [
{
box?: {
bottom?: long(name='Bottom', example='551'),
left?: long(name='Left', example='175'),
right?: long(name='Right', example='418'),
top?: long(name='Top', example='153'),
}(name='Box'),
boxId?: long(name='BoxId', example='0'),
isIntrude?: boolean(name='IsIntrude', example='false'),
score?: long(name='Score', example='0.950289249420166'),
type?: string(name='Type', example='person'),
}
](name='Elements'),
imageHeight?: long(name='ImageHeight', example='599'),
imageWidth?: long(name='ImageWidth', example='899'),
}(name='Data'),
requestId?: string(name='RequestId', example='AA2539F7-D139-458C-A9BA-3321318D6BC4'),
}
model DetectPedestrianIntrusionResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DetectPedestrianIntrusionResponseBody(name='body'),
}
async function detectPedestrianIntrusionWithOptions(tmpReq: DetectPedestrianIntrusionRequest, runtime: Util.RuntimeOptions): DetectPedestrianIntrusionResponse {
Util.validateModel(tmpReq);
var request = new DetectPedestrianIntrusionShrinkRequest{};
OpenApiUtil.convert(tmpReq, request);
if (!Util.isUnset(tmpReq.detectRegion)) {
request.detectRegionShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.detectRegion, 'DetectRegion', 'json');
}
var body : map[string]any = {};
if (!Util.isUnset(request.detectRegionShrink)) {
body['DetectRegion'] = request.detectRegionShrink;
}
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.regionType)) {
body['RegionType'] = request.regionType;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DetectPedestrianIntrusion',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function detectPedestrianIntrusion(request: DetectPedestrianIntrusionRequest): DetectPedestrianIntrusionResponse {
var runtime = new Util.RuntimeOptions{};
return detectPedestrianIntrusionWithOptions(request, runtime);
}
async function detectPedestrianIntrusionAdvance(request: DetectPedestrianIntrusionAdvanceRequest, runtime: Util.RuntimeOptions): DetectPedestrianIntrusionResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var detectPedestrianIntrusionReq = new DetectPedestrianIntrusionRequest{};
OpenApiUtil.convert(request, detectPedestrianIntrusionReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
detectPedestrianIntrusionReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var detectPedestrianIntrusionResp = detectPedestrianIntrusionWithOptions(detectPedestrianIntrusionReq, runtime);
return detectPedestrianIntrusionResp;
}
model DetectVideoLivingFaceRequest {
videoUrl?: string(name='VideoUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectVideoLivingFace/DetectVideoLivingFace1.mp4'),
}
model DetectVideoLivingFaceAdvanceRequest {
videoUrlObject?: readable(name='VideoUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/DetectVideoLivingFace/DetectVideoLivingFace1.mp4'),
}
model DetectVideoLivingFaceResponseBody = {
data?: {
elements?: [
{
faceConfidence?: float(name='FaceConfidence', example='0.84644949436187744'),
liveConfidence?: float(name='LiveConfidence', example='0.72464925050735474'),
rect?: [ int32 ](name='Rect'),
}
](name='Elements'),
}(name='Data'),
requestId?: string(name='RequestId', example='8E92F28B-F889-48CB-9FCC-3207CFA2215E'),
}
model DetectVideoLivingFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: DetectVideoLivingFaceResponseBody(name='body'),
}
async function detectVideoLivingFaceWithOptions(request: DetectVideoLivingFaceRequest, runtime: Util.RuntimeOptions): DetectVideoLivingFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.videoUrl)) {
body['VideoUrl'] = request.videoUrl;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'DetectVideoLivingFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function detectVideoLivingFace(request: DetectVideoLivingFaceRequest): DetectVideoLivingFaceResponse {
var runtime = new Util.RuntimeOptions{};
return detectVideoLivingFaceWithOptions(request, runtime);
}
async function detectVideoLivingFaceAdvance(request: DetectVideoLivingFaceAdvanceRequest, runtime: Util.RuntimeOptions): DetectVideoLivingFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var detectVideoLivingFaceReq = new DetectVideoLivingFaceRequest{};
OpenApiUtil.convert(request, detectVideoLivingFaceReq);
if(!Util.isUnset(request.videoUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.videoUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
detectVideoLivingFaceReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var detectVideoLivingFaceResp = detectVideoLivingFaceWithOptions(detectVideoLivingFaceReq, runtime);
return detectVideoLivingFaceResp;
}
model EnhanceFaceRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/EnhanceFace/EnhanceFace1.png'),
}
model EnhanceFaceAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/EnhanceFace/EnhanceFace1.png'),
}
model EnhanceFaceResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://vibktprfx-prod-prod-aic-vd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/face-enhancement/2021-11-30/8e34b61c-abcf-4708-9d9d-6501968ee806/20211130_080644126523_47ct9w3pgh.jpg?Expires=1638261404&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=2wPdcuCmr%2F86WpBL3HQJw5uCFl****'),
}(name='Data'),
requestId?: string(name='RequestId', example='8B031473-6773-4A4C-AF33-A233758E6E98'),
}
model EnhanceFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: EnhanceFaceResponseBody(name='body'),
}
async function enhanceFaceWithOptions(request: EnhanceFaceRequest, runtime: Util.RuntimeOptions): EnhanceFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'EnhanceFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function enhanceFace(request: EnhanceFaceRequest): EnhanceFaceResponse {
var runtime = new Util.RuntimeOptions{};
return enhanceFaceWithOptions(request, runtime);
}
async function enhanceFaceAdvance(request: EnhanceFaceAdvanceRequest, runtime: Util.RuntimeOptions): EnhanceFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var enhanceFaceReq = new EnhanceFaceRequest{};
OpenApiUtil.convert(request, enhanceFaceReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
enhanceFaceReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var enhanceFaceResp = enhanceFaceWithOptions(enhanceFaceReq, runtime);
return enhanceFaceResp;
}
model ExtractFingerPrintRequest {
imageData?: string(name='ImageData', example='iVBORw0KGgoAAAANSUhEUgAAASUAA****'),
imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xuhan/ExtractFingerPrint.png'),
}
model ExtractFingerPrintAdvanceRequest {
imageData?: string(name='ImageData', example='iVBORw0KGgoAAAANSUhEUgAAASUAA****'),
imageURLObject?: readable(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xuhan/ExtractFingerPrint.png'),
}
model ExtractFingerPrintResponseBody = {
data?: {
fingerPrint?: string(name='FingerPrint', example='/9j/4AAQSkZJRgABAQAAAQABAAD****'),
}(name='Data'),
requestId?: string(name='RequestId', example='D21978CC-C1E7-4A7A-A1B2-D5896BDC7ADF'),
}
model ExtractFingerPrintResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: ExtractFingerPrintResponseBody(name='body'),
}
async function extractFingerPrintWithOptions(request: ExtractFingerPrintRequest, runtime: Util.RuntimeOptions): ExtractFingerPrintResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageData)) {
body['ImageData'] = request.imageData;
}
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ExtractFingerPrint',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function extractFingerPrint(request: ExtractFingerPrintRequest): ExtractFingerPrintResponse {
var runtime = new Util.RuntimeOptions{};
return extractFingerPrintWithOptions(request, runtime);
}
async function extractFingerPrintAdvance(request: ExtractFingerPrintAdvanceRequest, runtime: Util.RuntimeOptions): ExtractFingerPrintResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var extractFingerPrintReq = new ExtractFingerPrintRequest{};
OpenApiUtil.convert(request, extractFingerPrintReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
extractFingerPrintReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var extractFingerPrintResp = extractFingerPrintWithOptions(extractFingerPrintReq, runtime);
return extractFingerPrintResp;
}
model ExtractPedestrianFeatureAttrRequest {
imageURL?: string(name='ImageURL'),
mode?: string(name='Mode'),
serviceVersion?: string(name='ServiceVersion'),
}
model ExtractPedestrianFeatureAttrAdvanceRequest {
imageURLObject?: readable(name='ImageURL'),
mode?: string(name='Mode'),
serviceVersion?: string(name='ServiceVersion'),
}
model ExtractPedestrianFeatureAttrResponseBody = {
data?: {
age?: string(name='Age'),
ageScore?: float(name='AgeScore'),
feature?: string(name='Feature'),
gender?: string(name='Gender'),
genderScore?: float(name='GenderScore'),
hair?: string(name='Hair'),
hairScore?: float(name='HairScore'),
lowerColor?: string(name='LowerColor'),
lowerColorScore?: float(name='LowerColorScore'),
lowerType?: string(name='LowerType'),
lowerTypeScore?: float(name='LowerTypeScore'),
objType?: string(name='ObjType'),
objTypeScore?: float(name='ObjTypeScore'),
orientation?: string(name='Orientation'),
orientationScore?: float(name='OrientationScore'),
qualityScore?: float(name='QualityScore'),
upperColor?: string(name='UpperColor'),
upperColorScore?: float(name='UpperColorScore'),
upperType?: string(name='UpperType'),
upperTypeScore?: float(name='UpperTypeScore'),
}(name='Data'),
requestId?: string(name='RequestId'),
}
model ExtractPedestrianFeatureAttrResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: ExtractPedestrianFeatureAttrResponseBody(name='body'),
}
async function extractPedestrianFeatureAttrWithOptions(request: ExtractPedestrianFeatureAttrRequest, runtime: Util.RuntimeOptions): ExtractPedestrianFeatureAttrResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.mode)) {
body['Mode'] = request.mode;
}
if (!Util.isUnset(request.serviceVersion)) {
body['ServiceVersion'] = request.serviceVersion;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ExtractPedestrianFeatureAttr',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function extractPedestrianFeatureAttr(request: ExtractPedestrianFeatureAttrRequest): ExtractPedestrianFeatureAttrResponse {
var runtime = new Util.RuntimeOptions{};
return extractPedestrianFeatureAttrWithOptions(request, runtime);
}
async function extractPedestrianFeatureAttrAdvance(request: ExtractPedestrianFeatureAttrAdvanceRequest, runtime: Util.RuntimeOptions): ExtractPedestrianFeatureAttrResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var extractPedestrianFeatureAttrReq = new ExtractPedestrianFeatureAttrRequest{};
OpenApiUtil.convert(request, extractPedestrianFeatureAttrReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
extractPedestrianFeatureAttrReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var extractPedestrianFeatureAttrResp = extractPedestrianFeatureAttrWithOptions(extractPedestrianFeatureAttrReq, runtime);
return extractPedestrianFeatureAttrResp;
}
model FaceBeautyRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/FaceBeauty/FaceBeauty4.png'),
sharp?: float(name='Sharp', example='1'),
smooth?: float(name='Smooth', example='0.1'),
white?: float(name='White', example='0.3'),
}
model FaceBeautyAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/FaceBeauty/FaceBeauty4.png'),
sharp?: float(name='Sharp', example='1'),
smooth?: float(name='Smooth', example='0.1'),
white?: float(name='White', example='0.3'),
}
model FaceBeautyResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://algo-app-taobao-mm-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/pixelai-portrait-beauty/2020_03_24/2bbbdb7907901412_facebeauty.jpg?Expires=1585277923&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=myOPfNQcRyijgrWBU%2BZ4dPuV5Q****'),
}(name='Data'),
requestId?: string(name='RequestId', example='35C284E1-C5F5-4E5E-B7AD-97BBF485CDC8'),
}
model FaceBeautyResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: FaceBeautyResponseBody(name='body'),
}
async function faceBeautyWithOptions(request: FaceBeautyRequest, runtime: Util.RuntimeOptions): FaceBeautyResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.sharp)) {
body['Sharp'] = request.sharp;
}
if (!Util.isUnset(request.smooth)) {
body['Smooth'] = request.smooth;
}
if (!Util.isUnset(request.white)) {
body['White'] = request.white;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'FaceBeauty',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function faceBeauty(request: FaceBeautyRequest): FaceBeautyResponse {
var runtime = new Util.RuntimeOptions{};
return faceBeautyWithOptions(request, runtime);
}
async function faceBeautyAdvance(request: FaceBeautyAdvanceRequest, runtime: Util.RuntimeOptions): FaceBeautyResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var faceBeautyReq = new FaceBeautyRequest{};
OpenApiUtil.convert(request, faceBeautyReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
faceBeautyReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var faceBeautyResp = faceBeautyWithOptions(faceBeautyReq, runtime);
return faceBeautyResp;
}
model FaceFilterRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/FaceFilter/FaceFilter9.png'),
resourceType?: string(name='ResourceType'),
strength?: float(name='Strength', example='0.8'),
}
model FaceFilterAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/FaceFilter/FaceFilter9.png'),
resourceType?: string(name='ResourceType'),
strength?: float(name='Strength', example='0.8'),
}
model FaceFilterResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://algo-app-taobao-mm-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/pixelai-portrait-filter/2020_03_24/bd6bb112b4ef3c8c_facebeauty.jpg?Expires=1585278860&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=UB3gBjSyTm0EZC0K881P883JpX****'),
}(name='Data'),
requestId?: string(name='RequestId', example='EA20A53F-9523-4FE6-92D4-69F9E0A066AF'),
}
model FaceFilterResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: FaceFilterResponseBody(name='body'),
}
async function faceFilterWithOptions(request: FaceFilterRequest, runtime: Util.RuntimeOptions): FaceFilterResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.resourceType)) {
body['ResourceType'] = request.resourceType;
}
if (!Util.isUnset(request.strength)) {
body['Strength'] = request.strength;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'FaceFilter',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function faceFilter(request: FaceFilterRequest): FaceFilterResponse {
var runtime = new Util.RuntimeOptions{};
return faceFilterWithOptions(request, runtime);
}
async function faceFilterAdvance(request: FaceFilterAdvanceRequest, runtime: Util.RuntimeOptions): FaceFilterResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var faceFilterReq = new FaceFilterRequest{};
OpenApiUtil.convert(request, faceFilterReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
faceFilterReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var faceFilterResp = faceFilterWithOptions(faceFilterReq, runtime);
return faceFilterResp;
}
model FaceMakeupRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/FaceMakeup/FaceMakeup8.png'),
makeupType?: string(name='MakeupType', example='whole'),
resourceType?: string(name='ResourceType', example='0'),
strength?: float(name='Strength', example='1'),
}
model FaceMakeupAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/FaceMakeup/FaceMakeup8.png'),
makeupType?: string(name='MakeupType', example='whole'),
resourceType?: string(name='ResourceType', example='0'),
strength?: float(name='Strength', example='1'),
}
model FaceMakeupResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://algo-app-taobao-mm-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/pixelai-portrait-makeup/2020_03_24/c0f815f46b3df61e_facebeauty.jpg?Expires=1585279130&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=1QkDpev9B7ybzup1MN%2F72kzrKL****'),
}(name='Data'),
requestId?: string(name='RequestId', example='AAECB606-E752-4CEA-8EA5-6EBE942A7663'),
}
model FaceMakeupResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: FaceMakeupResponseBody(name='body'),
}
async function faceMakeupWithOptions(request: FaceMakeupRequest, runtime: Util.RuntimeOptions): FaceMakeupResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.makeupType)) {
body['MakeupType'] = request.makeupType;
}
if (!Util.isUnset(request.resourceType)) {
body['ResourceType'] = request.resourceType;
}
if (!Util.isUnset(request.strength)) {
body['Strength'] = request.strength;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'FaceMakeup',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function faceMakeup(request: FaceMakeupRequest): FaceMakeupResponse {
var runtime = new Util.RuntimeOptions{};
return faceMakeupWithOptions(request, runtime);
}
async function faceMakeupAdvance(request: FaceMakeupAdvanceRequest, runtime: Util.RuntimeOptions): FaceMakeupResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var faceMakeupReq = new FaceMakeupRequest{};
OpenApiUtil.convert(request, faceMakeupReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
faceMakeupReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var faceMakeupResp = faceMakeupWithOptions(faceMakeupReq, runtime);
return faceMakeupResp;
}
model FaceTidyupRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/FaceTidyup/FaceTidyup5.png'),
shapeType?: int32(name='ShapeType', example='0'),
strength?: float(name='Strength', example='1'),
}
model FaceTidyupAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/FaceTidyup/FaceTidyup5.png'),
shapeType?: int32(name='ShapeType', example='0'),
strength?: float(name='Strength', example='1'),
}
model FaceTidyupResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://algo-app-taobao-mm-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/pixelai-portrait-shape/2020_03_24/7cb93b25ac5cbbb4_facetidy.jpg?Expires=1585280344&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=RIPIlTZ2GNmdLyACGWz6wUzJxN****'),
}(name='Data'),
requestId?: string(name='RequestId', example='8F3BF64D-4FDF-4AAF-9B34-11B4EF4CE815'),
}
model FaceTidyupResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: FaceTidyupResponseBody(name='body'),
}
async function faceTidyupWithOptions(request: FaceTidyupRequest, runtime: Util.RuntimeOptions): FaceTidyupResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.shapeType)) {
body['ShapeType'] = request.shapeType;
}
if (!Util.isUnset(request.strength)) {
body['Strength'] = request.strength;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'FaceTidyup',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function faceTidyup(request: FaceTidyupRequest): FaceTidyupResponse {
var runtime = new Util.RuntimeOptions{};
return faceTidyupWithOptions(request, runtime);
}
async function faceTidyupAdvance(request: FaceTidyupAdvanceRequest, runtime: Util.RuntimeOptions): FaceTidyupResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var faceTidyupReq = new FaceTidyupRequest{};
OpenApiUtil.convert(request, faceTidyupReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
faceTidyupReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var faceTidyupResp = faceTidyupWithOptions(faceTidyupReq, runtime);
return faceTidyupResp;
}
model GenRealPersonVerificationTokenRequest {
certificateName?: string(name='CertificateName'),
certificateNumber?: string(name='CertificateNumber', example='33010219001123123X'),
metaInfo?: string(name='MetaInfo', example='{"dwe":"ew4e"...}'),
}
model GenRealPersonVerificationTokenResponseBody = {
data?: {
verificationToken?: string(name='VerificationToken', example='9fca3791c158a479ead9f2ba65ab3XXX'),
}(name='Data'),
requestId?: string(name='RequestId', example='A31006F2-22E7-4538-93BB-DE6B563643EE'),
}
model GenRealPersonVerificationTokenResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: GenRealPersonVerificationTokenResponseBody(name='body'),
}
async function genRealPersonVerificationTokenWithOptions(request: GenRealPersonVerificationTokenRequest, runtime: Util.RuntimeOptions): GenRealPersonVerificationTokenResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.certificateName)) {
body['CertificateName'] = request.certificateName;
}
if (!Util.isUnset(request.certificateNumber)) {
body['CertificateNumber'] = request.certificateNumber;
}
if (!Util.isUnset(request.metaInfo)) {
body['MetaInfo'] = request.metaInfo;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'GenRealPersonVerificationToken',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function genRealPersonVerificationToken(request: GenRealPersonVerificationTokenRequest): GenRealPersonVerificationTokenResponse {
var runtime = new Util.RuntimeOptions{};
return genRealPersonVerificationTokenWithOptions(request, runtime);
}
model GenerateHumanAnimeStyleRequest {
algoType?: string(name='AlgoType', example='anime'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/GenerateHumanAnimeStyle/GenerateHumanAnimeStyle8.png'),
}
model GenerateHumanAnimeStyleAdvanceRequest {
algoType?: string(name='AlgoType', example='anime'),
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/GenerateHumanAnimeStyle/GenerateHumanAnimeStyle8.png'),
}
model GenerateHumanAnimeStyleResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/person-image-cartoonizer/59697D68-2A6E-4553-89BD-0FADD07881E8_7ee5_20201027-070958.jpg?Expires=1603784400&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSR****&Signature=ut2kn46Lz%2FRwqJ9jWJ0RBDut12****'),
}(name='Data'),
requestId?: string(name='RequestId', example='59697D68-2A6E-4553-89BD-0FADD07881E8'),
}
model GenerateHumanAnimeStyleResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: GenerateHumanAnimeStyleResponseBody(name='body'),
}
async function generateHumanAnimeStyleWithOptions(request: GenerateHumanAnimeStyleRequest, runtime: Util.RuntimeOptions): GenerateHumanAnimeStyleResponse {
Util.validateModel(request);
var query = {};
if (!Util.isUnset(request.algoType)) {
query['AlgoType'] = request.algoType;
}
if (!Util.isUnset(request.imageURL)) {
query['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
};
var params = new OpenApi.Params{
action = 'GenerateHumanAnimeStyle',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function generateHumanAnimeStyle(request: GenerateHumanAnimeStyleRequest): GenerateHumanAnimeStyleResponse {
var runtime = new Util.RuntimeOptions{};
return generateHumanAnimeStyleWithOptions(request, runtime);
}
async function generateHumanAnimeStyleAdvance(request: GenerateHumanAnimeStyleAdvanceRequest, runtime: Util.RuntimeOptions): GenerateHumanAnimeStyleResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var generateHumanAnimeStyleReq = new GenerateHumanAnimeStyleRequest{};
OpenApiUtil.convert(request, generateHumanAnimeStyleReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
generateHumanAnimeStyleReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var generateHumanAnimeStyleResp = generateHumanAnimeStyleWithOptions(generateHumanAnimeStyleReq, runtime);
return generateHumanAnimeStyleResp;
}
model GenerateHumanSketchStyleRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/GenerateHumanSketchStyle/GenerateHumanSketchStyle7.png'),
returnType?: string(name='ReturnType', example='head'),
}
model GenerateHumanSketchStyleAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/GenerateHumanSketchStyle/GenerateHumanSketchStyle7.png'),
returnType?: string(name='ReturnType', example='head'),
}
model GenerateHumanSketchStyleResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/person-image-pencil/fd49dd0a-9e24-4bb5-b303-0745cdb453e0_7aa6_20210128-073045.jpg?Expires=1611820849&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=1oLYG%2FPe%2BNRIK7XcsUQYaKF%2B1C****'),
}(name='Data'),
requestId?: string(name='RequestId', example='E499788C-22DA-4F0E-B9C0-0E9D30A25716'),
}
model GenerateHumanSketchStyleResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: GenerateHumanSketchStyleResponseBody(name='body'),
}
async function generateHumanSketchStyleWithOptions(request: GenerateHumanSketchStyleRequest, runtime: Util.RuntimeOptions): GenerateHumanSketchStyleResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.returnType)) {
body['ReturnType'] = request.returnType;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'GenerateHumanSketchStyle',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function generateHumanSketchStyle(request: GenerateHumanSketchStyleRequest): GenerateHumanSketchStyleResponse {
var runtime = new Util.RuntimeOptions{};
return generateHumanSketchStyleWithOptions(request, runtime);
}
async function generateHumanSketchStyleAdvance(request: GenerateHumanSketchStyleAdvanceRequest, runtime: Util.RuntimeOptions): GenerateHumanSketchStyleResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var generateHumanSketchStyleReq = new GenerateHumanSketchStyleRequest{};
OpenApiUtil.convert(request, generateHumanSketchStyleReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
generateHumanSketchStyleReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var generateHumanSketchStyleResp = generateHumanSketchStyleWithOptions(generateHumanSketchStyleReq, runtime);
return generateHumanSketchStyleResp;
}
model GetFaceEntityRequest {
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='66'),
}
model GetFaceEntityResponseBody = {
data?: {
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='66'),
faces?: [
{
faceId?: string(name='FaceId', example='3'),
}
](name='Faces'),
labels?: string(name='Labels'),
}(name='Data'),
requestId?: string(name='RequestId', example='DA7CAFEB-0A37-4496-9CDF-E3DBB6309CB2'),
}
model GetFaceEntityResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: GetFaceEntityResponseBody(name='body'),
}
async function getFaceEntityWithOptions(request: GetFaceEntityRequest, runtime: Util.RuntimeOptions): GetFaceEntityResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.dbName)) {
body['DbName'] = request.dbName;
}
if (!Util.isUnset(request.entityId)) {
body['EntityId'] = request.entityId;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'GetFaceEntity',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function getFaceEntity(request: GetFaceEntityRequest): GetFaceEntityResponse {
var runtime = new Util.RuntimeOptions{};
return getFaceEntityWithOptions(request, runtime);
}
model GetRealPersonVerificationResultRequest {
verificationToken?: string(name='VerificationToken', example='cwek23dw24geor89230hf2rw'),
}
model GetRealPersonVerificationResultResponseBody = {
data?: {
passed?: boolean(name='Passed', example='true'),
}(name='Data'),
requestId?: string(name='RequestId', example='10FC953D-7C0C-4915-8949-34E3246E5B79'),
}
model GetRealPersonVerificationResultResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: GetRealPersonVerificationResultResponseBody(name='body'),
}
async function getRealPersonVerificationResultWithOptions(request: GetRealPersonVerificationResultRequest, runtime: Util.RuntimeOptions): GetRealPersonVerificationResultResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.verificationToken)) {
body['VerificationToken'] = request.verificationToken;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'GetRealPersonVerificationResult',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function getRealPersonVerificationResult(request: GetRealPersonVerificationResultRequest): GetRealPersonVerificationResultResponse {
var runtime = new Util.RuntimeOptions{};
return getRealPersonVerificationResultWithOptions(request, runtime);
}
model HandPostureRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/HandPosture/HandPosture3.jpg'),
}
model HandPostureAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/HandPosture/HandPosture3.jpg'),
}
model HandPostureResponseBody = {
data?: {
metaObject?: {
height?: int32(name='Height', example='600'),
width?: int32(name='Width', example='500'),
}(name='MetaObject'),
outputs?: [
{
handCount?: int32(name='HandCount', example='1'),
results?: [
{
box?: {
confident?: float(name='Confident', example='0.555'),
positions?: [
{
points?: [ float ](name='Points'),
}
](name='Positions'),
}(name='Box'),
hands?: {
confident?: float(name='Confident', example='0.555'),
keyPoints?: [
{
label?: string(name='Label', example='thumb'),
positions?: [
{
points?: [ float ](name='Points'),
}
](name='Positions'),
}
](name='KeyPoints'),
}(name='Hands'),
}
](name='Results'),
}
](name='Outputs'),
}(name='Data'),
requestId?: string(name='RequestId', example='99CE0601-FA61-4A41-BBF0-72D3E1FF5139'),
}
model HandPostureResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: HandPostureResponseBody(name='body'),
}
async function handPostureWithOptions(request: HandPostureRequest, runtime: Util.RuntimeOptions): HandPostureResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'HandPosture',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function handPosture(request: HandPostureRequest): HandPostureResponse {
var runtime = new Util.RuntimeOptions{};
return handPostureWithOptions(request, runtime);
}
async function handPostureAdvance(request: HandPostureAdvanceRequest, runtime: Util.RuntimeOptions): HandPostureResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var handPostureReq = new HandPostureRequest{};
OpenApiUtil.convert(request, handPostureReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
handPostureReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var handPostureResp = handPostureWithOptions(handPostureReq, runtime);
return handPostureResp;
}
model LiquifyFaceRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/LiquifyFace/LiquifyFace1.png'),
slimDegree?: float(name='SlimDegree', example='1.0'),
}
model LiquifyFaceAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/LiquifyFace/LiquifyFace1.png'),
slimDegree?: float(name='SlimDegree', example='1.0'),
}
model LiquifyFaceResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/face-liquify/CA1C8937-B30C-15E6-B804-41C357BA413B_5eca_20210923-093411.jpg?Expires=1632391451&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=46apJQVNBz%2FFzDLEYn2M1w9MKA****'),
}(name='Data'),
requestId?: string(name='RequestId', example='CA1C8937-B30C-15E6-B804-41C357BA413B'),
}
model LiquifyFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: LiquifyFaceResponseBody(name='body'),
}
async function liquifyFaceWithOptions(request: LiquifyFaceRequest, runtime: Util.RuntimeOptions): LiquifyFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.slimDegree)) {
body['SlimDegree'] = request.slimDegree;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'LiquifyFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function liquifyFace(request: LiquifyFaceRequest): LiquifyFaceResponse {
var runtime = new Util.RuntimeOptions{};
return liquifyFaceWithOptions(request, runtime);
}
async function liquifyFaceAdvance(request: LiquifyFaceAdvanceRequest, runtime: Util.RuntimeOptions): LiquifyFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var liquifyFaceReq = new LiquifyFaceRequest{};
OpenApiUtil.convert(request, liquifyFaceReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
liquifyFaceReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var liquifyFaceResp = liquifyFaceWithOptions(liquifyFaceReq, runtime);
return liquifyFaceResp;
}
model ListFaceDbsRequest {
limit?: long(name='Limit', example='50'),
offset?: long(name='Offset', example='1'),
}
model ListFaceDbsResponseBody = {
data?: {
dbList?: [
{
name?: string(name='Name', example='default'),
}
](name='DbList'),
}(name='Data'),
requestId?: string(name='RequestId', example='2B93C43A-F824-40C8-AF79-844342B0F43A'),
}
model ListFaceDbsResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: ListFaceDbsResponseBody(name='body'),
}
async function listFaceDbsWithOptions(request: ListFaceDbsRequest, runtime: Util.RuntimeOptions): ListFaceDbsResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.limit)) {
body['Limit'] = request.limit;
}
if (!Util.isUnset(request.offset)) {
body['Offset'] = request.offset;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ListFaceDbs',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function listFaceDbs(request: ListFaceDbsRequest): ListFaceDbsResponse {
var runtime = new Util.RuntimeOptions{};
return listFaceDbsWithOptions(request, runtime);
}
model ListFaceEntitiesRequest {
dbName?: string(name='DbName', example='default'),
entityIdPrefix?: string(name='EntityIdPrefix', example='U1'),
labels?: string(name='Labels'),
limit?: int32(name='Limit', example='50'),
offset?: int32(name='Offset', example='1'),
order?: string(name='Order', example='asc'),
token?: string(name='Token', example='2'),
}
model ListFaceEntitiesResponseBody = {
data?: {
entities?: [
{
createdAt?: long(name='CreatedAt', example='1589203871832'),
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='222'),
faceCount?: int32(name='FaceCount', example='3'),
labels?: string(name='Labels'),
updatedAt?: long(name='UpdatedAt', example='1589203871832'),
}
](name='Entities'),
token?: string(name='Token', example='2'),
totalCount?: int32(name='TotalCount', example='200'),
}(name='Data'),
requestId?: string(name='RequestId', example='DA7CAFEB-0A37-4496-9CDF-E3DBB6309CB2'),
}
model ListFaceEntitiesResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: ListFaceEntitiesResponseBody(name='body'),
}
async function listFaceEntitiesWithOptions(request: ListFaceEntitiesRequest, runtime: Util.RuntimeOptions): ListFaceEntitiesResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.dbName)) {
body['DbName'] = request.dbName;
}
if (!Util.isUnset(request.entityIdPrefix)) {
body['EntityIdPrefix'] = request.entityIdPrefix;
}
if (!Util.isUnset(request.labels)) {
body['Labels'] = request.labels;
}
if (!Util.isUnset(request.limit)) {
body['Limit'] = request.limit;
}
if (!Util.isUnset(request.offset)) {
body['Offset'] = request.offset;
}
if (!Util.isUnset(request.order)) {
body['Order'] = request.order;
}
if (!Util.isUnset(request.token)) {
body['Token'] = request.token;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'ListFaceEntities',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function listFaceEntities(request: ListFaceEntitiesRequest): ListFaceEntitiesResponse {
var runtime = new Util.RuntimeOptions{};
return listFaceEntitiesWithOptions(request, runtime);
}
model MergeImageFaceRequest {
addWatermark?: boolean(name='AddWatermark', example='False'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MergeImageFace/MergeImageFace-1.png'),
mergeInfos?: [
{
imageURL?: string(name='ImageURL', example='http://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/ref/ref.jpg'),
templateFaceID?: string(name='TemplateFaceID', example='6cd509ea-54fa-4730-8e9d-c94cadcda048_0'),
}
](name='MergeInfos'),
modelVersion?: string(name='ModelVersion', example='v1'),
templateId?: string(name='TemplateId', example='6cd509ea-54fa-4730-8e9d-c94cadcda048'),
watermarkType?: string(name='WatermarkType'),
}
model MergeImageFaceAdvanceRequest {
addWatermark?: boolean(name='AddWatermark', example='False'),
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MergeImageFace/MergeImageFace-1.png'),
mergeInfos?: [
{
imageURL?: string(name='ImageURL', example='http://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/ref/ref.jpg'),
templateFaceID?: string(name='TemplateFaceID', example='6cd509ea-54fa-4730-8e9d-c94cadcda048_0'),
}
](name='MergeInfos'),
modelVersion?: string(name='ModelVersion', example='v1'),
templateId?: string(name='TemplateId', example='6cd509ea-54fa-4730-8e9d-c94cadcda048'),
watermarkType?: string(name='WatermarkType'),
}
model MergeImageFaceResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/image-face-fusion/09dedc78-c355-442a-9312-7ab074d6de49_54dc_20210129-025407.jpg?Expires=1611890647&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=2mk2OgIrwMqrvA%2FvDdp0MNaoVU****'),
}(name='Data'),
requestId?: string(name='RequestId', example='8473A5E5-488E-4612-800E-F95B42381570'),
}
model MergeImageFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: MergeImageFaceResponseBody(name='body'),
}
async function mergeImageFaceWithOptions(request: MergeImageFaceRequest, runtime: Util.RuntimeOptions): MergeImageFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.addWatermark)) {
body['AddWatermark'] = request.addWatermark;
}
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.mergeInfos)) {
body['MergeInfos'] = request.mergeInfos;
}
if (!Util.isUnset(request.modelVersion)) {
body['ModelVersion'] = request.modelVersion;
}
if (!Util.isUnset(request.templateId)) {
body['TemplateId'] = request.templateId;
}
if (!Util.isUnset(request.watermarkType)) {
body['WatermarkType'] = request.watermarkType;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'MergeImageFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function mergeImageFace(request: MergeImageFaceRequest): MergeImageFaceResponse {
var runtime = new Util.RuntimeOptions{};
return mergeImageFaceWithOptions(request, runtime);
}
async function mergeImageFaceAdvance(request: MergeImageFaceAdvanceRequest, runtime: Util.RuntimeOptions): MergeImageFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var mergeImageFaceReq = new MergeImageFaceRequest{};
OpenApiUtil.convert(request, mergeImageFaceReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
mergeImageFaceReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var mergeImageFaceResp = mergeImageFaceWithOptions(mergeImageFaceReq, runtime);
return mergeImageFaceResp;
}
model MonitorExaminationRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg'),
type?: long(name='Type', example='1'),
}
model MonitorExaminationAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MonitorExamination/1MonitorExamination1.jpg'),
type?: long(name='Type', example='1'),
}
model MonitorExaminationResponseBody = {
data?: {
chatScore?: float(name='ChatScore', example='0.28805577754974365'),
faceInfo?: {
completeness?: float(name='Completeness', example='1'),
faceNumber?: long(name='FaceNumber', example='1'),
pose?: {
pitch?: float(name='Pitch', example='-0.9185499548912048'),
roll?: float(name='Roll', example='-0.18541647493839264'),
yaw?: float(name='Yaw', example='8.095342636108398'),
}(name='Pose'),
}(name='FaceInfo'),
personInfo?: {
cellPhone?: {
score?: float(name='Score', example='0.39076218008995056'),
threshold?: float(name='Threshold', example='0.6'),
}(name='CellPhone'),
earPhone?: {
score?: float(name='Score', example='0.7980290651321411'),
threshold?: float(name='Threshold', example='0.6'),
}(name='EarPhone'),
personNumber?: long(name='PersonNumber', example='1'),
}(name='PersonInfo'),
threshold?: float(name='Threshold', example='0.5'),
}(name='Data'),
requestId?: string(name='RequestId', example='D0F6EB94-73B6-4CB8-B266-22D2F221C475'),
}
model MonitorExaminationResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: MonitorExaminationResponseBody(name='body'),
}
async function monitorExaminationWithOptions(request: MonitorExaminationRequest, runtime: Util.RuntimeOptions): MonitorExaminationResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.type)) {
body['Type'] = request.type;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'MonitorExamination',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function monitorExamination(request: MonitorExaminationRequest): MonitorExaminationResponse {
var runtime = new Util.RuntimeOptions{};
return monitorExaminationWithOptions(request, runtime);
}
async function monitorExaminationAdvance(request: MonitorExaminationAdvanceRequest, runtime: Util.RuntimeOptions): MonitorExaminationResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var monitorExaminationReq = new MonitorExaminationRequest{};
OpenApiUtil.convert(request, monitorExaminationReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
monitorExaminationReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var monitorExaminationResp = monitorExaminationWithOptions(monitorExaminationReq, runtime);
return monitorExaminationResp;
}
model PedestrianDetectAttributeRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/PedestrianDetectAttribute/PedestrianDetectAttribute1.jpg'),
}
model PedestrianDetectAttributeAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/PedestrianDetectAttribute/PedestrianDetectAttribute1.jpg'),
}
model PedestrianDetectAttributeResponseBody = {
data?: {
attributes?: [
{
age?: {
name?: string(name='Name', example='Age18-60'),
score?: float(name='Score', example='0.99590516090393066'),
}(name='Age'),
backpack?: {
name?: string(name='Name', example='No'),
score?: float(name='Score', example='0.96486538648605347'),
}(name='Backpack'),
gender?: {
name?: string(name='Name', example='female'),
score?: float(name='Score', example='0.97989875078201294'),
}(name='Gender'),
glasses?: {
name?: string(name='Name', example='No'),
score?: float(name='Score', example='0.87284471094608307'),
}(name='Glasses'),
handbag?: {
name?: string(name='Name', example='Yes'),
score?: float(name='Score', example='0.55011671781539917'),
}(name='Handbag'),
hat?: {
name?: string(name='Name', example='No'),
score?: float(name='Score', example='0.98272394016385078'),
}(name='Hat'),
lowerColor?: {
name?: string(name='Name'),
score?: float(name='Score', example='0.69961744546890259'),
}(name='LowerColor'),
lowerWear?: {
name?: string(name='Name', example='Trousers'),
score?: float(name='Score', example='0.6424860954284668'),
}(name='LowerWear'),
orient?: {
name?: string(name='Name', example='Front'),
score?: float(name='Score', example='0.97838658094406128'),
}(name='Orient'),
shoulderBag?: {
name?: string(name='Name', example='No'),
score?: float(name='Score', example='0.91198787838220596'),
}(name='ShoulderBag'),
upperColor?: {
name?: string(name='Name'),
score?: float(name='Score', example='0.97796273231506348'),
}(name='UpperColor'),
upperWear?: {
name?: string(name='Name', example='ShortSleeve'),
score?: float(name='Score', example='0.89291918277740479'),
}(name='UpperWear'),
}
](name='Attributes'),
boxes?: [
{
bottomRightX?: float(name='BottomRightX', example='584'),
bottomRightY?: float(name='BottomRightY', example='218'),
score?: float(name='Score', example='0.88381063938140869'),
topLeftX?: float(name='TopLeftX', example='36'),
topLeftY?: float(name='TopLeftY', example='27'),
}
](name='Boxes'),
height?: long(name='Height', example='584'),
personNumber?: int32(name='PersonNumber', example='1'),
width?: long(name='Width', example='264'),
}(name='Data'),
requestId?: string(name='RequestId', example='4F609A30-F645-481E-A513-CADAA14DFB0A'),
}
model PedestrianDetectAttributeResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: PedestrianDetectAttributeResponseBody(name='body'),
}
async function pedestrianDetectAttributeWithOptions(request: PedestrianDetectAttributeRequest, runtime: Util.RuntimeOptions): PedestrianDetectAttributeResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'PedestrianDetectAttribute',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function pedestrianDetectAttribute(request: PedestrianDetectAttributeRequest): PedestrianDetectAttributeResponse {
var runtime = new Util.RuntimeOptions{};
return pedestrianDetectAttributeWithOptions(request, runtime);
}
async function pedestrianDetectAttributeAdvance(request: PedestrianDetectAttributeAdvanceRequest, runtime: Util.RuntimeOptions): PedestrianDetectAttributeResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var pedestrianDetectAttributeReq = new PedestrianDetectAttributeRequest{};
OpenApiUtil.convert(request, pedestrianDetectAttributeReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
pedestrianDetectAttributeReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var pedestrianDetectAttributeResp = pedestrianDetectAttributeWithOptions(pedestrianDetectAttributeReq, runtime);
return pedestrianDetectAttributeResp;
}
model QueryFaceImageTemplateRequest {
pageNo?: long(name='PageNo'),
pageSize?: long(name='PageSize', example='100'),
templateId?: string(name='TemplateId', example='6cd509ea-54fa-4730-8e9d-c94cadcda048'),
}
model QueryFaceImageTemplateResponseBody = {
data?: {
elements?: [
{
createTime?: string(name='CreateTime', example='2021-01-29 10:19:05'),
faceInfos?: [
{
faceRect?: {
height?: string(name='Height', example='94'),
width?: string(name='Width', example='89'),
x?: string(name='X', example='254'),
y?: string(name='Y', example='318'),
}(name='FaceRect'),
templateFaceID?: string(name='TemplateFaceID', example='6cd509ea-54fa-4730-8e9d-c94cadcda048'),
}
](name='FaceInfos'),
templateId?: string(name='TemplateId', example='6cd509ea-54fa-4730-8e9d-c94cadcda048'),
templateURL?: string(name='TemplateURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/MergeImageFace/MergeImageFace-1.png'),
updateTime?: string(name='UpdateTime', example='2021-01-29 10:19:05'),
userId?: string(name='UserId', example='zhangsan'),
}
](name='Elements'),
total?: long(name='Total'),
}(name='Data'),
requestId?: string(name='RequestId', example='7C29675C-751F-4D2F-86FB-2BD8D69AC860'),
}
model QueryFaceImageTemplateResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: QueryFaceImageTemplateResponseBody(name='body'),
}
async function queryFaceImageTemplateWithOptions(request: QueryFaceImageTemplateRequest, runtime: Util.RuntimeOptions): QueryFaceImageTemplateResponse {
Util.validateModel(request);
var query = OpenApiUtil.query(Util.toMap(request));
var req = new OpenApi.OpenApiRequest{
query = OpenApiUtil.query(query),
};
var params = new OpenApi.Params{
action = 'QueryFaceImageTemplate',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'GET',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function queryFaceImageTemplate(request: QueryFaceImageTemplateRequest): QueryFaceImageTemplateResponse {
var runtime = new Util.RuntimeOptions{};
return queryFaceImageTemplateWithOptions(request, runtime);
}
model RecognizeActionRequest {
type?: int32(name='Type', example='0'),
URLList?: [
{
URL?: string(name='URL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RecognizeAction/1RecognizeAction1.png'),
imageData?: string(name='imageData', example='/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgQ****'),
}
](name='URLList'),
videoData?: string(name='VideoData', example='iVBORw0KGgoAAAANSUhEUgAAAoAAAAHJCAIAAACaEB9NAAEAAElEQVR4nNT9Wb****'),
videoUrl?: string(name='VideoUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RecognizeAction/RecognizeAction-video1.mp4'),
}
model RecognizeActionAdvanceRequest {
type?: int32(name='Type', example='0'),
URLList?: [
{
URLObject?: readable(name='URL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RecognizeAction/1RecognizeAction1.png'),
imageData?: string(name='imageData', example='/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgQ****'),
}
](name='URLList'),
videoData?: string(name='VideoData', example='iVBORw0KGgoAAAANSUhEUgAAAoAAAAHJCAIAAACaEB9NAAEAAElEQVR4nNT9Wb****'),
videoUrlObject?: readable(name='VideoUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RecognizeAction/RecognizeAction-video1.mp4'),
}
model RecognizeActionResponseBody = {
data?: {
elements?: [
{
boxes?: [
{
box?: [ int32 ](name='Box'),
}
](name='Boxes'),
labels?: [ string ](name='Labels'),
scores?: [ float ](name='Scores'),
timestamp?: int32(name='Timestamp', example='3'),
}
](name='Elements'),
}(name='Data'),
requestId?: string(name='RequestId', example='E9C40AF5-A7F8-49D5-8A0C-B21F15A07F17'),
}
model RecognizeActionResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: RecognizeActionResponseBody(name='body'),
}
async function recognizeActionWithOptions(request: RecognizeActionRequest, runtime: Util.RuntimeOptions): RecognizeActionResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.type)) {
body['Type'] = request.type;
}
if (!Util.isUnset(request.URLList)) {
body['URLList'] = request.URLList;
}
if (!Util.isUnset(request.videoData)) {
body['VideoData'] = request.videoData;
}
if (!Util.isUnset(request.videoUrl)) {
body['VideoUrl'] = request.videoUrl;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizeAction',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeAction(request: RecognizeActionRequest): RecognizeActionResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeActionWithOptions(request, runtime);
}
async function recognizeActionAdvance(request: RecognizeActionAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeActionResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var recognizeActionReq = new RecognizeActionRequest{};
OpenApiUtil.convert(request, recognizeActionReq);
if(!Util.isUnset(request.URLList)) {
var i0 : integer = 0;
for (var item0 : request.URLList) {
if(!Util.isUnset(item0.URLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = item0.URLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
var tmp : RecognizeActionRequest.URLList = recognizeActionReq.URLList[i0];
tmp.URL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
i0 = Number.ltoi(Number.add(Number.itol(i0), Number.itol(1)));
}
}
}
if(!Util.isUnset(request.videoUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.videoUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
recognizeActionReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeActionResp = recognizeActionWithOptions(recognizeActionReq, runtime);
return recognizeActionResp;
}
model RecognizeExpressionRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RecognizeExpression/RecognizeExpression10.jpg'),
}
model RecognizeExpressionAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RecognizeExpression/RecognizeExpression10.jpg'),
}
model RecognizeExpressionResponseBody = {
data?: {
elements?: [
{
expression?: string(name='Expression', example='surprise'),
faceProbability?: float(name='FaceProbability', example='0.99651491641998291'),
faceRectangle?: {
height?: int32(name='Height', example='174'),
left?: int32(name='Left', example='196'),
top?: int32(name='Top', example='41'),
width?: int32(name='Width', example='121'),
}(name='FaceRectangle'),
}
](name='Elements'),
}(name='Data'),
requestId?: string(name='RequestId', example='E1C4C576-1799-4079-A934-15BC406A54EF'),
}
model RecognizeExpressionResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: RecognizeExpressionResponseBody(name='body'),
}
async function recognizeExpressionWithOptions(request: RecognizeExpressionRequest, runtime: Util.RuntimeOptions): RecognizeExpressionResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizeExpression',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeExpression(request: RecognizeExpressionRequest): RecognizeExpressionResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeExpressionWithOptions(request, runtime);
}
async function recognizeExpressionAdvance(request: RecognizeExpressionAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeExpressionResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var recognizeExpressionReq = new RecognizeExpressionRequest{};
OpenApiUtil.convert(request, recognizeExpressionReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
recognizeExpressionReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeExpressionResp = recognizeExpressionWithOptions(recognizeExpressionReq, runtime);
return recognizeExpressionResp;
}
model RecognizeFaceRequest {
age?: boolean(name='Age', example='false'),
beauty?: boolean(name='Beauty', example='false'),
expression?: boolean(name='Expression', example='false'),
gender?: boolean(name='Gender', example='false'),
glass?: boolean(name='Glass', example='false'),
hat?: boolean(name='Hat', example='false'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RecognizeFace/RecognizeFace1.png'),
mask?: boolean(name='Mask', example='false'),
maxFaceNumber?: long(name='MaxFaceNumber', example='1'),
quality?: boolean(name='Quality', example='false'),
}
model RecognizeFaceAdvanceRequest {
age?: boolean(name='Age', example='false'),
beauty?: boolean(name='Beauty', example='false'),
expression?: boolean(name='Expression', example='false'),
gender?: boolean(name='Gender', example='false'),
glass?: boolean(name='Glass', example='false'),
hat?: boolean(name='Hat', example='false'),
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RecognizeFace/RecognizeFace1.png'),
mask?: boolean(name='Mask', example='false'),
maxFaceNumber?: long(name='MaxFaceNumber', example='1'),
quality?: boolean(name='Quality', example='false'),
}
model RecognizeFaceResponseBody = {
data?: {
ageList?: [ int32 ](name='AgeList', description='1'),
beautyList?: [ float ](name='BeautyList', description='1'),
denseFeatureLength?: int32(name='DenseFeatureLength', example='1024'),
denseFeatures?: [ string ](name='DenseFeatures', description='1'),
expressions?: [ int32 ](name='Expressions', description='1'),
faceCount?: int32(name='FaceCount', example='1'),
faceProbabilityList?: [ float ](name='FaceProbabilityList', description='1'),
faceRectangles?: [ int32 ](name='FaceRectangles', description='1'),
genderList?: [ int32 ](name='GenderList', description='1'),
glasses?: [ int32 ](name='Glasses', description='1'),
hatList?: [ int32 ](name='HatList', description='1'),
landmarkCount?: int32(name='LandmarkCount', example='105'),
landmarks?: [ float ](name='Landmarks', description='1'),
masks?: [ long ](name='Masks', description='1'),
poseList?: [ float ](name='PoseList', description='1'),
pupils?: [ float ](name='Pupils', description='1'),
qualities?: {
blurList?: [ float ](name='BlurList', description='1'),
fnfList?: [ float ](name='FnfList', description='1'),
glassList?: [ float ](name='GlassList', description='1'),
illuList?: [ float ](name='IlluList', description='1'),
maskList?: [ float ](name='MaskList', description='1'),
noiseList?: [ float ](name='NoiseList', description='1'),
poseList?: [ float ](name='PoseList', description='1'),
scoreList?: [ float ](name='ScoreList', description='1'),
}(name='Qualities'),
}(name='Data'),
requestId?: string(name='RequestId', example='8251C88E-8273-4DBF-94FB-A6BCB268CEA2'),
}
model RecognizeFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: RecognizeFaceResponseBody(name='body'),
}
async function recognizeFaceWithOptions(request: RecognizeFaceRequest, runtime: Util.RuntimeOptions): RecognizeFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.age)) {
body['Age'] = request.age;
}
if (!Util.isUnset(request.beauty)) {
body['Beauty'] = request.beauty;
}
if (!Util.isUnset(request.expression)) {
body['Expression'] = request.expression;
}
if (!Util.isUnset(request.gender)) {
body['Gender'] = request.gender;
}
if (!Util.isUnset(request.glass)) {
body['Glass'] = request.glass;
}
if (!Util.isUnset(request.hat)) {
body['Hat'] = request.hat;
}
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.mask)) {
body['Mask'] = request.mask;
}
if (!Util.isUnset(request.maxFaceNumber)) {
body['MaxFaceNumber'] = request.maxFaceNumber;
}
if (!Util.isUnset(request.quality)) {
body['Quality'] = request.quality;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizeFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeFace(request: RecognizeFaceRequest): RecognizeFaceResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeFaceWithOptions(request, runtime);
}
async function recognizeFaceAdvance(request: RecognizeFaceAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var recognizeFaceReq = new RecognizeFaceRequest{};
OpenApiUtil.convert(request, recognizeFaceReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
recognizeFaceReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeFaceResp = recognizeFaceWithOptions(recognizeFaceReq, runtime);
return recognizeFaceResp;
}
model RecognizeHandGestureRequest {
appId?: string(name='AppId', example='gesture_app'),
gestureType?: string(name='GestureType', example='gesture_recognition'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/cc/RecognizeHandGesture1.jpg'),
}
model RecognizeHandGestureAdvanceRequest {
appId?: string(name='AppId', example='gesture_app'),
gestureType?: string(name='GestureType', example='gesture_recognition'),
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/cc/RecognizeHandGesture1.jpg'),
}
model RecognizeHandGestureResponseBody = {
data?: {
height?: long(name='Height', example='53'),
score?: float(name='Score', example='0.921875'),
type?: string(name='Type', example='right'),
width?: long(name='Width', example='46'),
x?: long(name='X', example='237'),
y?: long(name='Y', example='216'),
}(name='Data'),
requestId?: string(name='RequestId', example='99AC4489-693D-4DF1-8BB7-7451DD71A16E'),
}
model RecognizeHandGestureResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: RecognizeHandGestureResponseBody(name='body'),
}
async function recognizeHandGestureWithOptions(request: RecognizeHandGestureRequest, runtime: Util.RuntimeOptions): RecognizeHandGestureResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.appId)) {
body['AppId'] = request.appId;
}
if (!Util.isUnset(request.gestureType)) {
body['GestureType'] = request.gestureType;
}
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizeHandGesture',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeHandGesture(request: RecognizeHandGestureRequest): RecognizeHandGestureResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeHandGestureWithOptions(request, runtime);
}
async function recognizeHandGestureAdvance(request: RecognizeHandGestureAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeHandGestureResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var recognizeHandGestureReq = new RecognizeHandGestureRequest{};
OpenApiUtil.convert(request, recognizeHandGestureReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
recognizeHandGestureReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeHandGestureResp = recognizeHandGestureWithOptions(recognizeHandGestureReq, runtime);
return recognizeHandGestureResp;
}
model RecognizePublicFaceRequest {
task?: [
{
imageData?: string(name='ImageData'),
imageURL?: string(name='ImageURL', example='https://viapi-oss.oss-cn-shanghai.aliyuncs.com/doc/facebody/xxx.jpg'),
}
](name='Task', description='1'),
}
model RecognizePublicFaceAdvanceRequest {
task?: [
{
imageData?: string(name='ImageData'),
imageURLObject?: readable(name='ImageURL', example='https://viapi-oss.oss-cn-shanghai.aliyuncs.com/doc/facebody/xxx.jpg'),
}
](name='Task', description='1'),
}
model RecognizePublicFaceResponseBody = {
data?: {
elements?: [
{
imageURL?: string(name='ImageURL', example='https://viapi-oss.oss-cn-shanghai.aliyuncs.com/doc/facebody/xxx.jpg'),
results?: [
{
label?: string(name='Label', example='sface'),
rate?: float(name='Rate', example='98.35'),
subResults?: [
{
faces?: [
{
id?: string(name='Id', example='AliFace_0006272'),
name?: string(name='Name'),
rate?: float(name='Rate', example='98.35'),
}
](name='Faces'),
h?: float(name='H', example='153'),
w?: float(name='W', example='132'),
x?: float(name='X', example='182'),
y?: float(name='Y', example='153'),
}
](name='SubResults'),
suggestion?: string(name='Suggestion', example='review'),
}
](name='Results'),
taskId?: string(name='TaskId', example='img3dhYqt1e4wO77Wnf2y@t@E-1tYAEt'),
}
](name='Elements'),
}(name='Data'),
requestId?: string(name='RequestId', example='AC4D107C-29E3-4873-A719-0D2217EA28A8'),
}
model RecognizePublicFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: RecognizePublicFaceResponseBody(name='body'),
}
async function recognizePublicFaceWithOptions(request: RecognizePublicFaceRequest, runtime: Util.RuntimeOptions): RecognizePublicFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.task)) {
body['Task'] = request.task;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizePublicFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizePublicFace(request: RecognizePublicFaceRequest): RecognizePublicFaceResponse {
var runtime = new Util.RuntimeOptions{};
return recognizePublicFaceWithOptions(request, runtime);
}
async function recognizePublicFaceAdvance(request: RecognizePublicFaceAdvanceRequest, runtime: Util.RuntimeOptions): RecognizePublicFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var recognizePublicFaceReq = new RecognizePublicFaceRequest{};
OpenApiUtil.convert(request, recognizePublicFaceReq);
if(!Util.isUnset(request.task)) {
var i0 : integer = 0;
for (var item0 : request.task) {
if(!Util.isUnset(item0.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = item0.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
var tmp : RecognizePublicFaceRequest.task = recognizePublicFaceReq.task[i0];
tmp.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
i0 = Number.ltoi(Number.add(Number.itol(i0), Number.itol(1)));
}
}
}
var recognizePublicFaceResp = recognizePublicFaceWithOptions(recognizePublicFaceReq, runtime);
return recognizePublicFaceResp;
}
model RetouchBodyRequest {
imageURL?: string(name='ImageURL', example='https://viapi-oss.oss-cn-shanghai.aliyuncs.com/doc/facebody/photo-1562956335-14faa1a9aeeb.jpeg'),
lengthenDegree?: float(name='LengthenDegree', example='1.0'),
slimDegree?: float(name='SlimDegree', example='1.0'),
}
model RetouchBodyAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='https://viapi-oss.oss-cn-shanghai.aliyuncs.com/doc/facebody/photo-1562956335-14faa1a9aeeb.jpeg'),
lengthenDegree?: float(name='LengthenDegree', example='1.0'),
slimDegree?: float(name='SlimDegree', example='1.0'),
}
model RetouchBodyResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/body-beautifier/C0AFBD40-C705-52EB-90F5-37FA2FA62880_468d_20210926-075355.jpg?Expires=1632644635&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=O7M9ITFAExDmwnZ86BFDVGeE%2BZ****'),
}(name='Data'),
requestId?: string(name='RequestId', example='C0AFBD40-C705-52EB-90F5-37FA2FA62880'),
}
model RetouchBodyResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: RetouchBodyResponseBody(name='body'),
}
async function retouchBodyWithOptions(request: RetouchBodyRequest, runtime: Util.RuntimeOptions): RetouchBodyResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.lengthenDegree)) {
body['LengthenDegree'] = request.lengthenDegree;
}
if (!Util.isUnset(request.slimDegree)) {
body['SlimDegree'] = request.slimDegree;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RetouchBody',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function retouchBody(request: RetouchBodyRequest): RetouchBodyResponse {
var runtime = new Util.RuntimeOptions{};
return retouchBodyWithOptions(request, runtime);
}
async function retouchBodyAdvance(request: RetouchBodyAdvanceRequest, runtime: Util.RuntimeOptions): RetouchBodyResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var retouchBodyReq = new RetouchBodyRequest{};
OpenApiUtil.convert(request, retouchBodyReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
retouchBodyReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var retouchBodyResp = retouchBodyWithOptions(retouchBodyReq, runtime);
return retouchBodyResp;
}
model RetouchSkinRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RetouchSkin/RetouchSkin3.png'),
retouchDegree?: float(name='RetouchDegree', example='1.0'),
whiteningDegree?: float(name='WhiteningDegree', example='1.0'),
}
model RetouchSkinAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RetouchSkin/RetouchSkin3.png'),
retouchDegree?: float(name='RetouchDegree', example='1.0'),
whiteningDegree?: float(name='WhiteningDegree', example='1.0'),
}
model RetouchSkinResponseBody = {
data?: {
imageURL?: string(name='ImageURL', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/skin-retouch/FD2BF3DF-3D98-1D5D-85BB-C8EC3A9FE347_3467_20210923-094238.jpg?Expires=1632391959&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=jXJcFTv3no7Gx%2BLuPvANhRSnc2****'),
}(name='Data'),
requestId?: string(name='RequestId', example='FD2BF3DF-3D98-1D5D-85BB-C8EC3A9FE347'),
}
model RetouchSkinResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: RetouchSkinResponseBody(name='body'),
}
async function retouchSkinWithOptions(request: RetouchSkinRequest, runtime: Util.RuntimeOptions): RetouchSkinResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.retouchDegree)) {
body['RetouchDegree'] = request.retouchDegree;
}
if (!Util.isUnset(request.whiteningDegree)) {
body['WhiteningDegree'] = request.whiteningDegree;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RetouchSkin',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function retouchSkin(request: RetouchSkinRequest): RetouchSkinResponse {
var runtime = new Util.RuntimeOptions{};
return retouchSkinWithOptions(request, runtime);
}
async function retouchSkinAdvance(request: RetouchSkinAdvanceRequest, runtime: Util.RuntimeOptions): RetouchSkinResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var retouchSkinReq = new RetouchSkinRequest{};
OpenApiUtil.convert(request, retouchSkinReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
retouchSkinReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var retouchSkinResp = retouchSkinWithOptions(retouchSkinReq, runtime);
return retouchSkinResp;
}
model SearchFaceRequest {
dbName?: string(name='DbName', example='default'),
dbNames?: string(name='DbNames', example='test1,test2,test3'),
imageUrl?: string(name='ImageUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/SearchFace/SearchFace1.png'),
limit?: int32(name='Limit', example='2'),
maxFaceNum?: long(name='MaxFaceNum', example='5'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='50.0'),
}
model SearchFaceAdvanceRequest {
dbName?: string(name='DbName', example='default'),
dbNames?: string(name='DbNames', example='test1,test2,test3'),
imageUrlObject?: readable(name='ImageUrl', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/SearchFace/SearchFace1.png'),
limit?: int32(name='Limit', example='2'),
maxFaceNum?: long(name='MaxFaceNum', example='5'),
qualityScoreThreshold?: float(name='QualityScoreThreshold', example='50.0'),
}
model SearchFaceResponseBody = {
data?: {
matchList?: [
{
faceItems?: [
{
confidence?: float(name='Confidence', example='36.820168'),
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='U1'),
extraData?: string(name='ExtraData'),
faceId?: string(name='FaceId', example='001'),
score?: float(name='Score', example='0.892133'),
}
](name='FaceItems'),
location?: {
height?: int32(name='Height', example='200'),
width?: int32(name='Width', example='200'),
x?: int32(name='X', example='5'),
y?: int32(name='Y', example='6'),
}(name='Location'),
qualitieScore?: float(name='QualitieScore', example='71.7349'),
}
](name='MatchList'),
}(name='Data'),
requestId?: string(name='RequestId', example='4159e64a-0fe8-436c-a8de-ee531555db3c'),
}
model SearchFaceResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: SearchFaceResponseBody(name='body'),
}
async function searchFaceWithOptions(request: SearchFaceRequest, runtime: Util.RuntimeOptions): SearchFaceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.dbName)) {
body['DbName'] = request.dbName;
}
if (!Util.isUnset(request.dbNames)) {
body['DbNames'] = request.dbNames;
}
if (!Util.isUnset(request.imageUrl)) {
body['ImageUrl'] = request.imageUrl;
}
if (!Util.isUnset(request.limit)) {
body['Limit'] = request.limit;
}
if (!Util.isUnset(request.maxFaceNum)) {
body['MaxFaceNum'] = request.maxFaceNum;
}
if (!Util.isUnset(request.qualityScoreThreshold)) {
body['QualityScoreThreshold'] = request.qualityScoreThreshold;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'SearchFace',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function searchFace(request: SearchFaceRequest): SearchFaceResponse {
var runtime = new Util.RuntimeOptions{};
return searchFaceWithOptions(request, runtime);
}
async function searchFaceAdvance(request: SearchFaceAdvanceRequest, runtime: Util.RuntimeOptions): SearchFaceResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var searchFaceReq = new SearchFaceRequest{};
OpenApiUtil.convert(request, searchFaceReq);
if(!Util.isUnset(request.imageUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
searchFaceReq.imageUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var searchFaceResp = searchFaceWithOptions(searchFaceReq, runtime);
return searchFaceResp;
}
model UpdateFaceEntityRequest {
dbName?: string(name='DbName', example='default'),
entityId?: string(name='EntityId', example='mm2'),
labels?: string(name='Labels'),
}
model UpdateFaceEntityResponseBody = {
requestId?: string(name='RequestId', example='DA7CAFEB-0A37-4496-9CDF-E3DBB6309CB2'),
}
model UpdateFaceEntityResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: UpdateFaceEntityResponseBody(name='body'),
}
async function updateFaceEntityWithOptions(request: UpdateFaceEntityRequest, runtime: Util.RuntimeOptions): UpdateFaceEntityResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.dbName)) {
body['DbName'] = request.dbName;
}
if (!Util.isUnset(request.entityId)) {
body['EntityId'] = request.entityId;
}
if (!Util.isUnset(request.labels)) {
body['Labels'] = request.labels;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'UpdateFaceEntity',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function updateFaceEntity(request: UpdateFaceEntityRequest): UpdateFaceEntityResponse {
var runtime = new Util.RuntimeOptions{};
return updateFaceEntityWithOptions(request, runtime);
}
model VerifyFaceMaskRequest {
imageData?: bytes(name='ImageData', example='iVBORw0KGgoAAAANSUhEUgAAAoAAAAHJCAIAAACaEB9NAAEAAElEQVR4nNT9Wb****'),
imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/ceshi/VerifyFaceMaskA.jpg'),
refData?: bytes(name='RefData', example='iVBORw0KGgoAAAANSUhEUgAAAoAAAAHJCAIAAACaEB9NAAEAAElEQVR4nNT9WbA****'),
refUrl?: string(name='RefUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/ceshi/VerifyFaceMaskB.jpg'),
}
model VerifyFaceMaskAdvanceRequest {
imageData?: bytes(name='ImageData', example='iVBORw0KGgoAAAANSUhEUgAAAoAAAAHJCAIAAACaEB9NAAEAAElEQVR4nNT9Wb****'),
imageURLObject?: readable(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/ceshi/VerifyFaceMaskA.jpg'),
refData?: bytes(name='RefData', example='iVBORw0KGgoAAAANSUhEUgAAAoAAAAHJCAIAAACaEB9NAAEAAElEQVR4nNT9WbA****'),
refUrlObject?: readable(name='RefUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/ceshi/VerifyFaceMaskB.jpg'),
}
model VerifyFaceMaskResponseBody = {
data?: {
confidence?: float(name='Confidence', example='13.484533309936523'),
mask?: int32(name='Mask', example='2'),
maskRef?: int32(name='MaskRef', example='2'),
rectangle?: [ int32 ](name='Rectangle'),
rectangleRef?: [ int32 ](name='RectangleRef'),
thresholds?: [ float ](name='Thresholds'),
}(name='Data'),
requestId?: string(name='RequestId', example='044386BA-271C-4DAD-9E08-581A685FB984'),
}
model VerifyFaceMaskResponse = {
headers?: map[string]string(name='headers'),
statusCode?: int32(name='statusCode'),
body?: VerifyFaceMaskResponseBody(name='body'),
}
async function verifyFaceMaskWithOptions(request: VerifyFaceMaskRequest, runtime: Util.RuntimeOptions): VerifyFaceMaskResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageData)) {
body['ImageData'] = request.imageData;
}
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.refData)) {
body['RefData'] = request.refData;
}
if (!Util.isUnset(request.refUrl)) {
body['RefUrl'] = request.refUrl;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'VerifyFaceMask',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function verifyFaceMask(request: VerifyFaceMaskRequest): VerifyFaceMaskResponse {
var runtime = new Util.RuntimeOptions{};
return verifyFaceMaskWithOptions(request, runtime);
}
async function verifyFaceMaskAdvance(request: VerifyFaceMaskAdvanceRequest, runtime: Util.RuntimeOptions): VerifyFaceMaskResponse {
// Step 0: init client
var accessKeyId = @credential.getAccessKeyId();
var accessKeySecret = @credential.getAccessKeySecret();
var securityToken = @credential.getSecurityToken();
var credentialType = @credential.getType();
var openPlatformEndpoint = @openPlatformEndpoint;
if(Util.isUnset(openPlatformEndpoint)) {
openPlatformEndpoint ='openplatform.aliyuncs.com';
}
if(Util.isUnset(credentialType)) {
credentialType ='access_key';
}
var authConfig = new OpenApi.Config{
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
securityToken = securityToken,
type = credentialType,
endpoint = openPlatformEndpoint,
protocol = @protocol,
regionId = @regionId,
};
var authClient = new OpenPlatform(authConfig);
var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
product = 'facebody',
regionId = @regionId,
};
var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
var ossConfig = new OSS.Config{
accessKeySecret = accessKeySecret,
type = 'access_key',
protocol = @protocol,
regionId = @regionId,
};
var ossClient : OSS = null;
var fileObj = new FileForm.FileField{};
var ossHeader = new OSS.PostObjectRequest.header{};
var uploadRequest = new OSS.PostObjectRequest{};
var ossRuntime = new OSSUtil.RuntimeOptions{};
OpenApiUtil.convert(runtime, ossRuntime);
var verifyFaceMaskReq = new VerifyFaceMaskRequest{};
OpenApiUtil.convert(request, verifyFaceMaskReq);
if(!Util.isUnset(request.imageURLObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.imageURLObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
verifyFaceMaskReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
if(!Util.isUnset(request.refUrlObject)) {
authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
ossConfig.accessKeyId = authResponse.body.accessKeyId;
ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
ossClient = new OSS(ossConfig);
fileObj = new FileForm.FileField{
filename = authResponse.body.objectKey,
content = request.refUrlObject,
contentType = '',
};
ossHeader = new OSS.PostObjectRequest.header{
accessKeyId = authResponse.body.accessKeyId,
policy = authResponse.body.encodedPolicy,
signature = authResponse.body.signature,
key = authResponse.body.objectKey,
file = fileObj,
successActionStatus = '201',
};
uploadRequest = new OSS.PostObjectRequest{
bucketName = authResponse.body.bucket,
header = ossHeader,
};
ossClient.postObject(uploadRequest, ossRuntime);
verifyFaceMaskReq.refUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var verifyFaceMaskResp = verifyFaceMaskWithOptions(verifyFaceMaskReq, runtime);
return verifyFaceMaskResp;
}