PerspectiveHypothesisUpdater.cpp
Go to the documentation of this file.
1 
20 #include <boost/foreach.hpp>
22 
24 #include "typedef.hpp"
25 #include <ros/ros.h>
26 
27 namespace next_best_view {
30  }
31 
33 
34  unsigned int PerspectiveHypothesisUpdater::update(const ObjectTypeSetPtr &objectTypeSetPtr, const ViewportPoint &viewportPoint) {
35  mDebugHelperPtr->writeNoticeably("STARTING UPDATE METHOD", DebugHelper::HYPOTHESIS_UPDATER);
36 
37  unsigned int counter = 0;
38 
39  mDebugHelperPtr->write(std::stringstream() << "Viewport: " << viewportPoint, DebugHelper::HYPOTHESIS_UPDATER);
40 
41  BOOST_FOREACH(int index, *viewportPoint.child_indices) {
42  ObjectPoint &objectPoint = viewportPoint.child_point_cloud->at(index);
43 
44  if (objectTypeSetPtr->find(objectPoint.type) == objectTypeSetPtr->end()) {
45  continue;
46  }
47 
48  Indices::iterator begin = objectPoint.active_normal_vectors->begin();
49  Indices::iterator end = objectPoint.active_normal_vectors->end();
50  for (Indices::iterator iter = begin; iter != end;) {
51  int normalIndex = *iter;
52  SimpleVector3 normalVector = objectPoint.normal_vectors->at(normalIndex);
53  SimpleVector3 objectPosition = objectPoint.getPosition();
54 
55  // rate the angle between the camera and the object normal
56  float rating = mDefaultRatingModulePtr->getNormalUtility(viewportPoint, normalVector, objectPosition, mNormalAngleThreshold);
57 
58  mDebugHelperPtr->write(std::stringstream() << "Normal utility: " << rating, DebugHelper::HYPOTHESIS_UPDATER);
59 
60  if (rating != 0.0) {
61  end--;
62  std::iter_swap(iter, end);
63  counter++;
64  continue;
65  }
66 
67  iter++;
68  }
69 
70  std::size_t iteratorDistance = std::distance(begin, end);
71  //ROS_INFO("Resizing active normal vectors from %d to %d at index %d", objectPoint.active_normal_vectors->size(), iteratorDistance, index);
72  objectPoint.active_normal_vectors->resize(iteratorDistance);
73 
74  // RGB
75  double ratio = double(objectPoint.active_normal_vectors->size()) / double(objectPoint.normal_vectors->size());
76 
77  objectPoint.color.r = ratio > .5 ? int((2.0 - 2 * ratio) * 255) : 255;
78  objectPoint.color.g = ratio > .5 ? 255 : int(2.0 * ratio * 255);
79  objectPoint.color.b = 0;
80  }
81 
82  mDebugHelperPtr->writeNoticeably("ENDING UPDATE METHOD", DebugHelper::HYPOTHESIS_UPDATER);
83 
84  return counter;
85  }
86 
88  mDefaultRatingModulePtr = defaultRatingModulePtr;
89  }
90 
93  }
94 
96  mNormalAngleThreshold = angle;
97  }
98 
100  return mNormalAngleThreshold;
101  }
102 }
SimpleVector3CollectionPtr normal_vectors
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
Definition: typedef.hpp:53
this namespace contains all generally usable classes.
static boost::shared_ptr< DebugHelper > getInstance()
Definition: DebugHelper.cpp:29
SimpleVector3 getPosition() const
unsigned int update(const ObjectTypeSetPtr &objectTypeSetPtr, const ViewportPoint &viewportPoint)
Updates the point cloud under the assumption that the given viewport was chosen.
void setDefaultRatingModule(DefaultRatingModulePtr defaultRatingModulePtr)


asr_next_best_view
Author(s): Aumann Florian, Borella Jocelyn, Heller Florian, Meißner Pascal, Schleicher Ralf, Stöckle Patrick, Stroh Daniel, Trautmann Jeremias, Walter Milena, Wittenbeck Valerij
autogenerated on Thu Jan 9 2020 07:20:18