0

I am using this code simulate real camera to capture 3D object:

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]);

The problems are:

  • I used VerticalAOV as input for camva. I chose VerticalAOV based on this image. However, this is illogical. To get real view, one should provide both Horizontal and Vertical Angle.

  • [ImageHeight, ImageWidth, Channels] = size(Image); returns wrong values. ImageWidth and ImageHeight does not provide the correct values. It is clear that one of the dimessions would wrong since only one dimension of the AOV was provided. However, why both of them are not correct?

  • The crop I made is to correct the dimensions of the image. However, it seems to be not useful step (I checked the result using ground truth data I have and they did not match).

P.S. export_fig can be found here: https://github.com/altmany/export_fig

Humam Helfawi
  • 19,566
  • 15
  • 85
  • 160
  • `export_fig` is popular, but not standard. You should include a download link for reference. It’s output is a bitmap, this bitmap size has nothing to do with the axes coordinates that you are comparing them to. – Cris Luengo Mar 04 '19 at 07:19
  • @CrisLuengo thanks for your reply! Your comment is correct. It is not related but it should be. So you are saying that using export_fig is not the right option to render image using a specific sensor and lens. Do you have any other suggestion ? – Humam Helfawi Mar 04 '19 at 10:53
  • I don’t know for sure what you are trying to accomplish, but there are the axes coordinates, and pixel (screen) coordinates. The camera position, patch position, etc are all w.r.t. axes coordinates. The resulting figure is rendered on screen, and `export_fig` copies that to a buffer. The screen rendering is related to the axes coordinates through the axes 'Position' property, as well as 'DataAspectRatio'. You probably want to control those. – Cris Luengo Mar 04 '19 at 14:49

0 Answers0