Barcode scanning
Real-time barcode scanning
The SDK can detect barcodes located on the packaging of packaged foods. To implement real-time 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 thedetectBarcode
flag.In the
recognitionResults
callback, check the propertycandidate.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.
Barcode scanning from an image
To recognise a barcode in an image, refer to the recognizeImageRemote function. The result of the barcode scanning process will come in the packagedFoodItem
attribute, and the resultType will be Barcode.
UI Example
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:
Last updated