Node.js Google cloud vision api 10限制结果(nodejs)
我已经读到,结果限制默认设置为10,但我不确定在谷歌提供的教程代码中在哪里更改Node.js Google cloud vision api 10限制结果(nodejs),node.js,google-cloud-vision,Node.js,Google Cloud Vision,我已经读到,结果限制默认设置为10,但我不确定在谷歌提供的教程代码中在哪里更改 vision.webDetection({ source: { filename: fileName } }) .then((results) => { const webDetection = results[0].webDetection; if (webDetection.fullMatchingImages.length) { console.log(`Full matc
vision.webDetection({ source: { filename: fileName } })
.then((results) => {
const webDetection = results[0].webDetection;
if (webDetection.fullMatchingImages.length) {
console.log(`Full matches found: ${webDetection.fullMatchingImages.length}`);
webDetection.fullMatchingImages.forEach((image) => {
console.log(` URL: ${image.url}`);
console.log(` Score: ${image.score}`);
});
}
})
.catch((err) => {
console.error('ERROR:', err);
});
尝试以下操作:
const bucketName = 'Bucket where the file resides, e.g. my-bucket';
const fileName = 'Path to file within bucket, e.g. path/to/image.png';
const request = {
source: {
imageUri: `gs://${bucketName}/${fileName}`
},
features: [{
maxResults: 10 // change this result
}]
};
vision.webDetection(request)
.then((results) => {
const webDetection = results[0].webDetection;
if (webDetection.fullMatchingImages.length) {
console.log(`Full matches found: ${webDetection.fullMatchingImages.length}`);
webDetection.fullMatchingImages.forEach((image) => {
console.log(` URL: ${image.url}`);
console.log(` Score: ${image.score}`);
});
}
})
.catch((err) => {
console.error('ERROR:', err);
});
参考: