[vtkusers] Generate 2D views (store them as images) from 3D models

Sebastien Jourdain sebastien.jourdain at kitware.com
Wed Jul 7 07:58:05 EDT 2010


Hi  Aitor,

The only way to prevent the window from poping up, is to use the
Offscreen option and compile vtk with OSMesa.
Otherwise, even in Offscreen mode, a black window will popup and disappear.

Seb

On Wed, Jul 7, 2010 at 7:36 AM, Aitor Aldomà <aldoma.aitor at gmail.com> wrote:
> Hi everybody,
>
> I want to generate 2D views of a 3D model and save them as jpeg image. At
> the moment, I am using vtkWindowToImageFilter to obtain the generated view
> from a RenderWindow. The problem is that I dont want to display the window
> on the screen, just wan the RenderWindow to render the view and store the
> result with vtkWindow without showing the window.
>
> This is part of the code i am using now, the problem is that the window will
> flash for a short time and then disapper. Is there a way to render the view
> without being displayed on the screen???
>
> renWin = vtk.vtkRenderWindow()
> renWin.AddRenderer(ren)
> ren.SetBackground(1, 1, 1)
> renWin.SetSize(128,128)
>
> ren.Render()
>
> winToImageFilter = vtk.vtkWindowToImageFilter()
> winToImageFilter.SetInput(renWin);
>
> renWin.Finalize()
> winToImageFilter.Update()
>
> jw = vtk.vtkJPEGWriter();
> jw.SetInput(winToImageFilter.GetOutput());
>
> jw.SetFileName(fileName + ".jpg");
> jw.Write();
>
> Thanks in advance
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK 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