Skip to content

Vision: imageContext isn't documented #2553

@jmdobry

Description

@jmdobry

Customer wondered how to pass a crop hint option to Vision#cropHints(). Turns out, you can't. The helper methods only accept an Image and a grpc options object, and do not accept imageContext.

In order to pass say, the aspectRatios option as part of the cropHints request, you have to use the annotateImage method directly, like so:

const Vision = require('@google-cloud/vision');
const vision = Vision();
vision.annotateImage({
  image: {
    source: {
      filename: '/path/to/image.png'
    }
  },
  features: [{ type: Vision.types.Feature.Type.CROP_HINTS }],
  imageContext: {
    cropHintsParams: {
      aspectRatios: [0.25]
    }
  }
}).then(...);

I'm not sure how folks are supposed to know this.

imageContext itself isn't even documented on the annotateImage method

Also, accessing the enum (e.g. Vision.types.Feature.Type.CROP_HINTS) is only documented in the client library's README, and even then, only for FACE_DETECTION.

Metadata

Metadata

Labels

api: visionIssues related to the Cloud Vision API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions