-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Good descriptor #1907
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
base: master
Are you sure you want to change the base?
Good descriptor #1907
Changes from 5 commits
7a13173
9f53706
e659feb
af62d30
c36a2fd
4a87ae4
5ef505d
184a3ed
746943e
1178ce7
2ca0d1f
27f4888
cc98609
6196343
eb9bd5b
d12ce7a
5ab5708
6837a05
e7a5826
0368f7e
a2e75b6
1a68855
ab0e4dc
fc66de7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| /* | ||
| * Software License Agreement (BSD License) | ||
| * | ||
| * Point Cloud Library (PCL) - www.pointclouds.org | ||
| * Copyright (c) 2010-2012, Willow Garage, Inc. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless you developed this code back in 2010-2012 while working at Willow Garage, please remove this copyright.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| * | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following | ||
| * disclaimer in the documentation and/or other materials provided | ||
| * with the distribution. | ||
| * * Neither the name of the copyright holder(s) nor the names of its | ||
| * contributors may be used to endorse or promote products derived | ||
| * from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
| * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| * | ||
| * $Id$ | ||
| * | ||
| */ | ||
|
|
||
| /** \brief GOOD: a Global Orthographic Object Descriptor for 3D object recognition and manipulation. | ||
| * GOOD descriptor has been designed to be robust, descriptive and efficient to compute and use. | ||
| * It has two outstanding characteristics: | ||
| * | ||
| * (1) Providing a good trade-off among : | ||
| * - descriptiveness, | ||
| * - robustness, | ||
| * - computation time, | ||
| * - memory usage. | ||
| * | ||
| * (2) Allowing concurrent object recognition and pose estimation for manipulation. | ||
| * | ||
| * \note This is an implementation of the GOOD descriptor which has been presented in the following papers: | ||
| * | ||
| * [1] Kasaei, S. Hamidreza, Ana Maria Tomé, Luís Seabra Lopes, Miguel Oliveira | ||
| * "GOOD: A global orthographic object descriptor for 3D object recognition and manipulation." | ||
| * Pattern Recognition Letters 83 (2016): 312-320.http://dx.doi.org/10.1016/j.patrec.2016.07.006 | ||
| * | ||
| * [2] Kasaei, S. Hamidreza, Luís Seabra Lopes, Ana Maria Tomé, Miguel Oliveira | ||
| * "An orthographic descriptor for 3D object learning and recognition." | ||
| * 2016 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), Daejeon, 2016, | ||
| * pp. 4158-4163. doi: 10.1109/IROS.2016.7759612 | ||
| * | ||
| * Please adequately refer to this work any time this code is being used by citing above papers. | ||
| * If you do publish a paper where GOOD descriptor helped your research, we encourage you to cite the above papers in your publications. | ||
| * | ||
| * \author Hamidreza Kasaei (Seyed.Hamidreza[at]ua[dot]pt) | ||
| */ | ||
|
|
||
| #include <pcl/features/good.h> | ||
| #include <pcl/io/pcd_io.h> | ||
| #include <pcl/io/ply_io.h> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you include |
||
| #include <boost/filesystem.hpp> | ||
|
|
||
| typedef pcl::PointXYZRGBA PointT; | ||
| using namespace pcl; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please refrain from using
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
|
||
| int | ||
| readPointCloud(std::string object_path, boost::shared_ptr<pcl::PointCloud<PointT> > point_cloud) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding spacing of the parenthesis in functions have a look at http://www.pointclouds.org/documentation/advanced/pcl_style_guide.php#spacing This would lead to readPointCloud (std::string object_path, boost::shared_ptr<pcl::PointCloud<PointT>> point_cloud)This comment is applicable to the remaining functions, methods and template instantiations of this PR. |
||
| { | ||
| std::string extension = boost::filesystem::extension(object_path); | ||
| if (extension == ".pcd" || extension == ".PCD") | ||
| { | ||
| if (pcl::io::loadPCDFile(object_path.c_str() , *point_cloud) == -1) | ||
| { | ||
| std::cout << "Cloud reading failed." << std::endl; | ||
| return (-1); | ||
| } | ||
| } | ||
| else if (extension == ".ply" || extension == ".PLY") | ||
| { | ||
| if (pcl::io::loadPLYFile(object_path , *point_cloud) == -1) | ||
| { | ||
| std::cout << "Cloud reading failed." << std::endl; | ||
| return (-1); | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider replacing both these blocks for |
||
| else | ||
| { | ||
| std::cout << "file extension is not correct. Syntax is: example_good_descriptor <path/file_name.pcd> or example_good_descriptor <path/file_name.ply>" << std::endl; | ||
| return -1; | ||
| } | ||
| return 1; | ||
| } | ||
|
|
||
| int main(int argc, char* argv[]) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spacing |
||
| { | ||
|
|
||
| if (argc < 2 ||argc > 2) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not simply
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| { | ||
| std::cout << "\n Syntax is: example_good_descriptor <path/file_name.pcd>" << std::endl; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use std::cerr instead |
||
| return 0; | ||
| } | ||
|
|
||
| std::string object_path = argv[1]; | ||
| pcl::PointCloud<PointT>::Ptr object (new pcl::PointCloud<PointT>); | ||
| if (readPointCloud( object_path, object)==-1) | ||
| return -1; | ||
|
|
||
| std::vector< float > object_description; | ||
| std::vector < boost::shared_ptr<pcl::PointCloud<PointT> > > vector_of_projected_views; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a required change. All these
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| boost::shared_ptr<pcl::PointCloud<PointT> > transformed_object (new pcl::PointCloud<PointT>); | ||
|
|
||
| Eigen::Matrix4f transformation; | ||
| pcl::PointXYZ center_of_bounding_box; | ||
| pcl::PointXYZ bounding_box_dimensions; | ||
| std::string order_of_projected_planes; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment to self: this smells, a string to indicate ordering... |
||
|
|
||
| // Setup the GOOD descriptor | ||
| // GOOD can also be setup in a line: GOODEstimation test_GOOD_descriptor (5, 0.0015); | ||
| GOODEstimation<PointT> test_GOOD_descriptor; | ||
| test_GOOD_descriptor.setNumberOfBins(5); | ||
| test_GOOD_descriptor.setThreshold(0.0015); | ||
|
|
||
| // Provide the original point cloud | ||
| test_GOOD_descriptor.setInputCloud(object); | ||
|
|
||
| // Compute GOOD discriptor for the given object | ||
| test_GOOD_descriptor.compute(object_description); | ||
| std::cout <<"\n GOOD = ["; | ||
| for (size_t i =0; i< object_description.size()-1; i ++) | ||
| std::cout << object_description.at(i)<<","; | ||
| std::cout << object_description.back() <<"]"<<std::endl; | ||
|
|
||
| /*_________________________________________ | ||
| | | | ||
| | Functionalities for Object Manipulation | | ||
| |__________________________________________| */ | ||
| // The following functinalities of GOOD are usefull for manipulation tasks: | ||
|
|
||
| // Get objec point cloud in local reference frame | ||
| test_GOOD_descriptor.getTransformedObject (transformed_object); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment to self: Why is a descriptor applying a transformation? Consider removing this method from the class. Check later on. |
||
|
|
||
| // Get three orthographic projects and transformation matrix | ||
| test_GOOD_descriptor.getOrthographicProjections (vector_of_projected_views); | ||
| test_GOOD_descriptor.getTransformationMatrix (transformation); | ||
| std::cout << "\n transofrmation matrix =\n"<<transformation << std::endl; | ||
|
|
||
| // Get object bounding box information | ||
| test_GOOD_descriptor.getCenterOfObjectBoundingBox (center_of_bounding_box); | ||
| test_GOOD_descriptor.getObjectBoundingBoxDimensions(bounding_box_dimensions); | ||
| std::cout<<"\n center_of_bounding_box = " << center_of_bounding_box<<std::endl; | ||
| std::cout<<"\n bounding_box_dimensions = " << bounding_box_dimensions <<std::endl; | ||
|
|
||
| // Get the order of the three projected planes | ||
| test_GOOD_descriptor.getOrderOfProjectedPlanes(order_of_projected_planes); | ||
| std::cout << "\n order of projected planes = "<<order_of_projected_planes << std::endl; | ||
|
|
||
| // Pass the following point cloud to a pcl::visualization::PCLVisualizer forVisualizing the | ||
| //transformed object, local reference fram and three orthographic projections | ||
|
|
||
| pcl::PointCloud<PointT>::Ptr transformed_object_and_projected_views (new pcl::PointCloud<PointT>); | ||
| *transformed_object_and_projected_views += *vector_of_projected_views.at(0); | ||
| *transformed_object_and_projected_views += *vector_of_projected_views.at(1); | ||
| *transformed_object_and_projected_views += *vector_of_projected_views.at(2); | ||
| *transformed_object_and_projected_views += *transformed_object; | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SeyedHamidreza will add visualization to the example at some point. |
||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| set(SUBSYS_NAME features) | ||
| set(SUBSYS_DESC "Point cloud features library") | ||
| set(SUBSYS_DEPS common search kdtree octree filters 2d) | ||
| set(SUBSYS_DEPS common sample_consensus search kdtree octree filters 2d) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment for myself:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SergioRAgostinho I hope this new dependency won't break your CI job distribution :)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filters also has it fortunately :phew: |
||
|
|
||
| set(build TRUE) | ||
| PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON) | ||
|
|
@@ -62,6 +62,8 @@ if(build) | |
| "include/pcl/${SUBSYS_NAME}/usc.h" | ||
| "include/pcl/${SUBSYS_NAME}/boundary.h" | ||
| "include/pcl/${SUBSYS_NAME}/range_image_border_extractor.h" | ||
| "include/pcl/${SUBSYS_NAME}/range_image_border_extractor.h" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate line
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate line is still here :x |
||
| "include/pcl/${SUBSYS_NAME}/good.h" | ||
| ) | ||
|
|
||
| set(impl_incs | ||
|
|
@@ -110,6 +112,7 @@ if(build) | |
| "include/pcl/${SUBSYS_NAME}/impl/usc.hpp" | ||
| "include/pcl/${SUBSYS_NAME}/impl/boundary.hpp" | ||
| "include/pcl/${SUBSYS_NAME}/impl/range_image_border_extractor.hpp" | ||
| "include/pcl/${SUBSYS_NAME}/impl/good.hpp" | ||
| ) | ||
|
|
||
| set(srcs | ||
|
|
@@ -150,6 +153,7 @@ if(build) | |
| src/3dsc.cpp | ||
| src/usc.cpp | ||
| src/range_image_border_extractor.cpp | ||
| src/good.cpp | ||
| ) | ||
|
|
||
| if(MSVC) | ||
|
|
||
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.
Replace this for Copyright (c) 2017-, Open Perception, Inc.