Food Quantity Detection

Capture a depth-based image sequence around food items to estimate their quantities accurately using the LogMeal Depth SDKs and Quantity Detection API.

IMPORTANT: Before integrating this use case we highly recommend integrating the Regular Image Food Recognition procedure.

What You’ll Build

You’ll implement a depth-based food quantity detection flow where your app captures a set of images or videos around food items using the LogMeal Depth SDK, validates device compatibility, and submits the captured data to the Food Quantity Detection API.

This use case enables automatic estimation of food portions and volume from real-world meals, improving dietary tracking, nutritional reporting, and food waste analysis.


Prerequisites

  • Plan: Recommend and above (see more info about LogMeal Plans)
  • User type: 🔴 APIUser (see more info about User Types)
  • Integrated LogMeal Depth SDK (iOS or Android)
  • Device with depth-sensing camera (ARCore or LiDAR capable)

SDK Access

The LogMeal Depth SDK is available for both mobile platforms:

If you are using React Native for your App implementation, you can integrate our ready-to-use LogMeal Depth React Native SDK module, which works for both iOS and Android.

Device Compatibility Check

Not all devices support depth-based quantity estimation. Before starting capture, verify device compatibility using the provided utilities:

Devices that fail compatibility checks should default to using the Regular Image Food Recognition procedure.


Sequence Diagrams

Main Flow (Depth Image Capture + Quantity Detection)

sequenceDiagram
  participant User
  participant App
  participant LogMeal API

  User->>App: Initiate capture session
  App->>App: Validate device compatibility (LogMealDepthUtils / ArCoreUtils)
  App->>User: Prompt user to move device 180º around food
  User->>App: Capture image sequence (Depth SDK)
  App->>LogMeal API: POST /image/segmentation/complete/quantity <br> (Authorization + captured data)
  LogMeal API-->>App: 200 OK (imageId, segmentation results, quantity data)
  App-->>User: Display items and estimated food quantity

Fallback Flow (Non-Compatible Device)

sequenceDiagram
  participant User
  participant App
  participant LogMeal API

  App->>App: Check device compatibility (Depth SDK)
  App-->>User: Notify device not supported ⚠️
  App->>LogMeal API: POST /image/segmentation/complete <br> (Standard segmentation)
  LogMeal API-->>App: 200 OK (segmentation results)
  App-->>User: Show regular segmentation results

Implementation Guide

Integration and Capture Steps

  1. Access the SDK – Download the appropriate SDK (iOS or Android) and carefully review its documentation before integration.

  2. Check device compatibility – Ensure the user’s device supports depth estimation. If not, fall back to regular segmentation.

  3. Capture image sequence – Instruct users to:

    • Initiate capture manually.
    • Perform a slow 180º movement around the food (at least 150º coverage) while keeping the camera pointed toward it.
    • Wait for the SDK to signal successful capture.
  4. Send captured data – Once capture completes, upload the sequence using one of the supported API endpoints.

Related Endpoints

Remember to check applicable request limitations inside each of the endpoints.


Common Pitfalls & Tips

  • Always check compatibility: If a device doesn’t support the SDK, revert to segmentation.
  • User motion: Ensure users perform full 180º arcs; shorter movements reduce accuracy.
  • Lighting: Recommend bright, diffuse lighting to enhance image quality.
  • File size: Keep each frame below 1 MB for optimal performance.
  • Communication: Clearly guide users during capture; incorrect movement patterns degrade accuracy.

Optional Enhancements

  • Combine results with Nutritional Analysis for energy and macro estimation.
  • Add pre- and post-meal captures to enable Waste Estimation workflows.
  • Integrate capture tutorials or overlay animations directly in your mobile UI.

Next Steps