-
-
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 another variant to getPointCloudRenderingProperties()
#2142
Add another variant to getPointCloudRenderingProperties()
#2142
Conversation
418bbad
to
79f6553
Compare
Proposal:
|
Right now, this feature doesn't work (sorry)... The management of adding point cloud to the scene is a bit complicated. The VTK property I retrieve is not the right one. I'm working on it.
Which function/method does return a std::vector? In the idea, why not merging the existing overload :) |
I think the proposed method is consistent with the existing interface. There is a setter with three double parameters, and now there is a getter with three output parameters. What Sergio suggests might be a better approach in general and perhaps using vectors is how I would implement all property setters/getters if I had to start from scratch. But as it is now, will be incoherent and feel foreign in the existing API. |
79f6553
to
9d48cb3
Compare
<Quite long answer, sorry./> Things are clear now. The proposition done in this PR is correct: it works well 👍 DetailsThe interface to add point cloud with rendering properties is subtle. I custom point cloud color and there are two way to deal with that: pcl/visualization/include/pcl/visualization/impl/pcl_visualizer.hpp Lines 129 to 133 in 6d646d1
and pcl/visualization/src/pcl_visualizer.cpp Lines 1375 to 1377 in 6d646d1
I was in trouble because I used the first method with a chosen After a while, I released that these two methods are not equivalent. When one uses a pcl/visualization/include/pcl/visualization/impl/pcl_visualizer.hpp Lines 1353 to 1373 in 6d646d1
At L. 1354, the custom color is put in a vtkDataArray If I set the color with ConclusionAs there are different ways to specify a color and they are not handle/stored in the same way, to retrieve a point cloud color, currently it is only possible with the To be able to retrieve a color set with a virtual bool
getColor (double &r, double &g, double &b) const And this color handler should always be accessible through a field of CloudActor. |
But such a getter only makes sense for a subset of all color handlers, namely |
@taketwo I'm lucky, the virtual bool
getColor (vtkSmartPointer<vtkDataArray> &scalars) const = 0; So as Anyway in this approach, the specification maybe a difficulty but the fact that a color handler is not always stored in a CloudActor makes the implementation really complicated (sometime you will be able to retrieve the color, sometime not because the handler is not stored). To deal with it, the first step should be to always store the color handler in CloudActor. For me, this discussion is beyong the scope of this PR. |
|
@taketwo What do you advice for this PR? |
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 per Sergio's comment:
property
is actually of typeRenderingProperties
Besides from that, I'm fine with merging.
visualization/src/pcl_visualizer.cpp
Outdated
{ | ||
double rgb[3]; | ||
actor->GetProperty ()->GetColor (rgb); | ||
actor->Modified (); |
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.
Do we need this?
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.
No, I delete it.
The prototype is fixed. |
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.
How about adding a unit test to validate what you just added and improve our test coverage in 0.0001%? :)
* \param[out] val2 the resultant property value | ||
* \param[out] val3 the resultant property value | ||
* \param[in] id the point cloud object id (default: cloud) | ||
* \note The list of properties can be found in \ref pcl::visualization::LookUpTableRepresentationProperties. |
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.
Lacks the comment about the \return
value.
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.
Done.
visualization/src/pcl_visualizer.cpp
Outdated
@@ -1503,6 +1503,39 @@ pcl::visualization::PCLVisualizer::getPointCloudRenderingProperties (int propert | |||
} | |||
return (true); | |||
} | |||
///////////////////////////////////////////////////////////////////////////////////////////// | |||
bool | |||
pcl::visualization::PCLVisualizer::getPointCloudRenderingProperties (RenderingProperties property, double &val1, double &val2, double &val3, const std::string &id) |
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.
Split each argument to one line each. This line is excessively long.
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.
Done.
visualization/src/pcl_visualizer.cpp
Outdated
} | ||
default: | ||
{ | ||
pcl::console::print_error ("[getPointCloudRenderingProperties] Unknown property (%d) specified!\n", property); |
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.
This error message is misleading. PCL_VISUALIZER_LINE_WIDTH
is a known property but would trigger this error message anyway.
"Property (%d) is either unknown or it requires a different number of variables to retrieve its contents."
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.
Done.
Unit test is always painful for me as I didn't know how to handle them. I made a proposition in my last commit. To compile and execute the test, I use the following command line: rm -rf ./* && cmake -DPCL_ONLY_CORE_POINT_TYPES=ON -DPCL_NO_PRECOMPILE=ON -DBUILD_tools=OFF -DBUILD_examples=OFF -DBUILD_apps=OFF -DBUILD_2d=OFF -DBUILD_filters=OFF -DBUILD_outofcore=OFF -DBUILD_people=OFF -DBUILD_recognition=OFF -DBUILD_registration=OFF -DBUILD_sample_consensus=OFF -DBUILD_ml=OFF -DBUILD_stereo=OFF -DBUILD_surface=OFF -DBUILD_geometry=ON -DBUILD_io=ON -DBUILD_kdtree=ON -DBUILD_octree=ON -DBUILD_search=ON -DBUILD_features=ON -DBUILD_visualization=ON -DBUILD_global_tests=ON -DBUILD_tests_common=OFF -DBUILD_tests_geometry=OFF -DBUILD_tests_io=OFF -DBUILD_tests_kdtree=OFF -DBUILD_tests_octree=OFF -DBUILD_tests_search=OFF -DBUILD_tests_surface=OFF -DBUILD_tests_segmentation=OFF -DBUILD_tests_features=OFF -DBUILD_tests_filters=OFF -DBUILD_tests_keypoints=OFF -DBUILD_tests_people=OFF -DBUILD_tests_outofcore=OFF -DBUILD_tests_recognition=OFF -DBUILD_tests_registration=OFF -DBUILD_tests_segmentation=OFF -DBUILD_tests_sample_consensus=OFF -DBUILD_tests_visualization=ON -DGTEST_INCLUDE_DIR=/home/frozar/soft/googletest/googletest/include -DGTEST_SRC_DIR=/home/frozar/soft/googletest/googletest -DCMAKE_BUILD_TYPE=Debug .. && make -j8 && ./test/visualization/test_visualization ../test/bunny.pcd Compare to the last unit tests added by @SergioRAgostinho (about octree), the |
CI IssueThere is something I don't understand with the continous integration test TASK="test-ext-1". This test should launch the visualization test, but when I check the execution on the last commit, I don't see the status of the For this test, I check the CMake configuration, compilation and execution on my laptop, and the "test_visualization" is effectively executed. I check a previous Travis build and "test_visualization" was also missing. It seems that the TASK="test-ext-1" never launch the "test_visualization". Does someone have an idea why? |
I can't look into right now but if you want some pointers check the differences between the cmake files for the other test/modules and the test/visualization one. |
Visualization tests are disabled when running in headless mode (i.e. without display), which is the case on Travis: pcl/test/visualization/CMakeLists.txt Line 12 in b0e83f2
|
@taketwo Well seen! So what should I do for this PR? |
From my side, we can merge. |
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.
Thanks for the trouble of writing the test :)
//////////////////////////////////////////////////////////////////////////////// | ||
TEST (PCL, PCLVisualizer_getPointCloudRenderingProperties) | ||
{ | ||
PCLVisualizer::Ptr visualizer (new PCLVisualizer); |
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.
This doesn't need to be a shared pointer.
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.
Ok, done.
std::string cloud_id = "input_cloud"; | ||
visualizer->addPointCloud (cloud, cloud_id); | ||
ASSERT_TRUE (visualizer->setPointCloudRenderingProperties (PCL_VISUALIZER_COLOR, | ||
1.d, 0.d, 0.d, cloud_id)); |
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'm so surprised these .d suffixes work. I couldn't find them on cppreference. I just hope it's supported by all the compilers.
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'm surprised that you are surprised, I used to see them (maybe it's a Fortran deformatin...). Bah, anyway, it is said that C++ assume an expression like '1.0' as a double (check this section).
So I delete this suffixes.
getPointCloudRenderingProperties()
In this PR, I proposed another method
getPointCloudRenderingProperties()
to handle the color property. The prototype is different, that's why I had to add a new method: typically to retrieve r, g, b properties.And in fact, this method handle only the COLOR property.