HO CHI MINH CITY UNIVERSITY OF TE CHNOLOGY AND EDUCATION FACULTY FOR HIGH QUALITY TRAININGVEHICLE AUTOMATIC CONTROL SYSTEMAUTONOMOUS VEHICLE DRIVEN BY IMAGE PROCESSING IN ADRUINO AND PYT
Trang 1HO 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
Trang 2THE SOCIALIST REPUBLIC OF VIETNAMIndependence – Freedom– Happiness -
Ho Chi Minh City, May 2022COURSE PROJECT ASSIGNMENT
Major: Automotive engineering Class: 19145CLA3,4
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
(Sign with full name) (Sign with full name)ADVISOR
Trang 3ABSTRACT 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
Trang 4LIST OF ACRONYMS
Trang 5LIST OF FIGURESFigure 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 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
Trang 6LIST OF TABLESTable 1 UNO Adruino Specifications[8]
Table 2 L-298N specification[10]
Trang 7During driving, people use their optical vision to control the vehicle The line acts as aprojection continuum for the vehicle One of the prerequisites for an automated car is thedevelopment of an Auto Detection system Computer vision is a technology that canallow cars to understand their surroundings It is a branch of artificial intelligence thatallows software to capture the content of images and videos Modern computer vision hascome a long way thanks to advances in deep learning, allowing it to recognize differentobjects in images by examining and comparing millions of examples and cleaning upaccurate live patterns define each object
Although effective specifically for these types of tasks, deep learning must have limitedimportance and can fail in unpredictable ways This means that a drive less vehicle couldload 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'schannel headers to make it error
TARGET
Using computer vision techniques in Python, we will identify road lane lines in whichautonomous 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 avoidaccidents
Trang 81 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 inertialestimations to distinguish natural changes and adjust to re-establish safe speed ordistance
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 driverwith lane-keeping and lane-keeping warning features when the vehicle begins to leave theassigned 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 anenhanced image or to extract some useful information from it It is a type of signalprocessing in which input is an image and output may be image or characteristics/featuresassociated with that image Nowadays, image processing is among rapidly growingtechnologies It forms core research area within engineering and computer sciencedisciplines 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 andsoftware.[1] It can be used for controlling the models Moreover, this software can connectand 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 newlanguage 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 newprogramme more and more easier than the past
OpenCV is a tool that help the user can communicate between Python and Arduino Fromthat, 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
Trang 9Figure 1 The normal coordinate.
Figure 2 The Hough Space
2
Trang 10Figure 3 The structure of cv2.line[4]
Trang 11Figure 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 plasticand specific for study
3.1.1 Adruino UNO
The Arduino UNO is a micro-processing board based on the ATmega328P It has 14digital input/output pins, six analog inputs, a 16 MHz ceramic resonator, a USB port, apower connection, an ICSP header, and a reset button
4
Trang 12Figure 7 Arduino Vehicle Mainboard [7]
The Arduino UNO's technical specs:
Table 1 UNO Adruino Specifications[8]
5
Trang 133.1.2 L-298N
Figure 8 L-298N [9]
The L298N Motor Driver Module is a high-performance motor driver for DC and StepperMotors An L298 motor driver IC and a 78M05 5V regulator make up this module Up tofour DC motors can be controlled by the L298N Module, or two DC motors withdirectional and speed control
L298N Module specs:
Table 2 L-298N specification[10]
6
Trang 143.1.3 Motors: 3V-9V geared motor
- 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 thesecomponents operate at low voltage, we just need to utilize wire with a tiny diameter
7
Trang 15Figure 10 the wires3.1.5 Camera
Trang 16Figure 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
Trang 17Figure 14 Model3.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
Trang 18Figure 17 ROI codesThen we choose a region of interest to increase the accuracy of the lane detecting process.
Figure 18 display lines codeThe code above help us to display the line of the lane we had detected through camera
Figure 19 Call “def-name” codeThis is the main part of the program, first we import the video from the camera, next wechange it into gray scale and then we call the function we had defined before for imageprocessing 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 thefunction 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
Trang 19Figure 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
Trang 20Figure 23 Setting for car turn right
+ Turning left:
Figure 24 Setting for car turn left
13
Trang 214 CONCLUSION
We succeeded in programming a program that can process images to get lanes; howeverthe limitation of the project is that we cannot make the program be able to handle left orright turning Moreover, we need to be careful about which COM that PC iscommunicating with Arduino Board
On over the world, the level of autonomous vehicle is stopping at the level “2+”, in thefuture, this programme will more and more grow up to reach the level “5”, which isknown 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: cv2-line-method/?ref=lbp
https://www.geeksforgeeks.org/python-opencv-[5] Python OpenCV – Canny() Function: canny
https://www.geeksforgeeks.org/python-opencv-[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 : khien-dong-co-dc-l298n/
https://nshopvn.com/product/mach-dieu-[10] L298N Motor Driver Module: driver-module
https://components101.com/modules/l293n-motor-[11] Geared DC Motor with Wheels 3V 6V 9V:
plastic-gear-dynamo-130-dual-shaft-electric-dinamo-diy-arduino-electronic-smart-robot-2wd-4wd-i216823519.html
https://www.lazada.com.ph/products/geared-dc-motor-with-wheels-3v-6v-9v-12v-dc-14