0

I have a vector shown here which represents the 3d points X, Y and Z of a video frame1. I have another vector for 3D points X, Y and Z of a video frame2, ... and so on.

Let's say I have 10 frames. I want to track each of the 3D points in frame1 in the next 9 frames. In other words I want to get the trajectory of each of the 3D points in frame1 through the next frames as shown in this pictrajectories of 3d points.

If anyone could please advise or guide me how to do this.

4

1 回答 1

2

首先:这些点在我看来就像一个表面......你确定你想要单个粒子的轨迹吗?恕我直言,通过您的点动画插值曲面将是更好的选择,但我可能是错的。

现在,有几种方法可以做你想做的事。首先是使用movie命令,结合getframe. 假设您有一个名为 的元胞数组frames,其中

frames{1} = XX;

您链接到的数据,并frames{2}通过frames{N}剩余N帧的数据。然后

% This could take a while....
figure(1);
set(gca, 'NextPlot', 'ReplaceChildren');
for ii = 1:N      
    pts = frames{ii};
    plot3(pts(:,1), pts(:,2), pts(:,3), 'r.');    
    F(ii) = getframe;  
end

% Then playback the movie 100 times
movie(F, 100)

如果您不想要动态图片,而是想要所有点轨迹的静态多色图,您可以一次调用plot3. 2帧的示例:

YY = XX;
YY(:,1) = YY(:,1) + 10*rand(size(YY(:,1)))-5;
YY(:,2) = YY(:,2) - 2*rand(size(YY(:,2)))+1;

plot3([XX(:,1) YY(:,1)].', [XX(:,2) YY(:,2)].', [XX(:,3) YY(:,3)].')

警告:这可能需要很长时间,并且看起来完全无法理解,超过 20 个点(这就是为什么我会通过这些点对插值表面进行动画处理,并用于surf制作帧:)

另一种选择是使用comet3,它追踪给定的轨迹。doc comet3在 MATLAB 命令窗口中键入以获取更多信息。

于 2013-09-02T09:39:24.027 回答