0% found this document useful (0 votes)
3 views

vehicle-automatic-control-system-autonomous-vehicle-driven-by-image-processing-in-adruino-and-python-programming

The document presents a project on developing an autonomous vehicle using image processing with Arduino and Python programming. It covers the introduction to self-driving cars, lane-keeping assistance, and the necessary hardware and software components involved in the project. The conclusion highlights the project's success in lane detection, while acknowledging limitations in handling turns and the need for future improvements.

Uploaded by

Hữu Phát Hồ
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

vehicle-automatic-control-system-autonomous-vehicle-driven-by-image-processing-in-adruino-and-python-programming

The document presents a project on developing an autonomous vehicle using image processing with Arduino and Python programming. It covers the introduction to self-driving cars, lane-keeping assistance, and the necessary hardware and software components involved in the project. The conclusion highlights the project's success in lane detection, while acknowledging limitations in handling turns and the need for future improvements.

Uploaded by

Hữu Phát Hồ
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

HO CHI MINH CITY UNIVERSITY OF TE CHNOLOGY AND EDUCATION

FACULTY FOR HIGH QUALITY TRAINING

VEHICLE AUTOMATIC CONTROL SYSTEM

AUTONOMOUS VEHICLE DRIVEN BY IMAGE PROCESSING IN ADRUINO


AND PYTHON PROGRAMMING

LE MINH NHAT 19144056

VU TRAN QUANG DUY 19145169


NGUYEN LAM TRUONG SON 19145175

HO DUONG DUY ANH 19145164

Major: AUTOMOTIVE ENGINEERING TECHNOLOGY

LECTURER: LE THANH PHUC, Ph.D

Ho Chi Minh City, May 2022


THE SOCIALIST REPUBLIC OF VIETNAM
Independence – Freedom– Happiness
--------

Ho Chi Minh City, May 2022

COURSE PROJECT ASSIGNMENT

Student name: Student ID:

Major: Automotive engineering Class: 19145CLA3,4______________


Advisor: Phone number: ________________

Date of assignment: Date of submission: _____________


_____________________

1. Project title: _________________________________________________________

2. Initial materials provided by the advisor: __________________________________

3. Content of the project: ________________________________________________

4. Final product: ________________________________________________________

CHAIR OF THE PROGRAM ADVISOR


(Sign with full name) (Sign with full name)
CONTENTS
ABSTRACT.........................................................................................................................................5
TARGET...............................................................................................................................................5
1. INTRODUCTION............................................................................................................................1
1.1. Self-driving car..........................................................................................................................1
1.2. Lane keeping assistance............................................................................................................1
2. LITERATURE REVIEW.................................................................................................................1
2.1. Adruino......................................................................................................................................1
2.2. Python, Open cv.........................................................................................................................1
2.3 The Hough Transform................................................................................................................2
2.4 Canny..........................................................................................................................................2
3. MODELING.....................................................................................................................................3
3.1. Hardware...................................................................................................................................3
3.1.1 Adruino UNO......................................................................................................................3
3.1.2 L-298N................................................................................................................................5
3.1.3 Motors: 3V-9V geared motor...............................................................................................6
3.1.4 Electric Wires......................................................................................................................7
3.1.5 Camera.................................................................................................................................7
3.1.6 Battery and battery tray.......................................................................................................8
3.2 Software..................................................................................................................................9
3.2.1 Python codes......................................................................................................................10
3.2.2 Adruino codes....................................................................................................................11
4. CONCLUSION..........................................................................................................................12
LIST OF ACRONYMS

ROI Region Of Interest


ATM ATEMEGA
LIST OF FIGURES
Figure 1. The normal coordinate.

Figure 2. The Hough Space.

Figure 3. The structure of cv2.line[4]

Figure 4. Image through Canny.

Figure 5. The structure of cv2.Canny[5]

Figure 6. Component of model. [6]

Figure 7. Arduino Vehicle Mainboard. [7]

Figure 8. L-298N. [9]

Figure 9. motor 3~9V[11].

Figure 10. the wires

Figure 11. Camera

Figure 12. Battery tray

Figure 13. Battery

Figure 14. Model

Figure 15. Import library codes

Figure 16. Color conversion codes

Figure 17. ROI codes

Figure 18. display lines code

Figure 19. Call “def-name” code

Figure 20. Declare to Arduino board

Figure 21. Set pins to output

Figure 22. Setting for car go straight

