﻿ 基于广义变换矩阵的机械零件三维模型骨架匹配
 上海理工大学学报  2019, Vol. 41 Issue (4): 381-387 PDF

3D Model Skeleton Matching of Mechanical Parts Based on Generalized Transform Matrix
ZHU Wenbo, YANG Chao, GAN Yi, CHEN Long
School of Mechanical Engineering, University of Shanghai for Science and Technology, Shanghai 200093, China
Abstract: A skeleton matching method for 3D models of mechanical parts based on generalized transformation matrix was proposed. The connection line between the two skeleton points is called the skeleton branch. Referring to the representation method of the relationship between the generalized connecting rods in the robotics, the skeleton branches are regarded as a number of connecting rods. A fixed coordinate system and a skeleton coordinate system are established at the skeleton point. The skeleton branch is represented by the generalized transformation matrix. The generalized transformation matrix is transformed into a vector. Referring to the method of correlation measurement in statistics, the similarity degree of the two generalized transformation matrices was obtained by calculating the Pearson correlation coefficients of two vectors, that is, the similarity degree of the two skeleton branches. Search the matching skeleton branches and calculate the similarity of the whole skeleton. Through the example verification and experimental analysis, the algorithm has a fast retrieval speed and good accuracy.
Key words: mechanical parts     3D model     skeleton     generalized transformation matrix     Pearson correlation coefficient     similarity degree

1 机械零件模型骨架

 图 1 提取模型1的骨架 Fig. 1 Extracting the skeleton of model one
2 骨架相似度计算

2.1 构建骨架枝的 ${{T}}$ 矩阵

 ${{{A}}_i} = \left[ {\begin{array}{*{20}{c}} {\cos\; {\theta _i}}&{ - \sin\; {\theta _i}}&0&{{b_{i - 1}}} \\ {\sin\; {\theta _i}\cos\; {\alpha _{i - 1}}}&{\cos\; {\theta _i}\cos\; {\alpha _{i - 1}}}&{ - \sin\; {\alpha _{i - 1}}}&{ - {d_i}\sin\; {\alpha _{i - 1}}} \\ {\sin\; {\theta _i}\sin\; {\alpha _{i - 1}}}&{\cos\; {\theta _i}\sin\; {\alpha _{i - 1}}}&{\cos\; {\alpha _{i - 1}}}&{{d_i}\cos\; {\alpha _{i - 1}}} \\ 0&0&0&1 \end{array}} \right]$ (1)

${{{A}}_1}$ 矩阵表示骨架枝 $\overline {{G_0}{G_1}}$ 的坐标系 $\left\{ {\rm{1}} \right\}$ 相对于固定坐标系 $\left\{ {\rm{0}} \right\}$ 的位姿， ${{{A}}_2}$ 矩阵表示骨架枝 $\overline {{G_1}{G_2}}$ 的坐标系 $\left\{ 2 \right\}$ 相对于坐标系 $\left\{ {\rm{1}} \right\}$ 的位姿，那么，坐标系 $\left\{ 2 \right\}$ 相对于固定坐标系 $\left\{ {\rm{0}} \right\}$ 的位姿可用 ${{{A}}_1}$ ${{{A}}_2}$ 的乘积，用 ${{{T}}_2}$ 来表示。

 ${{{T}}_2} = {{{A}}_1}{{{A}}_2}$ (2)

 ${{{T}}_3} = {{{A}}_1}{{{A}}_2}{{{A}}_3} = {{{T}}_2}{{{A}}_3}$ (3)

 图 2 模型1的骨架及坐标系 Fig. 2 Skeleton and coordinate system of model one

 $\qquad\quad{{{A}}_1} = \left[ {\begin{array}{*{20}{c}} {{\rm{0}}{\rm{.259}}}&{{\rm{ - 0}}{\rm{.966}}}&{\rm{0}}&{\rm{0}} \\ {{\rm{0}}{\rm{.966}}}&\;\;\;{{\rm{0}}{\rm{.259}}}&{\rm{0}}&{\rm{0}} \\ {\rm{0}}&{\rm{0}}&{{\rm{1}}{\rm{.000}}}&{\rm{0}} \\ {\rm{0}}&{\rm{0}}&{\rm{0}}&{{\rm{1}}{\rm{.000}}} \end{array}} \right]$ (4)

 $\qquad\;\;{{{A}}_{\rm{2}}} = \left[ {\begin{array}{*{20}{c}} {{\rm{0}}{\rm{.982}}}&{{\rm{ - 0}}{\rm{.191}}}&{\rm{0}}&{{\rm{12}}{\rm{.000}}} \\ {{\rm{0}}{\rm{.191}}}&\;\;\;{{\rm{0}}{\rm{.982}}}&{\rm{0}}&{\rm{0}} \\ {\rm{0}}&{\rm{0}}&{{\rm{1}}{\rm{.000}}}&{\rm{0}} \\ {\rm{0}}&{\rm{0}}&{\rm{0}}&\;\;\,{{\rm{1}}{\rm{.000}}} \end{array}} \right]$ (5)

