Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于运动捕捉数据分析和可视化的R软件包_R_Matlab_Data Visualization - Fatal编程技术网

用于运动捕捉数据分析和可视化的R软件包

用于运动捕捉数据分析和可视化的R软件包,r,matlab,data-visualization,R,Matlab,Data Visualization,我是R方面的新手,喜欢它,但我很惊讶地发现,完全没有可靠的软件包来分析运动捕捉数据 最简单的运动捕捉文件只是一个巨大的表格,其中包含附着到记录对象的每个点的“XYZ”坐标,以及捕捉到的每个帧的坐标。我知道我可以在R中找到单独的方法和函数来执行复杂的操作(如主成分分析),或者我可以绘制所有点的时间序列。但是,当我在寻找一些例子时,这些例子也可以从统计学上教育我如何分析人类的运动,并为数据的可视化表示提供一个很好的工具箱,结果证明R是一个寒冷的沙漠。另一方面,MATLAB有,尤其是后者有很好的选项来

我是R方面的新手,喜欢它,但我很惊讶地发现,完全没有可靠的软件包来分析运动捕捉数据

最简单的运动捕捉文件只是一个巨大的表格,其中包含附着到记录对象的每个点的“XYZ”坐标,以及捕捉到的每个帧的坐标。我知道我可以在R中找到单独的方法和函数来执行复杂的操作(如主成分分析),或者我可以绘制所有点的时间序列。但是,当我在寻找一些例子时,这些例子也可以从统计学上教育我如何分析人类的运动,并为数据的可视化表示提供一个很好的工具箱,结果证明R是一个寒冷的沙漠。另一方面,MATLAB有,尤其是后者有很好的选项来绘制和分析捕获。但老实说,与R相比,MATLAB的可视化引擎相当难看

对R运动捕捉软件包的一些特定请求包括:

  • 读取、编辑、可视化和转换mocap数据
  • 动力学和运动学分析
  • 时间序列与主成分分析
  • 设置数据动画

我是不是(在谷歌搜索中)遗漏了什么东西,还是真的没有针对R的mocap软件包?有人试过在R中玩运动捕捉数据吗?你能给我一些指导吗?

从RSeek上的快速搜索判断,R没有可用的运动捕捉软件包。看起来你需要为每个功能找到等价物。更一般的函数应该很容易找到(插值、子集、变换/投影、时间序列分析、pca、矩阵分析等),而编写自己的自定义函数(如估算瞬时动能)的过程可能是最好的学习方法


您可能会发现将数据转化为形状和可视化运动的软件包非常有用。

更新,2019年12月:Steen Harsted的软件包似乎比我构建的软件包功能强大得多。享受

请查看我的软件包,即
mocap
软件包:

它还远远不够完美,但只是一个开始,目前仅在ASF/AMC文件上测试


这是一篇包含更多细节的博客文章。

我使用包
rgl
从运动手势数据集创建动画。虽然它不是专门为手势数据制作的软件包,但您可以使用它

在下面的示例中,我们有上半身上8个点的手势数据:脊椎、肩部中心、头部、左肩、左腕、右肩和右腕。受试者双手向下,右臂向上移动

我将数据集限制为6次观察(如果你愿意的话,可以是几秒),因为如果不这样的话,在这里发布数据会变得很大

原始数据集中的每条线对应于一个时间观测值,每个体点的坐标以4个为一组定义(每四列为一个体点)。所以在每一行,我们有“x”,“y”,“z”,“br”代表脊柱,然后是“x”,“y”,“z”,“br”代表肩部中心,依此类推。“br”始终为1,以分隔每个身体部位的三个坐标(x、y、z)

以下是原始(受限)数据集:

现在我们使用
rgl
来绘制这个矩阵中的数据:

#install.packages("rgl")
library(rgl)

# INITIAL PLOT

x<-unlist(DATA.matrix[,1])
y<-unlist(DATA.matrix[,2])
z<-unlist(DATA.matrix[,3])

# OPEN A BLANK 3D PLOT AND SET INITIAL NEUTRAL VIEWPOINT
open3d()
rgl.viewpoint(userMatrix=rotationMatrix(0,0,0,0))

# SET FIGURE POSITION
# This is variable. It will depend on your dataset
# I've found that for this specific dataset a rotation
# of -0.7*pi on the Y axis works

# You can also plot and select the best view with
# your mouse. This selected view will be passed on
# to the animation.
U <- par3d("userMatrix")
par3d(userMatrix = rotate3d(U, -0.7*pi, 0,1,0))

# PLOT POINTS
points3d(x=x,y=y,z=z,size=6,col="blue")
text3d(x=x,y=y,z=z,texts=1:8,adj=c(-0.1,1.5),cex=0.8)

