From: Jessica on
Hi,

I am using mmreader and mplay to view some video files. Does anyone know whether it is possible to create a box that I can move around to different areas of the screen? For example, if I had a video of a person moving, I would like to move the box around, frame-by-frame, so that the box was always centered around the person's head. I would like to do this by dragging the box to the desired location. I don't need to keep track of the coordinates of this box.

Thanks!
From: Walter Roberson on
Jessica wrote:

> I am using mmreader and mplay to view some video files. Does anyone know
> whether it is possible to create a box that I can move around to
> different areas of the screen? For example, if I had a video of a person
> moving, I would like to move the box around, frame-by-frame, so that the
> box was always centered around the person's head. I would like to do
> this by dragging the box to the desired location. I don't need to keep
> track of the coordinates of this box.

There are a lot of different ways to get coordinates into Matlab, such
as ginput(), or by setting a button press callback function for the axis.

The actual drawing of the box onto an existing frame can be done via
rectangle()

Dragging the box around each time sounds kind of tedious. I would be
tempted, in such a case, to see if some light image processing might
work to isolate the head.
From: Jessica on
Walter Roberson <roberson(a)hushmail.com> wrote in message <fHgGn.3257$0M5.2287(a)newsfe07.iad>...
> Jessica wrote:
>
> > I am using mmreader and mplay to view some video files. Does anyone know
> > whether it is possible to create a box that I can move around to
> > different areas of the screen? For example, if I had a video of a person
> > moving, I would like to move the box around, frame-by-frame, so that the
> > box was always centered around the person's head. I would like to do
> > this by dragging the box to the desired location. I don't need to keep
> > track of the coordinates of this box.
>
> There are a lot of different ways to get coordinates into Matlab, such
> as ginput(), or by setting a button press callback function for the axis.
>
> The actual drawing of the box onto an existing frame can be done via
> rectangle()
>
> Dragging the box around each time sounds kind of tedious. I would be
> tempted, in such a case, to see if some light image processing might
> work to isolate the head.

Thanks for the quick response! The rectangle() code works well. However, for my purposes, I actually don't want it automated and need to be able to drag the rectangle around to different places on the screen. Any idea how to do this? Thanks!
From: Jessica on
Walter Roberson <roberson(a)hushmail.com> wrote in message <fHgGn.3257$0M5.2287(a)newsfe07.iad>...
> Jessica wrote:
>
> > I am using mmreader and mplay to view some video files. Does anyone know
> > whether it is possible to create a box that I can move around to
> > different areas of the screen? For example, if I had a video of a person
> > moving, I would like to move the box around, frame-by-frame, so that the
> > box was always centered around the person's head. I would like to do
> > this by dragging the box to the desired location. I don't need to keep
> > track of the coordinates of this box.
>
> There are a lot of different ways to get coordinates into Matlab, such
> as ginput(), or by setting a button press callback function for the axis.
>
> The actual drawing of the box onto an existing frame can be done via
> rectangle()
>
> Dragging the box around each time sounds kind of tedious. I would be
> tempted, in such a case, to see if some light image processing might
> work to isolate the head.


Also, the rectangle that I drew with rectangle() seems to disappear when I click forward to a new frame. Ideally, I would want the rectangle to remain on the screen all the time.
From: Walter Roberson on
Jessica wrote:

> Also, the rectangle that I drew with rectangle() seems to disappear when
> I click forward to a new frame. Ideally, I would want the rectangle to
> remain on the screen all the time.

for K = 1 : numframe
thisframe = mmreader(FileName, K, 1);
if K == 1
framehandle = image(thisframe);
else
set(framehandle, 'CData', thisframe);
rectangle(Some Appropriate Parameters);
end
pause(1/24); %24 frames per second or so...
end


If you use this setup, you will not need "hold on", as rectangle() always adds
to the current axis, and for each frame after the first you update the current
image rather than replacing it.