FPGA Based Lane Tracking System for Autonomous Vehicles
Total Page:16
File Type:pdf, Size:1020Kb
DEGREE PROJECT IN ELECTRICAL ENGINEERING, SECOND CYCLE STOCKHOLM, SWEDEN 2019 FPGA Based Lane Tracking system for Autonomous Vehicles ROHITH RAJ RAM PRAKASH KTH ROYAL INSTITUTE OF TECHNOLOGY ELECTRICAL ENGINEERING AND COMPUTER SCIENCE Abstract The application of Image Processing to Autonomous driving has drawn significant attention in recently. However, the demanding nature of the image processing algorithms conveys a considerable burden to any conventional real- time implementation. On the other hand, the emergence of FPGAs has brought numerous facilities toward fast prototyping and implementation of ASICs so that an image processing algorithm can be designed, tested and synthesized in a relatively short period in comparison to traditional approaches. This thesis investigates the best combination of current algorithms to reach an optimum solution to the problem of lane detection and tracking, while aiming to fit the design to a minimal system. The proposed structure realizes three algorithms, namely Edge Detector, Hough Transform, and Kalman filter. For each module, the theoretical background is investigated and a detailed description of the realization is given followed by an analysis of both achievements and shortages of the design. It is concluded by describing the advantages of implementing this architecture and the use of these kinds of systems. Keywords Autonomous drive, Image processing, FPGA, Sobel Edge detector, Hough Transform. i Sammanfattning Tillämpningen av bildbehandling inom autonoma fordon har fått stor uppmärksamhet den senaste tiden. Emellertid förmedlar den krävande karaktären hos bildbehandlingsalgoritmerna en stor belastning på vilken konventionell realtidsimplementering som helst. Å andra sidan har framväxten av FPGAer medfört många möjligheter till snabb prototypering och implementering av ASICar så att en bildbehandlingsalgoritm kan utformas, testas och syntetiseras på relativt kort tid jämfört med traditionella tillvägagångssätt. Denna avhandling undersöker den bästa kombinationen av nuvarande algoritmer för att uppnå en optimal lösning på problemet med spårning och fildetektering, med målet att krympa designen till ett minimalt system. Den föreslagna strukturen realiserar tre algoritmer, nämligen Edge Detector, Hough Transform och Kalman filter. För varje modul undersöks den teoretiska bakgrunden och en detaljerad beskrivning av realiseringen ges följd av en analys av både fördelar och brister i konstruktionen. Avhandlingen avslutas med en beskrivning av fördelarna med att implementera lösningen på det sätt den görs och hur dessa system kan användas. Nyckelord Autonoma enheter, Bildbehandling, FPGA, Sobel Edge Detector, Hough Transform. ii Acknowledgements First of all, I would like to thank my Industrial supervisors Gunnar Stjernberg and Adrian Sparrenborn at Synective Labs AB who was greatly involved in all the discussions and decisions related to specifications and scope of the project. Next, I would like to extend a note of thanks to Synective Labs AB for allowing me to work on such an interesting and challenging project. I would like to thank my examiner Prof. Johnny Öberg for the constant feedback and patience. And last but not least, I would like to gratefully express my thanks and love to my family and friends who have always been supporting me unconditionally. iii Contents List of Figures vi List of Tables 1 1 Introduction 2 1.1 Background ................................ 2 1.2 Thesis Goal ................................ 2 1.3 Outline .................................. 2 2 Related Work 4 2.1 Role of FPGA in Autonomous systems ................. 4 2.2 Literature Survey on the Conventional Design Methodologies on FPGAs for image processing ....................... 4 2.3 Detection of lines ............................. 5 2.4 Detection of circles ............................ 6 2.5 Active driver assistance system ..................... 7 2.6 Sobel Edge Detection System Design and Integration on an FPGA . 8 3 Methodology 10 3.1 Edge Detection .............................. 10 3.1.1 Theory ............................... 10 3.1.2 Matlab Simulation ........................ 11 3.2 Lane Detection .............................. 12 3.2.1 Theory ............................... 12 3.2.2 Implementation ......................... 13 3.3 MATLAB Simulation ........................... 14 4 Architecture 17 4.1 Hardware Architecture of the Line Detection System . 17 4.1.1 Camera Unit ........................... 17 4.1.2 Edge Extraction Unit ...................... 18 4.1.3 Hough Transform Unit ..................... 19 4.1.4 Line Identification Unit ..................... 21 4.2 System Architecture in FPGA ...................... 24 iv 4.2.1 Camera Pass-through Design . 24 4.2.2 Sobel Edge Detector Design ................... 35 4.2.3 Hough Transform Design .................... 36 5 Result and Analysis 37 5.1 Hardware Specification ......................... 38 5.2 Hardware test and Analysis ....................... 39 5.2.1 Edge detection test ........................ 39 5.2.2 Hough Transform Test ..................... 41 5.2.3 Resource Usage ......................... 43 5.2.4 Prototype ............................. 44 6 Conclusions 45 6.1 Conclusion ................................ 45 6.2 Future work ................................ 46 6.2.1 Insights and suggestions for further work . 46 6.2.2 Cost analysis ........................... 46 References 47 A MATLAB codes 51 A.1 MATLAB code for Sobel, Canny, Roberts and Prewitt filters . 51 A.2 MATLAB code for Hough Transform . 52 v List of Figures 3.1 Image input image to the filter ..................... 11 3.2 Sobel filter ................................ 12 3.3 Canny filter ................................ 12 3.4 Roberts filter ............................... 12 3.5 Prewitt filter ............................... 12 3.6 Hough transform lines ......................... 13 3.7 Sobel filter output / Hough Transform input . 15 3.8 Hough transform space ......................... 16 3.9 Hough transform lines ......................... 16 4.1 Configuration of Line Detection System . 17 4.2 FMC-IMAGEON Hardware – Connectivity Diagram [21] . 18 4.3 FMC-IMAGEON Hardware – Block Diagram [21] . 18 4.4 Configuration of Hough Transform Unit . 20 4.5 Configuration of Peak Detector ..................... 21 4.6 The Memory Controller ......................... 23 4.7 The architecture of Camera Pass-through Block Design . 24 4.8 Channel Architecture of Reads [26] . 25 4.9 Channel Architecture of Writes [26] . 25 4.10 Block Diagram of Video In to AXI4-Stream Core with the Video Timing Controller [27] ......................... 27 4.11 RGB and CMY Bayer CFA Patterns [28] . 28 4.12 Block Diagram of Color Filter Array Interpolation [28] . 29 4.13 AXI Interconnect Core Diagram [29] . 30 4.14 AXI IIC Bus Interface Top-Level Block Diagram [30] . 31 4.15 AXI4-Stream to Video Out core with the Video Timing Controller [34] .................................... 34 4.16 The architecture of Sobel Edge filter Design . 35 4.17 The architecture of the Hough Transform Design . 36 5.1 Zedboard and FMC camera setup with JTAG programmer . 38 5.2 Implemented Sobel Edge detector in FPGA . 39 5.3 Camera pass through Implemented . 39 vi 5.4 Sobel filter implemented ........................ 40 5.5 Implemented random XY lines in FPGA . 41 5.6 Implemented random XY lines with Video stream in FPGA . 41 5.7 Implemented Hough Transform in FPGA . 42 5.8 Implemented Hough Transform in MATLAB . 42 5.9 Prototype of miniature scale Autonomous car . 44 vii List of Tables 3.1 Filter masks ................................ 10 5.1 Design resource summary ........................ 43 1 1 Introduction 1.1 Background Nowadays the role of image processing is demanded in a wide range of industry and day to day applications. Image processing units are embedded in many devices ranging from mobile phones to Autonomous cars in the streets. However, the processing speed of some complex algorithms puts a barrier in a real-world implementation. FPGAs, on the other hand, are more flexible and handles these complex algorithms better in real-time environment that make a good choice for Autonomous driving. Most autonomous cars these days use GPUs as the brain for image processing and this thesis describes the real-world implementation of FPGAs for Autonomous cars. 1.2 Thesis Goal This thesis project aims to design and implement a miniature autonomous car that can detect, track lanes and move around in a controlled environment. The challenging task is extracting the required information from a video stream, which is performed by pre-processing extraction algorithms. There are external noises in the environment in which the experiment is conducted, like lighting, uneven lane marking etc., which must be kept in mind while deciding the optimal algorithm and designing the controller for this platform. Hence it must be decided which controller design has minimal resource utilization and power consumption. 1.3 Outline • chapter 2 conveys the results of the conducted survey on the conventional approaches already practiced by the expert toward implementing lane detection on the FPGA. • chapter 3 explains the theory behind the Edge detection and Steerable filters used for Autonomous driving. Then the advantages brought to the 2 design by applying this approach along with its disadvantages is explained. Finally, the MATLAB simulations of these filters are plotted and explained. • chapter 4 explains Architecture of the design implemented in FPGA. All the