This is a sample application that uses Jetpack Compose, TensorFlow Lite, and the SSD MobileNet model to perform real-time object detection on images.
![]() |
![]() |
---|---|
IMG 1 | IMG 2 |
- Android Studio 4.0 or higher
- Basic knowledge of Jetpack Compose, TensorFlow Lite, and Kotlin
- Clone the object detection application repository.
- Open Android Studio and select "Open an existing project".
- Navigate to the cloned folder and click "OK".
- Wait for Android Studio to sync and build the project.
- Connect your Android device to your computer or use an emulator.
- Run the application from Android Studio.
- Once the application has started on your device, grant the camera permissions.
- The application will automatically start detecting objects in real-time.
If you want to use your own object detection model, follow these steps:
- Place your TensorFlow Lite model file and dataset_labels.txt in the
app/src/main/ml
folder. - Modify the code in the
MainActivity
class to load your custom model. For example:companion object { private const val MODEL_FILE_NAME = "ssd_mobilenet_v1_1_metadata_1.tflite" private const val LABEL_FILE_NAME = "coco_dataset_labels_v1.txt"}
- For newer TensorFlow models, modify the ObjectDetector class. For example:
private val outputMap = mapOf( 0 to outputScores, 1 to outputBoundingBoxes, 2 to outputDetectionNum, 3 to outputLabels)
- Object detection may be slow on older devices.
- Detection accuracy may vary depending on the quality of the model used.
This project is licensed under the MIT License.