ocr-20191230/main.tea (2,424 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('ocr', @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 GetAsyncJobResultRequest {
jobId?: string(name='JobId', example='E75FE679-0303-4DD1-8252-1143B4FA8A27'),
}
model GetAsyncJobResultResponseBody = {
data?: {
errorCode?: string(name='ErrorCode', example='InvalidParameter'),
errorMessage?: string(name='ErrorMessage', example='paramsIllegal'),
jobId?: string(name='JobId', example='49E2CC28-ED1D-4CC5-854D-7D0AE2B20976'),
result?: string(name='Result'),
status?: string(name='Status', example='PROCESS_SUCCESS'),
}(name='Data'),
requestId?: string(name='RequestId', example='A1F44EC4-118D-4A03-B213-F908F36F7DAA'),
}
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 RecognizeBankCardRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeBankCard/yhk3.jpg'),
}
model RecognizeBankCardAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeBankCard/yhk3.jpg'),
}
model RecognizeBankCardResponseBody = {
data?: {
bankName?: string(name='BankName'),
cardNumber?: string(name='CardNumber', example='6212262315007683105'),
cardType?: string(name='CardType'),
validDate?: string(name='ValidDate', example='07/26'),
}(name='Data'),
requestId?: string(name='RequestId', example='D9C7521-0367-42EE-9646-FD066CCADB26'),
}
model RecognizeBankCardResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeBankCardResponseBody(name='body'),
}
async function recognizeBankCardWithOptions(request: RecognizeBankCardRequest, runtime: Util.RuntimeOptions): RecognizeBankCardResponse {
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 = 'RecognizeBankCard',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeBankCard(request: RecognizeBankCardRequest): RecognizeBankCardResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeBankCardWithOptions(request, runtime);
}
async function recognizeBankCardAdvance(request: RecognizeBankCardAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeBankCardResponse {
// 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 = 'ocr',
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 recognizeBankCardReq = new RecognizeBankCardRequest{};
OpenApiUtil.convert(request, recognizeBankCardReq);
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);
recognizeBankCardReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeBankCardResp = recognizeBankCardWithOptions(recognizeBankCardReq, runtime);
return recognizeBankCardResp;
}
model RecognizeBusinessLicenseRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeBusinessLicense/RecognizeBusinessLicense1.jpg'),
}
model RecognizeBusinessLicenseAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeBusinessLicense/RecognizeBusinessLicense1.jpg'),
}
model RecognizeBusinessLicenseResponseBody = {
data?: {
address?: string(name='Address'),
angle?: float(name='Angle', example='0'),
business?: string(name='Business'),
capital?: string(name='Capital'),
emblem?: {
height?: int32(name='Height', example='163'),
left?: int32(name='Left', example='366'),
top?: int32(name='Top', example='8'),
width?: int32(name='Width', example='162'),
}(name='Emblem'),
establishDate?: string(name='EstablishDate', example='20150504'),
legalPerson?: string(name='LegalPerson'),
name?: string(name='Name'),
QRCode?: {
height?: int32(name='Height', example='132'),
left?: int32(name='Left', example='156'),
top?: int32(name='Top', example='914'),
width?: int32(name='Width', example='126'),
}(name='QRCode'),
registerNumber?: string(name='RegisterNumber', example='91500108320423****'),
stamp?: {
height?: int32(name='Height', example='154'),
left?: int32(name='Left', example='650'),
top?: int32(name='Top', example='1030'),
width?: int32(name='Width', example='154'),
}(name='Stamp'),
title?: {
height?: int32(name='Height', example='10'),
left?: int32(name='Left', example='10'),
top?: int32(name='Top', example='10'),
width?: int32(name='Width', example='10'),
}(name='Title'),
type?: string(name='Type'),
validPeriod?: string(name='ValidPeriod', example='29991231'),
}(name='Data'),
requestId?: string(name='RequestId', example='F34D031B-02BD-4A59-BA35-EE068DD6F6E6'),
}
model RecognizeBusinessLicenseResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeBusinessLicenseResponseBody(name='body'),
}
async function recognizeBusinessLicenseWithOptions(request: RecognizeBusinessLicenseRequest, runtime: Util.RuntimeOptions): RecognizeBusinessLicenseResponse {
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 = 'RecognizeBusinessLicense',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeBusinessLicense(request: RecognizeBusinessLicenseRequest): RecognizeBusinessLicenseResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeBusinessLicenseWithOptions(request, runtime);
}
async function recognizeBusinessLicenseAdvance(request: RecognizeBusinessLicenseAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeBusinessLicenseResponse {
// 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 = 'ocr',
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 recognizeBusinessLicenseReq = new RecognizeBusinessLicenseRequest{};
OpenApiUtil.convert(request, recognizeBusinessLicenseReq);
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);
recognizeBusinessLicenseReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeBusinessLicenseResp = recognizeBusinessLicenseWithOptions(recognizeBusinessLicenseReq, runtime);
return recognizeBusinessLicenseResp;
}
model RecognizeCharacterRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeCharacter/RecognizeCharacter5.jpg'),
minHeight?: int32(name='MinHeight', example='10'),
outputProbability?: boolean(name='OutputProbability', example='true'),
}
model RecognizeCharacterAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeCharacter/RecognizeCharacter5.jpg'),
minHeight?: int32(name='MinHeight', example='10'),
outputProbability?: boolean(name='OutputProbability', example='true'),
}
model RecognizeCharacterResponseBody = {
data?: {
results?: [
{
probability?: float(name='Probability', example='0.99'),
text?: string(name='Text'),
textRectangles?: {
angle?: int32(name='Angle', example='-65'),
height?: int32(name='Height', example='409'),
left?: int32(name='Left', example='511'),
top?: int32(name='Top', example='150'),
width?: int32(name='Width', example='77'),
}(name='TextRectangles'),
}
](name='Results'),
}(name='Data'),
requestId?: string(name='RequestId', example='7A9BC7FE-2D42-57AF-93BC-09A229DD2F1D'),
}
model RecognizeCharacterResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeCharacterResponseBody(name='body'),
}
async function recognizeCharacterWithOptions(request: RecognizeCharacterRequest, runtime: Util.RuntimeOptions): RecognizeCharacterResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.minHeight)) {
body['MinHeight'] = request.minHeight;
}
if (!Util.isUnset(request.outputProbability)) {
body['OutputProbability'] = request.outputProbability;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizeCharacter',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeCharacter(request: RecognizeCharacterRequest): RecognizeCharacterResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeCharacterWithOptions(request, runtime);
}
async function recognizeCharacterAdvance(request: RecognizeCharacterAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeCharacterResponse {
// 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 = 'ocr',
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 recognizeCharacterReq = new RecognizeCharacterRequest{};
OpenApiUtil.convert(request, recognizeCharacterReq);
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);
recognizeCharacterReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeCharacterResp = recognizeCharacterWithOptions(recognizeCharacterReq, runtime);
return recognizeCharacterResp;
}
model RecognizeDriverLicenseRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeDriverLicense/jsz2.jpg'),
side?: string(name='Side', example='face'),
}
model RecognizeDriverLicenseAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeDriverLicense/jsz2.jpg'),
side?: string(name='Side', example='face'),
}
model RecognizeDriverLicenseResponseBody = {
data?: {
backResult?: {
archiveNumber?: string(name='ArchiveNumber', example='130601473955'),
cardNumber?: string(name='CardNumber', example='210288898898898888'),
name?: string(name='Name'),
record?: string(name='Record'),
}(name='BackResult'),
faceResult?: {
address?: string(name='Address'),
birthDate?: string(name='BirthDate'),
endDate?: string(name='EndDate', example='20190201'),
gender?: string(name='Gender'),
issueDate?: string(name='IssueDate', example='20130208'),
issueUnit?: string(name='IssueUnit'),
licenseNumber?: string(name='LicenseNumber', example='210288898898898888'),
name?: string(name='Name'),
nationality?: string(name='Nationality'),
startDate?: string(name='StartDate', example='20130208'),
vehicleType?: string(name='VehicleType', example='C1'),
}(name='FaceResult'),
}(name='Data'),
requestId?: string(name='RequestId', example='374D8C7E-9ECC-4750-A87F-50571702F175'),
}
model RecognizeDriverLicenseResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeDriverLicenseResponseBody(name='body'),
}
async function recognizeDriverLicenseWithOptions(request: RecognizeDriverLicenseRequest, runtime: Util.RuntimeOptions): RecognizeDriverLicenseResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.side)) {
body['Side'] = request.side;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizeDriverLicense',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeDriverLicense(request: RecognizeDriverLicenseRequest): RecognizeDriverLicenseResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeDriverLicenseWithOptions(request, runtime);
}
async function recognizeDriverLicenseAdvance(request: RecognizeDriverLicenseAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeDriverLicenseResponse {
// 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 = 'ocr',
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 recognizeDriverLicenseReq = new RecognizeDriverLicenseRequest{};
OpenApiUtil.convert(request, recognizeDriverLicenseReq);
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);
recognizeDriverLicenseReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeDriverLicenseResp = recognizeDriverLicenseWithOptions(recognizeDriverLicenseReq, runtime);
return recognizeDriverLicenseResp;
}
model RecognizeDrivingLicenseRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeDrivingLicense/xsz2.jpg'),
side?: string(name='Side', example='face'),
}
model RecognizeDrivingLicenseAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeDrivingLicense/xsz2.jpg'),
side?: string(name='Side', example='face'),
}
model RecognizeDrivingLicenseResponseBody = {
data?: {
backResult?: {
approvedLoad?: string(name='ApprovedLoad', example='300'),
approvedPassengerCapacity?: string(name='ApprovedPassengerCapacity', example='5'),
energyType?: string(name='EnergyType', example='-'),
fileNumber?: string(name='FileNumber'),
grossMass?: string(name='GrossMass', example='2205'),
inspectionRecord?: string(name='InspectionRecord'),
overallDimension?: string(name='OverallDimension', example='4945x1845x1480'),
plateNumber?: string(name='PlateNumber'),
tractionMass?: string(name='TractionMass', example='100'),
unladenMass?: string(name='UnladenMass', example='2000'),
}(name='BackResult'),
faceResult?: {
address?: string(name='Address'),
engineNumber?: string(name='EngineNumber', example='111111'),
issueDate?: string(name='IssueDate', example='20180313'),
model?: string(name='Model'),
owner?: string(name='Owner'),
plateNumber?: string(name='PlateNumber'),
registerDate?: string(name='RegisterDate', example='20180312'),
useCharacter?: string(name='UseCharacter'),
vehicleType?: string(name='VehicleType'),
vin?: string(name='Vin', example='SSVUDDTT2J2022555'),
}(name='FaceResult'),
}(name='Data'),
requestId?: string(name='RequestId', example='1DD989C1-4E08-4E04-9D5D-314901E91226'),
}
model RecognizeDrivingLicenseResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeDrivingLicenseResponseBody(name='body'),
}
async function recognizeDrivingLicenseWithOptions(request: RecognizeDrivingLicenseRequest, runtime: Util.RuntimeOptions): RecognizeDrivingLicenseResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.side)) {
body['Side'] = request.side;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizeDrivingLicense',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeDrivingLicense(request: RecognizeDrivingLicenseRequest): RecognizeDrivingLicenseResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeDrivingLicenseWithOptions(request, runtime);
}
async function recognizeDrivingLicenseAdvance(request: RecognizeDrivingLicenseAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeDrivingLicenseResponse {
// 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 = 'ocr',
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 recognizeDrivingLicenseReq = new RecognizeDrivingLicenseRequest{};
OpenApiUtil.convert(request, recognizeDrivingLicenseReq);
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);
recognizeDrivingLicenseReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeDrivingLicenseResp = recognizeDrivingLicenseWithOptions(recognizeDrivingLicenseReq, runtime);
return recognizeDrivingLicenseResp;
}
model RecognizeIdentityCardRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeIdentityCard/sfz1.jpg'),
side?: string(name='Side', example='face'),
}
model RecognizeIdentityCardAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeIdentityCard/sfz1.jpg'),
side?: string(name='Side', example='face'),
}
model RecognizeIdentityCardResponseBody = {
data?: {
backResult?: {
endDate?: string(name='EndDate', example='19800101'),
issue?: string(name='Issue'),
startDate?: string(name='StartDate', example='19970101'),
}(name='BackResult'),
frontResult?: {
address?: string(name='Address'),
birthDate?: string(name='BirthDate', example='19960111'),
cardAreas?: [
{
x?: float(name='X', example='40'),
y?: float(name='Y', example='81'),
}
](name='CardAreas'),
faceRectVertices?: [
{
x?: float(name='X', example='429.46124267578125'),
y?: float(name='Y', example='164.23321533203125'),
}
](name='FaceRectVertices'),
faceRectangle?: {
angle?: float(name='Angle', example='-87.710586547851562'),
center?: {
x?: float(name='X', example='475.59390258789062'),
y?: float(name='Y', example='225.20643615722656'),
}(name='Center'),
size?: {
height?: float(name='Height', example='97.063156127929688'),
width?: float(name='Width', example='118.16333770751953'),
}(name='Size'),
}(name='FaceRectangle'),
gender?: string(name='Gender'),
IDNumber?: string(name='IDNumber', example='310228199601115411'),
name?: string(name='Name'),
nationality?: string(name='Nationality'),
}(name='FrontResult'),
}(name='Data'),
requestId?: string(name='RequestId', example='D3F5BA69-79C4-46A4-B02B-58C4EEBC4C33'),
}
model RecognizeIdentityCardResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeIdentityCardResponseBody(name='body'),
}
async function recognizeIdentityCardWithOptions(request: RecognizeIdentityCardRequest, runtime: Util.RuntimeOptions): RecognizeIdentityCardResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.side)) {
body['Side'] = request.side;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizeIdentityCard',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeIdentityCard(request: RecognizeIdentityCardRequest): RecognizeIdentityCardResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeIdentityCardWithOptions(request, runtime);
}
async function recognizeIdentityCardAdvance(request: RecognizeIdentityCardAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeIdentityCardResponse {
// 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 = 'ocr',
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 recognizeIdentityCardReq = new RecognizeIdentityCardRequest{};
OpenApiUtil.convert(request, recognizeIdentityCardReq);
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);
recognizeIdentityCardReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeIdentityCardResp = recognizeIdentityCardWithOptions(recognizeIdentityCardReq, runtime);
return recognizeIdentityCardResp;
}
model RecognizeLicensePlateRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeLicensePlate/cpsb1.jpg'),
}
model RecognizeLicensePlateAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeLicensePlate/cpsb1.jpg'),
}
model RecognizeLicensePlateResponseBody = {
data?: {
plates?: [
{
confidence?: float(name='Confidence', example='0.99745339155197144'),
plateNumber?: string(name='PlateNumber'),
plateType?: string(name='PlateType'),
plateTypeConfidence?: float(name='PlateTypeConfidence', example='1'),
positions?: [
{
x?: long(name='X', example='466'),
y?: long(name='Y', example='293'),
}
](name='Positions'),
roi?: {
h?: int32(name='H', example='53'),
w?: int32(name='W', example='141'),
x?: int32(name='X', example='294'),
y?: int32(name='Y', example='256'),
}(name='Roi'),
}
](name='Plates'),
}(name='Data'),
requestId?: string(name='RequestId', example='3F10DAC3-CF4A-487C-BF33-3B8EB9AA12F2'),
}
model RecognizeLicensePlateResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeLicensePlateResponseBody(name='body'),
}
async function recognizeLicensePlateWithOptions(request: RecognizeLicensePlateRequest, runtime: Util.RuntimeOptions): RecognizeLicensePlateResponse {
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 = 'RecognizeLicensePlate',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeLicensePlate(request: RecognizeLicensePlateRequest): RecognizeLicensePlateResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeLicensePlateWithOptions(request, runtime);
}
async function recognizeLicensePlateAdvance(request: RecognizeLicensePlateAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeLicensePlateResponse {
// 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 = 'ocr',
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 recognizeLicensePlateReq = new RecognizeLicensePlateRequest{};
OpenApiUtil.convert(request, recognizeLicensePlateReq);
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);
recognizeLicensePlateReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeLicensePlateResp = recognizeLicensePlateWithOptions(recognizeLicensePlateReq, runtime);
return recognizeLicensePlateResp;
}
model RecognizePdfRequest {
fileURL?: string(name='FileURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/ocr/xxxx.pdf'),
}
model RecognizePdfAdvanceRequest {
fileURLObject?: readable(name='FileURL', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/ocr/xxxx.pdf'),
}
model RecognizePdfResponseBody = {
data?: {
angle?: long(name='Angle', example='0'),
height?: long(name='Height', example='788'),
orgHeight?: long(name='OrgHeight', example='610'),
orgWidth?: long(name='OrgWidth', example='394'),
pageIndex?: long(name='PageIndex', example='1'),
width?: long(name='Width', example='1220'),
wordsInfo?: [
{
angle?: long(name='Angle', example='0'),
height?: long(name='Height', example='16'),
positions?: [
{
x?: long(name='X', example='863'),
y?: long(name='Y', example='43'),
}
](name='Positions'),
width?: long(name='Width', example='205'),
word?: string(name='Word'),
x?: long(name='X', example='863'),
y?: long(name='Y', example='46'),
}
](name='WordsInfo'),
}(name='Data'),
requestId?: string(name='RequestId', example='CD9A9659-ABEE-4A7D-837F-9FDF40879A97'),
}
model RecognizePdfResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizePdfResponseBody(name='body'),
}
async function recognizePdfWithOptions(request: RecognizePdfRequest, runtime: Util.RuntimeOptions): RecognizePdfResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.fileURL)) {
body['FileURL'] = request.fileURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizePdf',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizePdf(request: RecognizePdfRequest): RecognizePdfResponse {
var runtime = new Util.RuntimeOptions{};
return recognizePdfWithOptions(request, runtime);
}
async function recognizePdfAdvance(request: RecognizePdfAdvanceRequest, runtime: Util.RuntimeOptions): RecognizePdfResponse {
// 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 = 'ocr',
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 recognizePdfReq = new RecognizePdfRequest{};
OpenApiUtil.convert(request, recognizePdfReq);
if(!Util.isUnset(request.fileURLObject)) {
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.fileURLObject,
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);
recognizePdfReq.fileURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizePdfResp = recognizePdfWithOptions(recognizePdfReq, runtime);
return recognizePdfResp;
}
model RecognizeQrCodeRequest {
tasks?: [
{
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeQrCode/RecognizeQrCode6.jpg'),
}
](name='Tasks', description='1'),
}
model RecognizeQrCodeAdvanceRequest {
tasks?: [
{
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeQrCode/RecognizeQrCode6.jpg'),
}
](name='Tasks', description='1'),
}
model RecognizeQrCodeResponseBody = {
data?: {
elements?: [
{
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeQrCode/RecognizeQrCode6.jpg'),
results?: [
{
label?: string(name='Label', example='qrcode'),
qrCodesData?: [ string ](name='QrCodesData', description='1'),
rate?: float(name='Rate', example='99.91'),
suggestion?: string(name='Suggestion', example='review'),
}
](name='Results'),
taskId?: string(name='TaskId', example='img5iGtwVIxQzc4Nqy$L84yHd-1v****'),
}
](name='Elements'),
}(name='Data'),
requestId?: string(name='RequestId', example='A53DC437-F883-4968-86D5-EB21FB044692'),
}
model RecognizeQrCodeResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeQrCodeResponseBody(name='body'),
}
async function recognizeQrCodeWithOptions(request: RecognizeQrCodeRequest, runtime: Util.RuntimeOptions): RecognizeQrCodeResponse {
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 = 'RecognizeQrCode',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeQrCode(request: RecognizeQrCodeRequest): RecognizeQrCodeResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeQrCodeWithOptions(request, runtime);
}
async function recognizeQrCodeAdvance(request: RecognizeQrCodeAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeQrCodeResponse {
// 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 = 'ocr',
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 recognizeQrCodeReq = new RecognizeQrCodeRequest{};
OpenApiUtil.convert(request, recognizeQrCodeReq);
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 : RecognizeQrCodeRequest.tasks = recognizeQrCodeReq.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 recognizeQrCodeResp = recognizeQrCodeWithOptions(recognizeQrCodeReq, runtime);
return recognizeQrCodeResp;
}
model RecognizeQuotaInvoiceRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeQuotaInvoice/RecognizeQuotaInvoice1.jpg'),
}
model RecognizeQuotaInvoiceAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeQuotaInvoice/RecognizeQuotaInvoice1.jpg'),
}
model RecognizeQuotaInvoiceResponseBody = {
data?: {
angle?: long(name='Angle', example='1'),
content?: {
invoiceAmount?: string(name='InvoiceAmount', example='10'),
invoiceCode?: string(name='InvoiceCode', example='144031800103'),
invoiceDetails?: string(name='InvoiceDetails'),
invoiceNo?: string(name='InvoiceNo', example='40637706'),
sumAmount?: string(name='SumAmount'),
}(name='Content'),
height?: long(name='Height', example='624'),
keyValueInfos?: [
{
key?: string(name='Key'),
value?: string(name='Value'),
valuePositions?: [
{
x?: long(name='X', example='544'),
y?: long(name='Y', example='387'),
}
](name='ValuePositions'),
valueScore?: float(name='ValueScore', example='100'),
}
](name='KeyValueInfos'),
orgHeight?: long(name='OrgHeight', example='610'),
orgWidth?: long(name='OrgWidth', example='855'),
width?: long(name='Width', example='865'),
}(name='Data'),
requestId?: string(name='RequestId', example='BC4C12D0-7FD3-419A-B997-A91212DF6D82'),
}
model RecognizeQuotaInvoiceResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeQuotaInvoiceResponseBody(name='body'),
}
async function recognizeQuotaInvoiceWithOptions(request: RecognizeQuotaInvoiceRequest, runtime: Util.RuntimeOptions): RecognizeQuotaInvoiceResponse {
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 = 'RecognizeQuotaInvoice',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeQuotaInvoice(request: RecognizeQuotaInvoiceRequest): RecognizeQuotaInvoiceResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeQuotaInvoiceWithOptions(request, runtime);
}
async function recognizeQuotaInvoiceAdvance(request: RecognizeQuotaInvoiceAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeQuotaInvoiceResponse {
// 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 = 'ocr',
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 recognizeQuotaInvoiceReq = new RecognizeQuotaInvoiceRequest{};
OpenApiUtil.convert(request, recognizeQuotaInvoiceReq);
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);
recognizeQuotaInvoiceReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeQuotaInvoiceResp = recognizeQuotaInvoiceWithOptions(recognizeQuotaInvoiceReq, runtime);
return recognizeQuotaInvoiceResp;
}
model RecognizeTableRequest {
assureDirection?: boolean(name='AssureDirection', example='false'),
hasLine?: boolean(name='HasLine', example='false'),
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeTable/RecognizeTable4.jpg'),
outputFormat?: string(name='OutputFormat', example='json'),
skipDetection?: boolean(name='SkipDetection', example='false'),
useFinanceModel?: boolean(name='UseFinanceModel', example='true'),
}
model RecognizeTableAdvanceRequest {
assureDirection?: boolean(name='AssureDirection', example='false'),
hasLine?: boolean(name='HasLine', example='false'),
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeTable/RecognizeTable4.jpg'),
outputFormat?: string(name='OutputFormat', example='json'),
skipDetection?: boolean(name='SkipDetection', example='false'),
useFinanceModel?: boolean(name='UseFinanceModel', example='true'),
}
model RecognizeTableResponseBody = {
data?: {
fileContent?: string(name='FileContent', example='UEsDBBQAAAAIAAAAIQBukMk4WAIAA****'),
tables?: [
{
head?: [ string ](name='Head'),
tableRows?: [
{
tableColumns?: [
{
endColumn?: int32(name='EndColumn', example='4'),
endRow?: int32(name='EndRow', example='1'),
height?: int32(name='Height', example='0'),
startColumn?: int32(name='StartColumn', example='1'),
startRow?: int32(name='StartRow', example='0'),
texts?: [ string ](name='Texts'),
width?: int32(name='Width', example='0'),
}
](name='TableColumns'),
}
](name='TableRows'),
tail?: [ string ](name='Tail'),
}
](name='Tables'),
}(name='Data'),
requestId?: string(name='RequestId', example='CBC36BE6-2A18-5256-82BD-8B5477E5D058'),
}
model RecognizeTableResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeTableResponseBody(name='body'),
}
async function recognizeTableWithOptions(request: RecognizeTableRequest, runtime: Util.RuntimeOptions): RecognizeTableResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.assureDirection)) {
body['AssureDirection'] = request.assureDirection;
}
if (!Util.isUnset(request.hasLine)) {
body['HasLine'] = request.hasLine;
}
if (!Util.isUnset(request.imageURL)) {
body['ImageURL'] = request.imageURL;
}
if (!Util.isUnset(request.outputFormat)) {
body['OutputFormat'] = request.outputFormat;
}
if (!Util.isUnset(request.skipDetection)) {
body['SkipDetection'] = request.skipDetection;
}
if (!Util.isUnset(request.useFinanceModel)) {
body['UseFinanceModel'] = request.useFinanceModel;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizeTable',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeTable(request: RecognizeTableRequest): RecognizeTableResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeTableWithOptions(request, runtime);
}
async function recognizeTableAdvance(request: RecognizeTableAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeTableResponse {
// 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 = 'ocr',
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 recognizeTableReq = new RecognizeTableRequest{};
OpenApiUtil.convert(request, recognizeTableReq);
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);
recognizeTableReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeTableResp = recognizeTableWithOptions(recognizeTableReq, runtime);
return recognizeTableResp;
}
model RecognizeTaxiInvoiceRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeTaxiInvoice/RecognizeTaxiInvoice2.jpg'),
}
model RecognizeTaxiInvoiceAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeTaxiInvoice/RecognizeTaxiInvoice2.jpg'),
}
model RecognizeTaxiInvoiceResponseBody = {
data?: {
invoices?: [
{
invoiceRoi?: {
h?: float(name='H', example='3625'),
w?: float(name='W', example='1773'),
x?: float(name='X', example='513'),
y?: float(name='Y', example='302'),
}(name='InvoiceRoi'),
items?: [
{
itemRoi?: {
angle?: float(name='Angle', example='-90'),
center?: {
x?: float(name='X', example='1593'),
y?: float(name='Y', example='1360'),
}(name='Center'),
size?: {
h?: float(name='H', example='81.999984741210938'),
w?: float(name='W', example='887.9998779296875'),
}(name='Size'),
}(name='ItemRoi'),
text?: string(name='Text', example='86655664'),
}
](name='Items'),
rotateType?: int32(name='RotateType', example='0'),
}
](name='Invoices'),
}(name='Data'),
requestId?: string(name='RequestId', example='B2BBBD26-1D3E-4CFA-A80B-6A9266B8D125'),
}
model RecognizeTaxiInvoiceResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeTaxiInvoiceResponseBody(name='body'),
}
async function recognizeTaxiInvoiceWithOptions(request: RecognizeTaxiInvoiceRequest, runtime: Util.RuntimeOptions): RecognizeTaxiInvoiceResponse {
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 = 'RecognizeTaxiInvoice',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeTaxiInvoice(request: RecognizeTaxiInvoiceRequest): RecognizeTaxiInvoiceResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeTaxiInvoiceWithOptions(request, runtime);
}
async function recognizeTaxiInvoiceAdvance(request: RecognizeTaxiInvoiceAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeTaxiInvoiceResponse {
// 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 = 'ocr',
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 recognizeTaxiInvoiceReq = new RecognizeTaxiInvoiceRequest{};
OpenApiUtil.convert(request, recognizeTaxiInvoiceReq);
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);
recognizeTaxiInvoiceReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeTaxiInvoiceResp = recognizeTaxiInvoiceWithOptions(recognizeTaxiInvoiceReq, runtime);
return recognizeTaxiInvoiceResp;
}
model RecognizeTicketInvoiceRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeTicketInvoice/RecognizeTicketInvoice1.png'),
}
model RecognizeTicketInvoiceAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeTicketInvoice/RecognizeTicketInvoice1.png'),
}
model RecognizeTicketInvoiceResponseBody = {
data?: {
count?: long(name='Count', example='1'),
height?: long(name='Height', example='594'),
orgHeight?: long(name='OrgHeight', example='1417'),
orgWidth?: long(name='OrgWidth', example='1417'),
results?: [
{
content?: {
antiFakeCode?: string(name='AntiFakeCode', example='81931914902643039780'),
invoiceCode?: string(name='InvoiceCode', example='044031860107'),
invoiceDate?: string(name='InvoiceDate', example='2018-09-20'),
invoiceNumber?: string(name='InvoiceNumber', example='09267581'),
payeeName?: string(name='PayeeName'),
payeeRegisterNo?: string(name='PayeeRegisterNo', example='914403002794492693'),
payerName?: string(name='PayerName'),
payerRegisterNo?: string(name='PayerRegisterNo', example='91440300MA5EXWHW6F'),
sumAmount?: string(name='SumAmount', example='¥220.00'),
}(name='Content'),
index?: long(name='Index', example='1'),
keyValueInfos?: [
{
key?: string(name='Key'),
value?: string(name='Value', example='044031860107'),
valuePositions?: [
{
x?: long(name='X', example='586'),
y?: long(name='Y', example='16'),
}
](name='ValuePositions'),
valueScore?: float(name='ValueScore', example='100'),
}
](name='KeyValueInfos'),
sliceRectangle?: [
{
x?: long(name='X', example='586'),
y?: long(name='Y', example='16'),
}
](name='SliceRectangle'),
type?: string(name='Type'),
}
](name='Results'),
width?: long(name='Width', example='594'),
}(name='Data'),
requestId?: string(name='RequestId', example='063C0178-7EA3-4754-96FB-C0C9AE6B9AAE'),
}
model RecognizeTicketInvoiceResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeTicketInvoiceResponseBody(name='body'),
}
async function recognizeTicketInvoiceWithOptions(request: RecognizeTicketInvoiceRequest, runtime: Util.RuntimeOptions): RecognizeTicketInvoiceResponse {
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 = 'RecognizeTicketInvoice',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeTicketInvoice(request: RecognizeTicketInvoiceRequest): RecognizeTicketInvoiceResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeTicketInvoiceWithOptions(request, runtime);
}
async function recognizeTicketInvoiceAdvance(request: RecognizeTicketInvoiceAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeTicketInvoiceResponse {
// 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 = 'ocr',
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 recognizeTicketInvoiceReq = new RecognizeTicketInvoiceRequest{};
OpenApiUtil.convert(request, recognizeTicketInvoiceReq);
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);
recognizeTicketInvoiceReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeTicketInvoiceResp = recognizeTicketInvoiceWithOptions(recognizeTicketInvoiceReq, runtime);
return recognizeTicketInvoiceResp;
}
model RecognizeTrainTicketRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeTrainTicket/RecognizeTrainTicket3.jpg'),
}
model RecognizeTrainTicketAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeTrainTicket/RecognizeTrainTicket3.jpg'),
}
model RecognizeTrainTicketResponseBody = {
data?: {
date?: string(name='Date'),
departureStation?: string(name='DepartureStation'),
destination?: string(name='Destination'),
level?: string(name='Level'),
name?: string(name='Name'),
number?: string(name='Number', example='G7350'),
price?: float(name='Price', example='104.5'),
seat?: string(name='Seat'),
}(name='Data'),
requestId?: string(name='RequestId', example='BE4B73EA-30A0-4573-A548-3A101B34641A'),
}
model RecognizeTrainTicketResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeTrainTicketResponseBody(name='body'),
}
async function recognizeTrainTicketWithOptions(request: RecognizeTrainTicketRequest, runtime: Util.RuntimeOptions): RecognizeTrainTicketResponse {
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 = 'RecognizeTrainTicket',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeTrainTicket(request: RecognizeTrainTicketRequest): RecognizeTrainTicketResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeTrainTicketWithOptions(request, runtime);
}
async function recognizeTrainTicketAdvance(request: RecognizeTrainTicketAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeTrainTicketResponse {
// 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 = 'ocr',
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 recognizeTrainTicketReq = new RecognizeTrainTicketRequest{};
OpenApiUtil.convert(request, recognizeTrainTicketReq);
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);
recognizeTrainTicketReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeTrainTicketResp = recognizeTrainTicketWithOptions(recognizeTrainTicketReq, runtime);
return recognizeTrainTicketResp;
}
model RecognizeVATInvoiceRequest {
fileType?: string(name='FileType', example='jpg'),
fileURL?: string(name='FileURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeVATInvoice/RecognizeVATInvoice3.jpg'),
}
model RecognizeVATInvoiceAdvanceRequest {
fileType?: string(name='FileType', example='jpg'),
fileURLObject?: readable(name='FileURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeVATInvoice/RecognizeVATInvoice3.jpg'),
}
model RecognizeVATInvoiceResponseBody = {
data?: {
box?: {
checkers?: [ float ](name='Checkers', description='1'),
clerks?: [ float ](name='Clerks', description='1'),
invoiceAmounts?: [ float ](name='InvoiceAmounts', description='1'),
invoiceCodes?: [ float ](name='InvoiceCodes', description='1'),
invoiceDates?: [ float ](name='InvoiceDates', description='1'),
invoiceFakeCodes?: [ float ](name='InvoiceFakeCodes', description='1'),
invoiceNoes?: [ float ](name='InvoiceNoes', description='1'),
itemNames?: [ int32 ](name='ItemNames', description='1'),
payeeAddresses?: [ float ](name='PayeeAddresses', description='1'),
payeeBankNames?: [ float ](name='PayeeBankNames', description='1'),
payeeNames?: [ float ](name='PayeeNames', description='1'),
payeeRegisterNoes?: [ float ](name='PayeeRegisterNoes', description='1'),
payees?: [ float ](name='Payees', description='1'),
payerAddresses?: [ float ](name='PayerAddresses', description='1'),
payerBankNames?: [ float ](name='PayerBankNames', description='1'),
payerNames?: [ float ](name='PayerNames', description='1'),
payerRegisterNoes?: [ float ](name='PayerRegisterNoes', description='1'),
sumAmounts?: [ float ](name='SumAmounts', description='1'),
taxAmounts?: [ float ](name='TaxAmounts', description='1'),
withoutTaxAmounts?: [ float ](name='WithoutTaxAmounts', description='1'),
}(name='Box'),
content?: {
antiFakeCode?: string(name='AntiFakeCode', example='02702870934284730434'),
checker?: string(name='Checker'),
clerk?: string(name='Clerk'),
invoiceAmount?: string(name='InvoiceAmount', example='200.00'),
invoiceCode?: string(name='InvoiceCode', example='031001600311'),
invoiceDate?: string(name='InvoiceDate', example='20190415'),
invoiceNo?: string(name='InvoiceNo', example='03753869'),
itemName?: [ string ](name='ItemName', description='1'),
payee?: string(name='Payee'),
payeeAddress?: string(name='PayeeAddress'),
payeeBankName?: string(name='PayeeBankName'),
payeeName?: string(name='PayeeName'),
payeeRegisterNo?: string(name='PayeeRegisterNo', example='91420200000123403'),
payerAddress?: string(name='PayerAddress'),
payerBankName?: string(name='PayerBankName', example='6221************1234'),
payerName?: string(name='PayerName'),
payerRegisterNo?: string(name='PayerRegisterNo', example='91420200000123403'),
sumAmount?: string(name='SumAmount', example='87'),
taxAmount?: string(name='TaxAmount', example='9.52'),
withoutTaxAmount?: string(name='WithoutTaxAmount', example='190.48'),
}(name='Content'),
}(name='Data'),
requestId?: string(name='RequestId', example='56A10D65-ECE0-59DE-9775-F6494D2AF13B'),
}
model RecognizeVATInvoiceResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeVATInvoiceResponseBody(name='body'),
}
async function recognizeVATInvoiceWithOptions(request: RecognizeVATInvoiceRequest, runtime: Util.RuntimeOptions): RecognizeVATInvoiceResponse {
Util.validateModel(request);
var body : map[string]any = {};
if (!Util.isUnset(request.fileType)) {
body['FileType'] = request.fileType;
}
if (!Util.isUnset(request.fileURL)) {
body['FileURL'] = request.fileURL;
}
var req = new OpenApi.OpenApiRequest{
body = OpenApiUtil.parseToMap(body),
};
var params = new OpenApi.Params{
action = 'RecognizeVATInvoice',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeVATInvoice(request: RecognizeVATInvoiceRequest): RecognizeVATInvoiceResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeVATInvoiceWithOptions(request, runtime);
}
async function recognizeVATInvoiceAdvance(request: RecognizeVATInvoiceAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeVATInvoiceResponse {
// 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 = 'ocr',
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 recognizeVATInvoiceReq = new RecognizeVATInvoiceRequest{};
OpenApiUtil.convert(request, recognizeVATInvoiceReq);
if(!Util.isUnset(request.fileURLObject)) {
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.fileURLObject,
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);
recognizeVATInvoiceReq.fileURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeVATInvoiceResp = recognizeVATInvoiceWithOptions(recognizeVATInvoiceReq, runtime);
return recognizeVATInvoiceResp;
}
model RecognizeVINCodeRequest {
imageURL?: string(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeVINCode/vin1.jpg'),
}
model RecognizeVINCodeAdvanceRequest {
imageURLObject?: readable(name='ImageURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeVINCode/vin1.jpg'),
}
model RecognizeVINCodeResponseBody = {
data?: {
vinCode?: string(name='VinCode', example='LVBB2FAF777999888'),
}(name='Data'),
requestId?: string(name='RequestId', example='911FC8CF-CC27-477E-BE3B-7ED77DF4DFE0'),
}
model RecognizeVINCodeResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeVINCodeResponseBody(name='body'),
}
async function recognizeVINCodeWithOptions(request: RecognizeVINCodeRequest, runtime: Util.RuntimeOptions): RecognizeVINCodeResponse {
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 = 'RecognizeVINCode',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeVINCode(request: RecognizeVINCodeRequest): RecognizeVINCodeResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeVINCodeWithOptions(request, runtime);
}
async function recognizeVINCodeAdvance(request: RecognizeVINCodeAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeVINCodeResponse {
// 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 = 'ocr',
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 recognizeVINCodeReq = new RecognizeVINCodeRequest{};
OpenApiUtil.convert(request, recognizeVINCodeReq);
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);
recognizeVINCodeReq.imageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeVINCodeResp = recognizeVINCodeWithOptions(recognizeVINCodeReq, runtime);
return recognizeVINCodeResp;
}
model RecognizeVideoCharacterRequest {
videoURL?: string(name='VideoURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/RecognizeVideoCharacter/xxxx.mp4'),
}
model RecognizeVideoCharacterAdvanceRequest {
videoURLObject?: readable(name='VideoURL', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/RecognizeVideoCharacter/xxxx.mp4'),
}
model RecognizeVideoCharacterResponseBody = {
data?: {
frames?: [
{
elements?: [
{
score?: float(name='Score', example='0.99'),
text?: string(name='Text'),
textRectangles?: [
{
angle?: long(name='Angle', example='-90'),
height?: long(name='Height', example='213'),
left?: long(name='Left', example='213'),
top?: long(name='Top', example='98'),
width?: long(name='Width', example='46'),
}
](name='TextRectangles'),
}
](name='Elements'),
timestamp?: long(name='Timestamp', example='6124533574'),
}
](name='Frames'),
height?: long(name='Height', example='1080'),
inputFile?: string(name='InputFile', example='oss://my-bucket/a/b/c.mp4'),
width?: long(name='Width', example='1920'),
}(name='Data'),
message?: string(name='Message'),
requestId?: string(name='RequestId', example='D3F5BA69-79C4-46A4-B02B-58C4EEBC4C33'),
}
model RecognizeVideoCharacterResponse = {
headers: map[string]string(name='headers'),
statusCode: int32(name='statusCode'),
body: RecognizeVideoCharacterResponseBody(name='body'),
}
async function recognizeVideoCharacterWithOptions(request: RecognizeVideoCharacterRequest, runtime: Util.RuntimeOptions): RecognizeVideoCharacterResponse {
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 = 'RecognizeVideoCharacter',
version = '2019-12-30',
protocol = 'HTTPS',
pathname = '/',
method = 'POST',
authType = 'AK',
style = 'RPC',
reqBodyType = 'formData',
bodyType = 'json',
};
return callApi(params, req, runtime);
}
async function recognizeVideoCharacter(request: RecognizeVideoCharacterRequest): RecognizeVideoCharacterResponse {
var runtime = new Util.RuntimeOptions{};
return recognizeVideoCharacterWithOptions(request, runtime);
}
async function recognizeVideoCharacterAdvance(request: RecognizeVideoCharacterAdvanceRequest, runtime: Util.RuntimeOptions): RecognizeVideoCharacterResponse {
// 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 = 'ocr',
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 recognizeVideoCharacterReq = new RecognizeVideoCharacterRequest{};
OpenApiUtil.convert(request, recognizeVideoCharacterReq);
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);
recognizeVideoCharacterReq.videoURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
}
var recognizeVideoCharacterResp = recognizeVideoCharacterWithOptions(recognizeVideoCharacterReq, runtime);
return recognizeVideoCharacterResp;
}