Comparative Study of Computer Vision Based Line Followers using Raspberry Pi and Jetson Nano

—The line follower robot is a mobile robot which can navigate and traverse to another place by following a trajectory in the form of black or white lines. This robot can also assist human in carrying out transportation and industrial automation. However, this robot also has several challenges with regard to the calibration issue, incompatibility on wavy surfaces, and also the light sensor placement due to the line width variation. Robot vision utilizes image processing and computer vision technology for recognizing objects and controlling the robot motion. This study discusses the implementation of vision based line follower robot using a camera as the only sensor used to capture objects. A comparison of robot performance employing different CPU controllers, namely Raspberry Pi and Jetson Nano, is made. The image processing uses an edge detection method which detects the border to discriminate two image areas and mark different parts. This method aims to enable the robot to control its motion based on the object captured by the webcam. The results show that the accuracies of the robot employing the Raspberry Pi and Jetson Nano are 96% and 98%, respectively.

other research applied a PID control algorithm to adjust the robot on the line. In [8] - [9], the line follower robot was equipped with a webcam mounted on the vehicle and connected to Matlab platform.
The robot vision requires a processing unit which is responsible for processing the digital images and controlling the robot motion. Therefore, a compact and portable processor is essential to support the robot mobility and performance [10]. Some platforms and development boards have been chosen so as to apply the color detection scheme on the line follower robot. The Arduino platform and Pixy camera were used to distinguish the path and the background using various approaches: the Otsu's Method, thresholding based on color mixtures, and color tracking through hue and saturation [11]. The motion control was fully automated based on the path line center. Employing a four-legged robot platform and a camera as the only sensor, the robot is capable of successfully following a line. In [12], the hardware setup of an autonomous robotic vehicle was developed based on color detection to navigate the vehicle in different directions. Raspberry Pi camera and OpenCV were used to access images which are the indications of the directions of the movements such as stop, left turn, right turn.
Another work designed and constructed a line follower robot with a TDRB-D5M camera connected to a Cyclone IV FPGA in a development board DE0-NANO [13]. The computer vision algorithms were programmed into the FPGA to guide the robot through a line of one of three possible colors by masking pixels in the camera image. Based on the color detected, the robot controlled the motors to keep up the sequence and advance at different speeds in the line.
The advantages of camera compared to the light sensor for line tracking are explained in [14]. The additional computational time is compensated by numerous benefits. This includes the fact that the travel speed decreases only in turns, while the robot can go on higher speed in the straight lines without any trouble. The speed also varies depending on the next element of the road captured by the camera. In contrast to the line sensor, the vulnerability to the vibration of the robot is also much lower.
In this study, a line follower was built using Raspberry Pi and Jetson Nano separately to compare their performance using the same image processing algorithm. The Raspberry Pi and Jetson Nano are chosen because, they both are categorized as mini CPUs which include processor, memory, peripherals, and Python compiler. The clock speed of these mini CPUs are approximately ten times faster than that of Arduino boards, making them suitable for dealing with real-time image processing applications. A webcam was used as a sensor which captures objects and the edge detection method was employed to mark the lines [15]. This method is intended so that the robot can traverse based on the information extracted from the image captured by the webcam. This paper is organized as follows: Section II explains the methods used in this study. Section III presents and discusses the results. Finally, section IV concludes the findings.

II. Methods
The computer vision based line follower consists of several main components such as a processing unit, two motor drivers, four DC motors, and a webcam. Fig. 1 shows a block diagram of the hardware used.
The webcam serves as the line reader which captures image and send it to the mini CPU, i.e. Raspberry Pi or Jetson Nano, as the brain of the line follower robot. These mini CPUs are in charge of receiving input data, and inferring the motion command to the driver motor. Then, the driver motor will actuate the DC motor so that the line follower can move accordingly.

A. Raspberry Pi Model B Pinout
Raspberry Pi is a single-board mini PC which provides a set of GPIOs to control electronic components. The board is equipped with a Broadcom BCM2711 processor (1.5 GHz quad-core Arm Cortex-A72 CPU), 4 GB of RAM, and microSD card reader for storage. In this study, Raspberry Pi is used to receive data from the webcam, process the data, and provide output to the motor driver. Table 1 shows the pinout of the Raspberry Pi 4 Model B. Whereas Fig. 2 shows the schematic of the Raspberry Pi and the motor driver.

