Feat: Add Real-time Object Detection with MediaPipe - #108
Conversation
- Replace main SurfaceView with TextureView to support capturing frame Bitmaps via getBitmap(). - Add ObjectDetectorHelper to encapsulate MediaPipe Object Detector Task API with CPU/GPU delegates. - Create OverlayView for scaling and rendering bounding boxes and classification labels onto standard video stream. - Integrate background detection thread execution loop (~10 FPS) in VideoActivity with lifecycle management. - Set up automated downloads for EfficientDet-Lite0 and EfficientDet-Lite2 model assets in app/build.gradle. - Add user menu toggles for object detection settings, persisting config values via SharedPreferences. - Update README.md with detailed instructions for the object detection feature. Reference: https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/object_detection
|
@kkbin505 thank you for the PR! |
That is a valid concern. The current implementation bundles both TFLite models with the app, which increases the APK size. Would it be preferable to keep the models outside the APK and load them from the app’s storage directory instead? The immediate practical scenario is to use the phone’s relatively powerful CPU/GPU for real-time object detection on the receiver side, without adding extra processing load to the air unit. At this stage, the feature is still experimental. A possible longer-term use case would be to expose detection results to an uplink, like MAVLink, so they could be used for assisted tracking. |
Description
Inspired by MarioFPV, I added a object detection function to OpenIPC. Instead of adding this function to the airunit, I added this funtion to the receiver end (PixelPilot) with Google MediaPipe Tasks Vision:
https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/object_detection
Users can now enable detection overlay to visualize bounding boxes, classification labels, and confidence scores directly on top of the live video stream.

Key Changes
1. Build & Dependencies
mediapipe(0.10.29) andgradleDownload(5.5.0) dependencies.downloadModelFile0,downloadModelFile1) to automatically fetchefficientdet-lite0.tfliteandefficientdet-lite2.tflitemodels duringpreBuild.noCompress 'tflite'to optimize model loading performance.2. UI & Rendering Setup
mainVideofromSurfaceViewtoTextureViewto support runtime frame grabbing viagetBitmap(). AddedOverlayViewabove it.configureTextureView()to adapterTextureViewlifecycle events (such as surface creation and destruction) for native decoding.3. Detection Core & Integration
onResume/onPause) to ensure safe thread termination.Manual Verification
https://youtu.be/KQsr3Jk9Ab8