## 5 Pedestrian Dense Optical Flow ROI Processing  
The pedestrian dense optical flow of the entire image obtained by FlowNet2.0 revealed that a large part of the optical flow consisted of immobile backgrounds, which could have caused excessive computation or even interference in the subsequent NN training and recognition. To eliminate excessive background areas and focus the analysis on pedestrians, a YOLOv2 object detection NN was employed to detect pedestrian location. Subsequently, the PROI was captured from the corresponding pedestrian dense optical flow, and the background region where no pedestrian optical flow was detected was discarded to reduce the optical flow size. Then, the obtained pedestrian optical flow was aligned centrally to facilitate zero-padding on the surrounding area until the maximal border (H length and W width) was reached. Through this method, the raw pedestrian color image was converted into a pedestrian optical flow ROI sequence.  
To facilitate batch training, the size of all optical flow input was set to 304 \(\times\) 480 pixels, and all values were normalized to the interval of [0, 1]. However, this size was still a considerable burden for the training network. According to [8, 9], low resolution can achieve similar effects while accelerating the training process. In contrast to [9], which reduced the size of raw images, the present study reduced the optical flow size to one-eighth of the original size (38 \(\times\) 60). Figure 5 presents the results of the encoded PROI captured from the optical flow, which was captured by the optical flow-capturing NN mapped onto the color image space.  
Figure 5: Pedestrian optical flow ROI obtained by FlowNet2.0 and YOLOv2.  
According to the training strategy and actual observation dataset in [9], the walking cycle of a pedestrian is approximately 25 frames per cycle. Therefore, every 25 frames from the processed pedestrian optical flow sequence were taken as a sample and each sample was taken five frames apart. Eight to twelve samples were taken from each sequence and the total number of samples was 26,948. Each optical flow contained two channels of directional displacement velocity, namely the x-direction displacement at velocity u and y-direction displacement at velocity v. Therefore, an input of size 38 length \(\times\) 60 width \(\times\) 50 channels was obtained for each sample.  
At the input stage, samples were processed by one-hot encoding (305 pedestrians coded from 0 to 304) to obtain the same number of dimensional vectors as that of pedestrian optical flow samples. Each dimension represented the probability of a specific pedestrian. The correct dimension was marked 1.0 and all others were marked 0.0. For example, if one ground truth was tagged No. 25, one-hot encoding would obtain a 305-dimensional vector where the vector with an index of 25 would be marked 1.0, and all others would be marked 0.0.  
The 26,948 samples were divided into a training set and testing set. This study established the following experimental plans:  
1. All samples were randomly distributed at a 7:3 ratio to yield 18,978 training samples and 7970 testing samples.
2. All samples were randomly distributed at a 5:5 ratio to yield 13,558 training samples and 13,390 testing samples.