I'm using Google Vision to detect photos on an image and the results are limited to the top 10. I want to extend this number to 50. How do I do that?
Here is my code:
const client = new vision.ImageAnnotatorClient();
for (const file of allFiles) {
if (file.metadata.contentType.startsWith("image/")) {
const [resultImageLabel] = await client.labelDetection(
`gs://${bucketName}/${file.name}`
);
const labels = resultImageLabel.labelAnnotations;
const faceDetection = resultFaceDetection.faceAnnotations;
const labelArray = [];
const labelScore = {};
// image Labelling
for (const label of labels) {
labelArray.push(label.description);
labelScore[label.description] = label.score;
}
console.log(labelArray);
console.log(labelScore);
}
}
The answers that i've seen are in JSON format so i added at the beginning of the for loop:
const request = {
image: {
source: { imageUri: `gs://${bucketName}/${file.name}` },
},
features: [
{
maxResults: 50,
},
],
};
// Changed from image path to request
const [resultImageLabel] = await client.labelDetection(request);
Then I get the following error:
functions: Error: Setting explicit features is not supported on this method. Use the #annotateImage method instead.
Looked through the "#annotateImage" documentation and I don't see what I'm missing.
When I comment out the "features" section of the code, everything works as before.
This is running in an https Firebase Cloud Function.