Hey Beau,<br><br>Thank you so much! You are right! I update the pointer to the <font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">vtkWindowToImageFilter every time when I call the image rendering function. After I added
</span></font><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">avi->SetInputConnection(w2i->GetOutputPort()) to the loop, the generated movie looks normal.<br>
<br>Also, off-screen rendering is acceptable. That is, when I set the off-screen rendering on, the program can still get proper movies. <br><br>Janny<br></span></font><br><div><span class="gmail_quote">On 5/30/07, <b class="gmail_sendername">
Beau Sapach</b> <<a href="mailto:beau.sapach@ualberta.ca">beau.sapach@ualberta.ca</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div link="blue" vlink="blue" lang="EN-US">
<div>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Hi Janny,</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">I'm not sure I understand your code…
the ImgRender() function somehow changes your input data and renders the image
(changing what is displayed in the window) and then returns a pointer to the
vtkWindowToImageFilter, correct? I'm not sure why you have w2i =
ImgRender() in your loop. Once you have a pointer to the filter you
shouldn't need to assign that pointer again, unless you're deleting
and re-creating the vtkWindowToImageFilter on each call to ImgRender(), are
you? If you are, then you should call avi->SetInputConnection(w2i->GetOutputPort())
each time you get a new w2i pointer.</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Beau</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<div>
<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">
<hr align="center" size="2" width="100%">
</span></font></div>
<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> Janny Dong
[mailto:<a href="mailto:janny.dong@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">janny.dong@gmail.com</a>] <br>
<b><span style="font-weight: bold;">Sent:</span></b> Tuesday, May 29, 2007 3:16
PM<br>
<b><span style="font-weight: bold;">To:</span></b> Beau Sapach<div><span class="e" id="q_112dd935447b1b55_1"><br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [vtkusers] How to
write AVI files properly, Please Help</span></div></span></font></p>
</div><div><span class="e" id="q_112dd935447b1b55_3">
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">Hey Beau,<br>
<br>
Thanks a lot for your suggestions. I still could not get correct movies. What I
did is:<br>
<br>
Define a function - static vtkWindowToImageFilter *ImgRender() to render the
images and pass WindowToImageFilter as a parameter to main(); <br>
My main function is<br>
int main( int argc, char *argv[] )<br>
{<br>
int imageN;<br>
//Generate avi file<br>
vtkWindowToImageFilter *w2i = ImgRender();<br>
vtkAVIWriter *avi = vtkAVIWriter::New();<br>
avi->SetInputConnection(w2i->GetOutputPort()); <br>
avi->SetFileName("test.avi");<br>
avi->Start();<br>
<br>
for (imageN = 0; imageN < 10; imageN ++)<br>
{<br>
w2i = ImgRender();<br>
avi->Write(); <br>
}<br>
avi->End(); <br>
avi->Delete();<br>
w2i->Delete();<br>
return 0;<br>
}<br>
<br>
I don't know how you set up your loop to generate movies. I already switched to
on-screen rendering and I could see the images in the rendering window were
changing. I am guessing probably it's not a good way to pass the
WindowToImageFilter as a parameter, but I have no better idea to do this right
now, because my image rendering part is fairly large, and I try to make the
code neat by defining the rendering part as a function and calling it in the
main function. <br>
<br>
Sorry to bother you and thanks for sharing your experience with me.<br>
<br>
Janny</span></font></p>
<div>
<p><span><font face="Times New Roman" size="3"><span style="font-size: 12pt;">On 5/29/07, <b><span style="font-weight: bold;">Beau
Sapach</span></b> <<a href="mailto:beau.sapach@ualberta.ca" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
beau.sapach@ualberta.ca</a>> wrote:</span></font></span></p>
<div link="blue" vlink="blue">
<div>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Hi Janny,</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">My movies are 2-4MB or less for 30 frames @ 25 frames per
second. I just realized something though. If you're using
SetOffScreenRendering(1) then when you call Render() the image in the window is
not updated. It's the image in the vtkRenderWindow that the
vtkWindowToImageFilter uses. I'm just guessing but the single static
image you're seeing in the AVI file is probably the last image that was
rendered to the window (before off-screen rendering was switched on).</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">It may work properly if you leave rendering on-screen.
Or if you want to use off-screen rendering you could probably get the
memory buffer that the vtkRenderWindow it's rendering to, and use the RGBA data
in there to build your own vtkImageData object and write that to the AVI.</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<div>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Beau</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">
<hr align="center" size="2" width="100%">
</span></font></div>
<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> Janny Dong [mailto:
<a href="mailto:janny.dong@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">janny.dong@gmail.com</a>] <br>
<b><span style="font-weight: bold;">Sent:</span></b> Tuesday, May 29, 2007 12:27
PM<br>
<b><span style="font-weight: bold;">To:</span></b> Beau Sapach<br>
<b><span style="font-weight: bold;">Cc:</span></b> vtkusers<br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [vtkusers] How to
write AVI files properly, Please Help</span></font></p>
</div>
<div><span>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">Beau, you said you didn't have size problem. You are
saying your movie is reasonably smaller? <br>
<br>
I added Modified() before the line WindowToImage->update() as you suggested.
The movie still shows a single static image. :( <br>
<br>
Janny</span></font></p>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">On
5/29/07, <b><span style="font-weight: bold;">Janny Dong</span></b> <<a href="mailto:janny.dong@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">janny.dong@gmail.com</a>>
wrote:</span></font></p>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">Thanks,
Beau. I tried to play with FFMPEG, but with no success. I am using MSVC, and
unfortunately FFMPEG doesn't support it, so I couldn't get the library
installed. My project requires automated movie generation. That's why I am
struggling to get everything under control in my code. :( <br>
<br>
Janny</span></font></p>
<div>
<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">On
5/29/07, <b><span style="font-weight: bold;">Beau Sapach</span></b> <<a href="mailto:beau.sapach@ualberta.ca" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> beau.sapach@ualberta.ca</a>>
wrote:</span></font></p>
<div link="blue" vlink="purple">
<div>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">I think I had a similar problem, not the size issue but the
single, static image issue. Try calling Modified() on
vtkWindowToImageFilter before you call Update(). As for frame rate I
don't know how to set that with vtk's classes, I suggest you look at FFMPEG, it
can be built into VTK but I've had little luck doing so. Currently I
write out image files and have my application call the ffmpeg executable to
encode the images as a movie, using ffmpeg command line options you can control
framerate.</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Beau</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<div>
<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">
<hr align="center" size="2" width="100%">
</span></font></div>
<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> vtkusers-bounces+beau.sapach=
<a href="mailto:ualberta.ca@vtk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">ualberta.ca@vtk.org</a>
[mailto:<a href="mailto:vtkusers-bounces+beau.sapach=ualberta.ca@vtk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">vtkusers-bounces+beau.sapach=ualberta.ca@vtk.org</a>] <b><span style="font-weight: bold;">
On Behalf Of </span></b>Janny Dong<br>
<b><span style="font-weight: bold;">Sent:</span></b> Tuesday, May 29, 2007 8:24
AM<br>
<b><span style="font-weight: bold;">To:</span></b> vtkusers<br>
<b><span style="font-weight: bold;">Subject:</span></b> [vtkusers] How to write
AVI files properly, Please Help</span></font></p>
</div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">I posted a similar question but didn't get any answer,
probably I didn't make it clear enough.<br>
<br>
I am coding a C++ program to visualize my data and generate movie
automatically. I put vtkAVIWriter in a loop to get a movie out of the
rendering. It did get an avi file, but not the one I expected. I have two
questions about it. <br>
<br>
(1) The size of the movie file is 18MB, but it has only 50 frames. Moreover, it
is only 3 second long. Can I compress the movie file with vtkAVIWriter? How can
I control the speed of the movie, like specifying number of frames per second? <br>
<br>
(2) I found the avi file displayed only one frame like a static image. However,
I did update the data when rendering each frame. The data rendering part in my
program is like<br>
data
points--->vtkPolyData--->vtkDelaunay2D--->vktPolyDataMapper--->vtkRenderer--->vtkWin32OpenGLRenderWindow->SetOffScreenRendering(1)--->vtkWindowToImageFilter--->vtkAVIWriter
<br>
<br>
I have something like: PolyDataMapper->update(); WindowToImage->update()
in my code. Did I call update() in a wrong way or should I call it in
different parts of the code?<br>
<br>
Any suggestions will be greatly appreciated. <br>
<br>
Janny<br>
</span></font></p>
</div>
</div>
</div>
</div>
<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
</div>
</div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
</span></div>
</div>
</div>
</div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
</span></div></div>
</div>
</blockquote></div><br>