-
public interface PassioSDKMain access point of the SDK. Defines all of the SDK's main capabilities. The API of the SDK is designed as a singleton with the instance containing the concrete implementation of the interface. The SDK is design to be called from the main thread. The execution of most of its functions will be delegated to an internal thread pool, but the resulting callback will always be invoked on the main thread.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumPassioSDK.FramesPerSecondDefines the processing speed of the SDK's camera recognition system. ONE - indicates that one frame will be analyzed every second. If the analysis time of that frame exceeds time of a second, the next frame will be analyzed only after the previous one has been complete. TWO - indicates that one frame will be analyzed every 500 milliseconds. This is the default behaviour of the SDK. MAX - there is no possible waiting period between the analysis of two frames. As soon as the recognition system is done with the previous frame, the analysis of the next one is called. This mode might is computational heavy and might take up a lot of processing power of the system.
public classPassioSDK.Companion
-
Method Summary
Modifier and Type Method Description abstract Unitconfigure(PassioConfiguration passioConfiguration, Function1<PassioStatus, Unit> onComplete)Initializes the SDK with the given passioConfiguration. abstract BooleanisSDKReady()Checks whether the SDK initialization ran to completion. abstract UnitstartCamera(PassioCameraViewProvider passioCameraViewProvider, Integer displayRotation, Integer cameraFacing, Boolean tapToFocus, Function1<PassioCameraData, Unit> onCameraReady)Starts the camera preview with the given PassioCameraViewProvider. abstract UnitstartCamera(PassioCameraViewProvider viewProvider, PassioCameraConfigurator configurator)abstract UnitstopCamera()abstract UnitenableFlashlight(Boolean enabled)Turns the device's flashlight on or off. abstract UnitsetCameraZoomLevel(Float zoomLevel)abstract Pair<Float, Float>getMinMaxCameraZoomLevel()abstract UnittakePicture(Function1<Bitmap, Unit> onResult)abstract UnitrunFrameEvery(Long timeForAnalysis)Sets the time between each analyzed frame. UnitshutDownPassioSDK()Finalizes the PassioSDK instance. abstract BooleanstartFoodDetection(FoodRecognitionListener foodRecognitionListener, FoodDetectionConfiguration detectionConfig)Registers a listener for the food detection process. abstract BooleanstopFoodDetection()Stops the food detection process. abstract Pair<Drawable, Drawable>lookupIconsFor(Context context, String passioID, IconSize iconSize, PassioIDEntityType type)abstract UnitfetchIconFor(Context context, String passioID, IconSize iconSize, Function1<Drawable, Unit> callback)For a given PassioID returns the corresponding image from the SDK's asset folder. abstract UnitsetPassioStatusListener(PassioStatusListener statusListener)If not null, the PassioStatusListener will provide callbacks when the internal state of the SDK's configuration process changes. abstract RectFboundingBoxToViewTransform(RectF boundingBox, Integer viewWidth, Integer viewHeight, Integer displayAngle, Boolean barcode)Transforms the bounding box of the camera frame to the coordinates of the preview view where it should be displayed. abstract StringiconURLFor(String passioID, IconSize size)abstract UnitfetchTagsFor(String refCode, Function1<List<String>, Unit> onTagsFetched)abstract UnitfetchInflammatoryEffectData(String refCode, Function1<List<InflammatoryEffectData>, Unit> onResult)abstract UnitsearchForFood(String term, Function2<List<PassioFoodDataInfo>, List<String>, Unit> callback)abstract UnitsearchForFoodSemantic(String term, Function2<List<PassioFoodDataInfo>, List<String>, Unit> callback)abstract UnitfetchFoodItemForDataInfo(PassioFoodDataInfo dataInfo, Double servingQuantity, String servingUnit, Function1<PassioFoodItem, Unit> callback)abstract UnitfetchFoodItemForProductCode(String productCode, Function1<PassioFoodItem, Unit> onResult)abstract UnitfetchFoodItemForPassioID(String passioID, Function1<PassioFoodItem, Unit> onResult)abstract UnitfetchSuggestions(PassioMealTime mealTime, Function1<List<PassioFoodDataInfo>, Unit> callback)abstract UnitfetchMealPlans(Function1<List<PassioMealPlan>, Unit> callback)abstract UnitfetchMealPlanForDay(String mealPlanLabel, Integer day, Function1<List<PassioMealPlanItem>, Unit> callback)abstract UnitrecognizeSpeechRemote(String text, Function1<List<PassioSpeechRecognitionModel>, Unit> callback)abstract UnitrecognizeImageRemote(Bitmap bitmap, PassioImageResolution resolution, String message, Function1<List<PassioAdvisorFoodInfo>, Unit> callback)abstract UnitfetchFoodItemForRefCode(String refCode, Function1<PassioFoodItem, Unit> callback)abstract UnitfetchFoodItemLegacy(String passioID, Function1<PassioFoodItem, Unit> callback)abstract UnitrecognizeNutritionFactsRemote(Bitmap bitmap, PassioImageResolution resolution, Function1<PassioFoodItem, Unit> callback)abstract UnitfetchHiddenIngredients(String foodName, Function1<PassioResult<List<PassioAdvisorFoodInfo>>, Unit> callback)abstract UnitfetchVisualAlternatives(String foodName, Function1<PassioResult<List<PassioAdvisorFoodInfo>>, Unit> callback)abstract UnitfetchPossibleIngredients(String foodName, Function1<PassioResult<List<PassioAdvisorFoodInfo>>, Unit> callback)abstract UnitsetAccountListener(PassioAccountListener listener)abstract PassioStatusgetPassioStatus()abstract BooleanupdateLanguage(String languageCode)abstract UnitreportFoodItem(String refCode, String productCode, List<String> notes, Function1<PassioResult<Boolean>, Unit> callback)abstract UnitsubmitUserCreatedFoodItem(PassioFoodItem foodItem, Function1<PassioResult<Boolean>, Unit> callback)abstract UnitpredictNextIngredients(List<String> currentIngredients, Function1<List<PassioFoodDataInfo>, Unit> callback)abstract UnitfetchUltraProcessingFoodRating(PassioFoodItem foodItem, Function1<PassioResult<PassioUPFRating>, Unit> callback)abstract UnitgenerateMealPlan(String request, Function1<PassioResult<PassioGeneratedMealPlan>, Unit> callback)abstract UnitgenerateMealPlanPreview(String request, Function1<PassioResult<PassioGeneratedMealPlan>, Unit> callback)-
-
Method Detail
-
configure
abstract Unit configure(PassioConfiguration passioConfiguration, Function1<PassioStatus, Unit> onComplete)
Initializes the SDK with the given passioConfiguration. See PassioConfiguration for more information on the different types of SDK configuration. The initialization process includes downloading or reading a cached version of the license and loading the models into the TensorFlowLite runner. This process is being executed on a background thread, but the callback with the result of the configuration process will be called on the main thread. You may call startCamera or startFoodDetection before this method, there is no need to wait the onComplete callback.
- Parameters:
passioConfiguration- the input configuration for the SDK.onComplete- the callback that will be called at the end of the configuration process with the result in the form of the {@link ai.passio.passiosdk.core.config.
-
isSDKReady
abstract Boolean isSDKReady()
Checks whether the SDK initialization ran to completion. The initialization process starts with the configure function.
-
startCamera
abstract Unit startCamera(PassioCameraViewProvider passioCameraViewProvider, Integer displayRotation, Integer cameraFacing, Boolean tapToFocus, Function1<PassioCameraData, Unit> onCameraReady)
Starts the camera preview with the given PassioCameraViewProvider. Using CameraX (https://developer.android.com/training/camerax), the camera system will start rendering the frames onto the PreviewView. Also this method binds the camera with the lifecycle provider of the CameraViewProvider. When that lifecycle provider calls onStart() the camera preview will start and when it calls onStop() the camera preview will stop and start the shutdown process. android.view.Surface.ROTATION_
- Parameters:
passioCameraViewProvider- provides the PreviewView to render the camera frames, the lifecycle holder which will start and stop the camera, and also the context provider needed to open the camera.displayRotation- if the orientation changes are enabled, use this parameter to notify the camera of the display rotation.tapToFocus- set true to enable a tap listener on the passioCameraViewProvider's PreviewView that will start a manual focus operation.
-
startCamera
abstract Unit startCamera(PassioCameraViewProvider viewProvider, PassioCameraConfigurator configurator)
-
stopCamera
abstract Unit stopCamera()
-
enableFlashlight
abstract Unit enableFlashlight(Boolean enabled)
Turns the device's flashlight on or off.
- Parameters:
enabled- if enabled is set to true, it will turn the flashlight on.
-
setCameraZoomLevel
abstract Unit setCameraZoomLevel(Float zoomLevel)
-
getMinMaxCameraZoomLevel
abstract Pair<Float, Float> getMinMaxCameraZoomLevel()
-
takePicture
abstract Unit takePicture(Function1<Bitmap, Unit> onResult)
-
runFrameEvery
abstract Unit runFrameEvery(Long timeForAnalysis)
Sets the time between each analyzed frame. For example, it the timeForAnalysis is set to 500L (0.5 seconds), the camera engine will analyze 2 frames per second. If set to 0L, the camera will analyze frames as fast as possible. If the time is smaller than the time it takes to analyze and process the frame, the SDK will work as if set to 0L. The default is set to 1000L (1 second).
- Parameters:
timeForAnalysis- the time passed between two frames that are being analyzed.
-
shutDownPassioSDK
Unit shutDownPassioSDK()
Finalizes the PassioSDK instance. Deallocates the memory reserved for TFLite models, transformation matrices and shuts down all the background queues that power the SDK. To run the SDK again, configure must be called.
-
startFoodDetection
@Deprecated(message = Local model detection is no longer supported, replaceWith = @ReplaceWith(imports = {}, expression = recognizeImageRemote), level = DeprecationLevel.WARNING) abstract Boolean startFoodDetection(FoodRecognitionListener foodRecognitionListener, FoodDetectionConfiguration detectionConfig)
Registers a listener for the food detection process. The results will be returned at a frequency defined in the FoodDetectionConfiguration.framesPerSecond field.
- Parameters:
foodRecognitionListener- the interface that serves as a callback for the recognition results.detectionConfig- an object that defines what to recognize, how often, and other recognition properties.
-
stopFoodDetection
@Deprecated(message = Local model detection is no longer supported, replaceWith = @ReplaceWith(imports = {}, expression = recognizeImageRemote), level = DeprecationLevel.WARNING) abstract Boolean stopFoodDetection()
Stops the food detection process. After this method is called no results should be delivered to a previously registered FoodRecognitionListener.
-
lookupIconsFor
abstract Pair<Drawable, Drawable> lookupIconsFor(Context context, String passioID, IconSize iconSize, PassioIDEntityType type)
-
fetchIconFor
abstract Unit fetchIconFor(Context context, String passioID, IconSize iconSize, Function1<Drawable, Unit> callback)
For a given PassioID returns the corresponding image from the SDK's asset folder.
- Parameters:
context- used to open assetspassioID- key to find the image
-
setPassioStatusListener
abstract Unit setPassioStatusListener(PassioStatusListener statusListener)
If not null, the PassioStatusListener will provide callbacks when the internal state of the SDK's configuration process changes. Passing null will unregister the listener.
-
boundingBoxToViewTransform
@Deprecated(message = Local model detection is no longer supported, replaceWith = @ReplaceWith(imports = {}, expression = recognizeImageRemote), level = DeprecationLevel.WARNING) abstract RectF boundingBoxToViewTransform(RectF boundingBox, Integer viewWidth, Integer viewHeight, Integer displayAngle, Boolean barcode)
Transforms the bounding box of the camera frame to the coordinates of the preview view where it should be displayed.
- Parameters:
boundingBox- the bounding box from the ObjectDetectionCandidate.viewWidth- the width of the camera preview view.viewHeight- the height of the camera preview view.displayAngle- the rotation of the camera preview view.barcode- does the bounding box belong to the barcode candidate.
-
iconURLFor
abstract String iconURLFor(String passioID, IconSize size)
-
fetchTagsFor
abstract Unit fetchTagsFor(String refCode, Function1<List<String>, Unit> onTagsFetched)
-
fetchInflammatoryEffectData
abstract Unit fetchInflammatoryEffectData(String refCode, Function1<List<InflammatoryEffectData>, Unit> onResult)
-
searchForFood
abstract Unit searchForFood(String term, Function2<List<PassioFoodDataInfo>, List<String>, Unit> callback)
-
searchForFoodSemantic
abstract Unit searchForFoodSemantic(String term, Function2<List<PassioFoodDataInfo>, List<String>, Unit> callback)
-
fetchFoodItemForDataInfo
abstract Unit fetchFoodItemForDataInfo(PassioFoodDataInfo dataInfo, Double servingQuantity, String servingUnit, Function1<PassioFoodItem, Unit> callback)
-
fetchFoodItemForProductCode
abstract Unit fetchFoodItemForProductCode(String productCode, Function1<PassioFoodItem, Unit> onResult)
-
fetchFoodItemForPassioID
abstract Unit fetchFoodItemForPassioID(String passioID, Function1<PassioFoodItem, Unit> onResult)
-
fetchSuggestions
abstract Unit fetchSuggestions(PassioMealTime mealTime, Function1<List<PassioFoodDataInfo>, Unit> callback)
-
fetchMealPlans
abstract Unit fetchMealPlans(Function1<List<PassioMealPlan>, Unit> callback)
-
fetchMealPlanForDay
abstract Unit fetchMealPlanForDay(String mealPlanLabel, Integer day, Function1<List<PassioMealPlanItem>, Unit> callback)
-
recognizeSpeechRemote
abstract Unit recognizeSpeechRemote(String text, Function1<List<PassioSpeechRecognitionModel>, Unit> callback)
-
recognizeImageRemote
abstract Unit recognizeImageRemote(Bitmap bitmap, PassioImageResolution resolution, String message, Function1<List<PassioAdvisorFoodInfo>, Unit> callback)
-
fetchFoodItemForRefCode
abstract Unit fetchFoodItemForRefCode(String refCode, Function1<PassioFoodItem, Unit> callback)
-
fetchFoodItemLegacy
abstract Unit fetchFoodItemLegacy(String passioID, Function1<PassioFoodItem, Unit> callback)
-
recognizeNutritionFactsRemote
abstract Unit recognizeNutritionFactsRemote(Bitmap bitmap, PassioImageResolution resolution, Function1<PassioFoodItem, Unit> callback)
-
fetchHiddenIngredients
abstract Unit fetchHiddenIngredients(String foodName, Function1<PassioResult<List<PassioAdvisorFoodInfo>>, Unit> callback)
-
fetchVisualAlternatives
abstract Unit fetchVisualAlternatives(String foodName, Function1<PassioResult<List<PassioAdvisorFoodInfo>>, Unit> callback)
-
fetchPossibleIngredients
abstract Unit fetchPossibleIngredients(String foodName, Function1<PassioResult<List<PassioAdvisorFoodInfo>>, Unit> callback)
-
setAccountListener
abstract Unit setAccountListener(PassioAccountListener listener)
-
getPassioStatus
abstract PassioStatus getPassioStatus()
-
updateLanguage
abstract Boolean updateLanguage(String languageCode)
-
reportFoodItem
abstract Unit reportFoodItem(String refCode, String productCode, List<String> notes, Function1<PassioResult<Boolean>, Unit> callback)
-
submitUserCreatedFoodItem
abstract Unit submitUserCreatedFoodItem(PassioFoodItem foodItem, Function1<PassioResult<Boolean>, Unit> callback)
-
predictNextIngredients
abstract Unit predictNextIngredients(List<String> currentIngredients, Function1<List<PassioFoodDataInfo>, Unit> callback)
-
fetchUltraProcessingFoodRating
abstract Unit fetchUltraProcessingFoodRating(PassioFoodItem foodItem, Function1<PassioResult<PassioUPFRating>, Unit> callback)
-
generateMealPlan
abstract Unit generateMealPlan(String request, Function1<PassioResult<PassioGeneratedMealPlan>, Unit> callback)
-
generateMealPlanPreview
abstract Unit generateMealPlanPreview(String request, Function1<PassioResult<PassioGeneratedMealPlan>, Unit> callback)
-
-
-
-