Vehicle Detection Using Principal Component Analysis

The detection of a vehicle in video is an activity that is important to help the security forces keep an eye on the traffic flow. However, it is hard to security forces to keep watching the video (CCTV) of traffic flow in all day long. Artificial intelligence can be use to help the security to monitoring and analyze the traffic of vehicles, such as to know the level of vehicle traffic density at a certain time period or find out detailed information about the vehicle that want to observed. In this study, Principle Component Analysis (PCA) method used to doing background substraction process to detect vehicles in a real time. To improve the results of PCA method, morphological operation is implemented. The experiment result shown that PCA method is well used to detect the vehicle in a real time with accuracy at 95%. 
   Abstrak 
Pendeteksian kendaraan menggunakan video merupakan kegiatan yang penting untuk membantu pihak keamanan untuk mengawasi arus lalu lintas. Akan tetapi, sangat sulit bagi pihak keamanan untuk terus mengawasi video arus lalu lintas sepanjang hari melalui CCTV. Oleh karena itu kecerdasan buatan dapat digunakan untuk membantu pihak keamanan dalam memantau dan menganalisis lalu lintas kendaraan, seperti untuk mengetahui tingkat kepadatan lalu lintas kendaraan pada periode waktu tertentu atau mengetahui informasi terperinci tentang kendaraan yang ingin diamati. Dalam penelitian ini, metode Principle Component Analysis (PCA) digunakan untuk melakukan proses substraksi latar belakang untuk mendeteksi kendaraan secara real time. Untuk meningkatkan hasil metode PCA, operasi morfologi diimplementasikan. Hasil percobaan menunjukkan bahwa metode PCA baik digunakan untuk mendeteksi kendaraan secara real time dengan tingkat akurasi 95%.


Introduction
Video surveillance has been used to observe trac and to see the state on the streets such as the number of vehicles. In the beginning, observation trac doing by human manually by monitoring CCTV video footage regularly. However this method is not eective because it is hard to human to monitor trac all day. Therefore, a lot of research is done to overcome this as well as provide methods that can be used to analyze videos from CCTV as needed. In this study, we propose background substraction using Principle Component Analysis (PCA) to detect vehicles on CCTV videos. This detection is done to nd the object of the moving vehicle on the video frame. The process of detecting objects can be done by using feature extraction on video frames. Feature extraction DOI : http://dx.doi.org/10.32409/jikstik.19. 2.2856 is performed to get the background image of the frame. In the next step, reduces the original image with the background image to obtain the image with the object only to be detected. This stage is called the background substraction. The resulting of background substraction is a binary image (foreground image).
Some researchers perform background substraction processes, such as Rad, AG, et. al. [1] that using the Mean Filter and combination of value and saturation to get the background and foreground of the video, which obtained an accuracy rate 93%. To recognize the object, Qing Tian, et.al. [2] used Support Vector Machine (SVM), then used Histograms of Oriented Gradients (HOG) features to extract features. Shweta [3] used a at frame to get the background from the video and use the threshold to get the foreground image. In the other research, Sundoro, et.al [4] used Gausian Mixture Model (GMM) to get background and foreground, has accuracy rate 90,5%. In case of road detection, Taeyoung Kim, et. al. [5] used PCA-based illumination invariant space computation. Sai Sri Harsha [6] developed background subtraction of multilane trac data based on an adaptive learning rate based on Gaussian mixture model (GMM) algorithm. A new backdrop Gaussian Mixture Model and dark elimination method have been used to deal with sudden enlightenment changes and camera shaking [7].

Material And Method
In this research we use Principle Component Analysis (PCA) to obtain a video background and use image morphology to detect a vehicle in some video. In general, the stages of research performed in this study are shown in Fig. 1.  Fig. 1, the rst step in this research is to obtain some video image of trac video. The camera used to acquire video image in this study is assumed to be motionless or static. Some video of trac extracted into some frames. All frames from video extraction saved into database frames. All the images in database frames are converted into grey images.
The next step is to use the Principle Component Analysis (PCA) method to nd background substraction and foreground images, because PCA is one of the techniques that can be used to get a foreground image from a set of images or video frames [8].

Principle Component Analysis
Principle component analysis is a technique for reducing dimensions [8] and can be used to determine the optimum location of a set of images [9]. If there are a number of data image, each image is converted into vectors and then combined into a matrix (X). The next step is transforms the X matrix (for example has size MÖN) into a lower dimension matrix (Y). Matrix Y called the principle component matrix corresponding to the linear transformation P represented by equation (1).
where: M = number of rows of X matrix, N = number of columns of X matrix R = the mean vector of the X matrix The principal component can be found by calculating the eigenvector and eigenvalues of the covariance matrix (X-r). The covariance C matrix can be seen in equation (2).
Row in the matrix P in equation (1) is formed by the eigenvector of C corresponding to the ordered eigenvalue. After being sorted, then we select an eigenvector corresponding to the highest eigenvalue to be a transformation matrix P, with K < M , so that the matrix Y in equation (1) have a size KxM . The matrix P in equation (1) is an orthonormal matrix, so based on the matrix theorem we have P ∧ (-1)=P ∧ T [10]. Thus the inverse of Principle Component Analysis (PCA) becomes equation (3).
Furthermore, after get background substraction and foreground images by using PCA, we implemented noise remover and morphological operations to foreground image, because foreground images still have unwanted noises and holes. After removed all noises and ll the holes, bounding box steps is used to complete the detection of vehicles.

