# Target Recognition and Navigation Path Optimization Based on NAO Robot
## 2 NAO Robot's Monocular Vision Spatial Target Localization
### Monocular Vision Location and Ranging  
The monocular vision positioning model is shown in Figure 1. According to the small hole perspective model, the position of the target in space is obtained through the transformation between the image coordinates and the actual space coordinates. When positioning the target object in robot coordinates, the height of the target should be lower than that of the camera.  
The local image can be obtained by observing the monocular vision positioning model, in which (a) top view, (b) side view, and (c) image coordinate system is shown in Figure 2.  
In the figure, \(\theta_{headpitch}\) is the head pitch angle, \(\theta_{headput}\) is the head deflection angle, \(\theta_{balpitch}\) is the vertical field angle, \(\theta_{ballput}\) is the horizontal field angle, \(H\) is the camera height,\(w\) is the image width, \(h\) is the image height, (\(X_{0}\), \(Y_{0}\)) is the image coordinate system coordinates, (\(X_{1}\), \(Y_{1}\)) is the world coordinate system coordinates, \(r\) is the small ball radius, \(\theta_{c\_direction}\) is \(47.64^{\circ}\).  
After image preprocessing, (\(X_{0}\), \(Y_{0}\)), \(w\) and \(h\) are the image resolution \(640\times 480\) pix, \(\theta_{c\_pitch}\) is the maximum value of the camera's vertical field angle, \(\theta_{c\_yaw}\) is the maximum value of the camera's pitch angle, where \(H\), \(\theta_{headpitch}\), \(X_{camera}\), \(Y_{camera}\) are obtained through internal functions.  
\[\theta_{balpitch}=\frac{(Y_{0}-240)\times\theta_{c\_pitch}}{480} \tag{3}\]  
\[\theta_{balyaw}=\frac{(320-X_{0})\times\theta_{c\_yaw}}{640} \tag{4}\]  
\[d_{pitch}=\frac{(H-r)}{tan(\frac{\theta_{c\_direction}\times H}{180}+\theta_{ headpitch}+\theta_{ballpitch})} \tag{5}\]  
\[d_{yaw}=\frac{d_{pitch}}{cos\theta_{ballyaw}} \tag{6}\]  
Figure 1: Monocular vision location model.  
Figure 2: Local image of monocular vision location model: (**a**) vertical view; (**b**) side view; (**c**) image coordinate system.  
\[X_{1} =d_{yuuv}\times cos\Big{(}\theta_{ballyuw}+\theta_{headyuw}\Big{)}+X_{camera} \tag{7}\] \[Y_{1} =d_{yuw}\times sin\Big{(}\theta_{ballyuw}+\theta_{headyuw}\Big{)}+Y_{camera} \tag{8}\]  
From Equations (3)-(6), the coordinates of the small ball world coordinate system (\(X_{1}\), \(Y_{1}\)) can be obtained. When the ball has a certain height, the NAO robot coordinate system is taken as the three-dimensional coordinate system. The height of the small ball is \(h_{1}\), modify Equation (5).  
\[d_{pitch}=\frac{(H-r-h_{1})}{tan(\frac{\theta_{e\_dist}\times p _{1}}{180}+\theta_{headpitch}+\theta_{ballpitch})} \tag{9}\]  
Bring Equation (9) into Equation (6) to get the coordinates of the ball at a certain height; \(h_{2}\) is the height from the origin to the ground under the robot coordinate system. The coordinates of the ball in the robot coordinate system are (\(X_{1}\), \(Y_{1}\), \(r+h_{1}-h_{2}\)).  
There is a certain error in the spherical coordinates obtained by calculation. To eliminate the error, the error coefficient \(k\) is proposed to compensate for the actual distance, as shown in:  
\[X=k\times x. \tag{10}\]  
The error coefficient \(k\) can be solved with a quartic polynomial:  
\[k=ax^{4}+bx^{3}+cx^{2}+dx+e \tag{11}\]  
**Remark 1**: _Since the two cameras of the NAO robot are on the forehead and mouth (hardware structure design problem), the overlapping area scanned with the two cameras is small. Thus, the stereo vision and full vision systems cannot be used in the NAO robot. Furthermore, as a typical system of visual positioning system, the monocular vision system has achieved many research achievements on the target location model, which has good stability._