B. Jetson Nano Pinout
Jetson Nano is a minicomputer device created by NVIDIA. Despite its small size, the computing performance of Jetson Nano is up to 472 GFLOPS (one million data processing per second) and is capable of running AI modern workloads and also very power efficient, absorbing only 5 watts of power. The device is equipped with a 128core Maxwell GPU, Quad-core ARM A57 @ 1.43 GHz, 4 GB of RAM and microSD card reader for storage. In this study, the OpenCV is compiled with Cuda support to make the most of the GPU in Jetson Nano. Jetson Nano is used to receive data from the webcam, process the data with Arduino to generate PWM. The Arduino is used to convert Jetson Nano digital signals into analog signals since the Jetson Nano only has very limited number of analog pins. The Arduino then forwards the output to the motor driver  Table 2 shows the pinout used on the Jetson Nano, while Fig. 3 shows the schematic of the Jetson Nano, Arduino, and motor drivers.

C. Edge Detection
The boundaries of the black and white image are determined by means of the edge detection. In this study, the method used is Sobel algorithm because of its simplicity [16]. Sobel filter is a straightforward approach to the notion of gradient with smoothing. The gradients in X an Y axes are detected by means of the 3×3 convolution mask. The operator comprises a pair of 3×3 convolution kernels, with one being the other rotated by 90 o , as shown by Fig. 4.
One kernel is employed for each of the two perpendicular orientations (vertical and horizontal) separately to give different measurements of the gradient component in each orientation (G x and G y ). In order to find the absolute magnitude at any point, the Gx and Gy can be employed according to Equation (1) [17].
As for the angle of orientation of the boundary, q, relative to the pixel grid is given by Equation 2.

D. Software
The flow diagram in this study is shown in Fig. 5. The image processing used the OpenCV library which execute the image processing program on the mini CPU to support the computer vision. The first step is the image-capturing process by the webcam. If the camera does not take a picture, the process will be repeated in the mini CPU until an image is captured. Then, the mini CPU conducts the image pre-processing which includes color conversion and color filtering from RGB to grayscale. Equation (3) shows the relationship between the RGB pixel values and the corresponding grayscale value.

3
(3) , r g b G + + = G denotes the grayscale value, r denotes the red component of pixel, g denotes the green component of pixel, and b denotes the blue component of pixel.
Having been converted into grayscale, the image is then converted to a binary image with the threshold being the mean of the grayscale value. After obtaining the binary image, all black pixels are assigned as object and white pixels as the background. Therefore, the robot is able to detect the edge of the map line easily [18]. Then, the coordinates of each part of the object are collected and thus the robot's motion can be appropriately determined.
The image processing process begins with the initial reading of the track image which is then forwarded to the motor driver whose task is to run the motor, both adjusting the rotational direction and speed of each motor. When the robot detects the black line, the robot will follow the line according to the line type (straight line, dashed line, turns, and junctions). If an image matches to a predefined category of lines, the mini CPU will display the string output at the terminal which represents the motion command. The motion commands used in this study are: go straight (lurus), turn right (belok kanan), and turn left (belok kiri).

E. Testing Arrangement
In order to assess the performance of both controllers, some metrics are used, each of which has a specific purpose. First, the recognition accuracy is measured to evaluate the correctness of the controllers in recognizing a range of lines on the map. Ten trials are conducted for each type of line, and based on the results, the accuracy can be calculated in percentage. Secondly, the effect of illumination is taken into account by varying the brightness of the indoor lighting. Two of ten trials are conducted in the open space so that the sunlight is incident on the map. Lastly, the travel time is considered to measure the speed at which the robot traverse on the map. The time elapsed is recorded for one lap, meaning that the start point is the

III. results and dIscussIon
The robot frame consists of two levels, where the lower level contains four DC motors, power banks, Li-Po battery and motor drivers. The upper level contains the mini CPU, motor driver and webcam. This robot has dimensions of 26 cm × 15 cm × 30 cm. The realization of the robot shown in Fig. 6. In order for the robot to predict the type of line, the webcam must fully capture the line in full width. Once the line is in the camera's field of view, the robot should be able to determine the motion that must be taken afterward [19]. The geometrical shape of the robot also constraints the minimum distance perceived by the camera, which is 8 cm. Because of that, the camera is mounted 25 cm above the base floor and directed downward.

