Capture Incoming People or Vehicles With the Raspberry Pi And LIDAR

A motion sensor and a camera attached to the Raspberry Pi connected to the Internet can create a database of people entering a building, the license plates of cars entering a garage, etc.
Motion Detection
The LIDAR sensor wasn’t my first choice when I was looking for a suitable distance sensor. Ultrasonic sensors came to mind first, but they made my solution unusable in some circumstances. Sensors like HC-SR04 (often used with Arduino) are small, simple, and cheap but suitable only for smaller distances, and they can’t fulfill the project’s requirement of detecting objects 6–10 meters away. Outdoor weather-resistant sensors like MB7092 XL-MaxSonar-WRMA1 were good enough to detect regular objects with surfaces like glass, wood, or steel but failed to detect persons wearing various types of clothes. Also, at more considerable distances, people weren’t detected at all at more considerable distances because of the wide pulse range. GARMIN’s LIDAR-Lite v3 sensor (optical with a laser) solved all my problems with precise motion detection in large distances, but it was also the most expensive of all the ones I’ve tried.

Source: buy.garmin.com
How to Select Only Incoming Objects?
Since my use case required handling only specific situations, I had to implement an algorithm to distinguish between incoming objects (getting closer to the sensor) and objects leaving the area. Python script reads values from the sensor with a frequency of 20 Hz, and for better accuracy, it averages a few values in a row to minimize the chance of false positives. Average values are then compared, and their increase or decrease is evaluated. A more excellent value means a more considerable distance, which means an object getting far away. A lower value indicates a smaller distance, so an object is coming closer. After analyzing a few actual situations, I’ve set a minimum difference between values, which must be met to even consider that value.
Capture the Object
The motion sensor serves as a trigger for the camera, taking a photo immediately on command from the motion sensor. The script uploads a photo asynchronously, so no additional detection is missed because of a delay.

Source: raspberrypi.com
Configurability
Every numeric variable in the script is configurable via the user interface provided by the backend application running on a remote server. Minimum and maximum distances, frequency, number of values to average, camera resolution, and other variables can be adjusted remotely to meet the needs of every place where this solution will be used. Thus, for example, places with low-quality internet connections can use a smaller camera resolution to speed up photo uploading.
The Cost of Hardware And Are There Another Options?
The hardware components cost around 200 EUR, which is higher than I expected for this project. That is mainly because of the higher price tag of the LIDAR sensor, but a few cheaper LIDAR sensors exist on the market. Test one piece thoroughly before ordering more to be sure the model fits the use case. Also, the most expensive Raspberry Pi 4 configuration (4GB RAM) was used, so the price can be reduced using a cheaper variant. The Camera Module v2 was the only recommended and official option for Raspberry Pi.
TL;DR
Using the Raspberry Pi, LIDAR sensor, and Camera Module, I’ve built a compact and portable hardware solution for detecting incoming objects such as people and vehicles, photographing them, and uploading them to a remote server. Rich configurability ensures its usability in various places, from small offices to long tunnels. It may sound like a trivial solution, but this project solved real-world issues for the client in the MVP phase. With my team at Touch4IT, we prefer to test the MVP first, so it’s cheaper and faster for our customer, then iteratively improve the solution for final production use.
Do you want to develop something you have no experience with? Do you lack an innovation department or people? We would be more than happy to discuss your situation with you and find the right solution.