diff --git a/utils/visionUtils.ts b/utils/visionUtils.ts index 70775ea..53acf24 100644 --- a/utils/visionUtils.ts +++ b/utils/visionUtils.ts @@ -21,21 +21,17 @@ export const scanProduct = async (imageData: string): Promise<{ name: string; qu const labels = result.labelAnnotations || []; - // Filter out generic labels const specificLabels = labels.filter(label => label.description && !['Food', 'Produce', 'Natural foods', 'Fruit', 'Vegetable'].includes(label.description) ); if (specificLabels.length > 0) { - // Use the most confident specific label const productName = specificLabels[0]?.description || 'Unknown Product'; - // Log all labels for debugging console.log('All labels:', labels.map(l => `${l.description || 'Unknown'} (${l.score || 'N/A'})`).join(', ')); return { name: productName, quantity: 1, allLabels: labels.map(label => label.description || '').filter(Boolean) }; } else if (labels.length > 0) { - // If no specific labels, use the most confident general label const productName = labels[0]?.description || 'Unknown Product'; return { name: productName, quantity: 1, allLabels: labels.map(label => label.description || '').filter(Boolean) }; } else {