Struggling with Distance Accuracy in AI Project

Hello everyone! I’m working on a project that involves a Raspberry Pi 5 paired with the Hailo AI kit. Our goal is to measure the change in object distance from a fixed camera, particularly vehicles, using only a single camera. Currently, we’re estimating the rate of change in distance and direction by tracking the variations in the x and y coordinates of the objects, which we obtain from bounding boxes. However, we’re finding the results to be quite inaccurate.

I would greatly appreciate any suggestions or methods to enhance the accuracy of our distance measurements. Thank you for your help!

Hey @yeyider245

Welcome to the Hailo Community!

The Hailo AI kit can enhance your distance measurement project on a Raspberry Pi 5 in several ways:

  1. Depth Estimation: Use pre-trained models from the Hailo Model Zoo for monocular depth estimation.

  2. Object Detection: Leverage optimized models like YOLO to detect vehicles and estimate distance based on bounding box size.

  3. Optical Flow: Implement optical flow in your AI pipeline for more accurate motion tracking.

  4. Kalman Filters: Combine Hailo’s AI platform with Kalman filtering for smoother motion estimation.

  5. Real-Time Processing: Optimize inference on Hailo for low-latency performance.

  6. Multi-Model Inference: Run depth estimation and object detection models simultaneously for improved accuracy.

Example code snippet for object detection and distance estimation:

from hailo_platform import VDevice, HEF, ConfigureParams

hef = HEF('path_to_your_detection_model.hef')
vdevice = VDevice()
network_group = vdevice.configure(hef, ConfigureParams.create_from_hef(hef))
runner = network_group.create_runner()

input_tensor = runner.get_input_vstream().create_host_buffers()
output_tensor = runner.get_output_vstream().create_host_buffers()

runner.infer(input_tensor, output_tensor)
bounding_box = output_tensor[0].buffer
distance = known_object_width / bounding_box_width
print(f"Estimated distance: {distance} meters")

These approaches can help improve the accuracy and reliability of your distance measurements. Would you like me to elaborate on any specific aspect?