App Structure

Learn about the structure of an object detection Android app that utilizes a TF Lite model to detect objects in images.

Suppose we want to develop an Android app that asks the user to pick up an image from the device storage and detect objects present in the image. The app utilizes a pretrained TF Lite object detection model.

To develop such an app, we can use the ObjectDetector API of the Task Library within the MainActivity of our Android project. The MainActivity is responsible for displaying the UI, handling user interactions, integrating the ObjectDetector API of the Task Library, extracting the bounding boxes, and displaying the object detection results.

The diagram below shows a possible implementation of the object detection Android app.

Press + to interact
Class diagram of the Android app
Class diagram of the Android app

The class diagram shows the fields (above) and methods (below) of the MainActivity class. A +/- before the name represents public/private fields or methods. In Kotlin, a field refers to a property or variable within a class. It represents the state or data associated with an object of that class. Fields hold values that the class’s methods can access and modify, depending ...