@google-cloud/vision
Version:
Google Cloud Vision API client for Node.js
890 lines (819 loc) • 8.16 MB
JavaScript
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
(function(global, factory) { /* global define, require, module */
/* AMD */ if (typeof define === 'function' && define.amd)
define(["protobufjs/minimal"], factory);
/* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports)
module.exports = factory(require("google-gax/build/src/protobuf").protobufMinimal);
})(this, function($protobuf) {
"use strict";
// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
// Exported root namespace
var $root = $protobuf.roots._google_cloud_vision_protos || ($protobuf.roots._google_cloud_vision_protos = {});
$root.google = (function() {
/**
* Namespace google.
* @exports google
* @namespace
*/
var google = {};
google.cloud = (function() {
/**
* Namespace cloud.
* @memberof google
* @namespace
*/
var cloud = {};
cloud.vision = (function() {
/**
* Namespace vision.
* @memberof google.cloud
* @namespace
*/
var vision = {};
vision.v1 = (function() {
/**
* Namespace v1.
* @memberof google.cloud.vision
* @namespace
*/
var v1 = {};
v1.Vertex = (function() {
/**
* Properties of a Vertex.
* @memberof google.cloud.vision.v1
* @interface IVertex
* @property {number|null} [x] Vertex x
* @property {number|null} [y] Vertex y
*/
/**
* Constructs a new Vertex.
* @memberof google.cloud.vision.v1
* @classdesc Represents a Vertex.
* @implements IVertex
* @constructor
* @param {google.cloud.vision.v1.IVertex=} [properties] Properties to set
*/
function Vertex(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* Vertex x.
* @member {number} x
* @memberof google.cloud.vision.v1.Vertex
* @instance
*/
Vertex.prototype.x = 0;
/**
* Vertex y.
* @member {number} y
* @memberof google.cloud.vision.v1.Vertex
* @instance
*/
Vertex.prototype.y = 0;
/**
* Creates a new Vertex instance using the specified properties.
* @function create
* @memberof google.cloud.vision.v1.Vertex
* @static
* @param {google.cloud.vision.v1.IVertex=} [properties] Properties to set
* @returns {google.cloud.vision.v1.Vertex} Vertex instance
*/
Vertex.create = function create(properties) {
return new Vertex(properties);
};
/**
* Encodes the specified Vertex message. Does not implicitly {@link google.cloud.vision.v1.Vertex.verify|verify} messages.
* @function encode
* @memberof google.cloud.vision.v1.Vertex
* @static
* @param {google.cloud.vision.v1.IVertex} message Vertex message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Vertex.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.x != null && Object.hasOwnProperty.call(message, "x"))
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.x);
if (message.y != null && Object.hasOwnProperty.call(message, "y"))
writer.uint32(/* id 2, wireType 0 =*/16).int32(message.y);
return writer;
};
/**
* Encodes the specified Vertex message, length delimited. Does not implicitly {@link google.cloud.vision.v1.Vertex.verify|verify} messages.
* @function encodeDelimited
* @memberof google.cloud.vision.v1.Vertex
* @static
* @param {google.cloud.vision.v1.IVertex} message Vertex message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Vertex.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a Vertex message from the specified reader or buffer.
* @function decode
* @memberof google.cloud.vision.v1.Vertex
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.cloud.vision.v1.Vertex} Vertex
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
Vertex.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.vision.v1.Vertex();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.x = reader.int32();
break;
}
case 2: {
message.y = reader.int32();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a Vertex message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.cloud.vision.v1.Vertex
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.cloud.vision.v1.Vertex} Vertex
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
Vertex.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a Vertex message.
* @function verify
* @memberof google.cloud.vision.v1.Vertex
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
Vertex.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.x != null && message.hasOwnProperty("x"))
if (!$util.isInteger(message.x))
return "x: integer expected";
if (message.y != null && message.hasOwnProperty("y"))
if (!$util.isInteger(message.y))
return "y: integer expected";
return null;
};
/**
* Creates a Vertex message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof google.cloud.vision.v1.Vertex
* @static
* @param {Object.<string,*>} object Plain object
* @returns {google.cloud.vision.v1.Vertex} Vertex
*/
Vertex.fromObject = function fromObject(object) {
if (object instanceof $root.google.cloud.vision.v1.Vertex)
return object;
var message = new $root.google.cloud.vision.v1.Vertex();
if (object.x != null)
message.x = object.x | 0;
if (object.y != null)
message.y = object.y | 0;
return message;
};
/**
* Creates a plain object from a Vertex message. Also converts values to other types if specified.
* @function toObject
* @memberof google.cloud.vision.v1.Vertex
* @static
* @param {google.cloud.vision.v1.Vertex} message Vertex
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
Vertex.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
object.x = 0;
object.y = 0;
}
if (message.x != null && message.hasOwnProperty("x"))
object.x = message.x;
if (message.y != null && message.hasOwnProperty("y"))
object.y = message.y;
return object;
};
/**
* Converts this Vertex to JSON.
* @function toJSON
* @memberof google.cloud.vision.v1.Vertex
* @instance
* @returns {Object.<string,*>} JSON object
*/
Vertex.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for Vertex
* @function getTypeUrl
* @memberof google.cloud.vision.v1.Vertex
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
Vertex.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/google.cloud.vision.v1.Vertex";
};
return Vertex;
})();
v1.NormalizedVertex = (function() {
/**
* Properties of a NormalizedVertex.
* @memberof google.cloud.vision.v1
* @interface INormalizedVertex
* @property {number|null} [x] NormalizedVertex x
* @property {number|null} [y] NormalizedVertex y
*/
/**
* Constructs a new NormalizedVertex.
* @memberof google.cloud.vision.v1
* @classdesc Represents a NormalizedVertex.
* @implements INormalizedVertex
* @constructor
* @param {google.cloud.vision.v1.INormalizedVertex=} [properties] Properties to set
*/
function NormalizedVertex(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* NormalizedVertex x.
* @member {number} x
* @memberof google.cloud.vision.v1.NormalizedVertex
* @instance
*/
NormalizedVertex.prototype.x = 0;
/**
* NormalizedVertex y.
* @member {number} y
* @memberof google.cloud.vision.v1.NormalizedVertex
* @instance
*/
NormalizedVertex.prototype.y = 0;
/**
* Creates a new NormalizedVertex instance using the specified properties.
* @function create
* @memberof google.cloud.vision.v1.NormalizedVertex
* @static
* @param {google.cloud.vision.v1.INormalizedVertex=} [properties] Properties to set
* @returns {google.cloud.vision.v1.NormalizedVertex} NormalizedVertex instance
*/
NormalizedVertex.create = function create(properties) {
return new NormalizedVertex(properties);
};
/**
* Encodes the specified NormalizedVertex message. Does not implicitly {@link google.cloud.vision.v1.NormalizedVertex.verify|verify} messages.
* @function encode
* @memberof google.cloud.vision.v1.NormalizedVertex
* @static
* @param {google.cloud.vision.v1.INormalizedVertex} message NormalizedVertex message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
NormalizedVertex.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.x != null && Object.hasOwnProperty.call(message, "x"))
writer.uint32(/* id 1, wireType 5 =*/13).float(message.x);
if (message.y != null && Object.hasOwnProperty.call(message, "y"))
writer.uint32(/* id 2, wireType 5 =*/21).float(message.y);
return writer;
};
/**
* Encodes the specified NormalizedVertex message, length delimited. Does not implicitly {@link google.cloud.vision.v1.NormalizedVertex.verify|verify} messages.
* @function encodeDelimited
* @memberof google.cloud.vision.v1.NormalizedVertex
* @static
* @param {google.cloud.vision.v1.INormalizedVertex} message NormalizedVertex message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
NormalizedVertex.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a NormalizedVertex message from the specified reader or buffer.
* @function decode
* @memberof google.cloud.vision.v1.NormalizedVertex
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.cloud.vision.v1.NormalizedVertex} NormalizedVertex
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
NormalizedVertex.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.vision.v1.NormalizedVertex();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.x = reader.float();
break;
}
case 2: {
message.y = reader.float();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a NormalizedVertex message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.cloud.vision.v1.NormalizedVertex
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.cloud.vision.v1.NormalizedVertex} NormalizedVertex
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
NormalizedVertex.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a NormalizedVertex message.
* @function verify
* @memberof google.cloud.vision.v1.NormalizedVertex
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
NormalizedVertex.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.x != null && message.hasOwnProperty("x"))
if (typeof message.x !== "number")
return "x: number expected";
if (message.y != null && message.hasOwnProperty("y"))
if (typeof message.y !== "number")
return "y: number expected";
return null;
};
/**
* Creates a NormalizedVertex message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof google.cloud.vision.v1.NormalizedVertex
* @static
* @param {Object.<string,*>} object Plain object
* @returns {google.cloud.vision.v1.NormalizedVertex} NormalizedVertex
*/
NormalizedVertex.fromObject = function fromObject(object) {
if (object instanceof $root.google.cloud.vision.v1.NormalizedVertex)
return object;
var message = new $root.google.cloud.vision.v1.NormalizedVertex();
if (object.x != null)
message.x = Number(object.x);
if (object.y != null)
message.y = Number(object.y);
return message;
};
/**
* Creates a plain object from a NormalizedVertex message. Also converts values to other types if specified.
* @function toObject
* @memberof google.cloud.vision.v1.NormalizedVertex
* @static
* @param {google.cloud.vision.v1.NormalizedVertex} message NormalizedVertex
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
NormalizedVertex.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
object.x = 0;
object.y = 0;
}
if (message.x != null && message.hasOwnProperty("x"))
object.x = options.json && !isFinite(message.x) ? String(message.x) : message.x;
if (message.y != null && message.hasOwnProperty("y"))
object.y = options.json && !isFinite(message.y) ? String(message.y) : message.y;
return object;
};
/**
* Converts this NormalizedVertex to JSON.
* @function toJSON
* @memberof google.cloud.vision.v1.NormalizedVertex
* @instance
* @returns {Object.<string,*>} JSON object
*/
NormalizedVertex.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for NormalizedVertex
* @function getTypeUrl
* @memberof google.cloud.vision.v1.NormalizedVertex
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
NormalizedVertex.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/google.cloud.vision.v1.NormalizedVertex";
};
return NormalizedVertex;
})();
v1.BoundingPoly = (function() {
/**
* Properties of a BoundingPoly.
* @memberof google.cloud.vision.v1
* @interface IBoundingPoly
* @property {Array.<google.cloud.vision.v1.IVertex>|null} [vertices] BoundingPoly vertices
* @property {Array.<google.cloud.vision.v1.INormalizedVertex>|null} [normalizedVertices] BoundingPoly normalizedVertices
*/
/**
* Constructs a new BoundingPoly.
* @memberof google.cloud.vision.v1
* @classdesc Represents a BoundingPoly.
* @implements IBoundingPoly
* @constructor
* @param {google.cloud.vision.v1.IBoundingPoly=} [properties] Properties to set
*/
function BoundingPoly(properties) {
this.vertices = [];
this.normalizedVertices = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* BoundingPoly vertices.
* @member {Array.<google.cloud.vision.v1.IVertex>} vertices
* @memberof google.cloud.vision.v1.BoundingPoly
* @instance
*/
BoundingPoly.prototype.vertices = $util.emptyArray;
/**
* BoundingPoly normalizedVertices.
* @member {Array.<google.cloud.vision.v1.INormalizedVertex>} normalizedVertices
* @memberof google.cloud.vision.v1.BoundingPoly
* @instance
*/
BoundingPoly.prototype.normalizedVertices = $util.emptyArray;
/**
* Creates a new BoundingPoly instance using the specified properties.
* @function create
* @memberof google.cloud.vision.v1.BoundingPoly
* @static
* @param {google.cloud.vision.v1.IBoundingPoly=} [properties] Properties to set
* @returns {google.cloud.vision.v1.BoundingPoly} BoundingPoly instance
*/
BoundingPoly.create = function create(properties) {
return new BoundingPoly(properties);
};
/**
* Encodes the specified BoundingPoly message. Does not implicitly {@link google.cloud.vision.v1.BoundingPoly.verify|verify} messages.
* @function encode
* @memberof google.cloud.vision.v1.BoundingPoly
* @static
* @param {google.cloud.vision.v1.IBoundingPoly} message BoundingPoly message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
BoundingPoly.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.vertices != null && message.vertices.length)
for (var i = 0; i < message.vertices.length; ++i)
$root.google.cloud.vision.v1.Vertex.encode(message.vertices[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
if (message.normalizedVertices != null && message.normalizedVertices.length)
for (var i = 0; i < message.normalizedVertices.length; ++i)
$root.google.cloud.vision.v1.NormalizedVertex.encode(message.normalizedVertices[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
return writer;
};
/**
* Encodes the specified BoundingPoly message, length delimited. Does not implicitly {@link google.cloud.vision.v1.BoundingPoly.verify|verify} messages.
* @function encodeDelimited
* @memberof google.cloud.vision.v1.BoundingPoly
* @static
* @param {google.cloud.vision.v1.IBoundingPoly} message BoundingPoly message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
BoundingPoly.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a BoundingPoly message from the specified reader or buffer.
* @function decode
* @memberof google.cloud.vision.v1.BoundingPoly
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.cloud.vision.v1.BoundingPoly} BoundingPoly
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
BoundingPoly.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.vision.v1.BoundingPoly();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
if (!(message.vertices && message.vertices.length))
message.vertices = [];
message.vertices.push($root.google.cloud.vision.v1.Vertex.decode(reader, reader.uint32()));
break;
}
case 2: {
if (!(message.normalizedVertices && message.normalizedVertices.length))
message.normalizedVertices = [];
message.normalizedVertices.push($root.google.cloud.vision.v1.NormalizedVertex.decode(reader, reader.uint32()));
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a BoundingPoly message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.cloud.vision.v1.BoundingPoly
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.cloud.vision.v1.BoundingPoly} BoundingPoly
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
BoundingPoly.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a BoundingPoly message.
* @function verify
* @memberof google.cloud.vision.v1.BoundingPoly
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
BoundingPoly.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.vertices != null && message.hasOwnProperty("vertices")) {
if (!Array.isArray(message.vertices))
return "vertices: array expected";
for (var i = 0; i < message.vertices.length; ++i) {
var error = $root.google.cloud.vision.v1.Vertex.verify(message.vertices[i]);
if (error)
return "vertices." + error;
}
}
if (message.normalizedVertices != null && message.hasOwnProperty("normalizedVertices")) {
if (!Array.isArray(message.normalizedVertices))
return "normalizedVertices: array expected";
for (var i = 0; i < message.normalizedVertices.length; ++i) {
var error = $root.google.cloud.vision.v1.NormalizedVertex.verify(message.normalizedVertices[i]);
if (error)
return "normalizedVertices." + error;
}
}
return null;
};
/**
* Creates a BoundingPoly message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof google.cloud.vision.v1.BoundingPoly
* @static
* @param {Object.<string,*>} object Plain object
* @returns {google.cloud.vision.v1.BoundingPoly} BoundingPoly
*/
BoundingPoly.fromObject = function fromObject(object) {
if (object instanceof $root.google.cloud.vision.v1.BoundingPoly)
return object;
var message = new $root.google.cloud.vision.v1.BoundingPoly();
if (object.vertices) {
if (!Array.isArray(object.vertices))
throw TypeError(".google.cloud.vision.v1.BoundingPoly.vertices: array expected");
message.vertices = [];
for (var i = 0; i < object.vertices.length; ++i) {
if (typeof object.vertices[i] !== "object")
throw TypeError(".google.cloud.vision.v1.BoundingPoly.vertices: object expected");
message.vertices[i] = $root.google.cloud.vision.v1.Vertex.fromObject(object.vertices[i]);
}
}
if (object.normalizedVertices) {
if (!Array.isArray(object.normalizedVertices))
throw TypeError(".google.cloud.vision.v1.BoundingPoly.normalizedVertices: array expected");
message.normalizedVertices = [];
for (var i = 0; i < object.normalizedVertices.length; ++i) {
if (typeof object.normalizedVertices[i] !== "object")
throw TypeError(".google.cloud.vision.v1.BoundingPoly.normalizedVertices: object expected");
message.normalizedVertices[i] = $root.google.cloud.vision.v1.NormalizedVertex.fromObject(object.normalizedVertices[i]);
}
}
return message;
};
/**
* Creates a plain object from a BoundingPoly message. Also converts values to other types if specified.
* @function toObject
* @memberof google.cloud.vision.v1.BoundingPoly
* @static
* @param {google.cloud.vision.v1.BoundingPoly} message BoundingPoly
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
BoundingPoly.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults) {
object.vertices = [];
object.normalizedVertices = [];
}
if (message.vertices && message.vertices.length) {
object.vertices = [];
for (var j = 0; j < message.vertices.length; ++j)
object.vertices[j] = $root.google.cloud.vision.v1.Vertex.toObject(message.vertices[j], options);
}
if (message.normalizedVertices && message.normalizedVertices.length) {
object.normalizedVertices = [];
for (var j = 0; j < message.normalizedVertices.length; ++j)
object.normalizedVertices[j] = $root.google.cloud.vision.v1.NormalizedVertex.toObject(message.normalizedVertices[j], options);
}
return object;
};
/**
* Converts this BoundingPoly to JSON.
* @function toJSON
* @memberof google.cloud.vision.v1.BoundingPoly
* @instance
* @returns {Object.<string,*>} JSON object
*/
BoundingPoly.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for BoundingPoly
* @function getTypeUrl
* @memberof google.cloud.vision.v1.BoundingPoly
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
BoundingPoly.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/google.cloud.vision.v1.BoundingPoly";
};
return BoundingPoly;
})();
v1.Position = (function() {
/**
* Properties of a Position.
* @memberof google.cloud.vision.v1
* @interface IPosition
* @property {number|null} [x] Position x
* @property {number|null} [y] Position y
* @property {number|null} [z] Position z
*/
/**
* Constructs a new Position.
* @memberof google.cloud.vision.v1
* @classdesc Represents a Position.
* @implements IPosition
* @constructor
* @param {google.cloud.vision.v1.IPosition=} [properties] Properties to set
*/
function Position(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* Position x.
* @member {number} x
* @memberof google.cloud.vision.v1.Position
* @instance
*/
Position.prototype.x = 0;
/**
* Position y.
* @member {number} y
* @memberof google.cloud.vision.v1.Position
* @instance
*/
Position.prototype.y = 0;
/**
* Position z.
* @member {number} z
* @memberof google.cloud.vision.v1.Position
* @instance
*/
Position.prototype.z = 0;
/**
* Creates a new Position instance using the specified properties.
* @function create
* @memberof google.cloud.vision.v1.Position
* @static
* @param {google.cloud.vision.v1.IPosition=} [properties] Properties to set
* @returns {google.cloud.vision.v1.Position} Position instance
*/
Position.create = function create(properties) {
return new Position(properties);
};
/**
* Encodes the specified Position message. Does not implicitly {@link google.cloud.vision.v1.Position.verify|verify} messages.
* @function encode
* @memberof google.cloud.vision.v1.Position
* @static
* @param {google.cloud.vision.v1.IPosition} message Position message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Position.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.x != null && Object.hasOwnProperty.call(message, "x"))
writer.uint32(/* id 1, wireType 5 =*/13).float(message.x);
if (message.y != null && Object.hasOwnProperty.call(message, "y"))
writer.uint32(/* id 2, wireType 5 =*/21).float(message.y);
if (message.z != null && Object.hasOwnProperty.call(message, "z"))
writer.uint32(/* id 3, wireType 5 =*/29).float(message.z);
return writer;
};
/**
* Encodes the specified Position message, length delimited. Does not implicitly {@link google.cloud.vision.v1.Position.verify|verify} messages.
* @function encodeDelimited
* @memberof google.cloud.vision.v1.Position
* @static
* @param {google.cloud.vision.v1.IPosition} message Position message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Position.encodeDelimited = function encodeDelimited(message, wri