Barcode scanning
Last updated
Last updated
The SDK can detect barcodes located on the packaging of packaged foods. To implement barcode scanning, the camera setup for continuous image recognition is needed.
Specifically for barcode scanning, these steps are required:
When defining a FoodDetectionConfiguration
object, enable the detectBarcode
flag.
In the recognitionResults
callback, check the property candidate.barcodeCandidates
. If this list is empty, no barcodes have been recognised.
If there is a single or multiple barcode candidates, use their value property and invoke this function to fetch the full nutrition data.
On smaller packages, barcodes can be very small. When trying to scan these barcodes, the user usually brings to package to close to the camera creating focus issues. To avoid this, but the camera zoom level to 2.
Set up the camera preview and detection session to recognise barcodes
Create a result view with two states: search and result
If the candidate.barcodeCandidates is empty, show the search state. Else, fetch the PassioFoodItem, and use it's name and icon to show the result
Example of an image that produces multiple BarcodeCandidates: