1

I'm writing a program to simulate the movement of a chaser following a target. The chaser is supposed to have a camera, and based on the target image, it follows the target.

Now, I've used 4 planar points in a square shape to represent the camera of the chaser. Thus, for chasing, I'm updating the position of these 4 points in a 3D plot to represent chaser movement.

I would like to know if it's possible to import a picture of, say, an actual camera and use that instead of the present 4 points, for aesthetic purposes? If yes, how?

I'm not very familiar with MATLAB, so I'd appreciate it if you could be detailed and specific with your answer. Thanks in advance

Amro
  • 123,847
  • 25
  • 243
  • 454
user1471216
  • 43
  • 1
  • 5
  • Here are some related questions: [Plotting multiple images in 3D-space](http://stackoverflow.com/q/7689586/97160), [How can I plot an image (.jpg) in MATLAB in both 2-D and 3-D?](http://stackoverflow.com/q/3719502/97160) – Amro Jun 29 '12 at 10:01

1 Answers1

3

Here is a quick example (based on this):

%# grayscale image
img = imread('cameraman.tif');

%# x/y/z coords of image corners
[X,Z,Y] = meshgrid([-1 1],[1 -1],0);

%# plot image in 3D space
figure, colormap gray
h = surf(X,Y,Z,img, 'CDataMapping','scaled', ...
    'FaceColor','texturemap', 'EdgeColor','none');
set(gca, 'XLim',[-2 2], 'YLim',[-4 0], 'ZLim',[-2 2], 'Box','on')

%# move image along the Y-dimension
t = linspace(0,-4,20);
for i=1:numel(t)
    set(h, 'YData',t(i)*ones(size(Y)))
    pause(.1)
end

I created an animation of the result, I even used a camera image :)

animation

Community
  • 1
  • 1
Amro
  • 123,847
  • 25
  • 243
  • 454
  • I did something of this sort, but I'm getting a fatal error and MATLAB is closing down – user1471216 Jul 02 '12 at 05:06
  • @user1471216: unless you post your code, there is no way for us to determine the problem. All I can suggest is to use the debugger to step through the code... – Amro Jul 02 '12 at 05:27