首页 > 解决方案 > 相机视角(垂直和水平)

问题描述

我正在使用此代码模拟真实相机来捕捉 3D 对象:

patch(ax, Object3D, 'FaceColor', 'flat');
camva(ax, rad2deg(VerticalAOV));  % Set the camera field of view
camup(ax, [0 -1 0]);
campos(ax, [CameraPosition.X CameraPosition.Y CameraPosition.Z]);  % Put the camera at the origin
camtarget(ax, [CameraPosition.X CameraPosition.Y CameraPosition.Z] + [0 0 1]); % The camera looks along the +Z axis
camproj(ax,'perspective');
axis image;
axis off;
WidthResolution = SensorWidthResolution/(ax.Position(3));
Image = export_fig('temp.jpg',ax, sprintf('-r%f', WidthResolution),'-nocrop');
[ImageHeight, ImageWidth, Channels] = size(Image);
Image = imcrop(Image,[(ImageWidth-Width)/2, (ImageHeight-Height)/2, Width-1, Height-1]);

问题是:

PS export_fig 可以在这里找到:https ://github.com/altmany/export_fig

标签: matlabcamera-view

解决方案


推荐阅读