Giter VIP home page Giter VIP logo

Comments (16)

bwoodsend avatar bwoodsend commented on May 27, 2024

No, I've never seen that before.

Could you elaborate a bit? When you say screenshot, do you mean vtkplotlib.save_fig() or the PrtSC button on your keyboard? Am I right in saying it's the black ring-shaped thing you want to screenshot but the little windows in the bottom left that shouldn't be there?

Also can you post your VTK version (using pip show vtk or conda info vtk)?

from vtkplotlib.

aditya-krish avatar aditya-krish commented on May 27, 2024

from vtkplotlib.

bwoodsend avatar bwoodsend commented on May 27, 2024

I hate to think what a lot of these vtk classes get up to underneath. I've just tried on Ubuntu 19.10 and that's all working normally. I'd like to do some tests but firstly does it change if you change the pixels parameter or plot something different (such as vpl.quick_test_plot())?

from vtkplotlib.

aditya-krish avatar aditya-krish commented on May 27, 2024

from vtkplotlib.

bwoodsend avatar bwoodsend commented on May 27, 2024

OK, I've tried what you said and I can't reproduce it at all. I noticed that screenshot_fig() doesn't call vtkWindowToImageFilter.Modified() which I think it aught to and there is also off screen rendering to play with. I've done a stripped down example for you to test. Could you give it a run for me please?

import vtkplotlib as vpl
import vtkplotlib.image_io
import matplotlib.pylab as plt
import vtk
import time

fig = vpl.figure()
vpl.quick_test_plot()

# Try turning this one on and off and see if it changes anything.
#fig.renWin.SetOffScreenRendering(True)

since = time.time()
while time.time() - since < 2:
    pass


fig.connect()
fig.reset_camera()
fig.renWin.Render()


win2im_filter = vtk.vtkWindowToImageFilter()
win2im_filter.SetInput(fig.renWin)
win2im_filter.Modified()
win2im_filter.Update()

arr = vpl.image_io.vtkimagedata_to_array(win2im_filter.GetOutput())

win2im_filter.SetInput(None)
vpl.close(fig)

plt.imshow(arr)
plt.show()

from vtkplotlib.

aditya-krish avatar aditya-krish commented on May 27, 2024

from vtkplotlib.

aditya-krish avatar aditya-krish commented on May 27, 2024

from vtkplotlib.

aditya-krish avatar aditya-krish commented on May 27, 2024

from vtkplotlib.

bwoodsend avatar bwoodsend commented on May 27, 2024

I am attaching the images generated by both

Either you forgot to attach or they didn't work... :)

Did you try the fig.renWin.SetOffScreenRendering(True) line near the top?

Also are you doing teeth as well? That's what I wrote this library for in the first place.

from vtkplotlib.

aditya-krish avatar aditya-krish commented on May 27, 2024

This following one is the correct image, output of fig.renWin.SetOffScreenRendering(True):
above_code

This is the bad screenshot generated by the above routine:
above_code2

This is the output of screenshot_fig:
screenshot_fig

Yes I am working on intra-oral scans, small world!!

The fig.renWin.SetOffScreenRendering(True) line seems to do the job, thanks a lot. The only issue is it is not running from the shell on the server and aborting with error "Aborting - bad X server connection." But that does not belong to this thread. I will edit the screenshot_fig in my environment to reflect this change. Thank you for your inputs.

from vtkplotlib.

bwoodsend avatar bwoodsend commented on May 27, 2024

OK, I'm glad you highlighted that. It looks like off screen rendering can get ugly. I'll pop it in the next update but as an optional parameter.

from vtkplotlib.

bwoodsend avatar bwoodsend commented on May 27, 2024

Could you do me a favour and keep me posted on your resolving that bad X-server issue? I'd like to at least add it to the docs if it's not practical to fix outright.

from vtkplotlib.

aditya-krish avatar aditya-krish commented on May 27, 2024

It works when I make a GUI login to the server, open terminal and run the application. It does not work when I connect to the server through SSH. Do you want me to post a screenshot of the error?

from vtkplotlib.

bwoodsend avatar bwoodsend commented on May 27, 2024

Might as well although I doubt I can help much. I did a google of "Aborting - bad X server connection" and this comment seems to say you need a special build of VTK with OSMesa. But the fact you can get it to work via the GUI suggests you already have everything you need.

from vtkplotlib.

aditya-krish avatar aditya-krish commented on May 27, 2024

Yes I am good with the current solution, even if it doesn't work with SSH, I was just suggesting it for your documentation purposes
bwoodsend_error_image

from vtkplotlib.

bwoodsend avatar bwoodsend commented on May 27, 2024

OK. I'll leave this issue open until I've pushed and released the changes. Thanks for your help with this.

Just as a warning to future readers of this thread: The fig.renWin.SetOffScreenRendering(True) option seems to mess the vtkRenderWindow irreversibly so that the figure can no longer be shown normally without crashing. Calling vpl.close(fig=fig) after screenhot_fig() or save_fig() resets the vtkRenderWindow so that the figure can be safely reshown. Hopefully this will all be ironed out in the next release (v1.3.0) so that you shouldn't need to worry about any of this.

from vtkplotlib.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.