VIETNAM NATIONAL UNIVERSITY HO CHI MINH CITY HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY NGUYEN NGOC TRUC STUDY ON CAMERA-BASED REAL-TIME CAR SPEED MORNITOR USING YOLOv5 MULTIPLE OBJECT DETECTION MODEL Major: Vehicle Engineering Major code: 8520116 MASTER’S THESIS HO CHI MINH CITY, July 2023 THIS THESIS IS COMPLETED AT HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY – VNU-HCM Supervisor: Trần Đăng Long, Ph.D Examiner 1: Trần Hữu Nhân, Ph.D Examiner 2: Nguyễn Văn Trạng, Ph.D This master’s thesis is defended at HCM City University of Technology, VNU- HCM City on July 15th, 2023 Master’s Thesis Committee: 1. Chairman: Lê Tất Hiển Assoc. Member: Võ Tấn Châu, Ph. Secretary: Hồng Đức Thông, Ph.
Reviewer 1: Trần Hữu Nhân, Ph. Reviewer 2: Nguyễn Văn Trạng, Ph.D Approval of the Chairman of Master’s Thesis Committee and Dean of Faculty of Transportation Engineering after the thesis being corrected (If any). CHAIRMAN OF THESIS COMMITTEE HEAD OF FACULTY OF TRANSPORTATION ENGINEERING i VIETNAM NATIONAL UNIVERSITY HO CHI MINH CITY SOCIALIST REPUBLIC OF VIETNAM HO CHI MINH CITY Independence – Freedom - Happiness UNIVERSITY OF TECHNOLOGY THE TASK SHEET OF MASTER’S THESIS Full name: Nguyễn Ngọc Trực Studen code: 2170108 Date of Birth: 30/07/1996 Place of birth: Đăk Lăk Major: Vehicle Engineering Major code: 8520116 I. THESIS TOPIC: Study on camera-based real-time car speed monitor using YOLOv5 multiple object detection model.
ĐỀ TÀI LUẬN VĂN : Nghiên cứu ứng dụng mô hình YOLOv5 nhận diện đa vật thể trong ảnh cho hệ thống giám sát tốc độ xe bằng camera theo thời gian thực. TASKS AND CONTENTS: - Develop a traffic sign recognition system, specifically for speed limit signs, from images captured by cameras on the road. - Employ the Jetson Nano embedded computer as the central processing unit to run the YOLOv5 model for detecting speed limit signs. Simultaneously, compare the sign recognition results with the vehicle's current speed accessed from the OBD-II system.
Subsequently, the system provides a direct alert to the driver on the screen if the speed limit is exceeded. TASKS STARTING DATE: February 06th, 2023. TASKS ENDING DATE: June 12th 2023. INSTRUCTOR: Trần Đăng Long, Ph.
Ho Chi Minh City, July 15th 2023. INSTRUCTOR HEAD OF DEPARTMENT (Full name & Signature) (Full name & Signature) DEAN - FACULTY OF TRANSPORTATION ENGINEERING (Full name & Signature) ii ACKNOWLEDGEMENT I would like to express my heartfelt gratitude to my thesis advisor, Ph.D Tran Dang Long, for his invaluable guidance, unwavering support, and continuous encouragement throughout the entire duration of this thesis. His expertise, insightful feedback, and constructive criticism have immensely contributed to the success of this research endeavor. I am also deeply grateful to Ho Nam Hoa, for his assistance and collaboration in helping me establish the OBD-II CAN communication.
His technical knowledge, dedication, and willingness to share his expertise have been instrumental in overcoming challenges and achieving significant milestones in this project. Furthermore, I extend my sincere appreciation to my friend, Bui Huu Nghia, for his valuable contribution in collecting the dataset. His commitment, attention to detail, and assistance in data acquisition have greatly enriched the quality of this research. I would also like to acknowledge the support and encouragement received from my family and friends throughout this academic journey.
Lastly, I am grateful to all the individuals who have directly or indirectly contributed to the completion of this thesis. Their support, guidance, and encouragement have been indispensable in shaping my research and personal growth. Ho Chi Minh City, 15th July, 2023 Researcher, Nguyen Ngoc Truc iii ABSTRACT This study aims to two objectives. Firstly, the design of a real-time traffic sign detection system for automobiles, with a specific focus on speed limit signs, using the YOLOv5 model.
Secondly, the study includes an assessment of the practical implementation of the traffic sign detection system by integrating it with a speed warning system that can be integrated into vehicles. This study includes several key tasks. Firstly, extensive research was conducted to identify real-time detection methods suitable for traffic signs. Subsequently, a comprehensive dataset of speed limit traffic signs was prepared, consists of 3200 images.
The next step involved training a model for the detection of these speed limit signs with the result of mAP 0. The model was then implemented on a Jetson Nano embedded computer. Parallelly, an ESP32 microcontroller was utilized to extract actual vehicle speed data from the OBD-II system. Lastly, the speed limit traffic sign detection system and the actual vehicle speed information were seamlessly integrated to develop a speed warning system.
The experimental results demonstrate the efficiency of the proposed traffic sign detection system in this study. The YOLOv5 model achieves 4 frames per second (FPS) on Jetson Nano computer in real-time detection speed. Moreover, by integrating the speed limit sign detection system with real-time monitoring of the actual vehicle speed, it enables timely warnings to the driver in the event of exceeding the speed limit. Additionally, the experimental results showed limitations of the speed limit traffic sign detection system.
One such limitation is its inability to detect the number of lanes on the road, which affects its accuracy in providing the precise speed limit, particularly in residential areas. Furthermore, there were instances where untrained traffic signs were mistakenly detected as speed limit signs. To address these issues, it is recommended to expand the training dataset to include a wider range of traffic signs, not limited to speed limit signs alone. In summary, the developed system exhibits significant potential for applications in the automotive industry, particularly in the field of Advanced Driver Assistance Systems (ADAS).
iv TÓM TẮT LUẬN VĂN THẠC SĨ Nghiên cứu này nhằm đạt được hai mục tiêu chính. Thứ nhất, thiết kế một hệ thống nhận diện biển báo giao thông theo thời gian thực cho ô tô, tập trung đặc biệt vào biển báo giới hạn tốc độ, bằng cách sử dụng mô hình YOLOv5. Thứ hai, nghiên cứu bao gồm việc đánh giá khả năng ứng dụng thực tế của hệ thống nhận diện biển báo giao thông bằng cách tích hợp với một hệ thống cảnh báo tốc độ có thể sử dụng trên xe ô tô. Nghiên cứu này bao gồm một số nhiệm vụ chính.
Đầu tiên, nghiên cứu xác định được các phương pháp nhận diện biển báo giao thông theo thời gian thực. Sau đó, đã chuẩn bị tập dữ liệu về biển báo giới hạn tốc độ, bao gồm 3200 hình ảnh. Bước tiếp theo, huấn luyện một mô hình để nhận diện các biển hạn chế tốc độ này với kết quả mAP là 0.922 trên 10 loại biển báo giao thông. Sau đó, mô hình đã được triển khai trên máy tính nhúng Jetson Nano.
Đồng thời, đã sử dụng vi điều khiển ESP32 để trích xuất dữ liệu tốc độ thực tế của xe từ hệ thống OBD-II. Cuối cùng, hệ thống nhận diện biển hạn chế tốc độ và thông tin tốc độ xe thực tế đã được tích hợp để phát triển thành một hệ thống cảnh báo tốc độ. Kết quả thử nghiệm thể hiện tính ứng dụng của hệ thống nhận diện biển báo giao thông được trình bày trong nghiên cứu này. Mô hình YOLOv5 đạt được 4 khung hình/giây (FPS) trên máy tính Jetson Nano trong quá trình nhận diện với thời gian thực.
Hơn nữa, bằng cách tích hợp hệ thống nhận diện biển báo giới hạn tốc độ với việc giám sát tốc độ thực tế của xe, hệ thống cho phép cảnh báo kịp thời cho người lái trong trường hợp vượt quá giới hạn tốc độ. Ngoài ra, kết quả thử nghiệm cũng cho thấy những hạn chế của hệ thống. Một trong những hạn chế đó là khả năng không thể nhận diện số làn đường trên đường, điều này ảnh hưởng đến độ chính xác của hệ thống trong việc xác định giới hạn tốc độ chính xác, đặc biệt là trong khu vực dân cư. Hơn nữa, có những trường hợp biển báo giao thông chưa được huấn luyện bị nhận diện nhầm là biển báo giới hạn tốc độ.
Để khắc phục các vấn đề này, tập dữ liệu huấn luyện cần được đa dạng hơn cho các loại biển báo giao thông khác, không chỉ giới hạn ở biển báo giới hạn tốc độ. Tóm lại, hệ thống được phát triển cho thấy tiềm năng đáng kể cho các ứng dụng trong ngành công nghiệp ô tô, đặc biệt là trong lĩnh vực Advanced Driver Assistance Systems (ADAS). v THE COMMITMENT OF THE THESIS’ AUTHOR I am Nguyen Ngoc Truc, Master’s student of Department of Vehicle Engineering, Faculty of Transportation, class 2021, at Ho Chi Minh City University of Technology. I guarantee that the information below is accurate: (i) I conducted all of the work for this research study by myself.
(ii) This thesis uses actual, reliable, and highly precise sources for its references and citations. (iii) The information and findings of this study were produced independently by me and honesty. Ho Chi Minh City, 15th July, 2023 Researcher, Nguyen Ngoc Truc vi Contents 1 Introduction 1 1.1 Speed Warning Systems .2 Traffic Sign Detection .6 Scope of Research .1 Convolutional Neural Networks .3 Fully Connected Layer .1 Introduce to YOLO .2 Intersection over Union .3 Precision and Recall .4 Mean Average Precision. 32 3 Design A Speed Limit Signs Detection Model 33 3.3 Training Model Parameters .1 Hardware Circuit Diagram .2 Software Algorithm Flowchart .3 Speed Limit Caching Algorithm .4 Finite State Machine Based Speed Warning Algorithm .2 Camera Raspberry Pi V2 .5 DC-DC Converter .6 OBD-II Adapter .3 Deploy on Jetson Nano .1 Build Model Engine .2 Run Model Engine.
64 5 Results and Discussions 66 5.2 Speed Limit Detection .3 Speed Warning Applications. 75 6 Conclusions and Future Works 78 References 80 Appendix 84 ix List of Figures 1.1 Types of ADAS .2 GSpeed, based on GPS and developed by iCar .3 Concept of Smart Road Signs communicate to vehicles .4 The comparison of YOLOv3 on performance .5 Research Contents and Workflows .1 An example of CNN architecture to classify handwritten digits .2 The Convolution Operation .3 An example of convolution with stride equal to 2 .4 An example of padding in convolutional .5 An example of max pooling and average pooling .6 An example of the fully connected layer’s input multiplied by the weights matrix to receive the output vector .7 Plot of sigmoid activation function .8 Plot of tanh activation function .9 Plot of ReLU activation function .10 How YOLO works .12 (a) DenseNet and (b) Cross Stage Partial DenseNet .13 YOLOv5 Network Architecture .14 Confusion Matrix Definition .15 Computing the Intersection over Union. 28 x LIST OF FIGURES 2.16 Define TP, FP base on IoU .17 The computer vision workflow on Roboflow .1 Dataset Preparation Workflows .2 Recorded Traffic Signs at Day and Night .3 Data annotating on roboflow .4 Image before and after augmentation .5 Dataset Health Check before Augment .6 Export Dataset with Download Code .7 The YOLOv5s Model Training Architecture .8 Training Results over 100 Epochs .10 Precision and Recall Curve .1 Concept of Experimental System .2 Hardware Circuit Diagram .3 Software Algorithm Flowchart .4 Speed Limit Caching Algorithm .5 FSM based speed warning algorithm .6 Jetson Nano Developer Kit B01 .7 Camera Raspberry Pi V2 .9 Module CAN Transceiver SN65HVD230 .10 DC-DC Buck Converter .11 OBD-II Male Adapter .1 The system setup for experiment .2 The system implemented on vehicle .3 The system was tested on vehicle .4 Speed detection system being tested in afternoon environments. 69 xi LIST OF FIGURES 5.5 Speed detection system being tested in nighttime environments .6 Speed detection system being tested in various environments .7 Speed detection system being tested in various environments .8 The width limit signs mistaken by speed limit 50 km/h .9 Speed limit 80 km/h mistaken by speed limit 60 km/h in few frames .