[vtkusers] how to output an avi file in VTK

Peter meancity at gmail.com
Mon May 29 04:50:28 EDT 2006


use a for loop to generate a serial of jpeg, png or whatever image files.

and use "animate shop" to create gif or avi.




On 5/29/06, Wang HJ <hjwang126 at hotmail.com> wrote:
>
> Hi,Marc
>
> Thank you for your reply, I have done it like you said, now *.avi can be
> created,  the animation just contains one still image although the still
> image can last sometime( not change anymore), why? Do I need another
> statements? Looking forwards to receiving your new suggestion. Thanks ,
> now my code is :
>
> vtkWindowToImageFilter *imageFilter = vtkWindowToImageFilter::New();
>  imageFilter->ReadFrontBufferOff();
>  imageFilter->SetInput(renWin);// renwin is defined as vtkRenderWindow
> *renWin
>  vtkAVIWriter *w=vtkAVIWriter::New();
>  w->SetInput(imageFilter->GetOutput());
>  w->SetFileName("c:/TestAVIWriter.avi");
>  w->Start();
>  for (i = 0; i < 9; ++i)
>    {
>    // Render the image and rotate the active camera by one degree
>    renWin->Render();
>  // aRenderer->GetActiveCamera()->Azimuth(10);
>   aRenderer->GetActiveCamera()->Elevation(-10);
>   aRenderer2->GetActiveCamera()->Elevation(10);
>   imageFilter->Update();
>    w->Write();
>   }
>   w->End();
>
>  HJ
>
>
>
> >From: Marc Cotran <marc at cotran.ca>
> >To: Wang HJ <hjwang126 at hotmail.com>
> >Subject: Re: [vtkusers] how to output an  avi file in VTK
> >Date: Sun, 28 May 2006 23:58:39 -0400
> >
> >Wang HJ wrote:
> >>Hi everybody
> >>
> >>I have a program to render images in a loop (so it looks like an
> >>animation) in vtk, now I want to save those results in an avi file, I knew
> >>I could use the class vtkAVIWriter, but I do not know how to use it, I
> >>wrote my code like:
> >>vtkAVIWriter *w=vtkAVIWriter::New();
> >>w->SetFileName("c:/TestAVIWriter.avi");
> >>w->Start();
> >>  for (i = 0; i < 9; ++i)
> >>    {
> >>    // Render the image and rotate the active camera by one degree
> >>    renWin->Render();
> >>  // aRenderer->GetActiveCamera()->Azimuth(10);
> >>   aRenderer->GetActiveCamera()->Elevation(-10);
> >>   aRenderer2->GetActiveCamera()->Elevation(10);
> >>   w->Write();
> >>   }
> >>   w->End();
> >Hello,
> >
> >You have to specify the input as a vtkImageData object. What you are trying
> >to do can be accomplished as follows:
> >
> >   vtkWindowToImageFilter *imageFilter = vtkWindowToImageFilter::New();
> >    imageFilter->ReadFrontBufferOff();
> >    imageFilter->SetInput(myRenderWindowInstance);
> >
> >    vtkAVIWriter *writer = vtkAVIWriter::New();
> >
> >    writer->SetFileName("tester.avi");
> >    writer->SetInput(imageFilter->GetOutput());
> >    writer->Start();
> >
> >    for (int i = 0; i < 30; i++)
> >    {
> >        do something;
> >        myRenderWindowInstance->Render();
> >        writer->Write();
> >    }
> >
> >    writer->End();
> >
> >HTH,
> >
> >Marc
>
>
> _______________________________________________
> 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