23 #ifndef ROBDEKON_DENSEGRAPHCRF_HPP
24 #define ROBDEKON_DENSEGRAPHCRF_HPP
30 #include <permutohedral.h>
31 #include <objective.h>
37 #include <pcl/point_types.h>
45 template <
class GraphT>
52 typedef typename boost::graph_traits<GraphT>::vertex_descriptor VtxId;
59 template <
typename FeatureT>
61 KernelType kernel_type = DIAG_KERNEL,
62 NormalizationType normalization_type = NORMALIZE_SYMMETRIC)
65 FeatureT functor(*_graph);
66 Eigen::MatrixXf features = functor.computeFeatures(sigma);
67 addPairwiseEnergy(features,
function, kernel_type, normalization_type);
72 bool use_time, LabelCompatibility*
function, KernelType kernel_type = DIAG_KERNEL,
73 NormalizationType normalization_type = NORMALIZE_SYMMETRIC)
78 addPairwiseEnergy(features,
function, kernel_type, normalization_type);
83 void map(
int n_iterations);
89 template <
class GraphT>
96 template <
class GraphT>
100 Eigen::MatrixXf energy(M_, N_);
102 const float u_energy = -log(1.0 / M_);
103 const float n_energy = -log((1.0 - gt_prob) / (M_ - 1));
104 const float p_energy = -log(gt_prob);
105 energy.fill(u_energy);
106 for (
int k = 0; k < N_; k++)
109 int r = (*_graph)[
static_cast<VtxId
>(k)].label;
113 energy.col(k).fill(n_energy);
114 energy(r, k) = p_energy;
118 setUnaryEnergy(energy);
121 template <
class GraphT>
125 VectorXs map_result = DenseCRF::map(n_iterations);
126 const int res_size = map_result.size();
128 for (
int i = 0; i < res_size; i++)
130 (*_graph)[
static_cast<VertexId>(i)].label = map_result[i];
134 template <
class GraphT>
138 Eigen::MatrixXf Q = inference(n_iterations);
141 const int res_size = map_result.size();
143 Eigen::VectorXf confidence_score;
146 confidence_score.resize(res_size);
147 for (
int i = 0; i < res_size; i++)
149 (*_graph)[
static_cast<VtxId
>(i)].label = map_result[i];
150 boost::put(cm,
static_cast<VtxId
>(i), Q(map_result[i], i));
151 confidence_score[i] = Q(map_result[i], i);
153 return confidence_score;
158 #endif //ROBDEKON_DENSEGRAPHCRF_HPP