Morphological Operations
A various of image processing techniques that related to the shape (or morphology) of features in some image represented by Morphological image processing [11]. The formulas or operators to carry out morphological operations are called morphological operators. Morphological operations are mostly applied to remove imperfections identied during segmentation process [11].
Other examples of morphological applications are object frame acquisition, determining the location of objects within the image, smoothing the contours and eliminating small holes. The essence of morphological operation is to use two pixel array that is the rst array of images to be subjected to morphological operations, while the second line is named as kernel or Structuring Element.
Two basic morphological processing operations are Dilation and Erosion. Dilation and Erosion play a role as the basic elements of many algorithms and dened in terms of more elementary set operations. Both of them are produced by the interaction of a set, called a Structuring Element, with a set of pixels of interest in the image. The structuring element has both a shape and an origin [11]. The Dilation and Erosion operations of image A with the structuring element B are formulated in equation (4) and (5) respectively, with A(x,y) is a set of pixels of interest (PI) in the image A and B(m,n) is a structuring element (SE) [12].  (6) and (7). In simple terms it can be said that the Opening operator is carried out by applying Erosion operations followed by Dilation operations, while the Closing operator does the opposite [12].
In general, the Opening operator smoothes the contour of an object. Meanwhile the Closing operator eliminates small holes, and lls gaps in the contour.
After the morphological process is carried out, bounding boxes are made from the morphological results. If a car is detected, there will be a bounding box around the car.

Experimental Result
In this study, we used vehicle trac video, that extracted into some of frames, which is in this case consisting of 80 frames. Some example of frames from trac video given in Fig. 2.

Figure 2: Example of Frames from Trac Video
Image 1 is the rst frame, image 2 is the 35 th frame, image 3 is the 52 th frame, image 4 is the 61 th frame, and image 5 is the last frame (80 th frame). Such images are dened as {X 1 , X 2 , X 3 ,...X 80 }. We use PCA method to get background image of images in Fig. 2, that can be seen in Fig. 3. Fig. 3 is background image which is obtained by using PCA method. By implemented PCA method to some image, one or some moving objects (vehicles) will be separated from the background. After that, we search foreground image by perform background substaction. Background substraction is performed by reduces the original image ( Fig. 2) with background image (Fig. 3). The result of foreground image can be seen in Fig. 4. There are unwanted noises on images in Fig.  4, so the noises must to be removed by using threshold determination. Fig. 5 shows the results of noise removal of images in Fig. 4. We can see that the unwanted noises on all images in Fig. 5 are removed.
Tarun Kumar [13] only used noise remover for detection of moving vehicles. In this research we use morphological operations to get a better results. Morphological operations, such as dilation, are used to ll some small holes from the observed object. The results of morphological operations can be seen on Fig. 6. Fig. 6 shows the results of dilation of each images in Fig. 5. Fig. 6 shows dilation image of morphological operations.
It can be seen that morphological operations can ll some small holes from the observed object. Furthermore, to complete the detection vehicle, we build bounding box of the observed object by using result of morphological operations from Fig. 6. The results of bounding box image of each frames are showed in Fig. 7. Bounding boxes are the detection of vehicles by using PCA method. The Evaluation Result In this research, we evaluate the results of the PCA by using some indicators such as precision, recall and accuracy. The formula of them can be seen in equation (8), (9)   FP (False Positive) : no vehicle is detected in real condition but is stated as a vehicle in the application.
FN (False Negative) : the vehicle is detected in real conditions but the application is not declared TN (True Negative) : no vehicle is detected in real conditions and the application is not declared.
In this study we use 80 sample image which contain vehicle. The evaluation result is shown in Table 1. Based on Table I we obtain a value of precision is 97,43%, value of recall is 97,43% and value of accuracy is 95%.

Conclusion
In perform the trac control, security forces usually use videos that obtained from CCTV and need to human to monitor trac all day. This method is not eective. In this study we use image processing to monitor trac such as detecting vehicles. Image processing methods that used to detect vehicles is Principle Component Analysis (PCA). PCA can separate some move objects with background image. The result of PCA method is a background image. After background image obtained, the original image is reduced with a background image to get some moving object. This step is called background substraction. The result of background substraction is a binary image of a moving object (foreground image). After that morphological operations and noise removal are used to get a clear objects. Then we use bounding box to detect object (vehicle). Based on the results of detection, it can be seen that the PCA method can detect vehicle with accuracy 95%. In future work, we will try to detect vehicles when trac conditions are heavy.