我已经读到,结果限制在默认情况下设置为10,但我不知道在google提供的教程代码中应该在哪里更改这个限制。
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);
});发布于 2017-11-11 08:01:28
尝试以下几点:
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);
});参考文献:maxResults
https://stackoverflow.com/questions/47074577
复制相似问题