A. Path Recognition Testing
This testing aims to determine the success rate of path recognition. Therefore, the actual image on the map, the motion command on the terminal and the captured image are compared, as shown in Table 3.
Raspberry Pi and Jetson Nano were used as mini CPUs and able to execute the whole algorithm without any trouble. Of all kinds of lines, the program could generate motion command that matches the actual track on the map. In this study, if the webcam detected white area, the mini CPU would drive the robot backwards command so that the robot could return to the black line on the map.
The key factor of successful path recognition lies on the accuracy of edge detection. In order to find out how accurate the edge detection is, ten experiments were carried out on each type of line to see whether or not the algorithm can recognize the type of line. The testing was done using Raspberry Pi and Jetson Nano as mini CPU separately, as shown in Table 4 and 5.
The accuracy metric is calculated using the Equation (4) as follows: with N s being the number of successful detections and N T being the number of trials. Based on Table 4, the Raspberry Pi can detect all types of lines with an accuracy rate of 100% except for line types 5 and 7, which contain circle shapes, with an accuracy rate of 90% and 70%, respectively. Meanwhile, based on Table 5, the Jetson Nano can detect all type of lines with an accuracy rate of 100%, except for line types 3 and 5, which are left and right turns, each obtaining an accuracy rate of 90%. These errors in detecting several types of lines was caused by lighting factor as the robot vision was obstructed by the robot's own shadow while moving across the map.

B. Effect of Light Intensity
Light intensity is one of the important factors that affect the success of path recognition. Light intensity testing is carried out to assess the webcam's capabilities in various light intensities and their effect to path recognition, as shown in Table 6. Based on the results in Table 6, the robot will not work if the light intensity is lower than 0.7 lumens / m 2 . Therefore, it can be inferred that the success of the webcam in detecting path on the map is influenced by the light intensity over the map area.
It is because the light might change the color of the detected object. For example, when the light intensity is too low, the color of the object become darker (pixel value is close to 0) due to the poor illumination. On the contrary, under bright lighting condition, the color of the object become brighter (pixel value is close to 255) due to the increased illumination. In this study, the robot is able to detect objects with a minimum light intensity of 0.7 lumens / m 2 and up to 91,600 lumens / m 2 . The motion control for each trial includes Go, Stop, Turn Left, and Turn Right.

C. Robot Travel Time on the Map
The robot travel time is the time elapsed to complete six laps. The testing was carried out with a light intensity of 88,990 lumens/m 2 using the Raspberry Pi and Jetson Nano as the mini CPU, and conducted ten times for each mini CPU. Fig. 7 shows the map used when testing the robot's travel time, and the results are shown in Table 7. Table 8 summarizes the performance comparison of line follower robots using Raspberry Pi and Jetson Nano. The results in Table 8 implies that the Jetson Nano outperforms Raspberry Pi in conducting the line following tasks.

D. Performance Comparison
Particularly, the Jetson Nano has a fastest lap of 20 seconds with a success percentage of 100% to complete the laps. Meanwhile the Raspberry Pi has a fastest lap 38.16 seconds with a success percentage of 98% to complete the laps. As for the overall accuracy of path

IV. conclusIon
A comparative study of computer vision based line follower was done. It can be concluded that the Raspberry Pi and Jetson Nano work well as mini CPUs to conduct line following tasks. The Jetson Nano has a fastest lap of 20 seconds with a success percentage of 100% to complete the laps. Meanwhile the Raspberry Pi has a fastest lap 38.16 seconds with a success percentage of 98% to complete the laps. As for the overall accuracy of path recognition, the Jetson Nano and the Raspberry yield 98% and 96%, respectively. Hence, it is obvious that the Jetson Nano outperforms Raspberry Pi for all aspects. In near future, a vision based line follower can be built by means of machine learning or artificial intelligence to see trade-off with the image processing.  Table 7. Travel time of the robot as many as 6 laps