«上一篇
 文章快速检索 高级检索

 应用科技  2018, Vol. 45 Issue (2): 55-59  DOI: 10.11991/yykj.201706012 0

### 引用本文

ZHANG Tianyi, YANG Zhong, HAN Jiaming, et al. Approach of vision navigation of UAV based on continuously adaptive mean-shift and stereo vision[J]. Applied Science and Technology, 2018, 45(2), 55-59. DOI: 10.11991/yykj.201706012.

### 文章历史

Approach of vision navigation of UAV based on continuously adaptive mean-shift and stereo vision
ZHANG Tianyi, YANG Zhong, HAN Jiaming, SONG Jiarong, ZHU Jiayuan
College of Automation Engineering, Nanjing University of Aeronautics and Astronautics, Nanjing 210016, China
Abstract: The purpose of this paper is to design an approach which lets the UAV automatically track the moving objects and avoid obstacles. In this approach, both the monocular and binocular cameras are installed on UAV. The images of a tracked object are captured by the monocular camera while the continuously adaptive mean-shift (Camshift) algorithm optimized by Kalman predictor is used to continuously track the target. At the same time, the image information in the forward direction of UAV is captured by the binocular cameras, SGM algorithm is used to generate depth maps, which are used to segment obstacles in front of UAV. By this approach, UAV can continuously track a moving vehicle and automatically avoid obstacles on the way of flight in real time. Experimental results demonstrate that this approach can effectively and precisely guide the UAV to track a moving object and avoid obstacles in the route of flight.
Key words: Camshift    stereo vision    UAV    object tracking    obstacle avoidance recognition    stereo match    vision navigation    image segmentation

1 无人机视觉导航系统架构

2 无人机移动目标跟踪算法

1）将输入的图像由RGB空间转化为HSV空间。

2）手动选择需要跟踪的移动目标区域，并计算该区域Hue通道的颜色概率分布图。

 $I(x,y) = {w_i} = \sum\limits_{u = 1}^m {{Q_u}} \delta [b({x_i}) - u]$

3）通过计算概率分布图的0阶矩( ${{ M}_{00}}$ )和1阶矩( ${{ M}_{01}}$ , ${{ M}_{10}}$ )，可以计算获得目标的质心位置 $({x_c},{y_c})$

 \begin{aligned}& {M_{00}} = \sum\limits_x {\sum\limits_y I } (x,y)\\& {M_{10}} = \sum\limits_x {\sum\limits_y {xI} } (x,y)\\& {M_{01}} = \sum\limits_x {\sum\limits_y {yI} } (x,y)\\& {x_c} = \frac{{{M_{10}}}}{{{M_{00}}}}\\& {y_c} = \frac{{{M_{01}}}}{{{M_{00}}}}\end{aligned}

