objectdet-20191230/main.tea (2,100 lines of code) (raw):

/** * */ import Util; import OSS; import OpenPlatform; import OSSUtil; import FileForm; import OpenApi; import OpenApiUtil; import EndpointUtil; extends OpenApi; init(config: OpenApi.Config){ super(config); @endpointRule = 'regional'; checkConfig(config); @endpoint = getEndpoint('objectdet', @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 DetectObjectElement { height?: long(name='Height', example='200'), score?: float(name='Score', example='0.68225745'), type?: string(name='Type', example='VEHICLE'), width?: long(name='Width', example='100'), x?: long(name='X', example='5'), y?: long(name='Y', example='10'), } model DetectObjectFrame { elements?: [ DetectObjectElement ](name='Elements'), time?: long(name='Time'), } model ClassifyVehicleInsuranceRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/ClassifyVehicleInsurance/ClassifyVehicleInsurance1.jpg'), } model ClassifyVehicleInsuranceAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/ClassifyVehicleInsurance/ClassifyVehicleInsurance1.jpg'), } model ClassifyVehicleInsuranceResponseBody = { data?: { labels?: [ { name?: string(name='Name', example='others'), score?: float(name='Score', example='0.0023'), } ](name='Labels'), threshold?: float(name='Threshold', example='0'), }(name='Data'), requestId?: string(name='RequestId', example='878EB16C-87C6-4C8B-897D-F68036F8AC97'), } model ClassifyVehicleInsuranceResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: ClassifyVehicleInsuranceResponseBody(name='body'), } async function classifyVehicleInsuranceWithOptions(request: ClassifyVehicleInsuranceRequest, runtime: Util.RuntimeOptions): ClassifyVehicleInsuranceResponse { 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 = 'ClassifyVehicleInsurance', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function classifyVehicleInsurance(request: ClassifyVehicleInsuranceRequest): ClassifyVehicleInsuranceResponse { var runtime = new Util.RuntimeOptions{}; return classifyVehicleInsuranceWithOptions(request, runtime); } async function classifyVehicleInsuranceAdvance(request: ClassifyVehicleInsuranceAdvanceRequest, runtime: Util.RuntimeOptions): ClassifyVehicleInsuranceResponse { // 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 = 'objectdet', 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 classifyVehicleInsuranceReq = new ClassifyVehicleInsuranceRequest{}; OpenApiUtil.convert(request, classifyVehicleInsuranceReq); 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); classifyVehicleInsuranceReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var classifyVehicleInsuranceResp = classifyVehicleInsuranceWithOptions(classifyVehicleInsuranceReq, runtime); return classifyVehicleInsuranceResp; } model DetectIPCObjectRequest { imageURL?: string(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/objectdet/detect-ipc-xxxx.jpg'), } model DetectIPCObjectAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/objectdet/detect-ipc-xxxx.jpg'), } model DetectIPCObjectResponseBody = { data?: { elements?: [ { box?: [ long ](name='Box'), score?: float(name='Score', example='0.7138671875'), targetRate?: float(name='TargetRate', example='0.8566723958333333'), type?: string(name='Type', example='DOG'), } ](name='Elements'), height?: long(name='Height', example='1200'), width?: long(name='Width', example='1600'), }(name='Data'), requestId?: string(name='RequestId', example='7AE23740-A3E5-5607-8E10-895DCBD4C260'), } model DetectIPCObjectResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectIPCObjectResponseBody(name='body'), } async function detectIPCObjectWithOptions(request: DetectIPCObjectRequest, runtime: Util.RuntimeOptions): DetectIPCObjectResponse { 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 = 'DetectIPCObject', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectIPCObject(request: DetectIPCObjectRequest): DetectIPCObjectResponse { var runtime = new Util.RuntimeOptions{}; return detectIPCObjectWithOptions(request, runtime); } async function detectIPCObjectAdvance(request: DetectIPCObjectAdvanceRequest, runtime: Util.RuntimeOptions): DetectIPCObjectResponse { // 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 = 'objectdet', 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 detectIPCObjectReq = new DetectIPCObjectRequest{}; OpenApiUtil.convert(request, detectIPCObjectReq); 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); detectIPCObjectReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectIPCObjectResp = detectIPCObjectWithOptions(detectIPCObjectReq, runtime); return detectIPCObjectResp; } model DetectKitchenAnimalsRequest { imageURLA?: string(name='ImageURLA', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectKitchenAnimals/DetectKitchenAnimals-left1.png'), imageURLB?: string(name='ImageURLB', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectKitchenAnimals/DetectKitchenAnimals-right1.png'), } model DetectKitchenAnimalsAdvanceRequest { imageURLAObject?: readable(name='ImageURLA', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectKitchenAnimals/DetectKitchenAnimals-left1.png'), imageURLBObject?: readable(name='ImageURLB', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectKitchenAnimals/DetectKitchenAnimals-right1.png'), } model DetectKitchenAnimalsResponseBody = { data?: { elements?: [ { rectangles?: { height?: long(name='Height', example='64'), left?: long(name='Left', example='292'), top?: long(name='Top', example='1048'), width?: long(name='Width', example='64'), }(name='Rectangles'), score?: float(name='Score', example='0.75105053'), type?: string(name='Type', example='mouse'), } ](name='Elements'), }(name='Data'), requestId?: string(name='RequestId', example='C306F16F-30E1-54F4-93DF-A52CCF6664D1'), } model DetectKitchenAnimalsResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectKitchenAnimalsResponseBody(name='body'), } async function detectKitchenAnimalsWithOptions(request: DetectKitchenAnimalsRequest, runtime: Util.RuntimeOptions): DetectKitchenAnimalsResponse { 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; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'DetectKitchenAnimals', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectKitchenAnimals(request: DetectKitchenAnimalsRequest): DetectKitchenAnimalsResponse { var runtime = new Util.RuntimeOptions{}; return detectKitchenAnimalsWithOptions(request, runtime); } async function detectKitchenAnimalsAdvance(request: DetectKitchenAnimalsAdvanceRequest, runtime: Util.RuntimeOptions): DetectKitchenAnimalsResponse { // 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 = 'objectdet', 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 detectKitchenAnimalsReq = new DetectKitchenAnimalsRequest{}; OpenApiUtil.convert(request, detectKitchenAnimalsReq); 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); detectKitchenAnimalsReq.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); detectKitchenAnimalsReq.imageURLB = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectKitchenAnimalsResp = detectKitchenAnimalsWithOptions(detectKitchenAnimalsReq, runtime); return detectKitchenAnimalsResp; } model DetectMainBodyRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectMainBody/DetectMainBody1.jpg'), } model DetectMainBodyAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectMainBody/DetectMainBody1.jpg'), } model DetectMainBodyResponseBody = { data?: { location?: { height?: int32(name='Height', example='320'), width?: int32(name='Width', example='583'), x?: int32(name='X', example='28'), y?: int32(name='Y', example='20'), }(name='Location'), }(name='Data'), requestId?: string(name='RequestId', example='2E59C333-5480-4231-A8AB-BEE1001EA7FE'), } model DetectMainBodyResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectMainBodyResponseBody(name='body'), } async function detectMainBodyWithOptions(request: DetectMainBodyRequest, runtime: Util.RuntimeOptions): DetectMainBodyResponse { Util.validateModel(request); var query = {}; if (!Util.isUnset(request.imageURL)) { query['ImageURL'] = request.imageURL; } var req = new OpenApi.OpenApiRequest{ query = OpenApiUtil.query(query), }; var params = new OpenApi.Params{ action = 'DetectMainBody', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectMainBody(request: DetectMainBodyRequest): DetectMainBodyResponse { var runtime = new Util.RuntimeOptions{}; return detectMainBodyWithOptions(request, runtime); } async function detectMainBodyAdvance(request: DetectMainBodyAdvanceRequest, runtime: Util.RuntimeOptions): DetectMainBodyResponse { // 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 = 'objectdet', 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 detectMainBodyReq = new DetectMainBodyRequest{}; OpenApiUtil.convert(request, detectMainBodyReq); 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); detectMainBodyReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectMainBodyResp = detectMainBodyWithOptions(detectMainBodyReq, runtime); return detectMainBodyResp; } model DetectObjectRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectObject/DetectObject1.jpg'), } model DetectObjectAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectObject/DetectObject1.jpg'), } model DetectObjectResponseBody = { data?: { elements?: [ { boxes?: [ int32 ](name='Boxes'), score?: float(name='Score', example='0.266'), type?: string(name='Type', example='chair'), } ](name='Elements'), height?: int32(name='Height', example='300'), width?: int32(name='Width', example='533'), }(name='Data'), requestId?: string(name='RequestId', example='6EF97B44-2763-4EAD-8737-FB9F5EE25FE2'), } model DetectObjectResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectObjectResponseBody(name='body'), } async function detectObjectWithOptions(request: DetectObjectRequest, runtime: Util.RuntimeOptions): DetectObjectResponse { 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 = 'DetectObject', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectObject(request: DetectObjectRequest): DetectObjectResponse { var runtime = new Util.RuntimeOptions{}; return detectObjectWithOptions(request, runtime); } async function detectObjectAdvance(request: DetectObjectAdvanceRequest, runtime: Util.RuntimeOptions): DetectObjectResponse { // 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 = 'objectdet', 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 detectObjectReq = new DetectObjectRequest{}; OpenApiUtil.convert(request, detectObjectReq); 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); detectObjectReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectObjectResp = detectObjectWithOptions(detectObjectReq, runtime); return detectObjectResp; } model DetectTransparentImageRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectTransparentImage/DetectTransparentImage1.png'), } model DetectTransparentImageAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectTransparentImage/DetectTransparentImage1.png'), } model DetectTransparentImageResponseBody = { data?: { elements?: [ { transparentImage?: int32(name='TransparentImage', example='0'), } ](name='Elements'), }(name='Data'), requestId?: string(name='RequestId', example='3F3F335E-640C-4860-A85F-774726FF56A7'), } model DetectTransparentImageResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectTransparentImageResponseBody(name='body'), } async function detectTransparentImageWithOptions(request: DetectTransparentImageRequest, runtime: Util.RuntimeOptions): DetectTransparentImageResponse { 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 = 'DetectTransparentImage', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectTransparentImage(request: DetectTransparentImageRequest): DetectTransparentImageResponse { var runtime = new Util.RuntimeOptions{}; return detectTransparentImageWithOptions(request, runtime); } async function detectTransparentImageAdvance(request: DetectTransparentImageAdvanceRequest, runtime: Util.RuntimeOptions): DetectTransparentImageResponse { // 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 = 'objectdet', 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 detectTransparentImageReq = new DetectTransparentImageRequest{}; OpenApiUtil.convert(request, detectTransparentImageReq); 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); detectTransparentImageReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectTransparentImageResp = detectTransparentImageWithOptions(detectTransparentImageReq, runtime); return detectTransparentImageResp; } model DetectVehicleRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectVehicle/DetectVehicle1.jpg'), } model DetectVehicleAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectVehicle/DetectVehicle1.jpg'), } model DetectVehicleResponseBody = { data?: { detectObjectInfoList?: [ { boxes?: [ int32 ](name='Boxes'), id?: int32(name='Id', example='1'), score?: float(name='Score', example='0.897'), type?: string(name='Type', example='vehicle'), } ](name='DetectObjectInfoList'), height?: int32(name='Height', example='436'), width?: int32(name='Width', example='612'), }(name='Data'), requestId?: string(name='RequestId', example='77BB1EB9-1707-4423-8391-CDAE6D29F9D5'), } model DetectVehicleResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectVehicleResponseBody(name='body'), } async function detectVehicleWithOptions(request: DetectVehicleRequest, runtime: Util.RuntimeOptions): DetectVehicleResponse { 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 = 'DetectVehicle', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectVehicle(request: DetectVehicleRequest): DetectVehicleResponse { var runtime = new Util.RuntimeOptions{}; return detectVehicleWithOptions(request, runtime); } async function detectVehicleAdvance(request: DetectVehicleAdvanceRequest, runtime: Util.RuntimeOptions): DetectVehicleResponse { // 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 = 'objectdet', 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 detectVehicleReq = new DetectVehicleRequest{}; OpenApiUtil.convert(request, detectVehicleReq); 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); detectVehicleReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectVehicleResp = detectVehicleWithOptions(detectVehicleReq, runtime); return detectVehicleResp; } model DetectVehicleICongestionRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectVehicleICongestion/DetectVehicleICongestion1.jpg'), preRegionIntersectFeatures?: [ { features?: [ string ](name='Features'), } ](name='PreRegionIntersectFeatures'), roadRegions?: [ { roadRegion?: [ { point?: { x?: long(name='X', example='400'), y?: long(name='Y', example='400'), }(name='Point'), } ](name='RoadRegion'), } ](name='RoadRegions'), } model DetectVehicleICongestionAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectVehicleICongestion/DetectVehicleICongestion1.jpg'), preRegionIntersectFeatures?: [ { features?: [ string ](name='Features'), } ](name='PreRegionIntersectFeatures'), roadRegions?: [ { roadRegion?: [ { point?: { x?: long(name='X', example='400'), y?: long(name='Y', example='400'), }(name='Point'), } ](name='RoadRegion'), } ](name='RoadRegions'), } model DetectVehicleICongestionShrinkRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectVehicleICongestion/DetectVehicleICongestion1.jpg'), preRegionIntersectFeaturesShrink?: string(name='PreRegionIntersectFeatures'), roadRegionsShrink?: string(name='RoadRegions'), } model DetectVehicleICongestionResponseBody = { data?: { elements?: [ { boxes?: [ { bottom?: long(name='Bottom', example='576'), left?: long(name='Left', example='341'), right?: long(name='Right', example='589'), top?: long(name='Top', example='434'), } ](name='Boxes'), id?: long(name='Id', example='1'), score?: float(name='Score', example='0.962890625'), typeName?: string(name='TypeName', example='vehicle'), } ](name='Elements'), regionIntersectFeatures?: [ { features?: [ string ](name='Features'), } ](name='RegionIntersectFeatures'), regionIntersectMatched?: [ { ids?: [ long ](name='Ids'), } ](name='RegionIntersectMatched'), regionIntersects?: [ { ids?: [ long ](name='Ids'), } ](name='RegionIntersects'), }(name='Data'), requestId?: string(name='RequestId', example='4FC381BB-04F2-50F4-B54B-593042BCF3C6'), } model DetectVehicleICongestionResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectVehicleICongestionResponseBody(name='body'), } async function detectVehicleICongestionWithOptions(tmpReq: DetectVehicleICongestionRequest, runtime: Util.RuntimeOptions): DetectVehicleICongestionResponse { Util.validateModel(tmpReq); var request = new DetectVehicleICongestionShrinkRequest{}; OpenApiUtil.convert(tmpReq, request); if (!Util.isUnset(tmpReq.preRegionIntersectFeatures)) { request.preRegionIntersectFeaturesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.preRegionIntersectFeatures, 'PreRegionIntersectFeatures', 'json'); } if (!Util.isUnset(tmpReq.roadRegions)) { request.roadRegionsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.roadRegions, 'RoadRegions', 'json'); } var body : map[string]any = {}; if (!Util.isUnset(request.imageURL)) { body['ImageURL'] = request.imageURL; } if (!Util.isUnset(request.preRegionIntersectFeaturesShrink)) { body['PreRegionIntersectFeatures'] = request.preRegionIntersectFeaturesShrink; } if (!Util.isUnset(request.roadRegionsShrink)) { body['RoadRegions'] = request.roadRegionsShrink; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'DetectVehicleICongestion', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectVehicleICongestion(request: DetectVehicleICongestionRequest): DetectVehicleICongestionResponse { var runtime = new Util.RuntimeOptions{}; return detectVehicleICongestionWithOptions(request, runtime); } async function detectVehicleICongestionAdvance(request: DetectVehicleICongestionAdvanceRequest, runtime: Util.RuntimeOptions): DetectVehicleICongestionResponse { // 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 = 'objectdet', 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 detectVehicleICongestionReq = new DetectVehicleICongestionRequest{}; OpenApiUtil.convert(request, detectVehicleICongestionReq); 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); detectVehicleICongestionReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectVehicleICongestionResp = detectVehicleICongestionWithOptions(detectVehicleICongestionReq, runtime); return detectVehicleICongestionResp; } model DetectVehicleIllegalParkingRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectVehicleIllegalParking/DetectVehicleIllegalParking2.jpg'), roadRegions?: [ { roadRegion?: [ { point?: { x?: long(name='X', example='400'), y?: long(name='Y', example='400'), }(name='Point'), } ](name='RoadRegion'), } ](name='RoadRegions'), } model DetectVehicleIllegalParkingAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectVehicleIllegalParking/DetectVehicleIllegalParking2.jpg'), roadRegions?: [ { roadRegion?: [ { point?: { x?: long(name='X', example='400'), y?: long(name='Y', example='400'), }(name='Point'), } ](name='RoadRegion'), } ](name='RoadRegions'), } model DetectVehicleIllegalParkingShrinkRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectVehicleIllegalParking/DetectVehicleIllegalParking2.jpg'), roadRegionsShrink?: string(name='RoadRegions'), } model DetectVehicleIllegalParkingResponseBody = { data?: { elements?: [ { boxes?: [ { bottom?: long(name='Bottom', example='268'), left?: long(name='Left', example='413'), right?: long(name='Right', example='499'), top?: long(name='Top', example='138'), } ](name='Boxes'), id?: long(name='Id', example='1'), score?: float(name='Score', example='0.9599609375'), typeName?: string(name='TypeName', example='vehicle'), } ](name='Elements'), regionIntersects?: [ { ids?: [ long ](name='Ids'), } ](name='RegionIntersects'), }(name='Data'), requestId?: string(name='RequestId', example='DB882EDD-991A-5A0C-A19B-CC7C4BA65E35'), } model DetectVehicleIllegalParkingResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectVehicleIllegalParkingResponseBody(name='body'), } async function detectVehicleIllegalParkingWithOptions(tmpReq: DetectVehicleIllegalParkingRequest, runtime: Util.RuntimeOptions): DetectVehicleIllegalParkingResponse { Util.validateModel(tmpReq); var request = new DetectVehicleIllegalParkingShrinkRequest{}; OpenApiUtil.convert(tmpReq, request); if (!Util.isUnset(tmpReq.roadRegions)) { request.roadRegionsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.roadRegions, 'RoadRegions', 'json'); } var body : map[string]any = {}; if (!Util.isUnset(request.imageURL)) { body['ImageURL'] = request.imageURL; } if (!Util.isUnset(request.roadRegionsShrink)) { body['RoadRegions'] = request.roadRegionsShrink; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'DetectVehicleIllegalParking', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectVehicleIllegalParking(request: DetectVehicleIllegalParkingRequest): DetectVehicleIllegalParkingResponse { var runtime = new Util.RuntimeOptions{}; return detectVehicleIllegalParkingWithOptions(request, runtime); } async function detectVehicleIllegalParkingAdvance(request: DetectVehicleIllegalParkingAdvanceRequest, runtime: Util.RuntimeOptions): DetectVehicleIllegalParkingResponse { // 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 = 'objectdet', 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 detectVehicleIllegalParkingReq = new DetectVehicleIllegalParkingRequest{}; OpenApiUtil.convert(request, detectVehicleIllegalParkingReq); 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); detectVehicleIllegalParkingReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectVehicleIllegalParkingResp = detectVehicleIllegalParkingWithOptions(detectVehicleIllegalParkingReq, runtime); return detectVehicleIllegalParkingResp; } model DetectVideoIPCObjectRequest { callbackOnlyHasObject?: boolean(name='CallbackOnlyHasObject', example='true'), startTimestamp?: long(name='StartTimestamp', example='1629086400'), videoURL?: string(name='VideoURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectVideoIPCObject/DetectVideoIPCObject1.mp4'), } model DetectVideoIPCObjectAdvanceRequest { callbackOnlyHasObject?: boolean(name='CallbackOnlyHasObject', example='true'), startTimestamp?: long(name='StartTimestamp', example='1629086400'), videoURLObject?: readable(name='VideoURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectVideoIPCObject/DetectVideoIPCObject1.mp4'), } model DetectVideoIPCObjectResponseBody = { data?: { frames?: [ { elements?: [ { height?: long(name='Height', example='156'), score?: float(name='Score', example='0.7812'), type?: string(name='Type', example='PERSON'), width?: long(name='Width', example='100'), x?: long(name='X', example='289'), y?: long(name='Y', example='271'), } ](name='Elements'), time?: long(name='Time', example='6124533574'), } ](name='Frames'), height?: long(name='Height', example='720'), inputFile?: string(name='InputFile', example='oss://viapi-test/viapi-3.0domepic/objectdet/DetectVideoIPCObject/DetectVideoIPCObject4.mp4'), width?: long(name='Width', example='1280'), }(name='Data'), message?: string(name='Message'), requestId?: string(name='RequestId', example='35B11E1B-800C-4598-B5AA-577E3BDBD917'), } model DetectVideoIPCObjectResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectVideoIPCObjectResponseBody(name='body'), } async function detectVideoIPCObjectWithOptions(request: DetectVideoIPCObjectRequest, runtime: Util.RuntimeOptions): DetectVideoIPCObjectResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.callbackOnlyHasObject)) { body['CallbackOnlyHasObject'] = request.callbackOnlyHasObject; } if (!Util.isUnset(request.startTimestamp)) { body['StartTimestamp'] = request.startTimestamp; } if (!Util.isUnset(request.videoURL)) { body['VideoURL'] = request.videoURL; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'DetectVideoIPCObject', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectVideoIPCObject(request: DetectVideoIPCObjectRequest): DetectVideoIPCObjectResponse { var runtime = new Util.RuntimeOptions{}; return detectVideoIPCObjectWithOptions(request, runtime); } async function detectVideoIPCObjectAdvance(request: DetectVideoIPCObjectAdvanceRequest, runtime: Util.RuntimeOptions): DetectVideoIPCObjectResponse { // 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 = 'objectdet', 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 detectVideoIPCObjectReq = new DetectVideoIPCObjectRequest{}; OpenApiUtil.convert(request, detectVideoIPCObjectReq); 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); detectVideoIPCObjectReq.videoURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectVideoIPCObjectResp = detectVideoIPCObjectWithOptions(detectVideoIPCObjectReq, runtime); return detectVideoIPCObjectResp; } model DetectWhiteBaseImageRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectWhiteBaseImage/DetectWhiteBaseImage1.jpg'), } model DetectWhiteBaseImageAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectWhiteBaseImage/DetectWhiteBaseImage1.jpg'), } model DetectWhiteBaseImageResponseBody = { data?: { elements?: [ { whiteBase?: int32(name='WhiteBase', example='0'), } ](name='Elements'), }(name='Data'), requestId?: string(name='RequestId', example='7A7F9EEB-44C4-4592-9089-A6185B222B23'), } model DetectWhiteBaseImageResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectWhiteBaseImageResponseBody(name='body'), } async function detectWhiteBaseImageWithOptions(request: DetectWhiteBaseImageRequest, runtime: Util.RuntimeOptions): DetectWhiteBaseImageResponse { 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 = 'DetectWhiteBaseImage', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectWhiteBaseImage(request: DetectWhiteBaseImageRequest): DetectWhiteBaseImageResponse { var runtime = new Util.RuntimeOptions{}; return detectWhiteBaseImageWithOptions(request, runtime); } async function detectWhiteBaseImageAdvance(request: DetectWhiteBaseImageAdvanceRequest, runtime: Util.RuntimeOptions): DetectWhiteBaseImageResponse { // 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 = 'objectdet', 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 detectWhiteBaseImageReq = new DetectWhiteBaseImageRequest{}; OpenApiUtil.convert(request, detectWhiteBaseImageReq); 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); detectWhiteBaseImageReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectWhiteBaseImageResp = detectWhiteBaseImageWithOptions(detectWhiteBaseImageReq, runtime); return detectWhiteBaseImageResp; } model DetectWorkwearRequest { clothes?: { maxNum?: long(name='MaxNum', example='1'), threshold?: double(name='Threshold', example='0.4'), }(name='Clothes'), imageUrl?: string(name='ImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/zhangchaorun/tiyan/xxxx.jpg'), labels?: [ string ](name='Labels', description='1'), } model DetectWorkwearAdvanceRequest { clothes?: { maxNum?: long(name='MaxNum', example='1'), threshold?: double(name='Threshold', example='0.4'), }(name='Clothes'), imageUrlObject?: readable(name='ImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/zhangchaorun/tiyan/xxxx.jpg'), labels?: [ string ](name='Labels', description='1'), } model DetectWorkwearShrinkRequest { clothesShrink?: string(name='Clothes'), imageUrl?: string(name='ImageUrl', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/zhangchaorun/tiyan/xxxx.jpg'), labels?: [ string ](name='Labels', description='1'), } model DetectWorkwearResponseBody = { data?: { elements?: [ { property?: [ { label?: string(name='Label', example='hat'), probability?: { no?: double(name='No', example='0.00036084422'), threshold?: long(name='Threshold', example='0'), unknown?: double(name='Unknown', example='0.0006906331'), yes?: double(name='Yes', example='0.9989485'), }(name='Probability'), } ](name='Property'), rectangles?: { height?: long(name='Height', example='96'), left?: long(name='Left', example='1067'), top?: long(name='Top', example='426'), width?: long(name='Width', example='88'), }(name='Rectangles'), score?: double(name='Score', example='0.63913465'), type?: string(name='Type', example='1'), } ](name='Elements'), }(name='Data'), requestId?: string(name='RequestId', example='16CA8094-D7BC-51D4-8D55-6AC59AB20E0B'), } model DetectWorkwearResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DetectWorkwearResponseBody(name='body'), } async function detectWorkwearWithOptions(tmpReq: DetectWorkwearRequest, runtime: Util.RuntimeOptions): DetectWorkwearResponse { Util.validateModel(tmpReq); var request = new DetectWorkwearShrinkRequest{}; OpenApiUtil.convert(tmpReq, request); if (!Util.isUnset(tmpReq.clothes)) { request.clothesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.clothes, 'Clothes', 'json'); } var body : map[string]any = {}; if (!Util.isUnset(request.clothesShrink)) { body['Clothes'] = request.clothesShrink; } if (!Util.isUnset(request.imageUrl)) { body['ImageUrl'] = request.imageUrl; } if (!Util.isUnset(request.labels)) { body['Labels'] = request.labels; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'DetectWorkwear', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function detectWorkwear(request: DetectWorkwearRequest): DetectWorkwearResponse { var runtime = new Util.RuntimeOptions{}; return detectWorkwearWithOptions(request, runtime); } async function detectWorkwearAdvance(request: DetectWorkwearAdvanceRequest, runtime: Util.RuntimeOptions): DetectWorkwearResponse { // 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 = 'objectdet', 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 detectWorkwearReq = new DetectWorkwearRequest{}; OpenApiUtil.convert(request, detectWorkwearReq); 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); detectWorkwearReq.imageUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var detectWorkwearResp = detectWorkwearWithOptions(detectWorkwearReq, runtime); return detectWorkwearResp; } model GetAsyncJobResultRequest { jobId?: string(name='JobId', example='35B11E1B-800C-4598-B5AA-577E3BDBD917'), } model GetAsyncJobResultResponseBody = { data?: { errorCode?: string(name='ErrorCode', example='InvalidParameter'), errorMessage?: string(name='ErrorMessage', example='paramsIllegal'), jobId?: string(name='JobId', example='35B11E1B-800C-4598-B5AA-577E3BDBD917'), result?: string(name='Result', example='{\\"inputFile\\":\\"oss://public-vigen-video/guotian.xgt/test_images/test_video\\",\\"width\\":1280,\\"height\\":720,\\"frames\\":[{\\"time\\":6124533574,\\"elements\\":[{\\"type\\":\\"PERSON\\",\\"score\\":0.7812,\\"x\\":289,\\"y\\":271,\\"width\\":100,\\"height\\":156},{\\"type\\":\\"PERSON\\",\\"score\\":0.4377,\\"x\\":917,\\"y\\":267,\\"width\\":34,\\"height\\":51}]}]}]}"}'), status?: string(name='Status', example='PROCESS_SUCCESS'), }(name='Data'), requestId?: string(name='RequestId', example='87FC80D2-2571-4BBD-BD61-AFF7912C556D'), } model GetAsyncJobResultResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: GetAsyncJobResultResponseBody(name='body'), } async function getAsyncJobResultWithOptions(request: GetAsyncJobResultRequest, runtime: Util.RuntimeOptions): GetAsyncJobResultResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.jobId)) { body['JobId'] = request.jobId; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'GetAsyncJobResult', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function getAsyncJobResult(request: GetAsyncJobResultRequest): GetAsyncJobResultResponse { var runtime = new Util.RuntimeOptions{}; return getAsyncJobResultWithOptions(request, runtime); } model RecognizeVehicleDamageRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/RecognizeVehicleDamage/RecognizeVehicleDamage1.jpg'), } model RecognizeVehicleDamageAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/RecognizeVehicleDamage/RecognizeVehicleDamage1.jpg'), } model RecognizeVehicleDamageResponseBody = { data?: { elements?: [ { boxes?: [ int32 ](name='Boxes', description='1'), score?: float(name='Score', example='0.683465'), scores?: [ float ](name='Scores', description='1'), type?: string(name='Type', example='1'), } ](name='Elements'), }(name='Data'), requestId?: string(name='RequestId', example='91FCB447-807D-4839-A5F0-E0A79D6B33C6'), } model RecognizeVehicleDamageResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: RecognizeVehicleDamageResponseBody(name='body'), } async function recognizeVehicleDamageWithOptions(request: RecognizeVehicleDamageRequest, runtime: Util.RuntimeOptions): RecognizeVehicleDamageResponse { 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 = 'RecognizeVehicleDamage', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function recognizeVehicleDamage(request: RecognizeVehicleDamageRequest): RecognizeVehicleDamageResponse { var runtime = new Util.RuntimeOptions{}; return recognizeVehicleDamageWithOptions(request, runtime); } async function recognizeVehicleDamageAdvance(request: RecognizeVehicleDamageAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeVehicleDamageResponse { // 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 = 'objectdet', 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 recognizeVehicleDamageReq = new RecognizeVehicleDamageRequest{}; OpenApiUtil.convert(request, recognizeVehicleDamageReq); 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); recognizeVehicleDamageReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var recognizeVehicleDamageResp = recognizeVehicleDamageWithOptions(recognizeVehicleDamageReq, runtime); return recognizeVehicleDamageResp; } model RecognizeVehicleDashboardRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/RecognizeVehicleDashboard/RecognizeVehicleDashboard1.jpg'), } model RecognizeVehicleDashboardAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/RecognizeVehicleDashboard/RecognizeVehicleDashboard1.jpg'), } model RecognizeVehicleDashboardResponseBody = { data?: { elements?: [ { boxes?: [ float ](name='Boxes'), className?: string(name='ClassName'), label?: string(name='Label', example='13'), score?: float(name='Score', example='0.9990643858909607'), } ](name='Elements'), }(name='Data'), requestId?: string(name='RequestId', example='3BDA7297-2515-4C9C-99EA-C5950B906BCF'), } model RecognizeVehicleDashboardResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: RecognizeVehicleDashboardResponseBody(name='body'), } async function recognizeVehicleDashboardWithOptions(request: RecognizeVehicleDashboardRequest, runtime: Util.RuntimeOptions): RecognizeVehicleDashboardResponse { 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 = 'RecognizeVehicleDashboard', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function recognizeVehicleDashboard(request: RecognizeVehicleDashboardRequest): RecognizeVehicleDashboardResponse { var runtime = new Util.RuntimeOptions{}; return recognizeVehicleDashboardWithOptions(request, runtime); } async function recognizeVehicleDashboardAdvance(request: RecognizeVehicleDashboardAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeVehicleDashboardResponse { // 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 = 'objectdet', 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 recognizeVehicleDashboardReq = new RecognizeVehicleDashboardRequest{}; OpenApiUtil.convert(request, recognizeVehicleDashboardReq); 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); recognizeVehicleDashboardReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var recognizeVehicleDashboardResp = recognizeVehicleDashboardWithOptions(recognizeVehicleDashboardReq, runtime); return recognizeVehicleDashboardResp; } model RecognizeVehiclePartsRequest { imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/RecognizeVehicleParts/RecognizeVehicleParts1.jpg'), } model RecognizeVehiclePartsAdvanceRequest { imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/RecognizeVehicleParts/RecognizeVehicleParts1.jpg'), } model RecognizeVehiclePartsResponseBody = { data?: { elements?: [ { boxes?: [ int32 ](name='Boxes', description='1'), score?: float(name='Score', example='0.9929494857788086'), type?: string(name='Type', example='hood'), } ](name='Elements'), originShapes?: [ int32 ](name='OriginShapes', description='1'), }(name='Data'), requestId?: string(name='RequestId', example='35771730-0FC5-4E7D-8C2F-2FADDFECAA39'), } model RecognizeVehiclePartsResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: RecognizeVehiclePartsResponseBody(name='body'), } async function recognizeVehiclePartsWithOptions(request: RecognizeVehiclePartsRequest, runtime: Util.RuntimeOptions): RecognizeVehiclePartsResponse { 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 = 'RecognizeVehicleParts', version = '2019-12-30', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function recognizeVehicleParts(request: RecognizeVehiclePartsRequest): RecognizeVehiclePartsResponse { var runtime = new Util.RuntimeOptions{}; return recognizeVehiclePartsWithOptions(request, runtime); } async function recognizeVehiclePartsAdvance(request: RecognizeVehiclePartsAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeVehiclePartsResponse { // 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 = 'objectdet', 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 recognizeVehiclePartsReq = new RecognizeVehiclePartsRequest{}; OpenApiUtil.convert(request, recognizeVehiclePartsReq); 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); recognizeVehiclePartsReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var recognizeVehiclePartsResp = recognizeVehiclePartsWithOptions(recognizeVehiclePartsReq, runtime); return recognizeVehiclePartsResp; }