# Construction of Robotics and Application of the Optical-Flow Algorithm in Determining Robot Motions
## 2 Methodology
To determine the object's distance \(d\) and angle of deviation \(\alpha\) in the camera's coordinate system, we propose utilizing the following correlation functions: \(d(h)\) relates the object's distance to its perceived height in the image, while \(\alpha(\Delta x)\) correlates the object's angle of deviation to its horizontal offset. These correlation functions are pre-trained based on the system's object recognition outcomes. Note that the current study focuses on objects moving in urban cities at distances smaller than 100 m. Consequently, we focused only on the algorithm for two-dimensional (2D) flat space. The change in position of the object in the z direction was not considered. Clearly, in 3D space, uncertainty in the z direction can increase. However, the algorithm could not be changed, and the concept in the current study can be applied for 3D space. The proposed method, however, necessitates the construction of two unique correlation functions for each distinct object, which can be computationally burdensome, especially when dealing with a large number of object classes. To address this limitation, we introduce a standardization approach. By establishing a standard object and its corresponding correlation functions \(d(h)\) and \(\alpha(\Delta x)\), along with a scale factor \(k_{dt}\) for each object class, the system can efficiently calculate the distance \(d\) and angle \(\alpha\) for any given object. For the details, two functions are shown by the below equations:  
\[d = *d(h/k_{dt})\] \[\alpha = *\alpha(\Delta x) \tag{5}\]  
The algorithm for determining the object's position, velocity, and movement angle is presented in Figure 2.  
In more detail, there are eight steps for determining the velocity and angles of the camera. The details of each step and its meaning are described as follows:  
Step 1: Image Acquisitions  
In this step, images of the object's area of activity are continuously updated by the camera and pre-processed to enhance image quality before being fed into the object detection and recognition program. In practice, to capture images, the authors use the Sony FCB-EV7520A camera--a high-quality industrial camera produced by Sony Corporation, Huizhou, China. With its high resolution of 4K (3840 \(\times\) 2160 pixels), powerful zoom capability (30\(\times\)), high-quality recording modes (4K, 1080p, 720p), and a frame rate of up to 60 fps, this camera effectively meets the needs of accurate and efficient object surveillance and recognition. Step 2: Object Detection  
Object detection is one of the most fundamental tasks in building high-tech systems for image processing applications. Previously, when deep learning and image processing technology were still simple, some image processing methods such as SIFT and HOG were often applied to detect objects using edge extraction techniques [18; 19]. However, with the advent of convolutional neural networks (CNN) [20; 21] and advancements in computer vision technology, many more efficient approaches and algorithms for object detection have emerged. Among the various object detection algorithms, the YOLO framework has stood out for its remarkable balance of speed and accuracy, enabling the rapid and reliable identification of objects in images [17; 22]. The YOLO algorithm takes an image as input and then uses a simple deep convolutional neural network to detect objects within the image. The architecture of the CNN model that forms the backbone of YOLO is shown below [17]. YOLO's real-time object detection capabilities have been invaluable in autonomous vehicle systems, enabling quick identification and tracking of various objects, such as vehicles, pedestrians [23; 24], bicycles, and other obstacles [25; 26]. These capabilities have been applied in numerous fields, including action recognition in video sequences for surveillance [27], sports analysis [28], and person-computer interaction. They have also  
Figure 2: Algorithm for determining the position, velocity, and direction of the object’s movement.