@azure/cognitiveservices-computervision
Version:
ComputerVisionClient Library with typescript type definitions for node.js and browser.
730 lines • 20.2 kB
JavaScript
/*
* 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.
*/
import { __assign, __extends } from "tslib";
import * as msRest from "@azure/ms-rest-js";
import * as Models from "./models";
import * as Mappers from "./models/mappers";
import * as Parameters from "./models/parameters";
import { ComputerVisionClientContext } from "./computerVisionClientContext";
var ComputerVisionClient = /** @class */ (function (_super) {
__extends(ComputerVisionClient, _super);
/**
* Initializes a new instance of the ComputerVisionClient class.
* @param endpoint Supported Cognitive Services endpoints.
* @param credentials Subscription credentials which uniquely identify client subscription.
* @param [options] The parameter options
*/
function ComputerVisionClient(credentials, endpoint, options) {
return _super.call(this, credentials, endpoint, options) || this;
}
ComputerVisionClient.prototype.analyzeImage = function (url, options, callback) {
return this.sendOperationRequest({
url: url,
options: options
}, analyzeImageOperationSpec, callback);
};
ComputerVisionClient.prototype.describeImage = function (url, options, callback) {
return this.sendOperationRequest({
url: url,
options: options
}, describeImageOperationSpec, callback);
};
ComputerVisionClient.prototype.detectObjects = function (url, options, callback) {
return this.sendOperationRequest({
url: url,
options: options
}, detectObjectsOperationSpec, callback);
};
ComputerVisionClient.prototype.listModels = function (options, callback) {
return this.sendOperationRequest({
options: options
}, listModelsOperationSpec, callback);
};
ComputerVisionClient.prototype.analyzeImageByDomain = function (model, url, options, callback) {
return this.sendOperationRequest({
model: model,
url: url,
options: options
}, analyzeImageByDomainOperationSpec, callback);
};
ComputerVisionClient.prototype.recognizePrintedText = function (detectOrientation, url, options, callback) {
return this.sendOperationRequest({
detectOrientation: detectOrientation,
url: url,
options: options
}, recognizePrintedTextOperationSpec, callback);
};
ComputerVisionClient.prototype.tagImage = function (url, options, callback) {
return this.sendOperationRequest({
url: url,
options: options
}, tagImageOperationSpec, callback);
};
ComputerVisionClient.prototype.generateThumbnail = function (width, height, url, options, callback) {
return this.sendOperationRequest({
width: width,
height: height,
url: url,
options: options
}, generateThumbnailOperationSpec, callback);
};
ComputerVisionClient.prototype.getAreaOfInterest = function (url, options, callback) {
return this.sendOperationRequest({
url: url,
options: options
}, getAreaOfInterestOperationSpec, callback);
};
ComputerVisionClient.prototype.read = function (url, options, callback) {
return this.sendOperationRequest({
url: url,
options: options
}, readOperationSpec, callback);
};
ComputerVisionClient.prototype.getReadResult = function (operationId, options, callback) {
return this.sendOperationRequest({
operationId: operationId,
options: options
}, getReadResultOperationSpec, callback);
};
ComputerVisionClient.prototype.analyzeImageInStream = function (image, options, callback) {
return this.sendOperationRequest({
image: image,
options: options
}, analyzeImageInStreamOperationSpec, callback);
};
ComputerVisionClient.prototype.getAreaOfInterestInStream = function (image, options, callback) {
return this.sendOperationRequest({
image: image,
options: options
}, getAreaOfInterestInStreamOperationSpec, callback);
};
ComputerVisionClient.prototype.describeImageInStream = function (image, options, callback) {
return this.sendOperationRequest({
image: image,
options: options
}, describeImageInStreamOperationSpec, callback);
};
ComputerVisionClient.prototype.detectObjectsInStream = function (image, options, callback) {
return this.sendOperationRequest({
image: image,
options: options
}, detectObjectsInStreamOperationSpec, callback);
};
ComputerVisionClient.prototype.generateThumbnailInStream = function (width, height, image, options, callback) {
return this.sendOperationRequest({
width: width,
height: height,
image: image,
options: options
}, generateThumbnailInStreamOperationSpec, callback);
};
ComputerVisionClient.prototype.analyzeImageByDomainInStream = function (model, image, options, callback) {
return this.sendOperationRequest({
model: model,
image: image,
options: options
}, analyzeImageByDomainInStreamOperationSpec, callback);
};
ComputerVisionClient.prototype.recognizePrintedTextInStream = function (detectOrientation, image, options, callback) {
return this.sendOperationRequest({
detectOrientation: detectOrientation,
image: image,
options: options
}, recognizePrintedTextInStreamOperationSpec, callback);
};
ComputerVisionClient.prototype.tagImageInStream = function (image, options, callback) {
return this.sendOperationRequest({
image: image,
options: options
}, tagImageInStreamOperationSpec, callback);
};
ComputerVisionClient.prototype.readInStream = function (image, options, callback) {
return this.sendOperationRequest({
image: image,
options: options
}, readInStreamOperationSpec, callback);
};
return ComputerVisionClient;
}(ComputerVisionClientContext));
// Operation Specifications
var serializer = new msRest.Serializer(Mappers);
var analyzeImageOperationSpec = {
httpMethod: "POST",
path: "analyze",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.visualFeatures,
Parameters.details,
Parameters.language0,
Parameters.descriptionExclude,
Parameters.modelVersion
],
requestBody: {
parameterPath: {
url: "url"
},
mapper: __assign(__assign({}, Mappers.ImageUrl), { required: true })
},
responses: {
200: {
bodyMapper: Mappers.ImageAnalysis
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var describeImageOperationSpec = {
httpMethod: "POST",
path: "describe",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.maxCandidates,
Parameters.language0,
Parameters.descriptionExclude,
Parameters.modelVersion
],
requestBody: {
parameterPath: {
url: "url"
},
mapper: __assign(__assign({}, Mappers.ImageUrl), { required: true })
},
responses: {
200: {
bodyMapper: Mappers.ImageDescription
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var detectObjectsOperationSpec = {
httpMethod: "POST",
path: "detect",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.modelVersion
],
requestBody: {
parameterPath: {
url: "url"
},
mapper: __assign(__assign({}, Mappers.ImageUrl), { required: true })
},
responses: {
200: {
bodyMapper: Mappers.DetectResult
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var listModelsOperationSpec = {
httpMethod: "GET",
path: "models",
urlParameters: [
Parameters.endpoint
],
responses: {
200: {
bodyMapper: Mappers.ListModelsResult
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var analyzeImageByDomainOperationSpec = {
httpMethod: "POST",
path: "models/{model}/analyze",
urlParameters: [
Parameters.endpoint,
Parameters.model
],
queryParameters: [
Parameters.language0,
Parameters.modelVersion
],
requestBody: {
parameterPath: {
url: "url"
},
mapper: __assign(__assign({}, Mappers.ImageUrl), { required: true })
},
responses: {
200: {
bodyMapper: Mappers.DomainModelResults
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var recognizePrintedTextOperationSpec = {
httpMethod: "POST",
path: "ocr",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.detectOrientation,
Parameters.language1,
Parameters.modelVersion
],
requestBody: {
parameterPath: {
url: "url"
},
mapper: __assign(__assign({}, Mappers.ImageUrl), { required: true })
},
responses: {
200: {
bodyMapper: Mappers.OcrResult
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var tagImageOperationSpec = {
httpMethod: "POST",
path: "tag",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.language0,
Parameters.modelVersion
],
requestBody: {
parameterPath: {
url: "url"
},
mapper: __assign(__assign({}, Mappers.ImageUrl), { required: true })
},
responses: {
200: {
bodyMapper: Mappers.TagResult
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var generateThumbnailOperationSpec = {
httpMethod: "POST",
path: "generateThumbnail",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.width,
Parameters.height,
Parameters.smartCropping,
Parameters.modelVersion
],
requestBody: {
parameterPath: {
url: "url"
},
mapper: __assign(__assign({}, Mappers.ImageUrl), { required: true })
},
responses: {
200: {
bodyMapper: {
serializedName: "parsedResponse",
type: {
name: "Stream"
}
}
},
default: {}
},
serializer: serializer
};
var getAreaOfInterestOperationSpec = {
httpMethod: "POST",
path: "areaOfInterest",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.modelVersion
],
requestBody: {
parameterPath: {
url: "url"
},
mapper: __assign(__assign({}, Mappers.ImageUrl), { required: true })
},
responses: {
200: {
bodyMapper: Mappers.AreaOfInterestResult
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var readOperationSpec = {
httpMethod: "POST",
path: "read/analyze",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.language2,
Parameters.pages,
Parameters.modelVersion,
Parameters.readingOrder
],
requestBody: {
parameterPath: {
url: "url"
},
mapper: __assign(__assign({}, Mappers.ImageUrl), { required: true })
},
responses: {
202: {
headersMapper: Mappers.ReadHeaders
},
default: {
bodyMapper: Mappers.ComputerVisionOcrError,
headersMapper: Mappers.ReadHeaders
}
},
serializer: serializer
};
var getReadResultOperationSpec = {
httpMethod: "GET",
path: "read/analyzeResults/{operationId}",
urlParameters: [
Parameters.endpoint,
Parameters.operationId
],
responses: {
200: {
bodyMapper: Mappers.ReadOperationResult
},
default: {
bodyMapper: Mappers.ComputerVisionOcrError
}
},
serializer: serializer
};
var analyzeImageInStreamOperationSpec = {
httpMethod: "POST",
path: "analyze",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.visualFeatures,
Parameters.details,
Parameters.language0,
Parameters.descriptionExclude,
Parameters.modelVersion
],
requestBody: {
parameterPath: "image",
mapper: {
required: true,
serializedName: "Image",
type: {
name: "Stream"
}
}
},
contentType: "application/octet-stream",
responses: {
200: {
bodyMapper: Mappers.ImageAnalysis
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var getAreaOfInterestInStreamOperationSpec = {
httpMethod: "POST",
path: "areaOfInterest",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.modelVersion
],
requestBody: {
parameterPath: "image",
mapper: {
required: true,
serializedName: "Image",
type: {
name: "Stream"
}
}
},
contentType: "application/octet-stream",
responses: {
200: {
bodyMapper: Mappers.AreaOfInterestResult
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var describeImageInStreamOperationSpec = {
httpMethod: "POST",
path: "describe",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.maxCandidates,
Parameters.language0,
Parameters.descriptionExclude,
Parameters.modelVersion
],
requestBody: {
parameterPath: "image",
mapper: {
required: true,
serializedName: "Image",
type: {
name: "Stream"
}
}
},
contentType: "application/octet-stream",
responses: {
200: {
bodyMapper: Mappers.ImageDescription
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var detectObjectsInStreamOperationSpec = {
httpMethod: "POST",
path: "detect",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.modelVersion
],
requestBody: {
parameterPath: "image",
mapper: {
required: true,
serializedName: "Image",
type: {
name: "Stream"
}
}
},
contentType: "application/octet-stream",
responses: {
200: {
bodyMapper: Mappers.DetectResult
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var generateThumbnailInStreamOperationSpec = {
httpMethod: "POST",
path: "generateThumbnail",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.width,
Parameters.height,
Parameters.smartCropping,
Parameters.modelVersion
],
requestBody: {
parameterPath: "image",
mapper: {
required: true,
serializedName: "Image",
type: {
name: "Stream"
}
}
},
contentType: "application/octet-stream",
responses: {
200: {
bodyMapper: {
serializedName: "parsedResponse",
type: {
name: "Stream"
}
}
},
default: {}
},
serializer: serializer
};
var analyzeImageByDomainInStreamOperationSpec = {
httpMethod: "POST",
path: "models/{model}/analyze",
urlParameters: [
Parameters.endpoint,
Parameters.model
],
queryParameters: [
Parameters.language0,
Parameters.modelVersion
],
requestBody: {
parameterPath: "image",
mapper: {
required: true,
serializedName: "Image",
type: {
name: "Stream"
}
}
},
contentType: "application/octet-stream",
responses: {
200: {
bodyMapper: Mappers.DomainModelResults
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var recognizePrintedTextInStreamOperationSpec = {
httpMethod: "POST",
path: "ocr",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.detectOrientation,
Parameters.language1,
Parameters.modelVersion
],
requestBody: {
parameterPath: "image",
mapper: {
required: true,
serializedName: "Image",
type: {
name: "Stream"
}
}
},
contentType: "application/octet-stream",
responses: {
200: {
bodyMapper: Mappers.OcrResult
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var tagImageInStreamOperationSpec = {
httpMethod: "POST",
path: "tag",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.language0,
Parameters.modelVersion
],
requestBody: {
parameterPath: "image",
mapper: {
required: true,
serializedName: "Image",
type: {
name: "Stream"
}
}
},
contentType: "application/octet-stream",
responses: {
200: {
bodyMapper: Mappers.TagResult
},
default: {
bodyMapper: Mappers.ComputerVisionErrorResponse
}
},
serializer: serializer
};
var readInStreamOperationSpec = {
httpMethod: "POST",
path: "read/analyze",
urlParameters: [
Parameters.endpoint
],
queryParameters: [
Parameters.language2,
Parameters.pages,
Parameters.modelVersion,
Parameters.readingOrder
],
requestBody: {
parameterPath: "image",
mapper: {
required: true,
serializedName: "Image",
type: {
name: "Stream"
}
}
},
contentType: "application/octet-stream",
responses: {
202: {
headersMapper: Mappers.ReadInStreamHeaders
},
default: {
bodyMapper: Mappers.ComputerVisionOcrError,
headersMapper: Mappers.ReadInStreamHeaders
}
},
serializer: serializer
};
export { ComputerVisionClient, ComputerVisionClientContext, Models as ComputerVisionModels, Mappers as ComputerVisionMappers };
//# sourceMappingURL=computerVisionClient.js.map