﻿ 基于毛笔建模的机器人书法系统
«上一篇
 文章快速检索 高级检索

 智能系统学报  2021, Vol. 16 Issue (4): 707-716  DOI: 10.11992/tis.202006033 0

### 引用本文

WANG Yuzhuo, MIN Huasong. Robot calligraphy system based on brush modeling[J]. CAAI Transactions on Intelligent Systems, 2021, 16(4): 707-716. DOI: 10.11992/tis.202006033.

### 文章历史

Robot calligraphy system based on brush modeling
WANG Yuzhuo , MIN Huasong
School of Information Science and Engineering, Wuhan University of Science and Technology, Wuhan 430081, China
Abstract: A novel robot calligraphy system is proposed to enable robots to write Chinese characters by using a brush in a slanted position, with the purpose of solving the problem of the existing robot calligraphy system taking only the straight state of the brush into consideration. First, writing marks are analyzed in this proposed system, and an appropriate stroke model is established based on the linear regression algorithm. Then, the trajectory information is obtained from the stroke image by using genetic algorithms, which are added with the rules of starting, running, and closing for virtual stroke images. Lastly, path planning for robots is realized by using a B-spline algorithm, and posture calculation is fulfilled through coordinate transformation, thereby achieving actual writing. In the experiments, three stroke characteristics are extracted as evaluation indicators. Experimental results show that the robot brush calligraphy system can achieve a better writing effect.
Key words: robot calligraphy    brush modeling    genetic algorithm    writing rules    path planning    posture change    calligraphy evaluation    stroke characteristics

1 机器人毛笔模型 1.1 模型概述

1.2 笔触模型

1.2.1 采集实际足迹

1.2.2 计算模型参数

