Skip to content
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

USC: fixed parameters / added descriptor-type #856

Merged
merged 1 commit into from
Sep 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/include/pcl/common/point_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace pcl
template<> inline bool isFinite<pcl::SHOT1344> (const pcl::SHOT1344&) { return (true); }
template<> inline bool isFinite<pcl::ReferenceFrame> (const pcl::ReferenceFrame&) { return (true); }
template<> inline bool isFinite<pcl::ShapeContext1980> (const pcl::ShapeContext1980&) { return (true); }
template<> inline bool isFinite<pcl::UniqueShapeContext1960> (const pcl::UniqueShapeContext1960&) { return (true); }
template<> inline bool isFinite<pcl::PFHSignature125> (const pcl::PFHSignature125&) { return (true); }
template<> inline bool isFinite<pcl::PFHRGBSignature250> (const pcl::PFHRGBSignature250&) { return (true); }
template<> inline bool isFinite<pcl::PPFSignature> (const pcl::PPFSignature&) { return (true); }
Expand Down
13 changes: 13 additions & 0 deletions common/include/pcl/impl/point_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
(pcl::PointWithScale) \
(pcl::PointSurfel) \
(pcl::ShapeContext1980) \
(pcl::UniqueShapeContext1960) \
(pcl::SHOT352) \
(pcl::SHOT1344) \
(pcl::PointUV) \
Expand Down Expand Up @@ -1201,6 +1202,18 @@ namespace pcl
friend std::ostream& operator << (std::ostream& os, const ShapeContext1980& p);
};

PCL_EXPORTS std::ostream& operator << (std::ostream& os, const UniqueShapeContext1960& p);
/** \brief A point structure representing a Unique Shape Context.
* \ingroup common
*/
struct UniqueShapeContext1960
{
float descriptor[1960];
float rf[9];
static int descriptorSize () { return 1960; }

friend std::ostream& operator << (std::ostream& os, const UniqueShapeContext1960& p);
};

PCL_EXPORTS std::ostream& operator << (std::ostream& os, const SHOT352& p);
/** \brief A point structure representing the generic Signature of Histograms of OrienTations (SHOT) - shape only.
Expand Down
18 changes: 18 additions & 0 deletions common/include/pcl/point_representation.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,24 @@ namespace pcl
}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <>
class DefaultPointRepresentation<UniqueShapeContext1960> : public PointRepresentation<UniqueShapeContext1960>
{
public:
DefaultPointRepresentation ()
{
nr_dimensions_ = 1960;
}

virtual void
copyToFloatArray (const UniqueShapeContext1960 &p, float * out) const
{
for (int i = 0; i < nr_dimensions_; ++i)
out[i] = p.descriptor[i];
}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <>
class DefaultPointRepresentation<SHOT352> : public PointRepresentation<SHOT352>
Expand Down
10 changes: 10 additions & 0 deletions common/include/pcl/point_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ namespace pcl
*/
struct ShapeContext1980;

/** \brief Members: float descriptor[1960], rf[9]
* \ingroup common
*/
struct UniqueShapeContext1960;

/** \brief Members: float pfh[125]
* \ingroup common
*/
Expand Down Expand Up @@ -565,6 +570,11 @@ POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::ShapeContext1980,
(float[9], rf, rf)
)

POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::UniqueShapeContext1960,
(float[1960], descriptor, shape_context)
(float[9], rf, rf)
)

POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::SHOT352,
(float[352], descriptor, shot)
(float[9], rf, rf)
Expand Down
10 changes: 10 additions & 0 deletions common/src/point_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,16 @@ namespace pcl
return (os);
}

std::ostream&
operator << (std::ostream& os, const UniqueShapeContext1960& p)
{
for (int i = 0; i < 9; ++i)
os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")");
for (size_t i = 0; i < 1960; ++i)
os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 1959 ? ", " : ")");
return (os);
}