Figure 23. Setting for car turn right

Figure 24. Setting for car turn left


LIST OF TABLES
Table 1. UNO Adruino Specifications[8]
Table 2. L-298N specification[10]
ABSTRACT
During driving, people use their optical vision to control the vehicle. The line acts as a
projection continuum for the vehicle. One of the prerequisites for an automated car is the
development of an Auto Detection system. Computer vision is a technology that can
allow cars to understand their surroundings. It is a branch of artificial intelligence that
allows software to capture the content of images and videos. Modern computer vision has
come a long way thanks to advances in deep learning, allowing it to recognize different
objects in images by examining and comparing millions of examples and cleaning up
accurate live patterns. define each object.
Although effective specifically for these types of tasks, deep learning must have limited
importance and can fail in unpredictable ways. This means that a drive less vehicle could
load onto a truck during the day or worse, accidentally hit a rider. Currently, tablets used
in autonomous vehicles are also vulnerable to adversaries, by manipulating the AI's
channel headers to make it error.
TARGET
Using computer vision techniques in Python, we will identify road lane lines in which
autonomous cars must run. This will be a critical part of autonomous cars, as the self-
driving cars should not cross it’s lane and should not go in opposite lane to avoid
accidents.
1. INTRODUCTION
1.1. Self-driving car
A self-driving vehicle is a sort of vehicle that needn't bother with an individual to work it.
It utilizes progressed tactile innovation like Lidar, Sonar, GPS, radar, or inertial
estimations to distinguish natural changes and adjust to re-establish safe speed or
distance.
The most important system in an autonomous vehicle is the lane-keeping assist system.

1.2. Lane keeping assistance


Lane-keeping Assistance is a type of driver assistance system that provides the driver
with lane-keeping and lane-keeping warning features when the vehicle begins to leave the
assigned lane. LAS recognizes lane markers using the windshield camera .
Image processing is a method to perform some operations on an image, in order to get an
enhanced image or to extract some useful information from it. It is a type of signal
processing in which input is an image and output may be image or characteristics/features
associated with that image. Nowadays, image processing is among rapidly growing
technologies. It forms core research area within engineering and computer science
disciplines too.
Image processing basically includes the following three steps:
Importing the image via image acquisition tools;
Analysing and manipulating the image;
Output in which result can be altered image or report that is based on image analysis.
2. LITERATURE REVIEW
2.1. Adruino
Arduino is an open-source electronics platform based on easy-to-use hardware and
software.[1] It can be used for controlling the models. Moreover, this software can connect
and process through many software, like OpenCV with many languages programming.
2.2. Python, OpenCV
Python is a language programming likes C,C++ or C#,… Its help the users have the new
language to run the programme, writting the game, websites or something else. Besides,
Python can receive the signal and send process to boards, such as: Arduino board,…
Especially, with the proliferation of the internet, python help coders can write the new
programme more and more easier than the past.
OpenCV is a tool that help the user can communicate between Python and Arduino. From
that, the users can easily code and put the new commands for Arduino to experiment.
2.3 The Hough Transform
- This state detect lane or lines follow Hough Transform. After using this command, we
need to transform from normal lines with normal coordinate lines from y=mx+b to the
new coordinate axes.

1
Figure 1. The normal coordinate.

Figure 2. The Hough Space.

2
Figure 3. The structure of cv2.line[4]
2.4 Canny
Canny() Function in OpenCV is used to detect the edges in an image. From the image we
have, through Canny, the image will show the special lines and changes it more white.

Figure 4. Image through Canny.

3
Figure 5. The structure of cv2.Canny[5]

3. MODELING
3.1. Hardware

Figure 6. Component of model. [6]


In order to make a model car for this project, we use a chassis which is made of plastic
and specific for study.
3.1.1 Adruino UNO
The Arduino UNO is a micro-processing board based on the ATmega328P. It has 14
digital input/output pins, six analog inputs, a 16 MHz ceramic resonator, a USB port, a
power connection, an ICSP header, and a reset button.

4
Figure 7. Arduino Vehicle Mainboard. [7]
The Arduino UNO's technical specs:

Table 1. UNO Adruino Specifications[8]

5
3.1.2 L-298N

Figure 8. L-298N. [9]


The L298N Motor Driver Module is a high-performance motor driver for DC and Stepper
Motors. An L298 motor driver IC and a 78M05 5V regulator make up this module. Up to
four DC motors can be controlled by the L298N Module, or two DC motors with
directional and speed control.
L298N Module specs:

