This is the second part of the project and here we are going to design Lidar-based Lane Detection System using Raspberry Pi.
In the previous part, we designed the LIDAR-based surrounding mapping and Anti-collision system for our ADAS system so we will carry forward the design for the detection of cars and road lanes for the ADAS system.
In the last design, we used the Raspberry Pi for that but here you can switch to Automotive grade SBC or Nvidia Jetson if you are making it for learning then you can use a raspberry pi as well. So in addition to the components needed in the previous project, we need to get a few more components listed in the bill of material.
Bill of Materials
|Components||Quantity||Description||Price Approx INR|
|Nvidia Jetson/Raspberry||1||4GB Ram||10,000|
|Webcam/Raspberry Pi cam||1||For night vision /5 to 10 MP||1000|
|SD card||1||32/64 GB||1000|
|HDMI 7 INCH Display||1||HDMI Display||3000|
NOTE:- You can also use a Raspberry Pi with 2GB or 4GB of ram and I am using here the NVIDIA Jetson just for Automotive grade requirement
For the vehicle get the 5V 4 amps power output from the vehicle. If masking for testing only, then you can power the NVIDIA JETSON with 5V 2A USB cables.
Now we need to connect the camera to NVIDIA JETSON. Here you can either use a ribbon cable-based CSI camera or any USB camera.
Next, connect the Nvidia jetson with the HDMI display and power that display with USB power. And for lidar connection, you can refer to the previous article on this series of ADAS designs.
Lane Detection System – Code
I assumed you have already prepared the NVIDIA Jetson with OS and Python environment; if not, then do that using the instruction at the following link.
Now first we need to install the open CV for processing the image needed in our ADAS system. using the linex terminal and then we install the number processing the numbers
sudo pip3 install opencv
sudo pip3 install numpy
Now after installing the modules, we are ready to code.
First, we import the numpy and OpenCV, then we set the camera for making the video frame using OpenCV, then we create the loop function for processing the video frames and then detect the edges, land pedestrians, and cars.
Now we display the processed frame in a loop on the HDMI display we have connected to.
Combining the Anti-collision System and Lane Detection System for ADAS
As we already have made the code to use lidar to map surroundings and view the map in real-time and alert the driver when any obstacle comes very closer to the car to avoid accidents. So now combining both codes with running at the same time shows the LIDAR map and Lane detection video on HDMI display attached to the car dashboard.
subprocess.run(python3 script1.py & python3 script2, sell = True)
To do that, we use the Python subprocess and create another code that runs both Python scripts simultaneously.
Lane Detection System Testing
Now after connecting the LIDAR, CAMERA, and Powering the Nvidia Jetson we run the ADAS Python script, and now we can see the output on the HDMI screen.