${{{A}}_2}$ 矩阵表示骨架枝 $\overline {{G_1}{G_2}}$ 的坐标系 $\left\{ 2 \right\}$ 相对于骨架枝 $\overline {{G_0}{G_1}}$ 坐标系 $\left\{ {\rm{1}} \right\}$ 的位姿，所以，坐标系 $\left\{ 2 \right\}$ 相对于固定坐标系 $\left\{ {\rm{0}} \right\}$ 的位姿按式（2）计算。

 ${{{T}}_2} = {{{A}}_1}{{{A}}_2} = \left[ {\begin{array}{*{20}{c}} {0.070}&{{\rm{ - 0}}{\rm{.998}}}&{\rm{0}}&{{\rm{3}}{\rm{.108}}} \\ {{\rm{0}}{\rm{.998}}}&\;\;\;{{\rm{0}}{\rm{.070}}}&{\rm{0}}&\!\!\!{11.592} \\ {\rm{0}}&{\rm{0}}&{{\rm{1}}{\rm{.000}}}&{\rm{0}} \\ {\rm{0}}&{\rm{0}}&{\rm{0}}&{{\rm{1}}{\rm{.000}}} \end{array}} \right]\!\!\!\!\!\!\!\!$ (6)

2.2 计算 ${{T}}$ 矩阵的相似度

 ${{{T}} = \left[ {\begin{array}{*{20}{c}} {{t_1}}&{{t_2}}&{{t_3}}&{{t_4}}\\ {{t_5}}&{{t_6}}&{{t_7}}&{{t_8}}\\ {{t_9}}&{{t_{10}}}&{{t_{11}}}&{{t_{12}}}\\ {{t_{13}}}&{{t_{14}}}&{{t_{15}}}&{{t_{16}}} \end{array}} \right]}$

 ${ T}_{\rm R} = \left[ {{t_1},{t_5},{t_9},{t_{13}},{t_2},{t_6}, \cdots ,{t_{16}}} \right]$ (7)

${{T}}$ 矩阵转化为向量 ${ T}_{\rm R}$ 后，引用统计学中的相关性度量方法，通过计算2个向量的皮尔逊相关系数[13]就可以得到2个 ${{T}}$ 矩阵的相似度 $sim({{ T}_n},{{ T}_m})$

 $sim({{{T}}_n},{{{T}}_m}) \!=\! \frac{{\displaystyle\sum\limits_{i = 1}^{16} {(T_{\rm{Rni}} - \overline {T}_{\rm{Rn}} )(T_{\rm{Rmi}} - \overline {T}_{\rm{Rm}} )} }}{{\sqrt {\displaystyle\sum\limits_{i = 1}^{16} {{{(T_{\rm{Rni}}\!\! -\!\! \overline {T}_{\rm{Rn}} )}^2}} }\!\!\!\! \sqrt {\displaystyle\sum\limits_{i = 1}^{16} {{{(T_{\rm{Rmi}} \!\!-\!\! \overline {T}_{\rm{Rm}} )}^2}} } }}\!\!\!\!\!\!\!\!\!\!\!$ (8)