std::ostream&
operator << (std::ostream& os, const SHOT352& p)
{
Expand Down
2 changes: 1 addition & 1 deletion features/include/pcl/features/impl/usc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ pcl::UniqueShapeContext<PointInT, PointOutT, PointRFT>::computePointDescriptor (
template <typename PointInT, typename PointOutT, typename PointRFT> void
pcl::UniqueShapeContext<PointInT, PointOutT, PointRFT>::computeFeature (PointCloudOut &output)
{
assert (descriptor_length_ == 1980);
assert (descriptor_length_ == 1960);

output.is_dense = true;

Expand Down
19 changes: 5 additions & 14 deletions features/include/pcl/features/usc.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ namespace pcl
* International Workshop on 3D Object Retrieval (3DOR 10) -
* in conjuction with ACM Multimedia 2010
*
* The suggested PointOutT is pcl::ShapeContext1980
* The suggested PointOutT is pcl::UniqueShapeContext1960
*
* \author Alessandro Franchi, Federico Tombari, Samuele Salti (original code)
* \author Nizar Sallem (port to PCL)
* \ingroup features
*/
template <typename PointInT, typename PointOutT = pcl::ShapeContext1980, typename PointRFT = pcl::ReferenceFrame>
template <typename PointInT, typename PointOutT = pcl::UniqueShapeContext1960, typename PointRFT = pcl::ReferenceFrame>
class UniqueShapeContext : public Feature<PointInT, PointOutT>,
public FeatureWithLocalReferenceFrames<PointInT, PointRFT>
{
Expand All @@ -85,32 +85,23 @@ namespace pcl
/** \brief Constructor. */
UniqueShapeContext () :
radii_interval_(0), theta_divisions_(0), phi_divisions_(0), volume_lut_(0),
azimuth_bins_(12), elevation_bins_(11), radius_bins_(15),
min_radius_(0.1), point_density_radius_(0.2), descriptor_length_ (), local_radius_ (2.5)
azimuth_bins_(14), elevation_bins_(14), radius_bins_(10),
min_radius_(0.1), point_density_radius_(0.1), descriptor_length_ (), local_radius_ (2.0)
{
feature_name_ = "UniqueShapeContext";
search_radius_ = 2.5;
search_radius_ = 2.0;
}

virtual ~UniqueShapeContext() { }

//inline void
//setAzimuthBins (size_t bins) { azimuth_bins_ = bins; }

/** \return The number of bins along the azimuth. */
inline size_t
getAzimuthBins () const { return (azimuth_bins_); }

//inline void
//setElevationBins (size_t bins) { elevation_bins_ = bins; }

/** \return The number of bins along the elevation */
inline size_t
getElevationBins () const { return (elevation_bins_); }

//inline void
//setRadiusBins (size_t bins) { radius_bins_ = bins; }

/** \return The number of bins along the radii direction. */
inline size_t
getRadiusBins () const { return (radius_bins_); }
Expand Down
4 changes: 2 additions & 2 deletions features/src/usc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
#include <pcl/impl/instantiate.hpp>
// Instantiations of specific point types
#ifdef PCL_ONLY_CORE_POINT_TYPES
PCL_INSTANTIATE_PRODUCT(UniqueShapeContext, ((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGBA))((pcl::ShapeContext1980))((pcl::ReferenceFrame)))
PCL_INSTANTIATE_PRODUCT(UniqueShapeContext, ((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGBA))((pcl::UniqueShapeContext1960))((pcl::ReferenceFrame)))
#else
PCL_INSTANTIATE_PRODUCT(UniqueShapeContext, (PCL_XYZ_POINT_TYPES)((pcl::ShapeContext1980))((pcl::ReferenceFrame)))
PCL_INSTANTIATE_PRODUCT(UniqueShapeContext, (PCL_XYZ_POINT_TYPES)((pcl::UniqueShapeContext1960))((pcl::ReferenceFrame)))
#endif
#endif // PCL_NO_PRECOMPILE

2 changes: 1 addition & 1 deletion test/features/test_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ TEST (PCL, FeaturePtr)
VFHEstimation<PointXYZ, PointNormal, VFHSignature308>::Ptr vfh (new VFHEstimation<PointXYZ, PointNormal, VFHSignature308> ());
vfh->setViewPoint (1.0f, 1.0f, 1.0f);

UniqueShapeContext<PointXYZ, ShapeContext1980, ReferenceFrame>::Ptr usc (new UniqueShapeContext<PointXYZ, ShapeContext1980, ReferenceFrame> ());
UniqueShapeContext<PointXYZ, UniqueShapeContext1960, ReferenceFrame>::Ptr usc (new UniqueShapeContext<PointXYZ, UniqueShapeContext1960, ReferenceFrame> ());
usc->setMinimalRadius (5);

StatisticalMultiscaleInterestRegionExtraction<PointXYZ>::Ptr smire (new StatisticalMultiscaleInterestRegionExtraction<PointXYZ> ());
Expand Down
47 changes: 24 additions & 23 deletions test/features/test_shot_estimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ checkDesc<ShapeContext1980>(const pcl::PointCloud<ShapeContext1980>& d0, const p
ASSERT_EQ (d0.points[i].descriptor[j], d1.points[i].descriptor[j]);
}

///////////////////////////////////////////////////////////////////////////////////
template <> void
checkDesc<UniqueShapeContext1960>(const pcl::PointCloud<UniqueShapeContext1960>& d0, const pcl::PointCloud<UniqueShapeContext1960>& d1)
{
ASSERT_EQ (d0.size (), d1.size ());
for (size_t i = 0; i < d1.size (); ++i)
for (size_t j = 0; j < 1960; ++j)
ASSERT_EQ (d0.points[i].descriptor[j], d1.points[i].descriptor[j]);
}

///////////////////////////////////////////////////////////////////////////////////
template <typename FeatureEstimation, typename PointT, typename NormalT, typename OutputT>
struct createSHOTDesc
Expand Down Expand Up @@ -187,9 +197,6 @@ struct createSHOTDesc<UniqueShapeContext<PointT, OutputT>, PointT, NormalT, Outp
const bool) const
{
UniqueShapeContext<PointT, OutputT> usc;
//usc.setAzimuthBins (4);
//usc.setElevationBins (4);
//usc.setRadiusBins (4);
usc.setMinimalRadius (0.004);
usc.setPointDensityRadius (0.008);
usc.setLocalRadius (0.04);
Expand Down Expand Up @@ -920,26 +927,20 @@ TEST (PCL,3DSCEstimation)
TEST (PCL, USCEstimation)
{
float meshRes = 0.002f;
//size_t nBinsL = 4;
//size_t nBinsK = 4;
//size_t nBinsJ = 4;
float radius = 20.0f * meshRes;
float rmin = radius / 10.0f;
float ptDensityRad = radius / 5.0f;

// estimate
UniqueShapeContext<PointXYZ, ShapeContext1980> uscd;
UniqueShapeContext<PointXYZ, UniqueShapeContext1960> uscd;
uscd.setInputCloud (cloud.makeShared ());
uscd.setSearchMethod (tree);
uscd.setRadiusSearch (radius);
//uscd.setAzimuthBins (nBinsL);
//uscd.setElevationBins (nBinsK);
//uscd.setRadiusBins (nBinsJ);
uscd.setMinimalRadius (rmin);
uscd.setPointDensityRadius (ptDensityRad);
uscd.setLocalRadius (radius);
// Compute the features
PointCloud<ShapeContext1980>::Ptr uscds (new PointCloud<ShapeContext1980>);
PointCloud<UniqueShapeContext1960>::Ptr uscds (new PointCloud<UniqueShapeContext1960>);
uscd.compute (*uscds);
EXPECT_EQ (uscds->size (), cloud.size ());

Expand All @@ -955,26 +956,26 @@ TEST (PCL, USCEstimation)

//EXPECT_EQ ((*uscds)[0].descriptor.size (), 64);

EXPECT_NEAR ((*uscds)[160].descriptor[56], 53.0597f, 1e-4f);
EXPECT_NEAR ((*uscds)[160].descriptor[734], 80.1063f, 1e-4f);
EXPECT_NEAR ((*uscds)[160].descriptor[1222], 93.8412f, 1e-4f);
EXPECT_NEAR ((*uscds)[160].descriptor[1605], 0.f, 1e-4f);
EXPECT_NEAR ((*uscds)[160].descriptor[1887], 32.6679f, 1e-4f);
EXPECT_NEAR ((*uscds)[160].descriptor[355], 123.0733f, 1e-4f);
EXPECT_NEAR ((*uscds)[160].descriptor[494], 154.9401f, 1e-4f);
EXPECT_NEAR ((*uscds)[160].descriptor[897], 0.f, 1e-4f);
EXPECT_NEAR ((*uscds)[160].descriptor[1178], 62.7496f, 1e-4f);
EXPECT_NEAR ((*uscds)[160].descriptor[1878], 31.3748f, 1e-4f);

EXPECT_NEAR ((*uscds)[168].descriptor[72], 65.3358f, 1e-4f);
EXPECT_NEAR ((*uscds)[168].descriptor[430], 88.8147f, 1e-4f);
EXPECT_NEAR ((*uscds)[168].descriptor[987], 0.f, 1e-4f);
EXPECT_NEAR ((*uscds)[168].descriptor[1563], 128.273f, 1e-4f);
EXPECT_NEAR ((*uscds)[168].descriptor[1915], 59.2098f, 1e-4f);
EXPECT_NEAR ((*uscds)[168].descriptor[57], 39.4986f, 1e-4f);
EXPECT_NEAR ((*uscds)[168].descriptor[704], 0.f, 1e-4f);
EXPECT_NEAR ((*uscds)[168].descriptor[906], 48.8803f, 1e-4f);
EXPECT_NEAR ((*uscds)[168].descriptor[1175], 83.4680f, 1e-4f);
EXPECT_NEAR ((*uscds)[168].descriptor[1756], 65.1737f, 1e-4f);

// Test results when setIndices and/or setSearchSurface are used
boost::shared_ptr<vector<int> > test_indices (new vector<int> (0));
for (size_t i = 0; i < cloud.size (); i+=3)
test_indices->push_back (static_cast<int> (i));

PointCloud<Normal>::Ptr normals (new PointCloud<Normal> ());
testSHOTIndicesAndSearchSurface<UniqueShapeContext<PointXYZ, ShapeContext1980>, PointXYZ, Normal, ShapeContext1980> (cloud.makeShared (), normals, test_indices);
testSHOTLocalReferenceFrame<UniqueShapeContext<PointXYZ, ShapeContext1980>, PointXYZ, Normal, ShapeContext1980> (cloud.makeShared (), normals, test_indices);
testSHOTIndicesAndSearchSurface<UniqueShapeContext<PointXYZ, UniqueShapeContext1960>, PointXYZ, Normal, UniqueShapeContext1960> (cloud.makeShared (), normals, test_indices);
testSHOTLocalReferenceFrame<UniqueShapeContext<PointXYZ, UniqueShapeContext1960>, PointXYZ, Normal, UniqueShapeContext1960> (cloud.makeShared (), normals, test_indices);
}

/* ---[ */
Expand Down