MEV Journal of Mechatronics, Electrical Power, an d Vehicular Technology 10 (2019) 7–16 Journal of Mechatronics, Electrical Power, and Vehicular Technology e-ISSN: 2088-6985 p-ISSN: 2087-3379 www.mevjournal.com doi: https://dx.doi.org/10.14203/j.mev.2019.v10.7-16 2088-6985 / 2087-3379 ©2019 Research Centre for Electrical Power an d Mechatronics - Indonesian Institute of Sciences (RCEPM LIPI). This is an open access article under the CC BY-NC-SA license (https://creativecommons.org/licenses/by-nc-sa/4.0/). Accreditation Number: (LIPI) 633/AU/P2MI-LIPI/03/2015 and (RISTEKDIKTI) 1/E/KPT/2015. Vehicular networking and computer vision-based distance estimation for VANET application using Raspberry Pi 3 Mulia Pratama a, *, Giambattista Gruosso b, Widodo Budi Santoso a, Achmad Praptijanto a a Research Centre for Electrical Power an d Mechatronic s, In donesian Institute of Sciences Jl. Cisitu No. 154D, Bandung, 40135, In donesia b Department of Electronics, Informatics and Bioengineerin g, Politecnico di Milano Via Ponzio 34/5, 20133, Milano, Italia Received 1 March 2019; accepted 2 December 2019; Published online 17 December 2019 Abstract This research was implementing vehicle networking using WIFI connection and computer vision to measure the distance of vehicles in front of a driver. In particular, this works aimed to improve a safe driving environment thus supporting the current technology concept being developed for inter-vehicular networking, VANET, especially in its safety application such as Overtaking Assistance System. Moreover, it can wirelessly share useful visual information such as hazard area of a road accident. In accordance with Vehicle-to-Vehicle (V2V) concept, a vehicle required to be able to conduct networking via a wireless connection. Useful data and video were the objects to be sent over the network established. The distance of a vehicle to other vehicles towards it is measured and sent via WIFI together with a video stream of the scenery experienced by the front vehicle. Haar Cascade Classifier is chosen to perform the detection. For distance estimation, at least three methods have been compared in this research and found evidence that, for measuring 5 meters, the iterative methods shows 5.80. This method performs well up to 15 meters. For measuring 20 meters, P3P method shows a better result with only 0.71 meters to the ground truth. To provide a physical implementation for both the detection and distance estimation mechanism, those methods were applied in a compact small-sized vehicle-friendly computer device the Raspberry Pi. The performance of the built system then analyzed in terms of streaming latency and accuracy of distance estimation and shows a good result in measuring distance up to 20 meters. ©2019 Research Centre for Electrical Power and Mechatronics - Indonesian Institute of Sciences. This is an open access article under the CC BY-NC-SA license (https://creativecommons.org/licenses/by-nc-sa/4.0/). Keywords: computer vision; Haar Cascade Classifier; distance estimation. I. Introduction Video streaming over the inter-vehicular network promises an improvement in road safety and driver- environment safety driving [1]. A vehicle with an intelligent transportation system and a camera adopted able to records surrounding geographic scenes of a highway and events during driving session and stream the video and data to other smart vehicles nearby through the advantage of an inter-vehicular network named VANET [2] for example. In VANET video and data streamed include the information of the road scenery and vehicle motion such as vehicle position, distance, and speed. Retrieving the relative position i.e. the longitudinal distance of a vehicle in front of the driver by the camera would be the main objective of this work. With this technology enabled in a vehicle, it encourages the decision making by drivers to for example overtaking a road lead [3] thus aiming to support the service of the basic safety application built based on SAE J2735 BSM via WIFI or DSRC/WAVE message protocol [4] in V2V and V2I communication [5][6] concept such as Overtaking Assistance System [3], Forward Collision Warning and emergency electronic brake light (EEBL). Similar works to this research were the research conducted by [7][8], employing the same vehicle detection methods, however, different methods to estimate the distance between vehicle and camera were proposed in this research. The works are done by [8] estimated distance by means of using geometric relation yielded a quite good result of the accuracy of 90.29 % with claimed error average 9.71 %. The research done by [9] utilized a homography matrix and Rodrigues Identity to compute the * Correspon ding Author. Tel: +62-81394486064 E-mail address: mulia.pratama@lipi.go.id https://dx.doi.org/10.14203/j.mev.2019.v10.7-16 http://u.lipi.go.id/1436264155 http://u.lipi.go.id/1434164106 http://mevjournal.com/index.php/mev/index https://dx.doi.org/10.14203/j.mev.2019.v10.7-16 https://creativecommons.org/licenses/by-nc-sa/4.0/ https://crossmark.crossref.org/dialog/?doi=10.14203/j.mev.2019.v10.7-16&domain=pdf https://creativecommons.org/licenses/by-nc-sa/4.0/ M. Pratama et al. / Journal of Mechatronics, Electrical Power, an d Vehicular Technology 10 (2019) 7–16 8 rotation matrix, the distance between vehicle calculated from this rotation matrix, however, it used a different method to detect the vehicles with the one proposed in this research. This research mainly conducted on a card-sized computational resource namely Raspberry Pi 3 with a camera as image input; all vehicle detection, image processing and the computing of linear algebra done using the computer. Haar Cascade Classifier used for vehicle detection as this method comparably the fastest to date. If a detection occurred, the algorithm sends the vehicle position and width annotated by the detection mechanism to the distance measurement algorithm which consists of several methods which will be compared for the performance namely the Triangle Similarity, SolvePnP-Iterative, and SolvePnP-P3P with and without Kalman filter. The useful data of longitudinal distance calculated, and visual images then are being sent via WIFI to other vehicles or Road-Side Unit. Considering the ADAS roadmap and its development and V2X which include VANET, this research would contribute to improving people and road safety. The outcome of this research could increase driver awareness of the surrounding for example by adding alarm if cars or objects are within the proximity of a vehicle, also hopefully contribute to autonomous vehicle development. II. Materials and Methods This section describes in detail of methods used in this research. Mainly this section study about vehicle detection utilizing Haar Classifier and distance measurement methods. The workflow of the system under discussion described in the following Figure 1. The camera captured an image frame to be analyzed for vehicular features indicating the frame consist of a vehicle image. If a vehicle confirmed then a bounding rectangle which approximates the width of the vehicle image is applied. Either the width or the coordinates of the rectangle drawn would then be used to estimate the distance between vehicle and camera. Distance information then sent via a wireless network to the other vehicles. The system developed was implemented in a Raspberry Pi 3 platform including the usage of its 8 MP Raspberry Pi camera. Data and video were streamed via Raspberry Pi 3 embedded WIFI trough Named Pipe FIFO and NetCat as a networking tool. The on-board WIFI chip is the advantage of Raspberry Pi 3 compared previous Raspberry Pi releases that require extra USB WIFI dongle, however, this research avoids the use of external USB WIFI dongle since there are many WIFI dongle manufacturers with their own characteristic in the market also some of them have an issue working with Raspberry Pi. Moreover, they might need more power than a Raspberry Pi port can support. A. Haar-Cascade classifier There exist a fast and trainable method for object recognition, The Haar Cascade Classifier [10] this method also used by [11] with the detector trained by BIT-Dataset and conclude that Haar Cascade Classifier is a good candidate for object detector. Research by [12] combines the Haar detector with the K-nearest neighbour technique to identify the license plate of vehicles that claimed to offer great efficiency for practical use. According to [13], the classifier superior performance over image-intensity based algorithm encourages the use of Haar Cascade in this work. Haar Cascade adopted by [10] was a machine learning mechanism. The classifier evaluates the simple feature of an incoming image rather than processing the image by pixel. As can be seen in Figure 2, image feature extraction involves Haar features, a geometrical shape of a rectangle consisting Figure 1. System flowchart M. Pratama et al. / Journal of Mechatronics, Electrical Power, an d Vehicular Technology 10 (2019) 7–16 9 of a pair region of white and black. Value of each image feature determined by the sum of the pixel under the white Haar region deducted from the sum of the pixel under the black one. Thus, the white rectangle weight 1 (one) and black region weight -1 (minus one). Two-rectangle feature (a) [10] used to extract edge feature on image and three-rectangle feature (b) used to extract line feature on image. For example, Figure 3 shows an applying Haar basic feature shapes over an image of a vehicle. The pixels sum of the black and white are summed up (by subtraction) and the difference is the value of the image feature underlying the mask Haar feature. To immediately evaluate the features and the author of [10] presented auxiliary Integral Image. Any large number of features extracted, their values can be quickly calculated with only four points of reference. B. Triangle similarity A simple spatial measurement based on geometrical properties of two similar triangles applied in this research referred to [14][15] and then be compared to other methods described later. Fed by a known distance of a camera to a vehicle and a known width of the vehicle, one can obtain a focal length of the camera. As can be seen in Figure 4, if DF is the real width of the vehicle and Ed is the real distance between camera to vehicle then one can find Bd’ as the focal length of camera in pixel, provide that information of AC is available. Information of AC length provided by the detection and tracking mechanism discussed previously and referred to as vehicle width in a pixel can be expressed using Equation (1) 𝐷𝐹 (𝑚𝑒𝑡𝑒𝑟𝑠) 𝐸𝑑(𝑚𝑒𝑡𝑒𝑟𝑠) = 𝐴𝐶 (𝑝𝑖𝑥𝑒𝑙𝑠) 𝐵𝑑 ′ (𝑝𝑖𝑥𝑒𝑙𝑠) (1) by reversing (1), provided the focal length, real vehicle width in meters and perceived vehicle width in pixels, one can estimate the distance from the camera to the vehicle E-d. However, this is true if the vehicle positioned assumed exactly on the camera centerline. There are cases when vehicle position deviates from camera centerline a few meters and as result for this to happen is that the focal length Bd’ of the camera needs to be reinitialized since the distance of the vehicle to the camera now is different for that particular position. Research by [14] did not examine this problem as a contrast to [15] that decide not to recommend using Triangle Similarity if such a case happened. The reinitialize of focal length can be done by a camera calibration process either automatically or manually which is impossible to be carried out while vehicle running on the road. To maintain the parameter the same for the analysis, this method tested with the assumption above retained. C. Iterative using Levenberg-Marquardt optimization The Triangle Similarity method previously described then will be compared with a perspective projection-based method. Figure 5 describes a Pinhole Camera mechanism to better gain insight to understand the Perspective-n-Point (PnP). One can infer from Figure 5, a model of a 3D box in universe reference characterized by its points Q0 to Qi is projected to a 2D image plane using perspective Figure 2. Haar feature shapes used to evaluate image features Figure 3. Haar feature used to detect rear windshield and rear tires of a vehicle that are distincive feature of a vehicle Figure 4. Two similar triangles M. Pratama et al. / Journal of Mechatronics, Electrical Power, an d Vehicular Technology 10 (2019) 7–16 10 transformation. The model reconstructed in the image plane through a series of matrix operation involving rotation matrix refer to each axis and a translation matrix. Rotation matrixes can be simplified into a single 3x3 matrix R 𝑅 = [ 𝑟11 𝑟21 𝑟31 𝑟12 𝑟22 𝑟32 𝑟13 𝑟23 𝑟33 ] (2) The vector of translation matrix T 𝑇 = [ 𝑡1 𝑡2 𝑡3 ] (3) Also, consider a camera matrix one interested to obtain 𝑐𝑎𝑚𝑒𝑟𝑎 𝑚𝑎𝑡𝑟𝑖𝑥 = [ 𝑓𝑥 0 0 0 𝑓𝑦 0 𝑐𝑥 𝑐𝑦 1 ] (4) 𝑠 [ 𝑢 𝑣 1 ] = [ 𝑓𝑥 0 0 0 𝑓𝑦 0 𝑐𝑥 𝑐𝑦 1 ] [ 𝑟11 𝑟21 𝑟31 𝑟12 𝑟22 𝑟32 𝑟13 𝑡1 𝑟23 𝑡2 𝑟33 𝑡3 ] [ 𝑋 𝑌 𝑍 1 ] (5) A point of the model reconstructed in the image plane (u, v) by (2), (3) and (4) according to (5) that is the Pinhole Camera equation where: X, Y, and Z is the real coordinate of a point on a cube for example point Qi. In universe of observer’s reference system. u and v is the coordinate of point qi in the observer’s image plane reference system. Hence, qi is the perspective projection of point Qi of the model. cx and cy are principal points usually at the image center. 𝑓𝑥 and 𝑓𝑦 is the focal length of the camera used. S is scaling factor. The aim here is to find the translation matrix T and retrieve its value as the distance between a vehicle and camera one interested. This research used the OpenCV library as computer vision tool to accomplish the computation. Using OpenCV solvePnP with an ITERATIVE method it follows that the computer vision using Levenberg- Marquardt optimization to minimize the reprojection error that was the sum of the squared deviation between a point and its projection. D. The P3P problem OpenCV provides a way to solve the P3P problem according to [16]. In OpenCV, the function SolvePnP can be used to estimate the pose of an object model that is to obtain the rotation matrix R and translation matrix T. Flag SOLVEPNP-P3P uses 3 object points for calculating the pose plus one additional point to provide the best result. The works by [16] present the complete solution classification for the Perspective-Three-Points (P3P) that shown P3P has multiple solutions from an algebraic perspective under certain real conditions. To understand the problem in research [16], Figure 6 provides a solution perspective where P, A, B, C are not-coplanar and P the center of perspective. Moreover, 𝑎′ , 𝑏′ , and 𝑐 ′ are |CB|, |AC|, and |AB| respectively and α = ∠BPC, β = ∠APC, γ = ∠APB, p = 2 cos α, q = 2 cos β, r = 2 cos γ. It also notified that X, Y, Z are representing the distance from point P to the corresponding point. From triangle PAC, PAB and PBC, P3P equation can be written as (6) { 𝑌2 + 𝑍2 − 𝑌𝑍𝑝 − 𝑎′ 2 = 0 𝑍2 + 𝑋 2 − 𝑍𝑋𝑞 − 𝑏′ 2 = 0 𝑍2 + 𝑌2 − 𝑋𝑌𝑟 − 𝑐 ′ 2 = 0 (6) according to [16] a set of solutions exist for X, Y, Z that are the space from the camera to the object, if comply with some condition specified on their paper. Figure 5. Pinhole camera illustration M. Pratama et al. / Journal of Mechatronics, Electrical Power, an d Vehicular Technology 10 (2019) 7–16 11 Substituting 𝑋 = 𝑥𝑍, 𝑌 = 𝑦𝑍, 𝑐 ′ = √𝑣𝑍, 𝑎′ = √𝑎𝑣𝑍, 𝑏′ = √𝑏𝑣𝑍 to (6), divided by 𝑍 it become { 𝑦2 + 1 − 𝑦𝑝 − 𝑎𝑣 = 0 𝑥 2 + 1 − 𝑥𝑞 − 𝑏𝑣 = 0 𝑥 2 + 𝑦2 − 𝑥𝑦𝑟 − 𝑣 = 0 (7) thus 𝑣 = 𝑥 2 + 𝑦2 − 𝑥𝑦𝑟 > 2, 𝑍 can be obtained by 𝑍 = 𝑐 ′/√𝑣, this value was the first order approximation of vehicle distance one interested. Moreover, one may find that by removing 𝑣 from (7) one my turn to a quadratic equation which yield a finite number of solutions if not at least four. E. Kalman filter To smoothen thus hopefully improve the distance accuracy, Kalman filter used with the help of noise characterizing to attain optimum Kalman filter. The filter works based on a loop of measuring, predict and update. In order for the filter to work, a certain matrix should be provided: Transition matrix F, Measurement matrix H, Q process noise matrix, R the measurement noise that is the noise characteristic that will be discussed in the next part of the paper. Each measurement 𝑧 as a result of the detection process will be passed as matrix H. The filter then predict the next state of the system by �̅� = 𝐹𝑥 (8) 𝑃 = 𝐹𝑃𝐹𝑇 + 𝑄 (9) with �̅� is the next state of the system predicted; 𝑥 is the current (posteriori) state; 𝑃 predicted the state of covariance or error; and 𝑃 is the current state of covariance. Then the filter updates the state of the system modified with the predicted state by the following equation 𝑥 = �̅� + 𝐾𝑦 (10) 𝑃 = (𝐼 − 𝐾𝐻)𝑃 (11) with 𝑧 is the measurement and 𝑦 is the residual defined as 𝑦 = 𝑧 − 𝐻�̅� (12) and 𝐾 as Kalman gain 𝐾 = 𝑃𝐻𝑇(𝐻𝑃𝐻𝑇 + 𝑅)−1 (13) Hereafter, the current state of the system 𝑥 is updated and the value can be used for the distance measurement algorithm. III. Results and Discussions A. Streaming latency The system was investigated for its performance in terms of latency, noise, and distance estimation accuracy. End-to-End latency mainly consists of 680x480 pixels video streaming latency and image processing which included the Haar Cascaded detection mechanism and distance estimation computation plus other additional negligible latency. The latency measurement for video streaming done on-line through with the help of an auxiliary camera and a digital stopwatch to count the whole measurement of the elapsed time. Auxiliary camera used taken from front laptop camera, the setup is illustrated in Figure 7. With this setup, both video previews from both cameras must be displayed adjacent to each other on the same display in a way so that when a print-screen button hit detected by the laptop, its screen displaying both measurements is saved to be analyzed. The real setup for measuring video-only stream can be seen in Figure 8, it shows the area of the laptop monitor screen. Figure 8 is displayed as it is captured from the laptop screen. Both windows are inverted because each of these Figure 6. Illustration of P3P problem origin Figure 7. Latency measurement set up M. Pratama et al. / Journal of Mechatronics, Electrical Power, an d Vehicular Technology 10 (2019) 7–16 12 windows shows two cameras reading of the same stopwatch displayed back on the laptop screen. The foremost display showed captured stopwatch image from local laptop camera and provided real measurement time counts about 21,780 milliseconds from start and served as offset basis to calculate End- to-End latency, while the image behind it was the streamed stopwatch images from Raspberry Pi which provided the streaming delayed behind by 297 counts at 21,483 milliseconds, real-time counts assumed ideal with no delay; note that milliseconds counting marked by the oval making. It was obvious that the time counted for real-time showed larger counts than the streaming, indicating that the stopwatch image frame from Raspberry Pi was experienced 297 milliseconds delay during travel to the laptop display. Table 1 reports the result of video streaming latency measurement included the delays for detection mechanism and distance measurement computation. The rightmost column was the End-to- End latency calculated by (14) 𝐸𝑛𝑑 − 𝑡𝑜 − 𝐸𝑛𝑑 = 𝑟𝑒𝑎𝑙𝑡𝑖𝑚𝑒 𝑒𝑙𝑎𝑝𝑠𝑒𝑑 𝑡𝑖𝑚𝑒 − 𝑠𝑡𝑟𝑒𝑎𝑚𝑖𝑛𝑔 𝑒𝑙𝑎𝑝𝑠𝑒𝑑 𝑡𝑖𝑚𝑒 (14) The total End-to-End latency measured 1,490 milliseconds for using the Triangle Similarity method and 1,436 milliseconds for ITERATIVE Levenberg- Marquardt while P3P showed no improvement, the delay was very huge. The allowed latency for the inter-vehicular network should be less than 200 milliseconds referred to [3] and [17]. Even for the aforementioned video-only streaming measured 297 milliseconds were out of the limit. An investigation for the source of such massive delay had been done by means of employing the time stamp function inserted in the program script. The time stamp was started to count just after the image captured and ended just after the distance computation finished and the image frame ready to be sent to the stream. Table 2 showed the time consumed. From the table above can be seen that even the time needed to do the computing was about one-fourth of total End-to-End latency. From this experiment, it can be assumed that the source of the long delay was not the detection and computing process. The most logical suspect which caused the delay was the transmission path or the client unit that receive the video and data stream. For future research, the latency needs to be investigated whether it is device specific by means of comparing it to a more reliable computational resource such as PC equipped with good Graphics processing unit. The usage of external USB WIFI dongle also needs to be considered for future research if not using the DSRC/WAVE standards for V2X. B. Noise characteristic Noise performance is critical for both visual and accuracy since the addition of noise worsens the visualization of the vehicle being monitored as the rectangle marking spread randomly around the vehicle image thus alters the result of distance Figure 8. Real-time vs Streamed latency measurement Table 1. End-to-end latency measurement Time e lapsed (in milliseconds) Methods Realtime Streaming Delta ITERATIVE LevMarq 49:653 48:348 1,305 P3P 50:863 49:363 1,500 Triangle Similarity 55:524 54:034 1,490 video only 21:780 21:483 297 Table 2. Detection and distance computation latency in millisecon ds Methods Start End Latency P3P 40:850 41:269 419 ITERATIVE LevMarq 35:849 36:285 436 Triangle Similarity 22:379 22:797 418 M. Pratama et al. / Journal of Mechatronics, Electrical Power, an d Vehicular Technology 10 (2019) 7–16 13 measurement as an error. Figure 9 showed the fluctuation in vehicle identification, indicated by the dispersion of the bounding box around the vehicle image. The detection comes from the cascaded classifier was fluctuating in terms of vehicle position on the image at each measurement frame every half second. Since the nature of the cascade classifier applied extensive numbers of Haar feature by sizes and shapes [10] in sliding window, the results produced resembles a random process which generates a stationary white noise added to the measurement, this part intended to investigate the characteristic of the noise whether it is white or not and to see if optimum Kalman filter can be exploited. White noise defined as a series of uncorrelated random variables following a continues distribution with zero mean and unity variance also a process is a white noise if its close-spaced time series sample is uncorrelated [18], moreover, if those samples were independent, it follows Gaussian distribution hence guaranteed for randomness. The following Figure 10 shows the fluctuation of 1000 measurement of for example 15 meters distance using the P3P method. One may effectively eliminate the noise online by employing optimal Kalman filter. To this aim, one had to verify that the noise was white for the filter can be optimally utilized. As the figure below is shown, the zero mean and standard deviation of 0.904 are verified by the data. Autocorrelation must be checked since it guarantees the randomness of the consecutive data generation. Figure 11 was the autocorrelation under confidence level of 95 %. The figure showed that the data was uncorrelated since most of the lag autocorrelations fell between the limit of the shaded area. Disregards lag 0, only one out of every 20 lags lie outside this limit, it was normal since it has a 95 % confidence level. The figure also showed that there were no patterned lags, for example a repeating lag position. Another method to verify the noise is by mean of the Anderson-Darling distribution test [19], the data were tested against the normal distribution. The Anderson-Darling test return test statistic A2 to be compared to a critical value of 0.576, 0.656, 0.787, 0.918 and 1.092 for significant level 10 %, 5 %, 2.5 %, 1 % and 0.5 % respectively. If the test returns A2 value greater than the value mentioned above it then the test sample not likely produced from a normal distribution. Fed the measurement data to the test procedure, it returns A2 value of 0.574, 0.653, 0.784, 0.914, and 1.088 respecting the same significant level indicating that the measurement data have normal (Gaussian) distribution. By those facts, it is concluded that the fluctuation generates a white Gaussian noise. With the noise characterized, the Kalman filter can be optimally employed to the measurement with the assumption that the simulated process noise was also white and uncorrelated to the noise being Figure 10. Noise from measuremet of 15 meters using P3P method with mean value subtracted -3 -2 -1 0 1 2 3 4 5 -100 100 300 500 700 900 1100 m e te rs frames Figure 9. Noisy vehicle markings M. Pratama et al. / Journal of Mechatronics, Electrical Power, an d Vehicular Technology 10 (2019) 7–16 14 discussed. With the unfiltered average signal of 15.48 meters and the noise rms of 0.900 meters, one may find the Signal to Noise Ratio (SNR) is 54.40 dB respect to the following formula (15) 𝑆𝑁𝑅 = 20 × 𝐿𝑜𝑔 ( 𝑆𝑖𝑔𝑛𝑎𝑙 √𝑁𝑜𝑖𝑠𝑒 2̅̅ ̅̅ ̅̅ ̅̅ ̅̅ √𝑁) (15) Hopefully, Kalman filter reduces the noise up to an order of magnitude. The result of filtering shows the noise reduction, Figure 12 showed the fluctuation after filtering. The noise rms improves to 0.34 meters but the signal average increase 15.51 meters thus improves SNR to 62.87 dB less than the expected, however, this adds offset error to the true 15 meters up to 0.51 meters from 0.48 meters unfiltered originally. Kalman filtering improves the visualization but worsens the accuracy to 3 cm for measurement of 15 meters distance. However, this assumption will be verified by investigating the observed behavior in other methods. C. Performance of distance estimation The system was tested in 5 to 20 meters involving three methods for distance estimation. These methods are discussed in this part were the Triangle Similarity, ITERATIVE with Lavenberg-Marquardt optimization and P3P, last two adopted from camera imaging and homography technique. The experiment applied on one type of vehicle to maintain the uniformity of parameters so it was easier to be analyzed for example the camera matrix that contains focal length calibrated using the most common city car width about 1.64 meters. Moreover, measuring with various kinds of vehicles avoided because it will guide to the further comparative analysis of the performance of the Haar Cascade Classifier such as true positive rate (TPR) which is not the scope of this paper. The dataset for training the classifier used here is not standard datasets such as BIT-dataset, KITTY or EPFL. All methods will be compared for its performance in terms of accuracy for a filtered and Figure 11. Autocorrelation from measurement data for 15 meters using P3P method Figure 12. Noise from measurement of 15 meters using P3P method after filtering -1 -1 0 1 1 2 -100 100 300 500 700 900 1100 m e te rs frames M. Pratama et al. / Journal of Mechatronics, Electrical Power, an d Vehicular Technology 10 (2019) 7–16 15 unfiltered result for about 1000 samples averaged. The setup was a parking area with markings every two meters. A car was set in a position while Raspberry Pi and the camera placed in a distance of 5, 10, 15, and 20 meters from the rear end of the car. Light intensity not recorded thus to maintain the same ambient and environment condition the camera also records a video while measuring, the video will be used to test the other methods. Table 3 present the averaged result for unfiltered 5 and 10 meters; the table also provides the standard deviation from the measurement placed inside the parentheses next to the averaged values. From the table, we can infer that the smallest offset error to 5 and 10 meters attained by the ITERATIVE Levenberg- Marquardt method with an error less than 1 meter to the true value while P3P contributes to the biggest offset, 1.78 meters and 2.63 meters for 5 and 10 m respectively. The performance gets more complicated when referring to Table 3 for 15 and 20 meters since the smallest offset error achieved by Triangle Similarity and P3P methods, they are 0.39 meters and 0.71 meters respectively retain the offset down below 1 meter respecting the ground truth value. The largest offset error now held by ITERATIVE with Levenberg- Marquardt iteration yields 1.72 meters and 3.16 meters respectively for 15 and 20 meters. As for the standard deviation, they will be compared with the filtered measurement and be examined for any improvements. Passing the measurements to a Kalman filter, Table 4 resumes the observation. Comparing to the previous table, the difference between unfiltered and filtered result is not significant, the biggest come from 5 meters of P3P, and it differs up to 30 centimeters. From this experiment employing ITERATIVE with Lavenberg-Marquardt and Kalman filtering was the best practice with accuracy 84.2 %, the error rate was 15.8 % for 5 meters distance and for 10 meters the accuracy was 91.2 %. Meanwhile, for 15 and 20 meters, the P3P method was reliable enough with accuracy 96.9 % and an error rate of 3.1 % at best. Respectively compared to the unfiltered measurement, for 5 and 10 meters the maximum accuracy was 92.3 % produce error rate 7.7 % while for 15- and 20-meters maximum accuracy was 96.8 % with error rate 3.2 %. The filtering effect also can be seen especially for measuring 15 and 20 meters; the standard deviation reduced to about 40 % to 60 % of the initial unfiltered measurement. IV. Conclusion To embody the research to a working experiment, a system was built incorporated Raspberry Pi 3 as its main computational platform. Using the system, there are two main mechanisms discussed in this paper: video streaming latency and distance estimation accuracy. Video streaming was able to be executed by the system but the latency was very huge up to 1500 milliseconds in which more than one- fourth of it was the process latency but VANET required less than 200 milliseconds for vehicular video streaming thus in term of latency the system built was not satisfied, the biggest delay was caused by the transmission or the client for the first approximation, required further research on this field. Suggestion for future research is to use WIFI dongle with external power supply or with more advanced topics, the adoption of DSRC/WAVE chip V2X standard instead of ordinary WIFI. Distance estimation highly dependent on the result of the vehicle detection mechanism mainly its fluctuation, to address that matter Kalman filter employed to filter the noise; unfortunately, it added offset error to the real measurement up to 30 centimeters at 5 meters. Moreover, in terms of accuracy the system built has good accuracy rated at 96.9 % for measuring 20 meters incorporating solve PnP-P3P method. Acknowledgment The authors would like to express the deepest appreciation to all those who provided a suggestion, comment, advice, and assistance on the completion of this research. Special gratitude would be given to Mr. Ahmad Dimyani, who’s contributed to substantial suggestions and also coordinate the completion of the project. Furthermore, the authors would also like to acknowledge the role of the staff of TELIMEK ICE Laboratory, who assists in the use of all required Table 3. Measurement results without filtering Grou nd Truth ITERA TIVE LevMarq (Std. Dev) P3P (Std.dev) Triang le Similarity (Std. Dev) 5 5.80 (0.17) 6.78 (0.55) 6.24 (0.18) 10 10.77 (0.50) 12.63 (0.53) 11.80 (0.54) 15 13.28 (0.89) 15.48 (0.81) 14.61 (0.94) 20 16.84 (1.03) 19.29 (1.07) 18.55 (1.11) Table 4. Measurement results filtered Grou nd Truth ITERA TIVE LevMarq (Std. Dev) P3P (Std. Dev) Triang le Similarity (Std. Dev) 5 5.79 (0.13) 7.14 (0.14) 6.23 (0.14) 10 10.88 (0.32) 12.70 (0.39) 11.79 (0.39) 15 13.31 (0.37) 15.51 (0.35) 14.53 (0.36) 20 16.92 (0.61) 19.38 (0.63) 18.48 (0.64) M. Pratama et al. / Journal of Mechatronics, Electrical Power, an d Vehicular Technology 10 (2019) 7–16 16 equipment, the provision on the necessary materials, and also on the complete sampling images collection. Special gratitude was presented to Mr. Amin and Mr. Kristian Ismail, who helped the authors on assembling the whole prototype and apprehending the task of filtering measurement. Declarations Author contribution M. Pratama and W.B. Santoso contributed equally as the main contributor of this paper. All authors read and approved the final paper. Funding statement This research did not receive any specific grant from funding agencies in the public, commercial, or not -for-profit sectors. Conflict of interest The authors declare no conflict of interest. Additional information No additional information is available for this paper. References [1] M. Mittal, “A Study of Live Video Streamin g over Highway Vehicular Ad hoc Networks,” Int. J. Comput. Appl., vol. 1, no. 21, pp. 86–90, Feb. 2010. [2] C. Iza-Paredes, A . M. Mezher, an d M. A guilar Igartua, “Adaptive Video-streaming Dissemination in Realistic Highway Vehicular Ad-Hoc Networks,” in Proceedings of the 13th ACM Symposium on Performance Evaluation of Wireless Ad Hoc, Sensor, & Ubiquitous Networks - PE-WASUN ’16, 2016, pp. 1–10. [3] A. Vinel, E. Belyaev, K. Egiazarian , and Y. Koucheryavy, “An Overtaking Assistance System Based on Joint Beaconing and Real-Time Video Transmission,” IEEE Trans. Veh. Technol., vol. 61, no. 5, pp. 2319–2329, 2012. [4] B. Cronin, “Vehicle Based Data and Availability,” U.S. Department of Transportation, 2016. [5] U. D. Gan dhi, A. Singh, A. Mukherjee, and A. Chan dak, “Smart vehicle connectivity for safety application s,” in 2014 International Conference on Reliability Optimization and Information Technology (ICROIT), 2014, pp. 262–266. [6] C. B. Math , H. Li, and S. Heemstra de Groot, “Risk Assessment for Traffic Safety Applications with V2V Communications,” in 2016 IEEE 84th Vehicular Technology Conference (VTC-Fall), 2016, pp. 1–6. [7] N. F. Mustamin, “Relative distance measurement between moving vehicles for manless driving,” in 2017 International Seminar on Application for Technology of In formation and Communication (iSemantic) , 2017, pp. 1–4. [8] A. A. Ali and H. A. Hussein, “Distance estimation and vehicle position detection based on monocular camera,” in 2016 Al- Sadeq International Conference on Multidisciplinary in IT and Communication Science and A pplications (AIC-MITCSA), 2016, pp. 1–4. [9] H.-K. Cheung, W.-C. Siu, S. Lee, L. Poon, and Chiu-Shing Ng, “Accurate distance estimation using camera orientation compen sation technique for vehicle driver assistance system,” in 2012 IEEE International Conference on Consumer Electronics (ICCE), 2012, pp. 227–228. [10] S. Jabri, M. Saidallah, A. El Belrhiti El Alaoui, and A. El Fergougui, “Movin g Vehicle Detection Using Haar-like, LBP and a Machine Learning Adaboost Algorithm,” in 2018 IEEE International Conference on Image Processin g, A pplication s and Systems (IPAS), 2018, pp. 121–124. [11] E. Baser and Y. Altun, “Detection and classification of vehicles in traffic by using haar cascade classifier,” Proc. 58th ISERD Int. Conf. Sci. Innov. Eng., no. December, pp. 19–22, 2016. [12] M. Rokonuzzaman , M. A. Al Amin, M. H. K. M. U. Ahmed, an d M. T. Rahman, “Automatic vehicle identification system using machine learning and robot operating system (ROS),” in 2017 4th International Conference on Advances in Electrical Engineering (ICAEE), 2017, pp. 253–258. [13] Y. Hasan, M. U. Arif, A . Asif, an d R. H. Raza, “Comparative analysis of vehicle detection in urban traffic environment using Haar cascaded classifiers and blob statistics,” in 2016 Future Technologies Conference (FTC) , 2016, pp. 547–552. [14] G. Kim and J.-S. Cho, “Vision-based vehicle detection and inter- vehicle distance estimation for driver alarm system,” Opt. Rev., vol. 19, no. 6, pp. 388–393, Nov. 2012. [15] R. K. Megalingam, V. Shriram, B. Likhith, G. Rajesh , and S. Ghanta, “Monocular distance estimation usin g pinhole camera approximation to avoid vehicle crash and back-over accidents,” in 2016 10th International Conference on Intelligent Systems and Control (ISCO), 2016, pp. 1–5. [16] X. Ying, G. Wang, X. Mei, S. Yang, an d H. Zha, “The perspective- 3-point problem when using a planar mirror,” Proc. - Int. Conf. Pattern Recognit., pp. 4033–4037, 2014. [17] B. Bellalta, E. Belyaev, M. Jon sson , and A. Vinel, “Performance Evaluation of IEEE 802.11p-Enabled Vehicular Video Surveillance System,” IEEE Commun . Lett., vol. 18, no. 4, pp. 708–711, Apr. 2014. [18] R. M. Howard, “White noise: A time domain basis,” 2015 Int. Conf. Noise Fluctuation s, ICNF 2015, pp. 1–4, 2015. [19] P. Closas, J. Arribas, and C. Fern, “Testing for normality of UWB- based distance measurements by the Anderson-Darling statistic,” Futur. Netw. Mob. Summit 2010 Conf. Proc., pp. 1–8, 2010. https://doi.org/10.5120/46-643 https://doi.org/10.5120/46-643 https://doi.org/10.5120/46-643 https://doi.org/10.1145/2989293.2989301 https://doi.org/10.1145/2989293.2989301 https://doi.org/10.1145/2989293.2989301 https://doi.org/10.1145/2989293.2989301 https://doi.org/10.1145/2989293.2989301 https://doi.org/10.1109/tvt.2012.2192301 https://doi.org/10.1109/tvt.2012.2192301 https://doi.org/10.1109/tvt.2012.2192301 https://doi.org/10.1109/tvt.2012.2192301 https://www.its.dot.gov/itspac/october2012/PDF/data_availability.pdf https://www.its.dot.gov/itspac/october2012/PDF/data_availability.pdf https://doi.org/10.1109/icroit.2014.6798327 https://doi.org/10.1109/icroit.2014.6798327 https://doi.org/10.1109/icroit.2014.6798327 https://doi.org/10.1109/icroit.2014.6798327 https://doi.org/10.1109/vtcfall.2016.7881202 https://doi.org/10.1109/vtcfall.2016.7881202 https://doi.org/10.1109/vtcfall.2016.7881202 https://doi.org/10.1109/vtcfall.2016.7881202 https://doi.org/10.1109/isemantic.2017.8251840 https://doi.org/10.1109/isemantic.2017.8251840 https://doi.org/10.1109/isemantic.2017.8251840 https://doi.org/10.1109/isemantic.2017.8251840 https://doi.org/10.1109/aic-mitcsa.2016.7759904 https://doi.org/10.1109/aic-mitcsa.2016.7759904 https://doi.org/10.1109/aic-mitcsa.2016.7759904 https://doi.org/10.1109/aic-mitcsa.2016.7759904 https://doi.org/10.1109/aic-mitcsa.2016.7759904 https://doi.org/10.1109/icce.2012.6161840 https://doi.org/10.1109/icce.2012.6161840 https://doi.org/10.1109/icce.2012.6161840 https://doi.org/10.1109/icce.2012.6161840 https://doi.org/10.1109/icce.2012.6161840 https://doi.org/10.1109/ipas.2018.8708898 https://doi.org/10.1109/ipas.2018.8708898 https://doi.org/10.1109/ipas.2018.8708898 https://doi.org/10.1109/ipas.2018.8708898 https://doi.org/10.1109/ipas.2018.8708898 http://www.worldresearchlibrary.org/up_proc/pdf/578-148663411819-22.pdf http://www.worldresearchlibrary.org/up_proc/pdf/578-148663411819-22.pdf http://www.worldresearchlibrary.org/up_proc/pdf/578-148663411819-22.pdf https://doi.org/10.1109/icaee.2017.8255362 https://doi.org/10.1109/icaee.2017.8255362 https://doi.org/10.1109/icaee.2017.8255362 https://doi.org/10.1109/icaee.2017.8255362 https://doi.org/10.1109/icaee.2017.8255362 https://doi.org/10.1109/ftc.2016.7821660 https://doi.org/10.1109/ftc.2016.7821660 https://doi.org/10.1109/ftc.2016.7821660 https://doi.org/10.1109/ftc.2016.7821660 https://doi.org/10.1007/s10043-012-0063-1 https://doi.org/10.1007/s10043-012-0063-1 https://doi.org/10.1007/s10043-012-0063-1 https://doi.org/10.1109/isco.2016.7727017 https://doi.org/10.1109/isco.2016.7727017 https://doi.org/10.1109/isco.2016.7727017 https://doi.org/10.1109/isco.2016.7727017 https://doi.org/10.1109/isco.2016.7727017 https://doi.org/10.1109/icpr.2014.691 https://doi.org/10.1109/icpr.2014.691 https://doi.org/10.1109/icpr.2014.691 https://doi.org/10.1109/lcomm.2014.022514.140206 https://doi.org/10.1109/lcomm.2014.022514.140206 https://doi.org/10.1109/lcomm.2014.022514.140206 https://doi.org/10.1109/lcomm.2014.022514.140206 https://doi.org/10.1109/icnf.2015.7288581 https://doi.org/10.1109/icnf.2015.7288581 https://ieeexplore.ieee.org/document/5722412 https://ieeexplore.ieee.org/document/5722412 https://ieeexplore.ieee.org/document/5722412 https://ieeexplore.ieee.org/document/5722412