首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在同一图形中连续更新两个图和标绘的摄像机(MATLAB)

如何在同一图形中连续更新两个图和标绘的摄像机(MATLAB)
EN

Stack Overflow用户
提问于 2016-03-11 03:10:10
回答 1查看 552关注 0票数 1

我的目标是使用MATLAB连续绘制相机相对于标记的位置和方向。

有三件事情需要绘制。(1)相机(2)所有圆点(3)原点'*‘相机和点都将在每个帧中移动。我将这三件事情都绘制在一个静态图形中,即使用hold on。如附图所示。

现在,我想要将它们连续(实时)绘制在与值change.Till相同的图形中。现在,我只能动态地更新这些东西中的一个,即一些随机值的循环点。如果我添加了另一个图,请告诉我如何更新同一图形和plotCamera中的多个图。

代码语言:javascript
运行
复制
hF = figure;
hAx = gca;
im_pt_2world=rand(3,3);
x_o=im_pt_2world(1,1); y_o=im_pt_2world(1,2); %origin of the calibrated world points
x_ip=im_pt_2world(:,1); y_ip=im_pt_2world(:,2);

hpoints = plot3(x_ip, y_ip,zeros(size(im_pt_2world, 1),1),'ro');


% I added the "ishandle" so the program will end in case u closed the figure
while (1) & ishandle(hpoints)

   %instead of using plot I directly change the data in the line
   % this is faster the plot if only because you don't need to reedefine the limits and labels...
im_pt_2world=rand(3,3);
x_ip=im_pt_2world(:,1); y_ip=im_pt_2world(:,2);


   set(hpoints,'ydata',y_ip);
   set(hpoints,'xdata',x_ip);
   drawnow  %updates the display

end

EN

回答 1

Stack Overflow用户

发布于 2016-03-11 03:55:06

plotCamera函数(计算机视觉系统工具箱)返回图形对象的句柄,您可以通过编程对其进行操作。更改对象的属性(如LocationOrientation )将在打印中移动相机。plotCamera的帮助示例显示了如何使相机在圆圈中飞行:

代码语言:javascript
运行
复制
% Plot a camera pointing along the Y-axis
R = [1     0     0;
     0     0    -1;
     0     1     0];

% Setting opacity of the camera to zero for faster animation.
cam = plotCamera('Location', [10 0 20], 'Orientation', R, 'Opacity', 0);

% Set view properties
grid on
axis equal
axis manual

% Make the space large enough for the animation.
xlim([-15, 20]);
ylim([-15, 20]);
zlim([15, 25]);

% Make the camera fly in a circle
for theta = 0:pi/64:10*pi
    % Rotation about cameras y-axis
    T = [cos(theta)  0  sin(theta);
            0        1      0;
         -sin(theta) 0  cos(theta)];
    cam.Orientation = T * R;
    cam.Location = [10 * cos(theta), 10 * sin(theta), 20];
    drawnow();
end

如果你真的想从中获得乐趣,你可以提供一个函数句柄,当你点击相机时调用它。例如,该函数可以显示摄像机看到的图像。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35925178

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档