# Motion Control System of Unmanned Railars Based on Image Recognition
## 2 Detecting Predefined Signs with Image Recognition
### Training Strong Classifiers of Motion Comands  
Since the railcars used in this experiment are mini train models with a scale of \(1/150\), the size of the predefined signs used in the experiment is only \(1\) cm by \(1\) cm. However, when training the strong  
Figure 2: Predefined signs serving as motion commands: (**a**) acceleration; (**b**) deceleration; (**c**) stop; (**d**) reverse.  
classifiers for those signs, the photo samples were enlarged to 9 cm \(\times\) 9 cm to retain much more detail, and avoid distortion so that we can get better results. Using the acceleration sign as our example, to train the strong classifier we have to prepare two image sample folders. One is the positive sample folder, which contains photos of our acceleration sign taken at slightly different angles, as shown in Figure 3.  
The other is the negative sample folder of background sample images, in which every photo has no acceleration sign as shown in Figure 4.  
OpenCV (Open Source Computer Vision Library) [17] provides many image processing related functions and utilities. OpenCV has adopted [PERSON] methodology and [PERSON]'s extended set of Haar-like features to provide two very useful utilities, _opencv_createsamples_ and _opencv_raincascade_[26] for training strong classifiers based on AdaBoost. To apply them, negative samples are further enumerated in a background description file [26]. It is a text file, in which each line contains an image filename (relative to the directory of the description file) of a negative sample image. With the prepared positive sample images and background description file, we first follow the instructions of applying _opencv_createsamples_ to generate an output vector file containing the positive samples for training. With the output vector file containing the positive samples obtained from _opencv_createsamples_ and the background description file, we then follow the instructions of using  
Figure 4: Some negative samples of acceleration sign.  
Figure 3: Some positive samples of acceleration sign.  
opency_fraincascade_ to obtain the strong classifier of acceleration in xml format. Repeating the same process we can obtain strong classifiers of deceleration, reverse and stop signs. After a classifier of a predefined sign is trained, it can be applied to a region of interest (of the same size as that which was used during the training) in an input image. The classifier outputs a \"1\" if the region is likely to show the predefined sign, and \"\(-\)1\" otherwise. To search for the predefined sign in the whole image, one can move the search window across the image and check every location using the classifier. The classifier is designed so that it can be easily \"resized\" in order to be able to find the predefined sign at different sizes, which is more efficient than resizing the image itself. Therefore, to find a predefined sign of an unknown size in the image, the scan procedure should be done several times at different scales. This can be done by applying _CascadeClassifier:detectMultiScale_[27] in OpenCV.  
In experiment, the accuracy of the strong classifier related to \(K\), the Number of iterations or cascade stages, should be trained. If \(K\) is too small (under training), false detections of non-predefined signs happen. On the other hand, if \(K\) is too large (over training), predefined signs could be overlooked by the system. Therefore, we should adjust \(K\) to get the classifiers with high accuracy.