-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new constructors to PCLVisualizer #2004
Add new constructors to PCLVisualizer #2004
Conversation
New constructors allow to provide custom renderers and render windows
fixes #1989 Oh, I have found that there is the code repeat. I will fix it tomorrow. |
Could you please elaborate why you first used raw pointers and then switched to smart pointers? I'd like to understand the implications of both options. |
I moved to smart pointers, because the visualizer stores smart pointers (consistency) and it is safer (if we use this renderer somewhere else, and decide to delete visualizer, the renderer will not be deleted). |
As far as I can tell, this is not entirely correct. The In general, the memory management in VTK is a bit of a mystery for me with all their "self-owning" pointers and reference counters inside objects. I'll just assume that you have tested your proposed changes (including destroying widget and visualizer in different order) and it does not crash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good. Since you are already doing a bit of refactoring, maybe try to minimize code repeat between these two different versions of construct()
function?
Also, please fix the code to match PCL style guide. Specifically, we need spaces between function names and brackets.
visualization/src/pcl_visualizer.cpp
Outdated
if (create_interactor) | ||
createInteractor(); | ||
|
||
win_->SetWindowName(name.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already done in line 339?
I have dug into vtk library and have found that it is save to convert smart pointers to raw ones. When the object is deleted, the special function handles if the reference count is not bigger than 1 nad deletes the object only if it is true. |
Also, I would like to continue refactoring pcl visualizer, but it will be other pull requests. |
visualization/src/pcl_visualizer.cpp
Outdated
// Set the window size as 1/2 of the screen size or the user given parameter | ||
if (!camera_set_ && !camera_file_loaded_) | ||
{ | ||
win_->SetSize (scr_size_x / 2, scr_size_y / 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I miss something, but why do we need this conditional resizing/repositioning? Resizing already happened in the other construct()
function.
I decided to add one more argument to 'small' construct function - resize_window. Another solution without additional argument would be to move window resizing to constructor (without camera loading), but I think that it would be inconsistent (we call only construct functions in all constructors) and harder to understand. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that adding resize_window
argument to one of the construct()
overloads is a good idea. Note that the code that actually resizes the window in duplicated in both versions of the function nevertheless. I take this as a strong indication that the granularity that we chose for splitting construction work into functions is wrong.
What do you think about the following: split construct()
into smaller functions, an call (some of) them as needed in each class constructor?
visualization/src/pcl_visualizer.cpp
Outdated
if (resize_window) | ||
{ | ||
int scr_size_x = win_->GetScreenSize ()[0], | ||
scr_size_y = win_->GetScreenSize ()[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please only declare one name per line.
Seems like the changes to the header file haven't been committed. |
Yeah, I missed to commit that header file. It would be nice, if we could achieve merging of this pull request until tomorrow) |
The build failed due to too long build of stage, other parts are ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder: squash on merge.
Some more questions - will it be merged to master or it will be waiting for pcl 1.9.0? And do I have to do anything? I am a bit newbie :) |
From my side it's ready to be merged in master. But for nontrivial PRs we typically wait for a "yes" from a second maintainer. I think @SergioRAgostinho will be back from his vacations very soon, will give it a quick look, and merge. |
* \param[in] argc | ||
* \param[in] argv | ||
*/ | ||
void setupCamera (int &argc, char **argv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment: I know this PR is only refactoring, but this signature is completely cryptic for me. Do you have any idea which format one passes to these camera parameters? Is there any way we can add some documentation to improve it this an the other signatures which pass these? From our current docs there's nothing on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, we pass the program arguments, which may contain -cam ".cam". It is good idea to add the documentation for it. I will do it, but in the another merge request. We are using my change in our project at the moment, and it will be nice to use pcl master repo instead of my fork.
hey @denix56 great work! I was just trying to make pcl visualizer work with QVTKOpenGLWidget and found this. I compiled from master today (not in debug mode :( ) and was just trying to use this new constructor but it crashes when doing the Is this how it's supposed to be used? Do you see anything wrong?
|
Could you please provide the system info the you use? I have tested the code that you gave on Ubuntu 16.04 and it worked fine for me. |
pcl built from master yesterday and VTK 8.0.1 built with OpenGL2 and Module_vtkRenderingExternal, Qt 5.9.2, in macOS 10.13 |
I will try to run the same code on Windows today.
You could also try to update to latest vtk master (8.1) or replace vtkNew
with vtkSmartPointer.
Maybe in debug mode it produces some kind of error?
13 окт. 2017 г. 13:43 пользователь "Nicolas Ulrich" <
[email protected]> написал:
… pcl built from master yesterday and VTK 8.0.1 built with OpenGL2 and
Module_vtkRenderingExternal, Qt 5.9.2, in macOS 10.13
Maybe I missed something when building pcl. I was using VTK7 and
QVTKWidget previously and now I'm trying to update to VTK 8
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2004 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AOdatX5VUE_N_AMqRm5prwlaI0i26IPbks5sr0zQgaJpZM4PhFAt>
.
|
Tested the code on Windows. I worked on it too. The problem might be caused if you use in your build pcl or vtk in release and qt in debug. As for me, in such combination it crashes. |
@nikolaseu If this is still a problem, please create a new issue with all the infos so that we can track it. |
I compiled vtk from master (8.1?) and it's working! thanks |
I'm looking for this resource. Can I get it from master or need to wait for pcl 1.9.0? |
You can get it from master. |
Thank you, Sergio! VideoQVTKOpenGLWidget.h
VideoQVTKOpenGLWidget.cpp
|
Better post it to the mailing list. The users don't come that often here because it's just a bug tracker. I'm sure you're gonna make some them very happy because I think QVtk is a recurrent topic. |
Add new constructors to PCLVisualizer New constructors allow to provide custom renderers and render windows.
I have been trying to use this constructor alongside with VTK trunk to create a pcl widget for Qt and I get segmentation faults if I set the I am running Ubuntu 18.04 using this commit for VTK and this commit for PCL. The two used libraries (VTK and PCL) are not installed, i link against this version instead of the installed one by setting the falgs You can find an example code here. |
@apalomer Let's move this to a new issue. |
Done: #2413 |
New constructors allow to provide custom renderers and render windows. It gives the ability to use QVTKOpenGLWidget and lots of vtk render windows.