[vtkusers] vtkWindowToImageFilter

Lasso, Andras (GE Healthcare) Andras.Lasso at med.ge.com
Wed Apr 4 05:04:10 EDT 2007


Mark,

We use vtkWindowToImageFilter to perform off-screen rendering.

In windows it works correctly with default settings (no rendering window
is displayed, rendered image is correct and complete).

In linux we had the same problem as you (a rendering window was popped
up, the captured image contained the pixels in the screen buffer at the
location of the rendering window, so if any window overlapped the area
then the captured image was corrupted).

The solution for us was to compile VTK with the MESA libraries (instead
of the default OpenGL):
OPENGL_INCLUDE_DIR:PATH=/export/home1/app1/Mesa-6.5.2/include
OPENGL_gl_LIBRARY:FILEPATH=/export/home1/app1/Mesa-6.5.2/lib/libGL.so
OPENGL_glu_LIBRARY:FILEPATH=/export/home1/app1/Mesa-6.5.2/lib/libGLU.so
OPENGL_xmesa_INCLUDE_DIR:PATH=/export/home1/app1/Mesa-6.5.2/include
OSMESA_INCLUDE_DIR:PATH=/export/home1/app1/Mesa-6.5.2/include
OSMESA_LIBRARY:FILEPATH=/export/home1/app1/Mesa-6.5.2/lib/libOSMesa.so
VTK_OPENGL_HAS_OSMESA:BOOL=ON
VTK_USE_MANGLED_MESA:BOOL=OFF
vtkRendering_LIB_DEPENDS:STATIC=vtkGraphics;vtkImaging;vtkIO;vtkftgl;vtk
freetype;/export/home1/app1/Mesa-6.5.2/lib/libGL.so;/export/home1/app1/M
esa-6.5.2/lib/libOSMesa.so;-lXt;-lSM;-lICE;-lSM;-lICE;/usr/X11R6/lib/lib
X11.so;/usr/X11R6/lib/libXext.so;/usr/X11R6/lib/libX11.so;/usr/X11R6/lib
/libXext.so;

