An Object-Driven Collision Detection with 2D Cameras using Artificial Intelligence and Computer Vision

Yang Liu, Evan Gunnell, Yu Sun, Hao Zheng2022 · DOI

Abstract

Autonomous driving is one of the most popular technologies in artificial intelligence. Collision detection is an important issue in automatic driving, which is related to the safety of automatic driving. Many collision detection methods have been proposed, but they all have certain limitations and cannot meet the requirements for automatic driving. Camera is one of the most popular methods to detect objects. The obstacle detection of the current camera is mostly completed by two or more cameras (binocular technology) or used in conjunction with other sensors (such as a depth camera) to achieve the purpose of distance detection. In this paper, we propose an algorithm to detect obstacle distances from photos or videos of a single camera.

Introduction

In the world of autonomous driving, knowing exactly how far away an obstacle is—collision detection—is a life-or-death requirement. Traditionally, this is solved using binocular (stereo) cameras, which mimic human depth perception, or active sensors like LiDAR and Time-of-Flight (TOF) cameras. However, these solutions come with high costs, complex hardware requirements, and significant computational overhead. Monocular (single-camera) systems are cheaper and simpler but face a fundamental mathematical challenge: a 2D image lacks the depth dimension. This research bridges this gap by proving that a single camera, paired with the right AI models, can infer distance with enough accuracy to be useful for automated systems.

Methodology

The proposed system architecture combines real-time object detection with a distance-estimation heuristic.

System architecture for monocular distance estimation.

The workflow involves several key stages:

  1. Object Detection: The system uses YOLOv5 (You Only Look Once) to identify objects in a frame. YOLOv5 was chosen for its architectural efficiency, utilizing a CSPDarknet backbone for feature extraction and a PANet neck for feature aggregation.
  2. Distance Heuristic: The core idea is based on the "width of screen ratio." As an object moves further away, its perceived width on the screen decreases. The authors argue that width is a more stable metric than height, as camera angles (pitch) can distort height more easily.
  3. Machine Learning Backend: Once the object is detected and its screen-width percentage is calculated, the data is passed to a backend server (built with Python Flask). The authors compared several regressive models to map this width percentage to a physical distance, including Linear Regression, Polynomial Ridge Regression, Random Forest Regression, and ElasticNet Regression.

Experimental Setup

A custom dataset was developed to validate this monocular approach.

  • Objects: Data was collected on three distinct objects with known physical widths: a person (20 inches), a cell phone (6 inches), and a stuffed penguin (13 inches).
  • Hardware: Data was captured using two different camera setups—a Razer Kiyo (4 megapixels) and a Dell G5 integrated camera (0.92 megapixels)—to test if camera quality significantly impacted the results.
  • Labels: The dataset included the camera type, object type, screen width percentage, and the ground-truth distance in feet.

Discussion and Key Insights

  • The "Prior Knowledge" Advantage: Much like a human can estimate distance with one eye closed because they know the approximate size of a car or a person, the model uses the known dimensions of recognized objects to "solve" for depth.
  • Width Over Height: Utilizing width fixes potential issues with camera angles. If a camera is tilted up or down, the perceived height of an object changes, but the perceived width remains relatively consistent.
  • Feature Dominance: Feature importance analysis revealed that the percentage of screen width is the overwhelmingly dominant factor in predicting distance. Interestingly, the specific camera type and the specific object type had a much lower impact on the prediction accuracy than expected.
  • Non-Linearity at Distance: The relationship between screen width and distance is not perfectly linear. As objects get further away, the change in screen width becomes miniscule, making it harder for models to differentiate between large distances (e.g., 20 feet vs. 30 feet).

Results

The study performed a comparative analysis of various machine learning models using cross-validation scores:

  • Top Performer: Random Forest Regression (depth=2) achieved the highest accuracy score, proving most suitable for the non-linear nature of the data.
  • Linear vs. Polynomial: While Linear Regression worked well for close-range objects, it struggled as distance increased. Polynomial Ridge Regression performed poorly in this specific implementation.
  • Worst Performer: ElasticNet Regression yielded the lowest scores among the tested models.
  • Qualitative Finding: The system successfully demonstrated that it could return real-time distance estimates to a display screen, dynamically updating as the object moved within the frame.

Conclusion and Future Work

While promising, several areas for improvement remain:

  • Dataset Threshold: The current study uses a relatively small training set. Future work will evaluate the "sufficient threshold" of data needed to maximize accuracy.
  • Distance Plateau: For small objects, the width percentage stops changing significantly after a certain distance, leading to a "no change" zone where the model cannot accurately predict depth.
  • Deep Learning Integration: Future work will explore using deep learning specifically for the depth-prediction component and investigating how varied camera parameters (focal length, aperture) can be better integrated into the model.

Summary updated

Abstract

Autonomous driving is one of the most popular technologies in artificial intelligence. Collision detection is an important issue in automatic driving, which is related to the safety of automatic driving. Many collision detection methods have been proposed, but they all have certain limitations and cannot meet the requirements for automatic driving. Camera is one of the most popular methods to detect objects. The obstacle detection of the current camera is mostly completed by two or more cameras (binocular technology) or used in conjunction with other sensors (such as a depth camera) to achieve the purpose of distance detection. In this paper, we propose an algorithm to detect obstacle distances from photos or videos of a single camera.
BibTeX
@misc{liu2022object,
  author = {Yang Liu and Evan Gunnell and Yu Sun and Hao Zheng},
  title = {{An Object-Driven Collision Detection with 2D Cameras using Artificial Intelligence and Computer Vision}},
  year = {2022},
  doi = {10.5121/csit.2022.120626},
}
Figure