[vtkusers] Asynchronous outputs
David Gobbi
dgobbi at atamai.com
Mon Apr 23 19:28:31 EDT 2007
Hi Tim,
A VTK source cannot serve pipeline requests from more than one thread.
In order for a vtkVideoSourceRecorder to work, the video would have to
feed through it to the rest of the pipeline, and internally, it would
have to be constructed so that pipeline requests coming from its output
don't propagate to its input. Then its input can run in one thread, and
its output in another. It is certainly possible to write such a class,
but it would be a little, ah, unorthodox. It would keep the
vtkVideoSource from having to directly serve requests from two threads,
though.
A long time ago I started a project where I was separating the
vtkVideoSource class into a vtkVideoSource and a vtkVideoBuffer, which
would expose a public interface including locking functions so that
frames stored in the buffer could be accessed from different threads.
Unfortunately I never completed the project and the code is pretty stale
by now (it dates back to VTK 3.2).
What I used to do instead of continually writing out the frames was just
set the video buffer to be huge and use a computer with lots of RAM.
That way I could just write out the frames after I was done. Each gig
of memory will hold 3000 frames at 640x480, that may or may not be
enough for what you want to do.
- David
Tim Soper wrote:
> Hi-
> I am still trying to get a follow-up to a question I had regarding how to best access a continually updating output. I have made a video frame grabber class based on the vtkVideoSource class but I want to add functionality for saving individual frames to file at a pretty fast rate. Currently I've just added code to the InternalGrab( ) function that saves each frame after grabbing it. It would be nice to do this asnychronously though. My idea was to make a vtkVideoSourceRecorder that would continously save frames from the associated video source inside a separate thread. What I'd like to do is something like this:
>
> videoSource = vtkVideoSource::New(); //create the source
> videoRecorder = vtkVideoSourceRecorder::New(); //create the recorder
>
> videoRecorder->SetInputConnection( videoSource->GetOutputPort() ); //connect the inputs/outputs
>
> videoSource->Record( ); //start grabbing frames
> videoRecorder->BeginRecord(); //start saving frames to file.
>
> This would allow me to save and and display at separate rates. As well, it seems more practical to separate these two functions into different classes. After trying to implement this though, the program chokes and freezes. It seems to be grabbing the output when it's busy grabbing another frame or something. Is there a more correct way to do this?
>
> Tim Soper
>
> Research Assistant
> University of Washington
> Department of Bioengineering
> Box 352142
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
More information about the vtkusers
mailing list