# Motion Control System of Unmanned Railars Based on Image Recognition
## 2 Detecting Predefined Signs with Image Recognition
### Image Recognition of Predefined Signs  
After image preprocessing, the system needs to detect the predefined signs that serve as motion commands in the consecutive gray level image frames. In this research, we need four strong classifiers to detect the four predefined signs of acceleration, deceleration, reverse and stop in consecutive gray level image frames. The system first extracts Haar-like features from consecutive gray level image frames. Then, input those features to predefined signs' classifiers in the main program. Once a predefined sign is detected, the system can respond properly to generate PWM commands to control the motion of the railcar. To enhance the integrity of this paper, how the integral image based extended set of Haar-like features works with the AdaBoost algorithm [10; 11; 12; 20], and can form a strong classifier to identify a predefined sign in image frames, is briefly explained in this section. For a gray level image, an integral image of a pixel with coordinates (\(x\), \(y\)) is the sum of its neighbors to the upper left, and is defined in (2):  
\[ii(x,y)=\sum_{x^{\prime}\leq x}\sum_{y^{\prime}\leq y}I\big{(}x^{\prime},y^{ \prime}\big{)}. \tag{2}\]  
Mathematically speaking, unlike the original pixels' gray level values that have many identical numbers in an image frame, their integral image values of pixels are quite different from each other. Therefore, integral image is very useful for unique feature extractions (See Figure 1). \[ii_{1}=Sum(A), \tag{3}\]  
\[ii_{2}=Sum(A)+Sum(B), \tag{4}\]  
\[ii_{3}=Sum(A)+Sum(C), \tag{5}\]  
\[ii_{4}=Sum(A)+Sum(B)+Sum(C)+Sum(D), \tag{6}\]  
\[Sum(D)=ii_{1}+ii_{4}-(ii_{2}+ii_{3}), \tag{7}\]  
\[Sum(C)=ii_{3}-ii_{1}, \tag{8}\]\[Sum(B)=i\dot{i}_{2}-i\dot{i}_{1}. \tag{9}\]  
According to Figure 1, applying (3)-(9), one can compute the integral images of individual blocks. Based on these integral images of individual blocks, the extended Haar-like rectangle features with different black and white areas as shown in the Figure 2 of [11] are used. They are sensitive to the presence of edges, bars and other simple image structures. In those features, black areas have negative and white areas positive weights. Two-rectangle feature is the sum of the pixels, which lie within the white rectangles being subtracted from the sum of pixels in the black rectangles, while a three-rectangle feature computes the sum within two outside rectangles, subtracted from the sum in a center rectangle. The number of features derived from extended Haar-like rectangle features is quite large. For example, for a 24 \(\times\) 24 detection window, the total number of features is 117,941--that is a number far larger than the number of pixels. Please refer to [11] for details. Actually, only very small numbers of these features are enough to combine to form an effective strong classifier. In this paper, AdaBoost algorithm [20; 25] is then employed to select the most suitable features. AdaBoost, short for Adaptive Boosting, is an iterative method to improve the accuracy of machine learning. Boosting is an ensemble technique (a.k.a. a committee method). A weak classifier with the least error rate is selected in every iteration. When the iterations finish, a strong classifier of highly accurate prediction is created by combining all weak learners. In this paper, the AdaBoost algorithm is chosen to build the four strong classifiers for both high accuracy and fast speed. To train a strong classifier with this AdaBoost algorithm, we have to prepare \(m\) training sets \(\left<x_{i},y_{i}\right>\), where \(x_{i}\) is the ith sample, \(y_{i}\) is the corresponding label of \(x_{i}\), and \(1\leq\mathrm{i}\leq\mathrm{m}\). For our application, the sample \(x_{i}\) is a vector of Haar-like features extracted from a training image frame. The label \(y_{i}=+1\) indicates the predefined sign shows up in the training image and the corresponding sample \(x_{i}\) is a positive sample.