Home › Forum › SofaPython3 › Using SofaPython3 › Visual not updated using python
Tagged: 64_bits, Linux_ubuntu, SOFA_2012
- This topic has 10 replies, 6 voices, and was last updated 3 years, 7 months ago by Bruno Marques.
-
AuthorPosts
-
17 February 2021 at 14:43 #18701AndreaBlocked
Hello team,
When I run
runSofa my_python_scene.py
everything seems to work correctly. However, when I run
python3 my_python_scene.py
my visual is not correctly updated.
I am working with the v20.12 release (both for SOFA and SP3) and I am using some OpenCV functions (from the OpencvPlugin) that add some visual markers with a mouse click event. The markers are correctly initialized (both when using runSofa or python3) but are not visible when using python3.
Any reason why this happens??
Thanks!
Andrea
18 February 2021 at 10:44 #18718jnbrunetModeratorHey Andrea,
Are you sure you are using the same GUI (qt vs qglviewer) for both python and runSofa?
Can you show us the part of your code that creates the root node, initializes it and starts the GUI?
18 February 2021 at 11:45 #18720AndreaBlockedHey JN,
I also thought the problem might come from the GUI, but I use qglviewer for both python and runSofa.
When running my scene with python, this is the code that creates the root node and the GUI:
root = Sofa.Core.Node() createScene(root) Sofa.Simulation.init(root) Sofa.Gui.GUIManager.Init("Acquire and register", "qglviewer") Sofa.Gui.GUIManager.createGUI(root, file) Sofa.Gui.GUIManager.SetDimension(640, 480) Sofa.Gui.GUIManager.MainLoop(root)
Thanks,
Andrea18 February 2021 at 14:36 #18722jnbrunetModeratorHey Andrea,
Does it render something or is it just black? Like, can you see forcefields and OglModels being drawn?
Does it help if you add
Sofa.Simulation.initVisual(root)
afterSofa.Simulation.init(root)
?J-N
18 February 2021 at 15:15 #18723AndreaBlockedHey JN,
My scene is a priori rendered correctly. I see my forcefields and ogl models, and also the images acquired by a realsense camera (plugged to my computer).
The issue comes when using the component OpenCVProjectivePointSelector from the OpencvPlugin. In particular when I select markers on the current image with a mouse click, these markers are displayed as red points when using runSofa (which is the expected behavior), but are invisible when using python (and yet they are correctly initialized).Not sure if it is relate, but adding
Sofa.Simulation.initVisual(root)
results in a segfault with the following error:-> /home/andrea/projects/sofa/build/install/lib/libSofaHelper.so.20.12.00(sofa::helper::BackTrace::dump()+0x27) [0x7fe673a69977] -> /home/andrea/projects/sofa/build/install/lib/libSofaHelper.so.20.12.00(sofa::helper::BackTrace::sig(int)+0x1d6) [0x7fe673a69d16] -> /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7fe677c54210] Segmentation fault (core dumped)
Hope this helps.
Andrea
19 February 2021 at 08:36 #18725jnbrunetModeratorHum, I’m not sure what’s going on here. If forcefields and OglModels are rendering, to me this means that everything is fine on the visual pipeline.
Can you try to debug your component to make sure it succeed to get to the rendering calls? For example, you could put a quick debug message inside the
draw()
method of the component just before callingvparams->drawTool()->drawXXX()
. Does it get there? Or does it get stopped by someif(...)
before calling the drawTool?19 February 2021 at 10:28 #18726AndreaBlockedHey JN,
It gets without problem to the draw() method.
vparams->drawTool()->drawSphere(point, 0.0038)
is effectively called. And the vectorpoint
is correctly updated.Andrea
1 March 2021 at 09:08 #18773FroyKeymasterHello @amendiza,
First thing first, your problem seems to be located while using the so-called “OpenCVPlugin” which seems to be a private plugin of yours.
In such cases, it is hard for us to provide appropriate support.From what I know, it seems the
draw()
in OpenCVProjectivePointSelector is conditioned with
if (f_listening.getValue() && d_draw.getValue())
Did these two Data are true while executing with Python3 ?As stated, this plugin is purely private to your team and not really useful for the whole SOFA community so it may be more appropriate to ask those questions in an other medium. (your team’s gitlab for example?)
1 March 2021 at 14:05 #18780bttBlockedDear @amendiza,
I am very interested in your team’s plugins (SOFACV and imageprocessing). So far, I have successfully compiled Sofacv with SOFA but it is not the case for Imageprocessing plugin. It seems due to the fact that this plugin is no longer compatible with current sofa versions (I suppose). I have tried with v19, v20.06, v20.12 and master branch but not quite successful. I just wonder your team would have a plan to update such plugin (and also sofacv) to be more compatible with SOFA? It would be great if there are such things and I would love to play with them soon. Thank you for your wonderful works anyway and looking forward to your reply soon
best,17 March 2021 at 19:17 #18869HugoKeymasterHey @newbie
I think @amendiza is using a private plugin named OpenCVPlugin while you are using the SofaCV plugin which is open. I am personnaly in favor of using as much as possible the open-source versions.
If I remember properly from this post you successfully compiled it, right?
Problem solved @amendiza ?
Best
Hugo
6 April 2021 at 08:33 #19071Bruno MarquesBlockedHi and sorry for the late reply @btt,
As far as I know SofaCV and ImageProcessing aren’t being used in the Mimesis team, which has a different plugin named OpenCVPlugin for these kinds of tasks.
The SofaCV plugin doesn’t have a huge community of users as of today and I was the main developer working on it. I’ve updated the codebase so that it compiles against the master branch of SOFA, and OpenCV 4.2, with the plugin’s default build options.
If you want extra features, such as the opencv_contrib bindings available through the plugin, you’ll have to do the extra work of fixing the compile issues, although with the basic version compiling, looking at the diff should give you clues on how to fix most issues related to SOFA’s & OpenCV’s evolutions:https://github.com/mimesis-inria/SofaCV/pull/4
https://github.com/mimesis-inria/ImageProcessing/pull/2If you have questions, I’ll try to answer the best I can, although my answers might arrive quite late, as I’m not working on this project anymore.
Best of luck!
– Bruno -
AuthorPosts
- You must be logged in to reply to this topic.