2.3 搜索匹配 ${{T}}$ 矩阵

 图 3 模型2的骨架及其坐标系 Fig. 3 Skeleton of model two and its coordinate system

 $\begin{array}{l} {{{T}}_9} = \left[ {\begin{array}{*{20}{c}} \;\;\;{0.588}&{0.809}&0&0\\ { - 0.809}&{0.588}&0&0\\ 0&0&{1.000}&0\\ 0&0&0&{1.000} \end{array}} \right]\\ {{{{T}}'}_3} = \left[ {\begin{array}{*{20}{c}} \;\;\;{{\rm{0}}.{\rm{643}}}&{{\rm{0}}.{\rm{766}}}&{\rm{0}}&{\rm{0}}\\ {{\rm{ - 0}}.{\rm{766}}}&{{\rm{0}}.{\rm{634}}}&{\rm{0}}&{\rm{0}}\\ {\rm{0}}&{\rm{0}}&{{\rm{1}}.{\rm{000}}}&{\rm{0}}\\ {\rm{0}}&{\rm{0}}&{\rm{0}}&{{\rm{1}}.{\rm{000}}} \end{array}} \right] \end{array}$

${{T}}_{{\rm{R}}9} = \left[ {0.588, - 0.809,0,0,0.809,\cdots,1.000} \right]$

${{T}}_{{\rm{R}}3}' = \left[ {0.643, - 0.766,0,0,0.766,\cdots,1.000} \right]$

 $\begin{split} &\!\!\quad sim({{T}}_n,{{T}}_m) \!=\! \frac{{\displaystyle\sum\limits_{i = 1}^n {({{{T}}_{{\rm{Rni}}}} \!-\! \overline {{T}}_{{\rm{Rn}}} )({{{T}}_{{\rm{Rmi}}}} \!-\! \overline {{T}}_{{\rm{Rm}}} )} }}{{\sqrt {\displaystyle\sum\limits_{i = 1}^n {{{({{{T}}_{{\rm{Rni}}}} \!-\! \overline {{T}}_{{\rm{Rn}}} )}^2}} } \sqrt {\displaystyle\sum\limits_{i = 1}^n {{{({{{T}}_{{\rm{Rmi}}}} \!-\! \overline {{T}}_{{\rm{Rm}}} )}^2}} } }} =\qquad\qquad\qquad\\ &\!\! \qquad \frac{{{\rm{3}}.{\rm{138}}}}{{{\rm{1}}.{\rm{896}} \times {\rm{1}}.{\rm{896}}}} \!= {\rm{0}}.{\rm{873}} \end{split}$

2.4 计算骨架相似度

 $sim(P,Q) = \frac{{\displaystyle\sum\limits_{i = 1}^{\min (p,q)} {sim\left( {{T}}_n,{{T}}_m \right)} {\text{·}} \left( {{L_n} + {L_m}} \right)}}{{{L_P} + {L_Q}}}$ (9)

 $sim = \frac{{0.754 \times (20 + {\rm{10}}) + {\rm{0}}{\rm{.672}} \times (10 + 29) + \cdots + 1.000 \times \left( {7 + {\rm{7}}} \right)}}{{{\rm{257}} + {\rm{184}}}} = {\rm{0}}{\rm{.760}}$
3 实例验证

4 实验分析

 图 4 查准率−查全率曲线图 Fig. 4 Accuracy-recall curve

5 结　论

a. 借鉴机器人学中描述广义连杆之间关系的理论方法，将机械零件骨架枝看成连杆，在骨架点处建立固定坐标系及骨架枝坐标系，构建骨架枝的广义变换 ${{T}}$ 矩阵。

b. $4 \times 4$ ${{T}}$ 矩阵转化成16维的向量，通过计算2个向量的皮尔逊相关系数得到2个 ${{T}}$ 矩阵的相似度，即得到2个骨架枝的相似度；搜索到相匹配的骨架枝后，计算整个骨架的相似度。

c. 本文提出的匹配算法不仅适用于基于电场法建立的骨架，而且对其他方式建立的骨架，只要存在骨架点和骨架枝都具有适用性。通过实例验证和实验分析，综合考虑计算量和查准率–查全率两方面，本文算法高效、准确，综合性能优于D2形状分布算法和基于递归分割算法。

 [1] YOU C F, TSAI Y L. 3D solid model retrieval for engineering reuse based on local feature correspondence[J]. The International Journal of Advanced Manufacturing Technology, 2010, 46(5/8): 649-661. [2] CHENG H C, LO C H, CHU C H, et al. Shape similarity measurement for 3D mechanical part using D2 shape distribution and negative feature decomposition[J]. Computers in Industry, 2011, 62(3): 269-280. DOI:10.1016/j.compind.2010.09.001 [3] 徐敬华, 张树有. 基于递归分割的机械零件三维形状结构检索方法[J]. 机械工程学报, 2009, 45(11): 176-183. [4] 董雁, 徐静. 基于装配结构相似的零件三维模型检索方法[J]. 机械工程学报, 2009, 45(4): 273-280. [5] EI-MEHALAWI M, MILLER R A. A database system of mechanical components based on geometric and topological similarity. Part Ⅱ: indexing, retrieval, matching, and similarity assessment[J]. Computer-Aided Design, 2003, 35(1): 95-105. DOI:10.1016/S0010-4485(01)00178-6 [6] 白静. 基于扩展特征树的三维CAD模型相似评价[J]. 计算机集成制造系统, 2014, 20(2): 267-275. [7] HAJIJ M, DEY T, LI X. Segmenting a surface mesh into pants using Morse theory[J]. Graphical Models, 2016, 88(6): 12-21. DOI:10.1016/j.gmod.2016.09.003 [8] 李雷, 徐盼盼, 王文成. 构建中值图以快速生成高质量的三维模型骨架[J]. 计算机辅助设计与图形学学报, 2017, 29(7): 1195-1202. DOI:10.3969/j.issn.1003-9775.2017.07.005 [9] 朱文博, 戚丽杰, 陈龙. 基于骨架和灰色关联分析相结合的机械零件三维模型检索[J]. 中国机械工程, 2015, 26(14): 1926-1931. DOI:10.3969/j.issn.1004-132X.2015.14.015 [10] 蔡自兴. 机器人学[M]. 北京: 清华大学出版社, 2000. [11] 李瑞峰. 工业机器人设计与应用[M]. 哈尔滨: 哈尔滨工业大学出版社, 2017. [12] 刘浩, 韩晶. MATLAB R2016a完全自学一本通[M]. 北京: 电子工业出版社, 2016. [13] 贾俊平. 统计学[M]. 6版. 北京: 中国人民大学出版社, 2016.