There may be drivers for MESA with that you can get hardware
acceleration (you need one that supports PBuffer rendering, otherwise
you'll have the same problem as with the OpenGL implementation).

If you would like to use OpenGL for on-screen rendering and MESA for
off-screen rendering then you have to compile VTK with mangled MESA (as
I understood from previous posts you may have to do some modifications
in VTK or MESA to make it work with the latest library versions).

Andras


-----Original Message-----
From: vtkusers-bounces+andras.lasso=med.ge.com at vtk.org
[mailto:vtkusers-bounces+andras.lasso=med.ge.com at vtk.org] On Behalf Of
Dominik Szczerba
Sent: Tuesday, April 03, 2007 10:36 PM
To: vtkusers at vtk.org
Subject: Re: [vtkusers] vtkWindowToImageFilter

I am not sure if this has really anything to do with VTK. I have a
commercial program that does the same thing when taking screenshots. I
recall now that disabling DRI removed this effect indicating problems
with the driver. I would disable DRI in your case just for a test.
bye
Dominik

On Tuesday 03 April 2007 22:23, you wrote:
> Hi Dominik,
>
> That's the problem - if any part of the render window is overlapped, 
> or just off screen rendering is on, I'll get an incorrect image.
>
> As far as I can tell, there is no way to do this at the moment. How 
> are other people doing this? I could try using vtkGL2PSExporter as you

> suggested but it might be too slow to do quick screen captures.
>
> Thanks,
> Mark
>
> On 4/3/07, Dominik Szczerba <domi at vision.ee.ethz.ch> wrote:
> > With a png file the covered of off-desktop part will be empty.My
code:
> >
> >                vtkSmartPointer<vtkPNGWriter> writer = 
> > vtkSmartPointer<vtkPNGWriter>::New(); w2i->Update();
> >                writer->SetInputConnection(w2i->GetOutputPort());
> >                writer->SetFileName((curr_fname+".png").c_str());
> >                renWin->Render();
> >                writer->Write();
> >                w2i->Modified(); //w2i is a global
> >
> > BTW. The effect of vtkGL2PSExporter will always be OK.
> > Dominik
> >
> > On Tuesday 03 April 2007 21:21, Mark Wyszomierski wrote:
> > > Hi Dominik,
> > >
> > > That didn't seem to have any effect for me, because the bitmap is 
> > > already written out at the time writer->Write() is called.
> > >
> > > Can I ask you though, what happens if you drag your render window 
> > > partially off your desktop screen so it gets clipped by the edges 
> > > - do you still get the entire render window contents captured? 
> > > Nothing I do seems to get around this problem. I've traced into 
> > > the render window class and it does seem to be reading the pixels
from the back buffer:
> > >
> > >     glReadBuffer(static_cast<GLenum>(this->GetBackLeftBuffer()));
> > >
> > > still I get artifacts of overlapping windows in my screenshot!
> > >
> > > Thanks,
> > > Mark
> > >
> > > On 4/3/07, Dominik Szczerba <domi at vision.ee.ethz.ch> wrote:
> > > > I have w2i->Modified() after write, else doesnt work.
> > > > --ds
> > > >
> > > > On Tuesday 03 April 2007 19:40, you wrote:
> > > > > Hi,
> > > > >
> > > > > I'm using the source from the example page. Looks like:
> > > > >
> > > > > void CSomeClass::Screenshot(vtkRenderWindow* pRenWin) {
> > > > >     vtkWindowToImageFilter* w2i =
vtkWindowToImageFilter::New();
> > > > >     vtkBMPWriter* writer = vtkBMPWriter::New();
> > > > >     w2i->SetInput(pRenWin);
> > > > >     w2i->Update();
> > > > >     writer->SetInputConnection(w2i->GetOutputPort());
> > > > >     writer->SetFileName("C:\\test.bmp");
> > > > >     pRenWin->Render();
> > > > >     writer->Write();
> > > > > }
> > > > >
> > > > > if the render window was doing offscreen rendering, the 
> > > > > resulting image will be just black. If doing on screen 
> > > > > rendering, the filter will just capture any other windows 'on
top of' the render window.
> > > > > I thought this filter used to capture exactly what was in the 
> > > > > renderer, regardless of what other windows were on top of it, 
> > > > > or if it was doing offscreen rendering. I know if I revert 
> > > > > back to the VTK release version the same code above works fine

> > > > > with offscreen rendering, probably with onscreen rendering and

> > > > > overlapping windows?
> > > > >
> > > > > Thanks,
> > > > > Mark
> > > > >
> > > > > On 4/3/07, Dominik Szczerba <domi at vision.ee.ethz.ch> wrote:
> > > > > > I once had a similar problem (empty screen) and if I recall 
> > > > > > properly the solution was to call Modified() somewhere.
> > > > > > Dominik
> > > > > >
> > > > > > On Tuesday 03 April 2007 15:19, Mark Wyszomierski wrote:
> > > > > > > Hi,
> > > > > > >
> > > > > > > Has anyone tried using the CVS version of 
> > > > > > > vtkWindowToImageFilter? It seems to produce an empty image

> > > > > > > when used. Reverting back to the 'release' version 5x of 
> > > > > > > VTK, the same code that uses it produces correct results. 
> > > > > > > Just wondering if anyone experienced the same thing or any

> > > > > > > ways around it,
> > > > > > >
> > > > > > > Thanks,
> > > > > > > Mark
> > > > > > > _______________________________________________
> > > > > > > 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
> > > > > >
> > > > > > --
> > > > > > Dominik Szczerba, PhD
> > > > > > Computer Vision Lab CH-8092 Zurich 
> > > > > > http://www.vision.ee.ethz.ch/~domi
> > > > > > _______________________________________________
> > > > > > 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
> > > >
> > > > --
> > > > Dominik Szczerba, PhD
> > > > Computer Vision Lab CH-8092 Zurich 
> > > > http://www.vision.ee.ethz.ch/~domi
> > > > _______________________________________________
> > > > 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
> >
> > --
> > Dominik Szczerba, PhD
> > Computer Vision Lab CH-8092 Zurich
> > http://www.vision.ee.ethz.ch/~domi
> > _______________________________________________
> > 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

--
Dominik Szczerba, PhD
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi
_______________________________________________
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