Google cloud vision api 10 Предельные результаты (nodejs)
Я прочитал, что предельные значения результата установлены по умолчанию на 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);
});
1 ответ
Попробуйте следующее:
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);
});
Ref: maxResults