4）计算移动物体的跟踪矩形框长轴 ${l_1}$ 和短轴 ${l_2}$ 的长度及目标相对于无人机运动方向角 $\theta$

 \left\{ \begin{aligned}& {l_1} = \sqrt {\frac{{(a + c) + \sqrt {{b^2} + {{(a - c)}^2}} }}{2}} \\& {l_2} = \sqrt {\frac{{(a + c) - \sqrt {{b^2} + {{(a - c)}^2}} }}{2}} \\& \theta = \frac{1}{2}\arctan (\frac{b}{{a - c}})\end{aligned} \right. (1)

 $a = \frac{{{M_{20}}}}{{{M_{00}}}} - x_c^2,b = 2(\frac{{{M_{11}}}}{{{M_{00}}}} - {x_c}{y_c}),c = \frac{{{M_{02}}}}{{{M_{00}}}} - y_c^2$
 ${M_{11}} = \sum\limits_{i = 1}^n {xy{w_i}} ,{M_{20}} = \sum\limits_{i = 1}^n {{x^2}{w_i}} ,{M_{02}} = \sum\limits_{i = 1}^n {{y^2}{w_i}}$

Camshift算法虽有诸多优点，但其返回的目标物体跟踪框的质心坐标容易受噪声影响。再有，当目标物体暂时被遮挡或丢失而后重新出现时，Camshift算法无法再次搜寻到目标物体，造成跟踪失败的情况。基于以上问题，本文采用Kalman预测器对连续自适应均值漂移算法进行优化[10-11]，具体步骤如下。

 ${{{X}}_k} = {\left[ {\begin{array}{*{20}{c}} {{x_k}}&{{y_k}}&{\begin{array}{*{20}{c}} {{\theta _k}}&{{v_{x,k}}}&{{v_{y,k}}} \end{array}}&{{v_{\theta ,k}}} \end{array}} \right]^{{T}}}$
 ${{{Z}}_k} = {\left[ {\begin{array}{*{20}{c}} {{x_k}}&{{y_k}}&{{\theta _k}} \end{array}} \right]^{{T}}}$

 ${{{X}}_{_k}} = {{{\varPhi}} _{k,k - 1}}{{{X}}_{k - 1}} + {{{N}}_{k - 1}}$ (8)

 ${ \varPhi _{k,k - 1}} = \left[ {\begin{array}{*{20}{c}}1 & 0 & 0 & {\Delta t} & 0 & 0\\0 & 1 & 0 & 0 & {\Delta t} & 0\\0 & 0 & 1 & 0 & 0 & {\Delta t}\\0 & 0 & 0 & 1 & 0 & 0\\0 & 0 & 0 & 0 & 1 & 0\\0 & 0 & 0 & 0 & 0 & 1\end{array}} \right]$

 ${{{Z}}_{_k}} = {{{H}}_k}{{{X}}_k} + {{{V}}_k}$ (10)

 ${{{H}}_k} = \left[ \begin{array}{l}\begin{array}{*{20}{c}}{\begin{array}{*{20}{c}}1 & 0 & 0\end{array}} & 0 & 0 & 0\end{array}\\\begin{array}{*{20}{c}}{\begin{array}{*{20}{c}}0 & 1 & 0\end{array}} & 0 & 0 & 0\end{array}\\\begin{array}{*{20}{c}}{\begin{array}{*{20}{c}}0 & 0 & 1\end{array}} & 0 & 0 & 0\end{array}\end{array} \right]$

 ${{\mathord{\buildrel{\hbox{$\scriptscriptstyle\frown$}} \over X} }}(k|k) = {{\mathord{\buildrel{\hbox{$\scriptscriptstyle\frown$}} \over X} }}(k|k - 1) + {{{K}}_k}[{{{Z}}_k} - {{{H}}_k}{{\mathord{\buildrel{\hbox{$\scriptscriptstyle\frown$}} \over X} }}(k|k - 1)]$

Kalman预测器的预测方程为

 ${{\mathord{\buildrel{\hbox{$\scriptscriptstyle\frown$}} \over X} }}(k + 1|k) = {{\varPhi \mathord{\buildrel{\hbox{$\scriptscriptstyle\frown$}} \over X} }}(k|k - 1) + {{\varPhi }}{{{K}}_k}[{{{Z}}_k} - {{{H}}_k}{{\mathord{\buildrel{\hbox{$\scriptscriptstyle\frown$}} \over X} }}(k|k - 1)]$ (13)

3 基于立体视觉的无人机避障算法

 $C(p,{D_p}) = \min (d(p,p - d,{I_{{L}}},{I_{{R}}}),d(p - d,p,{I_{{L}}},{I_{{R}}}))$
 $d(p,p - d,{I_{{L}}},{I_{{R}}}) = \mathop {\min }\limits_{p - 0.5 \leqslant p + 0.5} |{I_{{L}}}(p) - {I_{{R}}}(q)|$

 $S(p,d) = \sum\limits_r {{L_r}(p,d)}$

 $\begin{array}{l}{L_r}(p,d) = C(p,d) + \min ({L_r}(p - r,d),{L_r}(p - r,d - 1) + {P_1},\\{L_r}(p - r,d + 1) + {P_1},\mathop {\min }\limits_i {L_r}(p - r,i) + {P_2})\; - \min {L_r}(p - r,k)\end{array}$

 $Z = \frac{{fT}}{d}$

4 实验验证

4.1 基于双目视觉的无人机避障实验

4.2 无人机移动目标跟踪实验