Node.js 我可以在Google Vision api中给出纵横比吗?
我正在探索谷歌视觉和具体功能 “detectCrops”给了我作物的线索。这到底意味着什么 我尝试用一个示例图像点击api,得到了一个带有四个坐标的数组的响应。这个坐标表示什么?长宽比是固定的吗?我可以指定具体的纵横比吗。文件不清楚或我无法理解 我的代码Node.js 我可以在Google Vision api中给出纵横比吗?,node.js,google-vision,Node.js,Google Vision,我正在探索谷歌视觉和具体功能 “detectCrops”给了我作物的线索。这到底意味着什么 我尝试用一个示例图像点击api,得到了一个带有四个坐标的数组的响应。这个坐标表示什么?长宽比是固定的吗?我可以指定具体的纵横比吗。文件不清楚或我无法理解 我的代码 var vision = require('@google-cloud/vision')({ projectId: Credentials.PROJECT_ID, credentials: Credentials.AUTH_KEY })
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)
})
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 } ] }
回应
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)
})
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 } ] }
可以提供纵横比
vision.detectCrops('./img.jpg', {imageContext : {cropHintsParams : {aspectRatios : [1.77]}}}, function(err, crops, apiResponse) {
console.log('crops', crops)
}