mirror of https://github.com/CGAL/cgal
Remove deprecated parts of Classification
This commit is contained in:
parent
7518d5642a
commit
bd2a66ffcd
|
|
@ -1,431 +0,0 @@
|
|||
// Copyright (c) 2017 GeometryFactory Sarl (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
// Author(s) : Simon Giraudot
|
||||
|
||||
#ifndef CGAL_CLASSIFICATION_FEATURES_EIGEN_H
|
||||
#define CGAL_CLASSIFICATION_FEATURES_EIGEN_H
|
||||
|
||||
#include <CGAL/license/Classification.h>
|
||||
|
||||
#include <vector>
|
||||
#include <CGAL/Classification/Feature_base.h>
|
||||
#include <CGAL/Classification/Local_eigen_analysis.h>
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace Classification {
|
||||
|
||||
namespace Feature {
|
||||
|
||||
class Eigen_feature : public Feature_base
|
||||
{
|
||||
protected:
|
||||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
std::vector<float> attrib;
|
||||
#else
|
||||
const Classification::Local_eigen_analysis& eigen;
|
||||
#endif
|
||||
|
||||
public:
|
||||
template <typename InputRange>
|
||||
Eigen_feature (const InputRange&,
|
||||
const Classification::Local_eigen_analysis& eigen)
|
||||
#ifndef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
: eigen (eigen)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
virtual void init (std::size_t size, const Classification::Local_eigen_analysis& eigen)
|
||||
{
|
||||
attrib.reserve (size);
|
||||
for (std::size_t i = 0; i < size; ++ i)
|
||||
attrib.push_back (get_value (eigen, i));
|
||||
}
|
||||
#else
|
||||
virtual void init (std::size_t, const Classification::Local_eigen_analysis&)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual float get_value (const Classification::Local_eigen_analysis& eigen, std::size_t i) = 0;
|
||||
virtual float value (std::size_t pt_index)
|
||||
{
|
||||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
return attrib[pt_index];
|
||||
#else
|
||||
return get_value(eigen, pt_index);
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
\ingroup PkgClassificationFeatures
|
||||
|
||||
%Feature based on the eigenvalues of the covariance matrix of a
|
||||
local neighborhood. Linearity is defined, for the 3 eigenvalues
|
||||
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
|
||||
|
||||
\f[
|
||||
\frac{\lambda_1 - \lambda_2}{\lambda_1}
|
||||
\f]
|
||||
|
||||
Its default name is "linearity".
|
||||
*/
|
||||
CGAL_DEPRECATED_MSG("you are using the deprecated feature Linearity, please update your code with Eigenvalue instead")
|
||||
class Linearity
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
||||
\tparam Input model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\param input point range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
template <typename InputRange>
|
||||
Linearity (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen) : Eigen_feature (input, eigen)
|
||||
{
|
||||
this->set_name("linearity");
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
{
|
||||
const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i);
|
||||
if (ev[2] < 1e-15)
|
||||
return 0.;
|
||||
else
|
||||
return ((ev[2] - ev[1]) / ev[2]);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\ingroup PkgClassificationFeatures
|
||||
|
||||
%Feature based on the eigenvalues of the covariance matrix of a
|
||||
local neighborhood. Planarity is defined, for the 3 eigenvalues
|
||||
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
|
||||
|
||||
\f[
|
||||
\frac{\lambda_2 - \lambda_3}{\lambda_1}
|
||||
\f]
|
||||
|
||||
Its default name is "planarity".
|
||||
*/
|
||||
CGAL_DEPRECATED_MSG("you are using the deprecated feature Planarity, please update your code with Eigenvalue instead")
|
||||
class Planarity
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
||||
\param input point range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
template <typename InputRange>
|
||||
Planarity (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("planarity");
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
{
|
||||
const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i);
|
||||
if (ev[2] < 1e-15)
|
||||
return 0.;
|
||||
else
|
||||
return ((ev[1] - ev[0]) / ev[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
\ingroup PkgClassificationFeatures
|
||||
|
||||
%Feature based on the eigenvalues of the covariance matrix of a
|
||||
local neighborhood. Sphericity is defined, for the 3 eigenvalues
|
||||
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
|
||||
|
||||
\f[
|
||||
\frac{\lambda_3}{\lambda_1}
|
||||
\f]
|
||||
|
||||
Its default name is "sphericity".
|
||||
*/
|
||||
CGAL_DEPRECATED_MSG("you are using the deprecated feature Sphericity, please update your code with Eigenvalue instead")
|
||||
class Sphericity
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
||||
\param input point range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
template <typename InputRange>
|
||||
Sphericity (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("sphericity");
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
{
|
||||
const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i);
|
||||
if (ev[2] < 1e-15)
|
||||
return 0.;
|
||||
else
|
||||
return (ev[0] / ev[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
\ingroup PkgClassificationFeatures
|
||||
|
||||
%Feature based on the eigenvalues of the covariance matrix of a
|
||||
local neighborhood. Omnivariance is defined, for the 3 eigenvalues
|
||||
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
|
||||
|
||||
\f[
|
||||
(\lambda_1 \times \lambda_2 \times \lambda_3)^{\frac{1}{3}}
|
||||
\f]
|
||||
|
||||
Its default name is "omnivariance".
|
||||
*/
|
||||
CGAL_DEPRECATED_MSG("you are using the deprecated feature Omnivariance, please update your code with Eigenvalue instead")
|
||||
class Omnivariance
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
||||
\param input point range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
template <typename InputRange>
|
||||
Omnivariance (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("omnivariance");
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
{
|
||||
const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i);
|
||||
return (std::pow (CGAL::abs(ev[0] * ev[1] * ev[2]), 0.333333333f));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
\ingroup PkgClassificationFeatures
|
||||
|
||||
%Feature based on the eigenvalues of the covariance matrix of a
|
||||
local neighborhood. Anisotropy is defined, for the 3 eigenvalues
|
||||
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
|
||||
|
||||
\f[
|
||||
\frac{\lambda_1 - \lambda_3}{\lambda_1}
|
||||
\f]
|
||||
|
||||
Its default name is "anisotropy".
|
||||
*/
|
||||
CGAL_DEPRECATED_MSG("you are using the deprecated feature Anisotropy, please update your code with Eigenvalue instead")
|
||||
class Anisotropy
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
||||
\param input point range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
template <typename InputRange>
|
||||
Anisotropy (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("anisotropy");
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
{
|
||||
const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i);
|
||||
if (ev[2] < 1e-15)
|
||||
return 0.;
|
||||
else
|
||||
return ((ev[2] - ev[0]) / ev[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
\ingroup PkgClassificationFeatures
|
||||
|
||||
%Feature based on the eigenvalues of the covariance matrix of a
|
||||
local neighborhood. Eigentropy is defined, for the 3 eigenvalues
|
||||
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
|
||||
|
||||
\f[
|
||||
- \sum_{i=1}^3 \lambda_i \times \log{\lambda_i}
|
||||
\f]
|
||||
|
||||
Its default name is "eigentropy".
|
||||
*/
|
||||
CGAL_DEPRECATED_MSG("you are using the deprecated feature Eigentropy, please update your code with Eigenvalue instead")
|
||||
class Eigentropy
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
||||
\param input point range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
template <typename InputRange>
|
||||
Eigentropy (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("eigentropy");
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
{
|
||||
const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i);
|
||||
if (ev[0] < 1e-15
|
||||
|| ev[1] < 1e-15
|
||||
|| ev[2] < 1e-15)
|
||||
return 0.;
|
||||
else
|
||||
return (- ev[0] * std::log(ev[0])
|
||||
- ev[1] * std::log(ev[1])
|
||||
- ev[2] * std::log(ev[2]));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup PkgClassificationFeatures
|
||||
|
||||
%Feature based on the eigenvalues of the covariance
|
||||
matrix of a local neighborhood. Surface variation is defined, for
|
||||
the 3 eigenvalues \f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge
|
||||
0\f$, as:
|
||||
|
||||
\f[
|
||||
\frac{\lambda_3}{\lambda_1 + \lambda_2 + \lambda_3}
|
||||
\f]
|
||||
|
||||
Its default name is "surface_variation".
|
||||
*/
|
||||
CGAL_DEPRECATED_MSG("you are using the deprecated feature Surface_variation, please update your code with Eigenvalue instead")
|
||||
class Surface_variation
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
||||
\param input point range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
template <typename InputRange>
|
||||
Surface_variation (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("surface_variation");
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
{
|
||||
const Local_eigen_analysis::Eigenvalues& ev = eigen.eigenvalue(i);
|
||||
if (ev[0] + ev[1] + ev[2] < 1e-15)
|
||||
return 0.;
|
||||
else
|
||||
return (ev[0] / (ev[0] + ev[1] + ev[2]));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace Feature
|
||||
|
||||
} // namespace Classification
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif
|
||||
/// \endcond
|
||||
|
||||
#endif // CGAL_CLASSIFICATION_FEATURES_EIGEN_H
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
// Copyright (c) 2017 GeometryFactory Sarl (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
// Author(s) : Simon Giraudot
|
||||
|
||||
#ifndef CGAL_CLASSIFICATION_FEATURE_HSV_H
|
||||
#define CGAL_CLASSIFICATION_FEATURE_HSV_H
|
||||
|
||||
#include <CGAL/license/Classification.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <CGAL/Classification/Color.h>
|
||||
#include <CGAL/Classification/Feature_base.h>
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace Classification {
|
||||
|
||||
namespace Feature {
|
||||
|
||||
/*!
|
||||
\ingroup PkgClassificationFeatures
|
||||
|
||||
%Feature based on HSV colorimetric information. If the input
|
||||
point cloud has colorimetric information, it can be used for
|
||||
classification purposes. This feature is based on a Gaussian
|
||||
probabilistic model on one of the three HSV channels (hue,
|
||||
saturation or value). It computes the probability of the color of
|
||||
the input point to match this specific color channel defined by a
|
||||
mean and a standard deviation.
|
||||
|
||||
The HSV channels are defined this way:
|
||||
|
||||
- Hue ranges from 0 to 360 and measures the general "tint" of the
|
||||
color (green, blue, pink, etc.)
|
||||
|
||||
- Saturation ranges from 0 to 100 and measures the "strength" of the
|
||||
color (0 is gray and 100 is the fully saturated color)
|
||||
|
||||
- Value ranges from 0 to 100 and measures the "brightness" of the
|
||||
color (0 is black and 100 is the fully bright color)
|
||||
|
||||
For example, such an feature using the channel 0 (hue) with a
|
||||
mean of 90 (which corresponds to a green hue) can help to identify
|
||||
trees.
|
||||
|
||||
\image html trees.png
|
||||
|
||||
<center><em>Left: input point set with colors. Right: HSV feature on hue with
|
||||
a mean of 90 (from low values in white to high values in dark
|
||||
red).</em></center>
|
||||
|
||||
Its default name is the channel followed by the mean value (for
|
||||
example: "hue_180", "saturation_20" or "value_98").
|
||||
|
||||
\note The user only needs to provide a map to standard (and more common)
|
||||
RGB colors, the conversion to HSV is done internally.
|
||||
|
||||
\tparam GeomTraits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator` and its value type is the key type of
|
||||
`ColorMap`.
|
||||
\tparam ColorMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `CGAL::Classification::RGB_Color`.
|
||||
*/
|
||||
template <typename GeomTraits, typename PointRange, typename ColorMap>
|
||||
CGAL_DEPRECATED_MSG("you are using the deprecated feature Hsv, please update your code with Color_channel instead")
|
||||
class Hsv : public Feature_base
|
||||
{
|
||||
public:
|
||||
|
||||
/// Selected channel.
|
||||
enum Channel
|
||||
{
|
||||
HUE = 0, ///< 0
|
||||
SATURATION = 1, ///< 1
|
||||
VALUE = 2 ///< 2
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
typedef typename Classification::RGB_Color RGB_Color;
|
||||
typedef typename Classification::HSV_Color HSV_Color;
|
||||
|
||||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
std::vector<float> color_feature;
|
||||
#else
|
||||
const PointRange& input;
|
||||
ColorMap color_map;
|
||||
Channel m_channel;
|
||||
float m_mean;
|
||||
float m_sd;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
|
||||
\brief Constructs a feature based on the given color channel,
|
||||
mean and standard deviation.
|
||||
|
||||
\param input point range.
|
||||
\param color_map property map to access the colors of the input points.
|
||||
\param channel chosen HSV channel.
|
||||
\param mean mean value of the specified channel.
|
||||
\param sd standard deviation of the specified channel.
|
||||
*/
|
||||
Hsv (const PointRange& input,
|
||||
ColorMap color_map,
|
||||
Channel channel,
|
||||
float mean, float sd)
|
||||
#ifndef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
: input(input), color_map(color_map), m_channel(channel), m_mean(mean), m_sd(sd)
|
||||
#endif
|
||||
{
|
||||
|
||||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
for(std::size_t i = 0; i < input.size();i++)
|
||||
{
|
||||
HSV_Color c = Classification::rgb_to_hsv (get(color_map, *(input.begin()+i)));
|
||||
color_feature.push_back (std::exp (-(c[std::size_t(channel)] - mean)
|
||||
* (c[std::size_t(channel)] - mean) / (2. * sd * sd)));
|
||||
}
|
||||
#endif
|
||||
std::ostringstream oss;
|
||||
if (channel == HUE) oss << "hue";
|
||||
else if (channel == SATURATION) oss << "saturation";
|
||||
else if (channel == VALUE) oss << "value";
|
||||
oss << "_" << mean;
|
||||
this->set_name (oss.str());
|
||||
}
|
||||
|
||||
virtual float value (std::size_t pt_index)
|
||||
{
|
||||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
return color_feature[pt_index];
|
||||
#else
|
||||
HSV_Color c = Classification::rgb_to_hsv (get(color_map, *(input.begin()+pt_index)));
|
||||
return std::exp (-(c[std::size_t(m_channel)] - m_mean)
|
||||
* (c[std::size_t(m_channel)] - m_mean) / (2.f * m_sd * m_sd));
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace Feature
|
||||
|
||||
} // namespace Classification
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif
|
||||
/// \endcond
|
||||
|
||||
#endif // CGAL_CLASSIFICATION_FEATURE_HSV_H
|
||||
|
|
@ -293,64 +293,6 @@ public:
|
|||
/// @}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
// deprecated
|
||||
template <typename VectorMap = Default,
|
||||
typename ColorMap = Default,
|
||||
typename EchoMap = Default>
|
||||
CGAL_DEPRECATED_MSG("you are using a deprecated constructor of CGAL::Classification::Point_set_feature_generator, please update your code")
|
||||
Point_set_feature_generator(Feature_set& features,
|
||||
const PointRange& input,
|
||||
PointMap point_map,
|
||||
std::size_t nb_scales,
|
||||
VectorMap normal_map = VectorMap(),
|
||||
ColorMap color_map = ColorMap(),
|
||||
EchoMap echo_map = EchoMap(),
|
||||
float voxel_size = -1.f)
|
||||
: m_input (input), m_point_map (point_map)
|
||||
{
|
||||
m_bbox = CGAL::bounding_box
|
||||
(boost::make_transform_iterator (m_input.begin(), CGAL::Property_map_to_unary_function<PointMap>(m_point_map)),
|
||||
boost::make_transform_iterator (m_input.end(), CGAL::Property_map_to_unary_function<PointMap>(m_point_map)));
|
||||
|
||||
CGAL::Real_timer t; t.start();
|
||||
|
||||
m_scales.reserve (nb_scales);
|
||||
|
||||
m_scales.push_back (new Scale (m_input, m_point_map, m_bbox, voxel_size));
|
||||
|
||||
if (voxel_size == -1.f)
|
||||
voxel_size = m_scales[0]->grid_resolution();
|
||||
|
||||
for (std::size_t i = 1; i < nb_scales; ++ i)
|
||||
{
|
||||
voxel_size *= 2;
|
||||
m_scales.push_back (new Scale (m_input, m_point_map, m_bbox, voxel_size, m_scales[i-1]->grid));
|
||||
}
|
||||
t.stop();
|
||||
CGAL_CLASSIFICATION_CERR << "Scales computed in " << t.time() << " second(s)" << std::endl;
|
||||
t.reset();
|
||||
|
||||
typedef typename Default::Get<VectorMap, typename GeomTraits::Vector_3 >::type
|
||||
Vmap;
|
||||
typedef typename Default::Get<ColorMap, CGAL::Color >::type
|
||||
Cmap;
|
||||
typedef typename Default::Get<EchoMap, std::size_t >::type
|
||||
Emap;
|
||||
|
||||
generate_point_based_features (features);
|
||||
generate_normal_based_features (features, get_parameter<Vmap>(normal_map));
|
||||
generate_color_based_features (features, get_parameter<Cmap>(color_map));
|
||||
generate_echo_based_features (features, get_parameter<Emap>(echo_map));
|
||||
}
|
||||
|
||||
// Functions to remove when deprecated constructor is removed
|
||||
void generate_normal_based_features(const CGAL::Constant_property_map<Iterator, typename GeomTraits::Vector_3>&) { }
|
||||
void generate_color_based_features(const CGAL::Constant_property_map<Iterator, CGAL::Color>&) { }
|
||||
void generate_echo_based_features(const CGAL::Constant_property_map<Iterator, std::size_t>&) { }
|
||||
#endif
|
||||
|
||||
virtual ~Point_set_feature_generator()
|
||||
{
|
||||
clear();
|
||||
|
|
|
|||
|
|
@ -89,14 +89,6 @@ if(TARGET test_classification_point_set)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
create_single_source_cgal_program( "deprecated_test_classification_point_set.cpp" CXX_FEATURES ${needed_cxx_features} )
|
||||
if(TARGET deprecated_test_classification_point_set)
|
||||
target_link_libraries(deprecated_test_classification_point_set PUBLIC ${classification_linked_libraries})
|
||||
if (TBB_FOUND)
|
||||
CGAL_target_use_TBB( deprecated_test_classification_point_set )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
create_single_source_cgal_program( "test_classification_io.cpp" CXX_FEATURES ${needed_cxx_features} )
|
||||
if(TARGET test_classification_io)
|
||||
target_link_libraries(test_classification_io PUBLIC ${classification_linked_libraries})
|
||||
|
|
|
|||
|
|
@ -1,136 +0,0 @@
|
|||
#include <CGAL/internal/disable_deprecation_warnings_and_errors.h>
|
||||
|
||||
#if defined (_MSC_VER) && !defined (_WIN64)
|
||||
#pragma warning(disable:4244) // boost::number_distance::distance()
|
||||
// converts 64 to 32 bits integers
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Classification.h>
|
||||
#include <CGAL/Point_set_3.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef Kernel::Point_3 Point;
|
||||
typedef Kernel::Vector_3 Vector;
|
||||
|
||||
typedef CGAL::Point_set_3<Point> Point_set;
|
||||
typedef Point_set::Point_map Point_map;
|
||||
|
||||
typedef Kernel::Iso_cuboid_3 Iso_cuboid_3;
|
||||
|
||||
namespace Classification = CGAL::Classification;
|
||||
|
||||
typedef Classification::Label_handle Label_handle;
|
||||
typedef Classification::Feature_handle Feature_handle;
|
||||
typedef Classification::Label_set Label_set;
|
||||
typedef Classification::Feature_set Feature_set;
|
||||
|
||||
typedef Classification::Sum_of_weighted_features_classifier Classifier;
|
||||
|
||||
typedef Classification::Point_set_feature_generator<Kernel, Point_set, Point_map> Feature_generator;
|
||||
|
||||
typedef Point_set::Property_map<std::size_t> Size_t_map;
|
||||
typedef Point_set::Property_map<Classification::RGB_Color> Color_map;
|
||||
|
||||
|
||||
|
||||
int main (int, char**)
|
||||
{
|
||||
Point_set pts;
|
||||
|
||||
pts.add_normal_map();
|
||||
|
||||
bool map_added = false;
|
||||
Size_t_map echo_map;
|
||||
Color_map color_map;
|
||||
|
||||
boost::tie (echo_map, map_added) = pts.add_property_map<std::size_t> ("echo");
|
||||
assert (map_added);
|
||||
boost::tie (color_map, map_added) = pts.add_property_map<Classification::RGB_Color> ("color");
|
||||
assert (map_added);
|
||||
|
||||
for (std::size_t i = 0; i < 1000; ++ i)
|
||||
{
|
||||
Point_set::iterator it
|
||||
= pts.insert (Point (CGAL::get_default_random().get_double(),
|
||||
CGAL::get_default_random().get_double(),
|
||||
CGAL::get_default_random().get_double()),
|
||||
Vector (CGAL::get_default_random().get_double(),
|
||||
CGAL::get_default_random().get_double(),
|
||||
CGAL::get_default_random().get_double()));
|
||||
echo_map[*it] = std::size_t(CGAL::get_default_random().get_int(0, 4));
|
||||
color_map[*it] = CGAL::make_array ((unsigned char)(CGAL::get_default_random().get_int(0, 255)),
|
||||
(unsigned char)(CGAL::get_default_random().get_int(0, 255)),
|
||||
(unsigned char)(CGAL::get_default_random().get_int(0, 255)));
|
||||
}
|
||||
|
||||
Feature_set features;
|
||||
Feature_generator generator (features, pts, pts.point_map(),
|
||||
5, // using 5 scales
|
||||
pts.normal_map(),
|
||||
color_map, echo_map);
|
||||
|
||||
assert (generator.number_of_scales() == 5);
|
||||
assert (features.size() == 59);
|
||||
|
||||
Label_set labels;
|
||||
|
||||
std::vector<int> training_set (pts.size(), -1);
|
||||
for (std::size_t i = 0; i < 20; ++ i)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "label_" << i;
|
||||
Label_handle lh = labels.add(oss.str().c_str());
|
||||
|
||||
for (std::size_t j = 0; j < 10; ++ j)
|
||||
training_set[std::size_t(CGAL::get_default_random().get_int(0, int(training_set.size())))] = int(i);
|
||||
}
|
||||
assert (labels.size() == 20);
|
||||
|
||||
Classifier classifier (labels, features);
|
||||
|
||||
classifier.train<CGAL::Sequential_tag> (training_set, 800);
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
classifier.train<CGAL::Parallel_tag> (training_set, 800);
|
||||
#endif
|
||||
|
||||
std::vector<int> label_indices(pts.size(), -1);
|
||||
|
||||
Classification::classify<CGAL::Sequential_tag>
|
||||
(pts, labels, classifier, label_indices);
|
||||
|
||||
Classification::classify_with_local_smoothing<CGAL::Sequential_tag>
|
||||
(pts, pts.point_map(), labels, classifier,
|
||||
generator.neighborhood().sphere_neighbor_query(0.01f),
|
||||
label_indices);
|
||||
|
||||
Classification::classify_with_graphcut<CGAL::Sequential_tag>
|
||||
(pts, pts.point_map(), labels, classifier,
|
||||
generator.neighborhood().k_neighbor_query(12),
|
||||
0.2f, 10, label_indices);
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
Classification::classify<CGAL::Sequential_tag>
|
||||
(pts, labels, classifier, label_indices);
|
||||
|
||||
Classification::classify_with_local_smoothing<CGAL::Sequential_tag>
|
||||
(pts, pts.point_map(), labels, classifier,
|
||||
generator.neighborhood().sphere_neighbor_query(0.01f),
|
||||
label_indices);
|
||||
|
||||
Classification::classify_with_graphcut<CGAL::Sequential_tag>
|
||||
(pts, pts.point_map(), labels, classifier,
|
||||
generator.neighborhood().k_neighbor_query(12),
|
||||
0.2f, 10, label_indices);
|
||||
#endif
|
||||
|
||||
Classification::Evaluation evaluation (labels, training_set, label_indices);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Loading…
Reference in New Issue