vedo
vedo copied to clipboard
Vedo Points becomes White or Transparent
We encountered problems when plotting point cloud points by Vedo in a pyside2 environment. It was good before however, without any notice of system change, points become white or transparent when run the same code recently. We tried the explore5D sample code on our system and got the same issue. Are there any suggestions to fix it?
Attached the explore5D output as FYI
Python 3.9.7
vedo: 2023.5.0
matplotlib: 3.7.3
Thanks for reporting, this is a weird bug in VTK which happens only on some machines. Try
mypoints.render_points_as_spheres(False)
Thank you Marcomusy! The code above did work initially.
Unfortunately, we passed the first plot but the later plot causes fatal errors. Due to biz reason we can't provide the code here. The working logic is simple: we first plot the raw point cloud, then do different works against those points and passed the new points, numpy array, to ploter to replot it. at the plotter we do:
mypoints = Points(self.xyz,c ="rainbow") mypoints.render_points_as_spheres(False) plt.show(mypoints,zoom=1.3,axes=1, title = plot_type)
This was running in a multithreading framework of pyside2. That means a worker to do the data process and the main thread deal with plotting. Data passed between them are numpy arrays.
The error codes are :
Windows fatal exception: access violation
Thread 0x00002af4 (most recent call first): File "our_env\lib\concurrent\futures\thread.py", line 75 in _worker File "our_env\lib\threading.py", line 910 in run File "our_env\lib\threading.py", line 973 in _bootstrap_inner File "our_env\lib\threading.py", line 930 in _bootstr
Appreciate if you can provide further assistance. Regards
DR.
BTW, we did plt.clear() before the plotting
The code was running in a spyder console, The final error msg following above are :
Main thread:
Current thread 0x00002ac0 (most recent call first):
File "our_env\lib\site-packages\vedo\plotter.py", line 3235 in show
....
File "our_env\lib\site-packages\spyder_kernels\py3compat.py", line 356 in compat_exec
File "our_env\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 469 in exec_code
File "our_env\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 611 in _exec_file
File "our_env\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 524 in runfile
File "C:\Users\Complie-WIN10\AppData\Local\Temp\ipykernel_10088\3320116497.py", line 1 in
This seems related to the qt widget line 3235 is
if self.qt_widget is not None:
self.qt_widget.GetRenderWindow().AddRenderer(self.renderer)
can you try it on the dev version:
pip install -U git+https://github.com/marcomusy/vedo.git
PS: also add
settings.enable_default_mouse_callbacks = False
settings.enable_default_keyboard_callbacks = False
settings.enable_pipeline = False
Hello,2024.5.0+dev31 installed. where to pu the following settings? in my working py or vedo setting files?
settings.enable_default_mouse_callbacks = False settings.enable_default_keyboard_callbacks = False settings.enable_pipeline = False
Installed dev31 and put settings into our py code. The result2 are:
-
The initial plot disappared from plot window but move to somewhere outside view. We need to zoom to find it
-
The flowup plot got errors as following:
self.plt.show(mypoints,zoom=1.3,axes=1, title= plot_type) ## axes= 1/7/11
File our_env\site-packages\vedo\plotter.py:3288 in show bns = self.renderer.ComputeVisiblePropBounds() AttributeError: 'NoneType' object has no attribute 'ComputeVisiblePropBounds'
We did further tests ,here are some information:
- comment out the mouse and keyboard call back settting (=False), the inital plotter remains at the central of window without errors
- remove the pipline settings cause plt.clear() errors as following:
File out_envs\lib\site-packages\vedo\plotter.py:3489 in clear self.get_meshes() File our_env\lib\site-packages\vedo\plotter.py:1211 in get_meshes at = self.renderers.index(renderer) ValueError: <vtkmodules.vtkRenderingOpenGL2.vtkOpenGLRenderer(0x000001DFF0442770) at 0x000001DFF7CCB460> is not in list
PS If we want to clean up older points' show before plotting new points, are there any better way than plt.clear()? It looks like the clear() causes item 2 above.
There are problems connecting to git. Just a quick question: where to put those settings?
发自我的荣耀手机
-------- 原始邮件 -------- 发件人: Marco Musy @.> 日期: 2024年1月30日周二 半夜11:03 收件人: marcomusy/vedo @.> 抄送: DRLing2021 @.>, Author @.> 主 题: Re: [marcomusy/vedo] Vedo Points becomes White or Transparent (Issue #1039)
PS: also add
settings.enable_default_mouse_callbacks = False settings.enable_default_keyboard_callbacks = False settings.enable_pipeline = False
― Reply to this email directly, view it on GitHubhttps://github.com/marcomusy/vedo/issues/1039#issuecomment-1917088230, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2XDDDVVCVUDGO5KB7FWWK3YREDVDAVCNFSM6AAAAABCQSMKQGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJXGA4DQMRTGA. You are receiving this because you authored the thread.Message ID: @.***>
Hi Marco, would you please advise what to do to deal with the new error messages?
File our_env\site-packages\vedo\plotter.py:3288 in show bns = self.renderer.ComputeVisiblePropBounds() AttributeError: 'NoneType' object has no attribute 'ComputeVisiblePropBounds'
Sorry, i was away, you put the senttings in your script on top E.g.:
import vedo
vedo.settings.enable_default_mouse_callbacks = False
vedo.settings.enable_default_keyboard_callbacks = False
to add and remove object do not use clear() rather give individual objects a name and add/remove them individualy:
def mycallback(event):
# in some callback:
obj1 = vedo.Points(...)
obj1.name = "mypoints"
# remove some other previous Points and add the new one:
plotter.remove("mypoints").add(obj1, obj2, ...)
# plotter.reset_camera() # if needed
plotter.render()
plotter = vedo.Plotter()
plotter.add_callback("key press", mycallback)
plotter.show(some objects, ....)
there are many examples showing this mechanism e.g.:
examples/basic/mousehighlight.py
examples/volumetric/slicer2.py
...
make sure you can reproduce those.
vedo --search remove
No problem Macro. We did what you suggested with some changes as the plots' show use different parms as following:
The first plot use no remove command as there is nothing yet but we give it a name self.Show_PC = Points(self.xyz,c="green") ### actors of points self.Show_PC.name = "last" ## self.Show_PC.render_points_as_spheres(False) print("Points Gened") self.Show_PC.cmap('viridis', Z) self.plt.show(self.Show_PC,zoom=1.3,axes=1, title= plot_type)
The following re-plots with new data we use the following codes: self.Show_PC = Points(self.xyz,c="green") ### actors of points self.Show_PC.name = "last" ## self.Show_PC.render_points_as_spheres(False) print("Tiered Gened") self.Show_PC.cmap('viridis', Z) #,name="mydata")
self.plt.remove("last") ##.add(self.Show_PC) we use show below but not
self.plt.show(self.Show_PC,zoom=2.35axes=1, title= plot_type)
Unfortunately we got following errors:
self.plt.remove("last") ##.add(self.Show_PC)
File our_env\lib\site-packages\vedo\plotter.py:995 in remove for a in self.get_actors(include_non_pickables=True): File our_env\lib\site-packages\vedo\plotter.py:1287 in get_actors at = self.renderers.index(renderer) ValueError: None is not in list
No problem Macro. We did what you suggested with some changes as the plots' show use different parms as following:
The first plot use no remove command as there is nothing yet but we give it a name self.Show_PC = Points(self.xyz,c="green") ### actors of points self.Show_PC.name = "last" ## self.Show_PC.render_points_as_spheres(False) print("Points Gened") self.Show_PC.cmap('viridis', Z) self.plt.show(self.Show_PC,zoom=1.3,axes=1, title= plot_type)
The following re-plots with new data we use the following codes: self.Show_PC = Points(self.xyz,c="green") ### actors of points self.Show_PC.name = "last" ## self.Show_PC.render_points_as_spheres(False) print("Tiered Gened") self.Show_PC.cmap('viridis', Z) #,name="mydata")
self.plt.remove("last") ##.add(self.Show_PC) we use show below but not
self.plt.show(self.Show_PC,zoom=2.35axes=1, title= plot_type)
Unfortunately we got following errors:
self.plt.remove("last") ##.add(self.Show_PC)
File our_env\lib\site-packages\vedo\plotter.py:995 in remove for a in self.get_actors(include_non_pickables=True): File our_env\lib\site-packages\vedo\plotter.py:1287 in get_actors at = self.renderers.index(renderer) ValueError: None is not in list
Hi Macro,
We‘ve tried serval ways but the "remove " seems never work. Basically what we do are as: Step1: Plot the raw data
self.Show_PC = Points(self.xyz,c="green") <=== convert numpy to Points
self.Show_PC.name = "last" <=== give Points a name "last"
self.Show_PC.render_points_as_spheres(False) <=== To fix the White/Transparent issue
self.Show_PC.cmap('viridis', Z) <=== assign a cmap
self.plt.add(self.Show_PC) <=== add "last " to Plotter
self.plt.show(zoom=1.3,axes=1, title= plot_type) <=== render with parms (this is different from what you
said and from samples )
Step2: Processed the raw data and get new data Setp2: Plot the new data
self.Show_PC = Points(self.xyz,c="green") <=== assign new data to Points
self.Show_PC.name = "last" <=== give a name, same as before, to new Points
self.Show_PC.render_points_as_spheres(False) <=== To fix the White/Transparent issue
self.Show_PC.cmap('viridis', Z) <=== assign a cmap
self.plt.remove("last").add(self.Show_PC) <=== this is where ERROR reported
self.plt.show(zoom=1.3,axes=1, title= plot_type) ## axes= 1/7/11
The error msg are:
File our_env\lib\site-packages\vedo\plotter.py:995 in remove
for a in self.get_actors(include_non_pickables=True):
File our_env\lib\site-packages\vedo\plotter.py:1287 in get_actors
at = self.renderers.index(renderer)
ValueError: None is not in list
Would you mind to advice what to do to fix it? Do we do it in a right way or are there something missing here to make it run? We need to fix it to move the work ahead. Your help is highly appreciated.
The definition of self.plt in our code is
self.vtkWidget = QVTKRenderWindowInteractor(self.Plot_Frame_3d)
self.plt = Plotter(qt_widget=self.vtkWidget,axes=1)
This is different from the sample codes we got from vedo --search xxxx. It this reason why we encountered those errors?
Hi Macro, we did further investigation and got the latest results as following:
- Vedo sample code, examples/volumetric/slicer2.py, runs well with the desired result
-
Our Vedo scrip still stuck with the errors:
File our_env\lib\site-packages\vedo\plotter.py:995 in remove for a in self.get_actors(include_non_pickables=True):
File our_env\lib\site-packages\vedo\plotter.py:1287 in get_actors at = self.renderers.index(renderer)
ValueError: None is not in list
Our running enviroment: VTK: 9.26. Qt interrface: PySide2 <===== suspect this is the error causer? We checked the Plotter code line 995 and later. It seems that the renderer is not picked correctly when running our working code. But it is ok for the slicer2.py sample code. One major difference between the codes is that ours runs in a qt framework through pyside2 interface. self.Plot_Frame_3d = QFrame(self.centralwidget) ... self.vtkWidget = QVTKRenderWindowInteractor(self.Plot_Frame_3d) self.plt = Plotter(qt_widget=self.vtkWidget,axes=1)
- We suspect the error relates to pysideX version. After checking Vedo Github we found that in vtkmodules_9.2.6_hierarchy.txt there is no pyside* information rather in vtkmodules_9.3.0_hierarchy.txt there is one place says: vtkmodules.qt.QVTKRenderWindowInteractor.PySide6 Does it mean that we should upgrade to pyside6 and vtk 9.3.0? Since upgrade from pyside2 to pyside6 needs lots script changes we haven't done this step yet.
Would you mind to kindely help us to move it forward as our work has been suspended for days waiting to see the visual result to descide the next step. Thanks in advance.! @marcomusy
Hi Marcro, Just want to let you know that after various experiments, we figured out that if Show() is BEFORE add(), things are ok. This is weired. But add/remove issues is fixed !
Hi @DRLing2021 sorry for the delay - i'm happy that you managed to fix the problem, just to confirm that the general structure is
def somecallback():
# here you call add(), remove(), render()
# or plt += some_object
# but NOT show()
# in your main script you define the Plotter and call show() only once, which does a number of inittializations
plt = Plotter()
plt += Sphere()
...
plt.add_callback("key press", somecallback)
plt.show()
Obviously you can have plt as a member of a class, but the general idea is the same.
Please look at some examples, especially the ones in examples/other/qt_*.py
Hi Marco, thanks for you coments. Sorry for late update as I have been on leave last weeks. The code we run on experimental env is different from what suggested above in that the plotter.show() has to be BEFORE add(). The sample code is as following:
The questions regarding above codes are :
- Are there anything wrong, or double wrong, in the codes that cause the show() has to be BEFORE add()?
- The code is suppose to increase the Z value scale after each button press. it results in the points zoom out of view. Is there anyway to set "autoscale" so that all points fit into the show window?
PS we use pyside2 that is different from the sample examples/other/qt_*.py, We guess it should not be a problem
Regards. DR, Ling