diff --git a/sdk/cognitiveservices/cognitiveservices-computervision/README.md b/sdk/cognitiveservices/cognitiveservices-computervision/README.md index e4067518d8f2..ade59c53b169 100644 --- a/sdk/cognitiveservices/cognitiveservices-computervision/README.md +++ b/sdk/cognitiveservices/cognitiveservices-computervision/README.md @@ -15,92 +15,75 @@ npm install @azure/cognitiveservices-computervision ### How to use -#### nodejs - Authentication, client creation and listModels as an example written in TypeScript. +#### nodejs - client creation and listModels as an example written in TypeScript. -##### Install @azure/ms-rest-azure-js +##### Install @azure/ms-rest-nodeauth +- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. ```bash -npm install @azure/ms-rest-azure-js +npm install @azure/ms-rest-nodeauth@"^3.0.0" ``` ##### Sample code -The following sample describes a given image using Computer Vision. To know more, refer to the [Azure Documentation on Computer Vision](https://docs.microsoft.com/azure/cognitive-services/computer-vision/home) -```javascript +While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package +```typescript +const msRestNodeAuth = require("@azure/ms-rest-nodeauth"); const { ComputerVisionClient } = require("@azure/cognitiveservices-computervision"); -const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js"); - -async function main() { - const computerVisionKey = process.env["computerVisionKey"] || ""; - const computerVisionEndPoint = - process.env["computerVisionEndPoint"] || ""; - const cognitiveServiceCredentials = new CognitiveServicesCredentials(computerVisionKey); - const client = new ComputerVisionClient(cognitiveServiceCredentials, computerVisionEndPoint); - - const url = - "https://docs.microsoft.com/azure/includes/media/shared-image-galleries/shared-image-gallery.png"; - const options = { - maxCandidates: 5, - language: "en" - }; - client - .describeImage(url, options) - .then((result) => { - console.log("The result is:"); - console.log(result); - }) - .catch((err) => { - console.log("An error occurred:"); - console.error(err); - }); -} - -main(); +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new ComputerVisionClient(creds, subscriptionId); + client.listModels().then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.error(err); +}); ``` -#### browser - Authentication, client creation and listModels as an example written in JavaScript. +#### browser - Authentication, client creation and listModels as an example written in JavaScript. + +##### Install @azure/ms-rest-browserauth + +```bash +npm install @azure/ms-rest-browserauth +``` ##### Sample code -- index.html +See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. +- index.html ```html @azure/cognitiveservices-computervision sample + @@ -111,4 +94,4 @@ main(); - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcognitiveservices%2Fcognitiveservices-computervision%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/cognitiveservices/cognitiveservices-computervision/README.png) diff --git a/sdk/cognitiveservices/cognitiveservices-computervision/rollup.config.js b/sdk/cognitiveservices/cognitiveservices-computervision/rollup.config.js index 139f0875c51f..9da1581466fe 100644 --- a/sdk/cognitiveservices/cognitiveservices-computervision/rollup.config.js +++ b/sdk/cognitiveservices/cognitiveservices-computervision/rollup.config.js @@ -21,8 +21,8 @@ const config = { "@azure/ms-rest-azure-js": "msRestAzure" }, banner: `/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. diff --git a/sdk/cognitiveservices/cognitiveservices-computervision/src/computerVisionClient.ts b/sdk/cognitiveservices/cognitiveservices-computervision/src/computerVisionClient.ts index ebf433435f03..92547bee818d 100644 --- a/sdk/cognitiveservices/cognitiveservices-computervision/src/computerVisionClient.ts +++ b/sdk/cognitiveservices/cognitiveservices-computervision/src/computerVisionClient.ts @@ -1,7 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is @@ -1025,7 +1024,8 @@ const readOperationSpec: msRest.OperationSpec = { queryParameters: [ Parameters.language2, Parameters.pages, - Parameters.modelVersion + Parameters.modelVersion, + Parameters.readingOrder ], requestBody: { parameterPath: { @@ -1340,7 +1340,9 @@ const readInStreamOperationSpec: msRest.OperationSpec = { ], queryParameters: [ Parameters.language2, - Parameters.pages + Parameters.pages, + Parameters.modelVersion, + Parameters.readingOrder ], requestBody: { parameterPath: "image", diff --git a/sdk/cognitiveservices/cognitiveservices-computervision/src/computerVisionClientContext.ts b/sdk/cognitiveservices/cognitiveservices-computervision/src/computerVisionClientContext.ts index b2339601b2a8..d71b14d44074 100644 --- a/sdk/cognitiveservices/cognitiveservices-computervision/src/computerVisionClientContext.ts +++ b/sdk/cognitiveservices/cognitiveservices-computervision/src/computerVisionClientContext.ts @@ -1,7 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is diff --git a/sdk/cognitiveservices/cognitiveservices-computervision/src/models/index.ts b/sdk/cognitiveservices/cognitiveservices-computervision/src/models/index.ts index 6b552eb7d9af..93a3087368c0 100644 --- a/sdk/cognitiveservices/cognitiveservices-computervision/src/models/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-computervision/src/models/index.ts @@ -1,6 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. @@ -997,6 +997,12 @@ export interface ComputerVisionClientReadOptionalParams extends msRest.RequestOp * 'latest'. */ modelVersion?: string; + /** + * Optional parameter to specify which reading order algorithm should be applied when ordering + * the extract text elements. Can be either 'basic' or 'natural'. Will default to 'basic' if not + * specified. Default value: 'basic'. + */ + readingOrder?: string; } /** @@ -1182,6 +1188,18 @@ export interface ComputerVisionClientReadInStreamOptionalParams extends msRest.R * comma. */ pages?: string[]; + /** + * Optional parameter to specify the version of the OCR model used for text extraction. Accepted + * values are: "latest", "latest-preview", "2021-04-12". Defaults to "latest". Default value: + * 'latest'. + */ + modelVersion?: string; + /** + * Optional parameter to specify which reading order algorithm should be applied when ordering + * the extract text elements. Can be either 'basic' or 'natural'. Will default to 'basic' if not + * specified. Default value: 'basic'. + */ + readingOrder?: string; } /** diff --git a/sdk/cognitiveservices/cognitiveservices-computervision/src/models/mappers.ts b/sdk/cognitiveservices/cognitiveservices-computervision/src/models/mappers.ts index 6f1620af6611..6c74514879b2 100644 --- a/sdk/cognitiveservices/cognitiveservices-computervision/src/models/mappers.ts +++ b/sdk/cognitiveservices/cognitiveservices-computervision/src/models/mappers.ts @@ -1,6 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. diff --git a/sdk/cognitiveservices/cognitiveservices-computervision/src/models/parameters.ts b/sdk/cognitiveservices/cognitiveservices-computervision/src/models/parameters.ts index ff723637d68f..ea099ded221b 100644 --- a/sdk/cognitiveservices/cognitiveservices-computervision/src/models/parameters.ts +++ b/sdk/cognitiveservices/cognitiveservices-computervision/src/models/parameters.ts @@ -1,7 +1,6 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is @@ -225,6 +224,19 @@ export const pages: msRest.OperationQueryParameter = { }, collectionFormat: msRest.QueryCollectionFormat.Csv }; +export const readingOrder: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "readingOrder" + ], + mapper: { + serializedName: "readingOrder", + defaultValue: 'basic', + type: { + name: "String" + } + } +}; export const smartCropping: msRest.OperationQueryParameter = { parameterPath: [ "options",