Lidar based Lane Detection System using Raspberry Pi

0
56
Lidar based Lane Detection System using Raspberry Pi

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.

lidar-lane-detection-system-1-500x329-8060526
LIDAR-based Lane Detection 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.

raspberry-pi-lane-detection-500x380-2749363
Raspberry Pi Lane Detection System

Bill of Materials

Components Quantity Description Price Approx INR
Nvidia Jetson/Raspberry 14GB Ram 10,000
Webcam/Raspberry Pi cam 1For night vision /5 to 10 MP1000
SD card 132/64 GB 1000
HDMI 7 INCH Display 1HDMI Display 3000
Total 15,000

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

Connection

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.

lane-detection-code-2-500x287-5873612
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.

import subprocess

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

lane-detection-system-project-2-5043864

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.