[vtkusers] vtkVideoSource problem
Simon DROUIN
sdrouin at bic.mni.mcgill.ca
Tue Jul 13 08:05:26 EDT 2004
Madhusudhanan Balasubramanian wrote:
> I'm trying grab frames from a video capture board. I tried Play(),
> Stop(), FastForward() and Rewind() functions, but none of them seem to
> have control over the tape connected to the video capture board.
>
> Here is my code fragment:
> //Initialize the video source
> this->videoSource = vtkVideoSource::New();
> this->videoSource->SetFrameSize(640, 480, 1);
> this->videoSource->SetFrameRate(30);
> this->videoSource->SetNumberOfOutputFrames(1);
> this->videoSource->SetFrameCount(0);
> this->videoSource->Play();
> (won't this send a play command to the tape?)
>
> this->videoSource->ReleaseSystemResources();
> this->videoSource->Delete();
> I've searched through the archives but didn't help much in
> understanding whether Play() and other such commands would actually
> send commands to play the tape.
>
> I tried grab() too, but didn't work (returns a data size of 0, 0, 0)
I think you need to call Initialize() on the video source before you can
grab anything. There might be some other parameters that need to be set
like VideoInput and VideoFormat. Also, if you want to grab continuously,
you have to call Record(). Play() is just used to playback what the
video source has in its memory buffer. Record() will put the latest
frame in the output of the video source and will keep all grabbed frames
in a memory buffer (of size FrameBufferSize, default = 1 ). Record will
keep overwriting the same frame in the buffer unless you set AutoAdvance
to On (default = OFF).
I find this interface is pretty counter-intuitive. I would create a new
class (vtkSimpleVideoSource) that would simply grab frames continuously
and copy the grabbed frames to its output. A second class
(vtkVideoBuffer) could be connected to the output and listen for a new
frame event for the video source. I'll write that when I have time.
Simon
More information about the vtkusers
mailing list