0

I was exploring google vision and in the specific function 'detectCrops', gives me the crop hints. what does this means exactly?

I tried hitting the api with a sample image and got a response of an array with four coordinates. what does this coordinates signify? is the aspect ratio fixed? can i specify a specific aspect ratio? . The documentation is not clear or i am not able to understand.

My code

var vision = require('@google-cloud/vision')({
  projectId: Credentials.PROJECT_ID,
  credentials: Credentials.AUTH_KEY
})

vision.detectCrops('img.jpg', function(err, crops, apiResponse) {
  console.log('err', err)
  console.log('crops', crops)
  console.log('apiResponse', apiResponse)
})

The response

err null

crops [ [ { x: 0, y: 0 },
  { x: 649, y: 0 },
  { x: 649, y: 399 },
  { x: 0, y: 399 } ] ]

apiResponse { responses:
 [ { faceAnnotations: [],
   landmarkAnnotations: [],
   logoAnnotations: [],
   labelAnnotations: [],
   textAnnotations: [],
   fullTextAnnotation: null,
   safeSearchAnnotation: null,
   imagePropertiesAnnotation: null,
   cropHintsAnnotation: [Object],
   webDetection: null,
   error: null } ] }
Akash Dathan
  • 4,348
  • 2
  • 24
  • 45

1 Answers1

1

aspect ratio can be provided.

vision.detectCrops('./img.jpg', {imageContext : {cropHintsParams : {aspectRatios : [1.77]}}}, function(err, crops, apiResponse) {
  console.log('crops', crops) 
}
Akash Dathan
  • 4,348
  • 2
  • 24
  • 45