Loading...
Searching...
No Matches
sparse_quantized_multi_mod_template.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2011, Willow Garage, Inc.
*
* 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 Willow Garage, Inc. 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.
*
*/
#pragma once
#include <vector>
#include <pcl/recognition/region_xy.h>
namespace pcl
{
/** \brief Feature that defines a position and quantized value in a specific modality.
* \author Stefan Holzer
*/
struct QuantizedMultiModFeature
{
/** \brief Constructor. */
QuantizedMultiModFeature () = default;
/** \brief x-position. */
int x{0};
/** \brief y-position. */
int y{0};
/** \brief the index of the corresponding modality. */
std::size_t modality_index{0u};
/** \brief the quantized value attached to the feature. */
unsigned char quantized_value{0u};
/** \brief Compares whether two features are the same.
* \param[in] base the feature to compare to.
*/
bool
compareForEquality (const QuantizedMultiModFeature & base) const
{
if (base.x != x)
return false;
if (base.y != y)
return false;
if (base.modality_index != modality_index)
return false;
if (base.quantized_value != quantized_value)
return false;
return true;
}
/** \brief Serializes the object to the specified stream.
* \param[out] stream the stream the object will be serialized to. */
void
serialize (std::ostream & stream) const
{
write (stream, x);
write (stream, y);
write (stream, modality_index);
write (stream, quantized_value);
}
/** \brief Deserializes the object from the specified stream.
* \param[in] stream the stream the object will be deserialized from. */
void
deserialize (std::istream & stream)
{
read (stream, x);
read (stream, y);
read (stream, modality_index);
read (stream, quantized_value);
}
};
/** \brief A multi-modality template constructed from a set of quantized multi-modality features.
* \author Stefan Holzer
*/
struct SparseQuantizedMultiModTemplate
{
/** \brief Constructor. */
SparseQuantizedMultiModTemplate () = default;
/** \brief The storage for the multi-modality features. */
std::vector<QuantizedMultiModFeature> features;
/** \brief The region assigned to the template. */
RegionXY region;
/** \brief Serializes the object to the specified stream.
* \param[out] stream the stream the object will be serialized to. */
void
serialize (std::ostream & stream) const
{
const int num_of_features = static_cast<int> (features.size ());
write (stream, num_of_features);
for (int feature_index = 0; feature_index < num_of_features; ++feature_index)
{
features[feature_index].serialize (stream);
}
region.serialize (stream);
}
/** \brief Deserializes the object from the specified stream.
* \param[in] stream the stream the object will be deserialized from. */
void
deserialize (std::istream & stream)
{
features.clear ();
int num_of_features;
read (stream, num_of_features);
features.resize (num_of_features);
for (int feature_index = 0; feature_index < num_of_features; ++feature_index)
{
features[feature_index].deserialize (stream);
}
region.deserialize (stream);
}
};
}
pcl
Definition convolution.h:46
pcl::read
void read(std::istream &stream, Type &value)
Function for reading data from a stream.
Definition region_xy.h:46
pcl::write
void write(std::ostream &stream, Type value)
Function for writing data to a stream.
Definition region_xy.h:63
pcl::QuantizedMultiModFeature::deserialize
void deserialize(std::istream &stream)
Deserializes the object from the specified stream.
Definition sparse_quantized_multi_mod_template.h:96
pcl::QuantizedMultiModFeature::QuantizedMultiModFeature
QuantizedMultiModFeature()=default
Constructor.
pcl::QuantizedMultiModFeature::modality_index
std::size_t modality_index
the index of the corresponding modality.
Definition sparse_quantized_multi_mod_template.h:60
pcl::QuantizedMultiModFeature::x
int x
x-position.
Definition sparse_quantized_multi_mod_template.h:56
pcl::QuantizedMultiModFeature::serialize
void serialize(std::ostream &stream) const
Serializes the object to the specified stream.
Definition sparse_quantized_multi_mod_template.h:85
pcl::QuantizedMultiModFeature::quantized_value
unsigned char quantized_value
the quantized value attached to the feature.
Definition sparse_quantized_multi_mod_template.h:62
pcl::QuantizedMultiModFeature::y
int y
y-position.
Definition sparse_quantized_multi_mod_template.h:58
pcl::QuantizedMultiModFeature::compareForEquality
bool compareForEquality(const QuantizedMultiModFeature &base) const
Compares whether two features are the same.
Definition sparse_quantized_multi_mod_template.h:68
pcl::RegionXY
Defines a region in XY-space.
Definition region_xy.h:82
pcl::SparseQuantizedMultiModTemplate::region
RegionXY region
The region assigned to the template.
Definition sparse_quantized_multi_mod_template.h:117
pcl::SparseQuantizedMultiModTemplate::deserialize
void deserialize(std::istream &stream)
Deserializes the object from the specified stream.
Definition sparse_quantized_multi_mod_template.h:137
pcl::SparseQuantizedMultiModTemplate::serialize
void serialize(std::ostream &stream) const
Serializes the object to the specified stream.
Definition sparse_quantized_multi_mod_template.h:122
pcl::SparseQuantizedMultiModTemplate::SparseQuantizedMultiModTemplate
SparseQuantizedMultiModTemplate()=default
Constructor.
pcl::SparseQuantizedMultiModTemplate::features
std::vector< QuantizedMultiModFeature > features
The storage for the multi-modality features.
Definition sparse_quantized_multi_mod_template.h:114