3次Bézier曲线如式(1)所示：

 \begin{aligned}B({{t}}) = {P_0}{(1 - t)^3} + 3{P_1}t{(1 - t)^2} + 3{P_2}{t^2}(1 - t) + {P_3}{t^3} \\ \;t \in [0,1]\quad\quad\quad\quad\quad\quad\quad\quad \end{aligned} (1)

 \left\{ {\begin{aligned} &{{P_{1x}} = \frac{{{L_t} - 4{L_h}}}{3}} \\ &{{P_{2x}} = {L_h}} \\ &{{P_{1y}} = {P_{2y}} = \frac{{4{L_r}}}{3}} \end{aligned}} \right. (2)

 $\left\{ {\begin{array}{*{20}{c}} {{L_{{t}}} = 0.205\;5h + 0.040\;5\alpha + 0.481\;4} \\ {{L_{{h}}} = 0.001\;1{h^2} + 0.004\;8\alpha + 0.240\;7} \\ {{L_{{r}}} = 0.057\;5h + 0.009\;7\alpha + 0.413\;4} \end{array}} \right.$ (3)

1.3 笔画模型

${S_{{n}}}\! =\! \left\{ {\left( {{x_1},{y_1},{h_1},{\alpha _1}} \right), \left( {{x_2},{y_2},{h_2},{\alpha _2}} \right), \cdots \left( {{x_n},{y_n},{h_n},{\alpha _n}} \right)} \right\}$ 表示笔画模型中毛笔运动轨迹，其中 $x$ $y$ 是笔触模型原点在纸面坐标系上坐标值， $h$ 值表示毛笔所受压力，而 $\alpha$ 值的改变反应毛笔倾斜情况。位置信息和高度信息是通过遗传算法从笔画图像中提取，遗传算法得到的初步轨迹信息需要根据起笔、行笔、收笔规则进行修改，并添加倾斜信息。

1.3.1 遗传算法提取信息

 ${f_1} = {p_1}{x^5} + {p_2}{x^4} + {p_3}{x^3} + {p_4}{x^2} + {p_5}{x^1} + {p_6}$ (4)

 \left\{ \begin{aligned} &{f_2} = \sum_{i = 0}^k {{y_i}} \cdot{l_i}(x) \\ &{l_i}(x) = \frac{{\left( {x - {x_0}} \right) \cdots \left( {x - {x_{i - 1}}} \right)\left( {x - {x_{i + 1}}} \right) \cdots \left( {x - {x_k}} \right)}}{{\left( {{x_i} - {x_0}} \right) \cdots \left( {{x_i} - {x_{i - 1}}} \right)\left( {{x_i} - {x_{i + 1}}} \right) \cdots \left( {{x_i} - {x_k}} \right)}} \end{aligned} \right. (5)

 $\min {\rm{ObjV}} = \left| {{f_1} - {f_2}} \right|$ (6)

 $F(i) = \frac{1}{{{\rm{ObjV}}(i)}}$ (7)

 \left\{ {\begin{aligned} & {{F^{'}} = {{\rm{ObjV}}^{'}} = 1 - \frac{{\displaystyle\sum\limits_{i = 1}^M {\displaystyle\sum\limits_{j = 1}^N {\left| {{X_{i,j}} - X_{i,j}^{'}} \right|} } }}{{\displaystyle\sum\limits_{i = 1}^M {\displaystyle\sum\limits_{j = 1}^N {\left({X_{i,j}}\cdot X_{i,j}^{'} + \left| {{X_{i,j}} - X_{i,j}^{'}} \right|\right)} } }}} \\ &{{X_{i,j}} = \left\{ {\begin{array}{*{20}{c}} {1,\quad {\rm{ pixel}}\;{{(i, j)}}\;{\rm{is}}\;{\rm{white}}} \\ {0,\quad {\rm{pixel}}\;{{ (i, j)}}\;{\rm{ is }}\;{\rm{black}}} \end{array}} \right.} \end{aligned}} \right. (8)

$k = 10$ 时，两者存在较大差异；当 $k = 20$ $k = 30$ 的仿真效果较好，但是 $k = 30$ 时，虚拟笔画轮廓不光滑，说明需要增加迭代次数进行优化，但这会增加运算成本。因此合理选择基因数 $k$ ，既可以较好复现目标图像，又降低运算量。

1.3.2 书写规则修改轨迹

1.4 控制模型

1.4.1 路径规划

 \left\{ \begin{aligned} &{p_i}(t) = \displaystyle\sum\limits_{k = 0}^3 {{P_{i + k}}} \cdot {F_k}(t),\quad 0 \leqslant t \leqslant 1 \\ & {F_k}(t) = \frac{1}{6}\displaystyle\sum\limits_{j = 0}^{3 - k} {{{( - 1)}^j}C_4^j{{(t + 3 - k - j)}^3}} \end{aligned} \right. (9)

 $\left( {\begin{array}{*{20}{c}} {{{{P}}_{{0}}}} \\ {{{{P}}_{{1}}}} \\ {{{{P}}_{{2}}}} \\ \vdots \\ {{{{P}}_{{{n - 1}}}}} \\ {{{{P}}_{{n}}}} \\ {{{{P}}_{{{n + 1}}}}} \end{array}} \right){{ = 6}}{\left( {\begin{array}{*{20}{c}} {{{ - 3}}}&{{0}}&{{3}}&{}&{}&{}&{} \\ {{1}}&{{4}}&{{1}}&{}&{}&{}&{} \\ {}&{{1}}&{{4}}&{{1}}&{}&{}&{} \\ {}&{}&{}& \vdots &{}&{} \\ {}&{}&{}&{{1}}&{{4}}&{{1}}&{} \\ {}&{}&{}&{}&{{1}}&{{4}}&{{1}} \\ {}&{}&{}&{}&{{{ - 3}}}&{{0}}&{{3}} \end{array}} \right)^{{{ - 1}}}}\left( {\begin{array}{*{20}{c}} {\left( {{{0,0,0}}} \right)} \\ {\left( {{{{x}}_{{1}}}{{,}}{{{y}}_{{1}}}{{,}}{{{h}}_{{1}}}} \right)} \\ {\left( {{{{x}}_{{2}}}{{,}}{{{y}}_{{2}}}{{,}}{{{h}}_{{2}}}} \right)} \\ \vdots \\ {\left( {{{{x}}_{{{n - 1}}}}{{,}}{{{y}}_{{{n - 1}}}}{{,}}{{{h}}_{{{n - 1}}}}} \right)} \\ {\left( {{{{x}}_{{n}}}{{,}}{{{y}}_{{n}}}{{,}}{{{h}}_{{n}}}} \right)} \\ {\left( {{{0,0,0}}} \right)} \end{array}} \right)$ (10)

1.4.2 姿态计算

 $\left\{ \begin{array}{l} \Delta {{X = L \cdot}}\sin \alpha \\ \Delta Z{{ = L\cdot (1 - \cos}}\;\alpha ) \end{array} \right.$ (11)

 \left\{ \begin{aligned} &{\boldsymbol{P = M}}\times{{\boldsymbol{P}}_{{0}}} \\ &{\boldsymbol{M = }}\left[ {\begin{array}{*{20}{c}} {{{{a}}^{{2}}}{{ + (1 - }}{{{a}}^{{2}}}{{)c}}}&{{{ab(1 - c)}}}&{{{ - bd}}}&{{{\Delta X'}}} \\ {{{ab(1 - c)}}}&{{{{b}}^{{2}}}{{ + (1 - }}{{{b}}^{{2}}}{{)c}}}&{{{ad}}}&{{{\Delta Y'}}} \\ {{{bc}}}&{{{ - ad}}}&{{c}}&{{{\Delta Z'}}} \\ {{0}}&{{0}}&{{0}}&{{1}} \end{array}} \right] \\ &{a = - 1\cdot \cos (\beta - \frac{{\text{π}} }{2} + \theta ),b = - 1\cdot \sin (\beta - \frac{{\text{π}} }{2} + \theta ),c = \cos (\alpha ),d = \sin (\alpha )} \\ & \Delta X' = L\cdot \sin \alpha \cdot \sin (\beta + \theta ),\Delta Y' = L\cdot \sin \alpha \cdot \sin (\beta + \theta ),\Delta Z' = L\cdot(1 - \cos \alpha ) \end{aligned} \right. (12)

2 笔画评价指标

2.1 骨架相似度

CPD算法将点集配准问题转换为概率密度估计问题，其将原始点集的分布表示成混合高斯模型，迭代修改高斯模型的参数，当原始点集与目标点集对应的似然函数达到最大时，配准完成。

ICP算法要求两个点集成员个数一致，计算出从原始点集上的每个点到目标点集的每个点的距离，使其和目标点集的最近点匹配，计算均方差误差，如直到均方差误差满足要求时，配准完成。

 ${S_1} = \frac{m}{n}$ (13)

2.2 外形相似度

 \left\{ {\begin{aligned} & {{S_2} = 1 - \frac{{\displaystyle\sum\limits_{i = 1}^M {\displaystyle\sum\limits_{j = 1}^N {\left| {{X_{i,j}} - X_{i,j}^{'}} \right|} } }}{{\displaystyle\sum\limits_{i = 1}^M {\displaystyle\sum\limits_{j = 1}^N {\left({X_{i,j}} \cdot X_{i,j}^{'} + \left| {{X_{i,j}} - X_{i,j}^{'}} \right|\right)} } }}} \\ & {{X_{i,j}} = \left\{ {\begin{aligned} {1,\quad{\rm{ pixel}}\;{{ (i, j)}}\;{\rm{ is}}\;{\rm{ white}}} \\ {0,\quad{\rm{ pixel}}\;{{ (i, j)}}\;{\rm{ is }}\;{\rm{black}}} \end{aligned}} \right.} \end{aligned}} \right. (14)

2.3 起笔收笔相似度

 ${S_3} = \frac{{X \cdot {X'}}}{{\sqrt {\displaystyle\sum\nolimits_i {{x_i}} } \times \sqrt {\displaystyle\sum\nolimits_i {{x'}_i} } }}$ (15)

3 实际机器人书写实验

3.1 评价指标验证

 Download: 图 17 “橫”根据书写规则修改后实验图片 Fig. 17 “Horizontal” modified experimental picture according to writing rules
3.2 基本笔画书写

3.3 汉字仿真