[vtkusers] Re: how to output an avi file in VTK

Wang HJ hjwang126 at hotmail.com
Mon May 29 05:49:39 EDT 2006


Hi Goodwin,

many thanks, you are right! Now my code works and created a correct avi 
file. Thanks again

now I would like to share my code
vtkWindowToImageFilter *imageFilter = vtkWindowToImageFilter::New();
  imageFilter->SetInput(renWin);
  vtkAVIWriter *w=vtkAVIWriter::New();
  w->SetFileName("c:/TestAVIWriter.avi");
  w->SetInputConnection(imageFilter->GetOutputPort());
  w->Start();
  for (i = 0; i < 9; ++i)
    {
    // Render the image and rotate the active camera by one degree
	  renWin->Render();
   aRenderer->GetActiveCamera()->Elevation(-10);
   aRenderer2->GetActiveCamera()->Elevation(10);
   imageFilter->Modified();
   w->Write();
   }
   w->End();

  HJ

>From: Goodwin Lawlor <goodwin.lawlor at ucd.ie>
>To: vtkusers at public.kitware.com
>Subject: [vtkusers] Re: how to output an  avi file in VTK
>Date: Mon, 29 May 2006 09:34:29 +0000
>
>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();
>>......
>>
>>but it did not write "*.avi" file at all.
>>
>>it gave me this message:
>>ERROR: In .\vtkAVIWriter.cxx, line 74
>>vtkAVIWriter (025F39E8): Write:Please specify an input!
>>
>>how can I connect the specify input  . Thanks in advance
>>
>
>Hi HJ,
>
>Try:
>
>vtkWindowToImage *w2i = vtkWindowToImage::New();
>   w2i->SetInput(renWin);
>
>vtkAVIWriter *w=vtkAVIWriter::New();
>   w->SetFileName("c:/TestAVIWriter.avi");
>   w->SetInputConnection(w2i->GetOutputPort());
>   w->Start();
>
>  for (i = 0; i < 9; ++i)
>    {
>    // Render the image and rotate the active camera by one degree
>    aRenderer->GetActiveCamera()->Azimuth(10);
>    aRenderer->GetActiveCamera()->Elevation(-10);
>    aRenderer2->GetActiveCamera()->Elevation(10);
>    renWin->Render();
>    w2i->Modified();
>    w->Write();
>    }
>
>   w->End();
>
>
>hth
>
>Goodwin
>
>_______________________________________________
>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