23#ifndef ROBDEKON_DENSEGRAPHCRF_HPP
24#define ROBDEKON_DENSEGRAPHCRF_HPP
26#include <pcl/point_types.h>
37#include <permutohedral.h>
41 template <
class GraphT>
48 typedef typename boost::graph_traits<GraphT>::vertex_descriptor VtxId;
54 template <
typename FeatureT>
57 LabelCompatibility* function,
58 KernelType kernel_type = DIAG_KERNEL,
59 NormalizationType normalization_type = NORMALIZE_SYMMETRIC)
62 FeatureT functor(*_graph);
63 Eigen::MatrixXf features = functor.computeFeatures(sigma);
64 addPairwiseEnergy(features, function, kernel_type, normalization_type);
74 LabelCompatibility* function,
75 KernelType kernel_type = DIAG_KERNEL,
76 NormalizationType normalization_type = NORMALIZE_SYMMETRIC)
80 *_graph, use_rgb, use_norm, use_xyz, use_curv, use_time);
82 addPairwiseEnergy(features, function, kernel_type, normalization_type);
87 void map(
int n_iterations);
93 template <
class GraphT>
95 DenseCRF(static_cast<int>(
boost::num_vertices(*
Graph)), M), _graph(
Graph)
99 template <
class GraphT>
104 Eigen::MatrixXf energy(M_, N_);
106 const float u_energy = -log(1.0 / M_);
107 const float n_energy = -log((1.0 - gt_prob) / (M_ - 1));
108 const float p_energy = -log(gt_prob);
109 energy.fill(u_energy);
110 for (
int k = 0; k < N_; k++)
113 int r = (*_graph)[
static_cast<VtxId
>(k)].label;
117 energy.col(k).fill(n_energy);
118 energy(r, k) = p_energy;
122 setUnaryEnergy(energy);
125 template <
class GraphT>
130 VectorXs map_result = DenseCRF::map(n_iterations);
131 const int res_size = map_result.size();
133 for (
int i = 0; i < res_size; i++)
135 (*_graph)[
static_cast<VertexId>(i)].label = map_result[i];
139 template <
class GraphT>
144 Eigen::MatrixXf Q = inference(n_iterations);
147 const int res_size = map_result.size();
149 Eigen::VectorXf confidence_score;
152 confidence_score.resize(res_size);
153 for (
int i = 0; i < res_size; i++)
155 (*_graph)[
static_cast<VtxId
>(i)].label = map_result[i];
156 boost::put(cm,
static_cast<VtxId
>(i), Q(map_result[i], i));
157 confidence_score[i] = Q(map_result[i], i);
159 return confidence_score;
Eigen::VectorXf map_and_confidence(int n_iterations)
void computeUnaryEnergyFromGraph(float gt_prob)
void map(int n_iterations)
void addPairwiseGaussianFeature(std::vector< float > sigma, LabelCompatibility *function, KernelType kernel_type=DIAG_KERNEL, NormalizationType normalization_type=NORMALIZE_SYMMETRIC)
DenseGraphCRF(GraphPtrT Graph, int M)
void addCombinedGaussianFeature(std::vector< float > sigma, bool use_rgb, bool use_norm, bool use_xyz, bool use_curv, bool use_time, LabelCompatibility *function, KernelType kernel_type=DIAG_KERNEL, NormalizationType normalization_type=NORMALIZE_SYMMETRIC)
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
This file offers overloads of toIce() and fromIce() functions for STL container types.
boost::property_map< CloudGraphWithTimestamp, boost::vertex_confidence_t >::type ConfidenceMap
boost::graph_traits< Graph >::vertex_descriptor VertexId
boost::subgraph< CloudGraph > Graph
Eigen::MatrixXf computeFeatures(std::vector< float > sigma)