Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
Google Inc.
Anand Suresh
Brett Bergmann
Jesse Friedman
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Brett Bergmann <[email protected]>
Burcu Dogan <[email protected]>
Hector Rovira <[email protected]>
Ido Shamun <[email protected]>
Jesse Friedman <[email protected]>
Johan Euphrosine <[email protected]>
Marco Ziccardi <[email protected]>
Patrick Costello <[email protected]>
Expand Down
7 changes: 7 additions & 0 deletions lib/vision/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ Vision.prototype.annotate = function(requests, callback) {
* image path, a remote image URL, or a gcloud File object.
* @param {string[]|object=} options - An array of types or a configuration
* object.
* @param {object=} options.imageContext - See an
* [`ImageContext`](https://cloud.google.com/vision/reference/rest/v1/images/annotate#ImageContext)
* resource.
* @param {number} options.maxResults - The maximum number of results, per type,
* to return in the response.
* @param {string[]} options.types - An array of feature types to detect from
Expand Down Expand Up @@ -312,6 +315,10 @@ Vision.prototype.detect = function(images, options, callback) {
}
};

if (is.object(options.imageContext)) {
cfg.imageContext = options.imageContext;
}

if (is.number(options.maxResults)) {
cfg.features.maxResults = options.maxResults;
}
Expand Down
34 changes: 34 additions & 0 deletions test/vision/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,40 @@ describe('Vision', function() {
async.each(shortNames, checkConfig, done);
});

it('should allow setting imageContext', function(done) {
var imageContext = {
latLongRect: {
minLatLng: {
latitude: 37.420901,
longitude: -122.081293
},
maxLatLng: {
latitude: 37.423228,
longitude: -122.086347
}
}
};

vision.annotate = function(config) {
assert.deepEqual(config, [
{
image: IMAGES[0],
features: {
type: 'LABEL_DETECTION'
},
imageContext: imageContext

This comment was marked as spam.

This comment was marked as spam.

}
]);

done();
};

vision.detect(IMAGE, {
types: ['label'],
imageContext: imageContext
}, assert.ifError);
});

it('should allow setting maxResults', function(done) {
var maxResults = 10;

Expand Down