Table 2. L-298N specification[10]


6
3.1.3 Motors: 3V-9V geared motor

Figure 9. motor 3~9V[11]


Motor specifications:
- Operating voltage: 3V~ 9V DC (Works best from 6 - 8V).
- Maximum torque: 800g.
- Scale: 1:48 (3V).
- No-load speed: 125 rpm (3V) (With 66mm wheel: 26m/1min).
- 208 RPM (5V) (With 66mm wheel: 44m/1min).
- No-load current: 70mA (250mA MAX).
3.1.4 Electric Wires

We will utilize electric wires to link the model car's electrical components. Because these
components operate at low voltage, we just need to utilize wire with a tiny diameter.

7
Figure 10. the wires
3.1.5 Camera

Figure 11. Camera


To capture the lane of the road for the self-driving car, we use the camera to take a photos
and analyze them by Opencv for controlling the motors.
3.1.6 Battery and battery tray

8
Figure 12. Battery tray

Figure 13. Battery


To ensure the power supplied of the model we use two 3.7v rechargeable batteries.
And then we have installed into a complete model

9
Figure 14. Model
3.2 Software
3.2.1 Python codes

Figure 15. Import library codes


- Firstly, we use the cv2 and numpy to declare the library.

Figure 16. Color conversion codes

We define a function for bluring the image to easily detech the line and change the photo
to the canny form.

10
Figure 17. ROI codes
Then we choose a region of interest to increase the accuracy of the lane detecting process.

Figure 18. display lines code


The code above help us to display the line of the lane we had detected through camera.

Figure 19. Call “def-name” code


This is the main part of the program, first we import the video from the camera, next we
change it into gray scale and then we call the function we had defined before for image
processing. We also call a function to choose a region of interest .
For drawing the lines we have detected we use Hough line transform and then we call the
function to display the line which is detected camera.
3.2.2 Adruino codes
- Firstly, we need to declare which port connect between L298N and Arduino board.

11
Figure 20. Declare to Arduino board
- Secondly, set all the motor control pins to outputs.

Figure 21. Set pins to output


- Next, codes that send to arduino board, helping the car go follow directions:
+ Going straight:

Figure 22. Setting for car go straight

+ Turning right:

12
Figure 23. Setting for car turn right

+ Turning left:

Figure 24. Setting for car turn left

13
4. CONCLUSION
We succeeded in programming a program that can process images to get lanes; however
the limitation of the project is that we cannot make the program be able to handle left or
right turning. Moreover, we need to be careful about which COM that PC is
communicating with Arduino Board.
On over the world, the level of autonomous vehicle is stopping at the level “2+”, in the
future, this programme will more and more grow up to reach the level “5”, which is
known as the highest level of this programme.

REFERENCE
What is Arduino? : https://www.arduino.cc/en/Guide/Introduction
What is Python? : Edpresso Team https://www.educative.io/edpresso/what-is-python
[3] Line detection in python with OpenCV | Houghline method:
https://www.geeksforgeeks.org/line-detection-python-opencv-houghline-method/?
ref=gcse
[4] Python OpenCV | cv2.line() method: https://www.geeksforgeeks.org/python-opencv-
cv2-line-method/?ref=lbp
[5] Python OpenCV – Canny() Function: https://www.geeksforgeeks.org/python-opencv-
canny
[6] LKRB100 BỘ XE ROBOT THÔNG MINH TRÁNH VẬT CẢN ARDUINO UNO –
SHIELD L298: http://robocon.vn/detail/lkrb100-bo-xe-robot-thong-minh-tranh-vat-can-
arduino-uno-shield-l298.html
[7], [8] Arduino UNO R3 là gì?: http://arduino.vn/bai-viet/42-arduino-uno-r3-la-gi
[9] Mạch Điều Khiển Động Cơ DC L298N : https://nshopvn.com/product/mach-dieu-
khien-dong-co-dc-l298n/
[10] L298N Motor Driver Module: https://components101.com/modules/l293n-motor-
driver-module
[11] Geared DC Motor with Wheels 3V 6V 9V:
https://www.lazada.com.ph/products/geared-dc-motor-with-wheels-3v-6v-9v-12v-dc-
plastic-gear-dynamo-130-dual-shaft-electric-dinamo-diy-arduino-electronic-smart-robot-
2wd-4wd-i216823519.html

14

You might also like