Vedo: Plotter: the first screenshot is blank + image quality issue

Created on 7 Oct 2020  路  16Comments  路  Source: marcomusy/vedo

Hi, I have stumbled into an issue with screenshooting today. Minimal example:

import vedo
vedo.embedWindow(False)

corners = [[-20,-20], [20,20]]
plane = vedo.shapes.Rectangle(*corners, c='lightgrey') # alpha<1 makes it immediately invisible when looking from above
sphere = vedo.shapes.Sphere(pos=(0,0, 10),r=2)


plotter = vedo.plotter.Plotter(axes=7, interactive=False)
plotter.add([sphere, plane])
plotter.show()
plotter.screenshot('test.png') 
plotter.screenshot('test2.png') 
plotter.close()
  • The first screenshot is just blank, the second is saved normally.
  • Same with vedo.io.screenshot (both when saving to file or to a numpy array).
  • My OS is Windows. I use the latest version vedo 2020.4.0.
  • Same behaviour from jupyter notebook or a script.

The second issue is that the screenshot, generated with offscreen option seem to have conisderably lower quality. For now I am just going to not use this option, but I was just surprised by this behaviour.

Cheers,
icemtel

All 16 comments

hi I cannot reproduce the issue, this works for me.

import vedo
vedo.embedWindow(False)

corners = [[-20,-20], [20,20]]
plane = vedo.Rectangle(*corners, c='lightgrey', alpha=0.9)
#plane.lighting('off') # avoid reflective glare at 90deg
sphere = vedo.Sphere(pos=(0,0, 10),r=2)

plotter = vedo.Plotter(axes=7, bg="bb", bg2="ly", interactive=1)
#plotter.add([sphere, plane])
plotter += [sphere, plane] # faster
plotter.show().screenshot('test.png') 

what vtk and python version do you have? (press h to get them)

@marcomusy I have to say that in your example I cannot make a screenshot at all: after I close an interactive window, the next time I call this plotter (e.g. to make a screenshot) the program crashes. (Is there a "safe" way to close the plotter window?)

If I run your example with interactive=0, then the screenshot is blank, with dark-grey color (before is was all white).
Just for fun of it, I have changed the color of the plane, but it does not change the screenshot color.

Below are my versions

(' vedo 2020.4.0 ',)
('| vtk 8.2.0 | python 3.8',)

P.S. thanks for the plane.lighting('off') tip!

many mysteries here...
I thought that vtk8.2 wheels for python 3.8 in windows did not exist.. did you compile vtk from source?

If I run your example with interactive=0, then the screenshot is blank, with dark-grey color (before is was all white).

i dont understand this behavior :(

in your example I cannot make a screenshot at all: after I close an interactive window, the next time I call this plotter (e.g. to make a screenshot) the program crashes.

i'm afraid i cannot reproduce it either :( what happens if instead of closing the window you press q in the window?

I have installed vtk via conda-forge.

I have just tried to use vtk 8.1, but it does not change anything.

Press q instead of closing the window actually helps - I don't get vtk errors! But the screenshot issue still persists.

I have just tried to use vtk 8.1, but it does not change anything.

i'm afraid this has to to with some upstream vtk problem then .. not related to vedo..

Press q instead of closing the window actually helps - I don't get vtk errors! But the screenshot issue still persists.

ok -that points to the vtkRenderingWindow being deleted when closing the window by hitting the close icon... i'll see if I can reproduce it in windows or at least protect the method.
Thanks for reporting!

Not sure if we understood each other. I meant that the problem is not solved by changing to vtk8.1.

ok -that points to the vtkRenderingWindow being deleted when closing the window by hitting the close icon... i'll see if I can reproduce it in windows or at least protect the method.
Thanks for reporting!

Makes sense & you're welcome!

I meant that the problem is not solved by changing to vtk8.1.

got it :) the thing is that it's probably some bug in vtk rather than in the downstream vedo, i'm not sure how can i verify that though..

I will become more clear if other people will happen to report a similar
problem.

At least taking a screenshot shot twice solves the problem for me.

P.S.I think vedo is a really helpful tool, but I think it's missing some
kind of QA or discussion board (although I don't know how big is vedo
community)
Usually I find answers to questions like "how to do X" on stackoverflow,
but with vedo it's just github issues and they lack "choose the best
answer" and voting system (so it takes more time to find the right answer)
& clutter real bug reports Would love to know your thoughts on that.

