26 #include <AffordanceKit/ColorMap.h>
28 #include <Inventor/nodes/SoDrawStyle.h>
33 visualizationNode(nullptr)
63 if (primitive->getId() != entry.first.first->getId())
68 AffordanceKit::PrimitivePair pp = entry.first;
70 unsigned int size = primitive->getSamplingSize();
71 if (size == 0 ||
affordance->getThetaSize(pp) != size * size)
76 armarx::DebugDrawer24BitColoredPointCloud pointCloud;
77 pointCloud.pointSize = 7;
78 pointCloud.transparency = 0;
81 pointCloud.points.reserve((size / 4) * (size / 4));
83 std::map<std::pair<unsigned int, unsigned int>, AffordanceKit::Belief> maxBeliefMap;
85 const Eigen::MatrixXf&
T =
affordance->getTheta(pp);
86 for (
unsigned int i = 0; i <
T.cols(); i++)
88 unsigned int index1 = i / size;
89 unsigned int index2 = i % size;
92 index1 = index1 - (index1 % 4);
93 index2 = index2 - (index2 % 4);
96 std::pair<unsigned int, unsigned int>
indices = (index1 <= index2) ? std::pair<unsigned int, unsigned int>(index1, index2) : std::pair<unsigned int, unsigned int>(index2, index1);
98 AffordanceKit::Belief belief(
T.col(i));
99 if ((maxBeliefMap.find(
indices) == maxBeliefMap.end()) || (belief.expectedProbability() > maxBeliefMap.at(
indices).expectedProbability()))
101 maxBeliefMap[
indices] = belief;
105 std::cout <<
"maxBeliefMap size: " << maxBeliefMap.size() << std::endl;
107 for (
auto& entry : maxBeliefMap)
109 if (entry.second.expectedProbability() < minExpectedProbability)
115 const Eigen::Matrix4f& x2 = primitive->getSampling(entry.first.second);
116 Eigen::Vector3i
c = AffordanceKit::ColorMap::GetVisualizationColor(entry.second);
118 armarx::DebugDrawer24BitColoredPointCloudElement e1;
122 e1.color = armarx::DrawColor24Bit {(
unsigned char)
c(0), (
unsigned char)
c(1), (
unsigned char)
c(2)};
123 pointCloud.points.push_back(e1);
125 armarx::DebugDrawer24BitColoredPointCloudElement e2;
129 e2.color = armarx::DrawColor24Bit {(
unsigned char)
c(0), (
unsigned char)
c(1), (
unsigned char)
c(2)};
130 pointCloud.points.push_back(e2);
133 std::cout <<
"pointCloud size: " << pointCloud.points.size() << std::endl;
135 debugDrawer->set24BitColoredPointCloudVisu(layerName,
id +
"_sampling", pointCloud);