SDK Initialization and Configuration

Two things are required for the SDK to work: a proper license key and the neural network files that the SDK uses to run the recognition process.

  • The license key can be requsted at support@passiolife.com

Android Platform

Android Platform requires .passiosecure files in the assets folder

  • Add .passiosecure files into your android project directory app/src/main/assets. Files that the SDK needs have an extension .passiosecure and are encrypted

SDK Initialization

When your component mounts, configure the SDK using your Passio provided developer key and start food detection.

const [isReady, setIsReady] = useState(false);

// Effect to configure the SDK and request camera permission
useEffect(() => {
  Promise.all([
    PassioSDK.configure({
      key: 'your-developer-key',
      autoUpdate: true,
    }),
    PassioSDK.requestCameraAuthorization(),
  ]).then(([sdkStatus, cameraAuthorized]) => {
    console.log(
      `SDK configured: ${sdkStatus.mode} Camera authorized: ${cameraAuthorized}`,
    );
    setIsReady(sdkStatus.mode === 'isReadyForDetection' && cameraAuthorized);
  });
}, []);

autoUpdate: true : Set to true to enable the download of AI models from Passio's servers.

The possible states of the SDK after calling configure. Switch on sdkStatus.mode to access the data associated with each state.

MODE: notReady, isReadyForDetection and error

notReady : SDK is not ready due to missing model files. Please download the specified file and call configure again, passing in the localFileURLs of the downloaded files.

isReadyForDetection: SDK configured successfully. This status much be reached before calling startFoodDetection

error: SDK failed to configure in an unrecoverable way. Please read the error message for more information

If at any point you need help from the Passio team, please reach out to us at support@passiolife.com

Last updated