@icemtel - thanks for your comments, I appreciate the feedback.
At present vedo's community is not so large (I would love to know how many people outside my lab is actively using it!).
I'm very much open to any suggestions about Q&A platforms, I'm not sure which could be the most effective one (slack? gitter? discourse? twitter/facebook? ...).
I've got some questions on stackoverflow too which I tend to redirect to github issues here. I must say I have mixed feelings about stackoverflow.
We always welcome new contributors - so if you like the project and/or have ideas on how to improve please share them!

Unfortunately, I don't have much experience with the platforms you mentioned.

I am curious, what troubles did you have with stackoverflow? From a new user's perspective stackoverflow usually helps me a lot as I can find the best answer quickly. In github issues it's not always clear what answer solves the issue. I think the other platforms you suggested do not address this problem.

Also I personally felt discouraged to open an issue, because it's usually for bug reports :). In the end it worked out well for me, as I dived in in documentation myself and got more comfortable, but many people might get pushed away.

I also like a forum solution in Home Assistant community (another open source project) https://community.home-assistant.io/ it is powered by discourse if I am not mistaken. Also allows to "pick the answer" and give some thumbs up to people. (Don't know how hard is it to set it up and host)

By the way, when I searched for solutions, could barely find something by name "vedo", but had more success with "vtkplotter". I suppose that's an older name of the package? Maybe that's worth mentioning in README?

So that was a little feedback from my part. I am mostly done with 3D graphics for my project, at least for some time. But if I happen to spot something I will surely make PR or open an issue :)

Unfortunately, I don't have much experience with the platforms you mentioned.

I am curious, what troubles did you have with stackoverflow? From a new user's perspective stackoverflow usually helps me a lot as I can find the best answer quickly. In github issues it's not always clear what answer solves the issue. I think the other platforms you suggested do not address this problem.

just the feeling of an unfriendly community. Btw I just found out that discourse is not free (unless one i s very skilled at setting up servers and stuff which i'm not..), but i'll keep an eye on alternatives (eg flarum)

Also I personally felt discouraged to open an issue, because it's usually for bug reports :). In the end it worked out well for me, as I dived in in documentation myself and got more comfortable, but many people might get pushed away.

I see the point..

I also like a forum solution in Home Assistant community (another open source project) https://community.home-assistant.io/ it is powered by discourse if I am not mistaken. Also allows to "pick the answer" and give some thumbs up to people. (Don't know how hard is it to set it up and host)

I could not understand very well what this is though

By the way, when I searched for solutions, could barely find something by name "vedo", but had more success with "vtkplotter". I suppose that's an older name of the package? Maybe that's worth mentioning in README?

So that was a little feedback from my part. I am mostly done with 3D graphics for my project, at least for some time. But if I happen to spot something I will surely make PR or open an issue :)

you are very welcome to! thanks again for the feedback!

Yeah I can see that, for example, this discussion would not be happening at stackoverflow, due to format limitations.

Flarum looks rather similar to discourse indeed.

I could not understand very well what this is though

Not sure what the question is referring to, but basically it's a forum for Home Assistant, it's something you can install on a raspberry pi to control your smart lights, thermostats, etc.

What about github discussions? https://github.com/vercel/vercel/discussions

Cheers, icemtel

github discussions sounds interesting - i guess one needs to refer to an organization, so I could create a test discussion here https://github.com/orgs/conda-forge/teams/vedo

i'm a bit confused though on how the thing is supposed to work

@marcomusy I think "team discussions" and "discussions" are different things (confusing indeed!).
Perhaps github discussions are still in beta and you should ask to enable it here? https://github.community/t/can-one-apply-for-github-discussions-beta/121120/2

If I run your example with interactive=0, then the screenshot is blank, with dark-grey color (before is was all white).

I had the same issue and it helped after installing vtk version 9.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DeepaMahm picture DeepaMahm  路  5Comments

vigji picture vigji  路  3Comments

FedeClaudi picture FedeClaudi  路  7Comments

MarkusRosen picture MarkusRosen  路  3Comments

bhaveshshrimali picture bhaveshshrimali  路  6Comments