# You can also plot each body point name.
# This might be helpful when you don't know the
# initial orientation of your plot

# text3d(x=x,y=y,z=z,texts=rownames(DATA.matrix),
#        cex=0.6,adj=c(-0.1,1.5))

# Based on the plotted figure, connect the line segments
CONNECTOR<-c(1,2,2,3,3,4,3,5,3,7,5,6,7,8)
segments3d(x=x[CONNECTOR],y=y[CONNECTOR],z=z[CONNECTOR],col="red")
我知道这个解决方案并不优雅,但它是有效的


您可能没有遗漏任何内容。My favo(u)rite解决方案,
库(sos);findFn(“{motion capture}”)
,没有想出任何有用的方法。还有文化方面的问题:用R做一些很酷的事情是可能的,但是如果所有从事运动捕捉的酷孩子都在使用MATLAB或Python,那么这就是事情要做的地方。我肯定会看一看,看看Python做了什么,看看Python和R之间的接口,看看R中还没有实现的任何统计重担……你可以使用包“forecast”和“ftsa”进行时间序列和主成分分析。
# Single time point for analysis
time.point<-1
# Number of coordinates
coordinates<-4
# Number of body points
body.points<-dim(DATA.time.obs)[2]/coordinates

# Total time of gesture
total.time<-dim(DATA.time.obs)[1]

# Transform data for a single time. observation into a matrix
DATA.matrix<-matrix(DATA.time.obs[1,],c(body.points,coordinates),byrow = TRUE)
colnames(DATA.matrix)<-c("x","y","z","br")
rownames(DATA.matrix)<-c("hip_center","spine","shoulder_center","head",
                         "left_shoulder","left_wrist","right_shoulder",
                         "right_wrist")
                        x        y        z br
hip_center      -0.064310 0.101546 2.990067  1
spine           -0.091378 0.165703 3.029513  1
shoulder_center -0.090019 0.518603 3.022399  1
head            -0.042211 0.687271 2.987086  1
left_shoulder   -0.231384 0.419869 2.953286  1
left_wrist      -0.299824 0.173991 2.882627  1
right_shoulder   0.063367 0.399478 3.136306  1
right_wrist      0.134907 0.176191 3.159998  1
#install.packages("rgl")
library(rgl)

# INITIAL PLOT

x<-unlist(DATA.matrix[,1])
y<-unlist(DATA.matrix[,2])
z<-unlist(DATA.matrix[,3])

# OPEN A BLANK 3D PLOT AND SET INITIAL NEUTRAL VIEWPOINT
open3d()
rgl.viewpoint(userMatrix=rotationMatrix(0,0,0,0))

# SET FIGURE POSITION
# This is variable. It will depend on your dataset
# I've found that for this specific dataset a rotation
# of -0.7*pi on the Y axis works

# You can also plot and select the best view with
# your mouse. This selected view will be passed on
# to the animation.
U <- par3d("userMatrix")
par3d(userMatrix = rotate3d(U, -0.7*pi, 0,1,0))

# PLOT POINTS
points3d(x=x,y=y,z=z,size=6,col="blue")
text3d(x=x,y=y,z=z,texts=1:8,adj=c(-0.1,1.5),cex=0.8)

# You can also plot each body point name.
# This might be helpful when you don't know the
# initial orientation of your plot

# text3d(x=x,y=y,z=z,texts=rownames(DATA.matrix),
#        cex=0.6,adj=c(-0.1,1.5))

# Based on the plotted figure, connect the line segments
CONNECTOR<-c(1,2,2,3,3,4,3,5,3,7,5,6,7,8)
segments3d(x=x[CONNECTOR],y=y[CONNECTOR],z=z[CONNECTOR],col="red")
movement.points<-function(DATA,time.point,CONNECTOR,body.points,coordinates){

  DATA.time<-DATA[time.point,]

  DATA.time<-matrix(DATA.time,c(body.points,coordinates),byrow = TRUE)

  x<-unlist(DATA.time[,1])
  y<-unlist(DATA.time[,2])
  z<-unlist(DATA.time[,3])

  # I used next3d instead of open3d because now I want R to plot 
  # several plots on top of our original, creating the animation

  next3d(reuse=FALSE)
  points3d(x=x,y=y,z=z,size=6,col="blue")
  segments3d(x=c(x,x[CONNECTOR]),y=c(y,y[CONNECTOR]),z=c(z,z[CONNECTOR]),col="red")
# You can control the "velocity" of the animation by changing the 
# parameter below. Smaller = faster
  Sys.sleep(0.5)
}