StereoCameraModelFilter.cpp
Go to the documentation of this file.
1 
21 
22 namespace next_best_view {
23  StereoCameraModelFilter::StereoCameraModelFilter(const SimpleVector3 &leftCameraPivotPointOffset, const SimpleVector3 &rightCameraPivotPointOffset) :
24  CameraModelFilter(), mFilteringType(INTERSECTION) {
25  mLeftCameraModelFilter = SingleCameraModelFilter(leftCameraPivotPointOffset);
26  mRightCameraModelFilter = SingleCameraModelFilter(rightCameraPivotPointOffset);
27  }
28 
30  if (!this->haveParametersChanged()) {
31  return;
32  }
33 
34  // set up left camera
43 
44  // set up right camera
53 
54  this->setParametersChanged(false);
55  }
56 
58  this->copySettings();
59 
60  // create the result.
61  indicesPtr = IndicesPtr(new Indices());
62 
63  // do the filtering
64  FilteringType filteringType = this->getFilteringType();
65  if (filteringType == LEFT) {
66  mLeftCameraModelFilter.filter(indicesPtr);
67  } else if (filteringType == RIGHT) {
68  mRightCameraModelFilter.filter(indicesPtr);
69  } else if (filteringType == BOTH) {
70  // get the left filter
71  IndicesPtr leftIndicesPtr(new Indices());
72  mLeftCameraModelFilter.filter(leftIndicesPtr);
73 
74  // get the right filter
75  IndicesPtr rightIndicesPtr(new Indices());
76  mRightCameraModelFilter.filter(rightIndicesPtr);
77 
78  // create the result.
79  indicesPtr = IndicesPtr(new Indices(leftIndicesPtr->size() + rightIndicesPtr->size()));
80  // merge both vectors
81  std::merge(leftIndicesPtr->begin(), leftIndicesPtr->end(), rightIndicesPtr->begin(), rightIndicesPtr->end(), indicesPtr->begin());
82 
83  // ensure they are sorted to be considered unique
84  std::sort(indicesPtr->begin(), indicesPtr->end());
85  Indices::iterator uniqueEndIterator = std::unique(indicesPtr->begin(), indicesPtr->end());
86 
87  // resize the resulting vector
88  indicesPtr->resize(std::distance(indicesPtr->begin(), uniqueEndIterator));
89  } else {
90  // get the left filter
91  IndicesPtr leftIndicesPtr(new Indices());
92  mLeftCameraModelFilter.filter(leftIndicesPtr);
93 
94  // setting the left indices as resource
95  mRightCameraModelFilter.setIndices(leftIndicesPtr);
96  mRightCameraModelFilter.filter(indicesPtr);
97  }
98  }
99 
101  mFilteringType = type;
102  }
103 
105  return mFilteringType;
106  }
107 
109  mLeftCameraModelFilter.setPivotPointOffset(cameraPivotPointOffset);
110  }
111 
114  }
115 
117  mRightCameraModelFilter.setPivotPointOffset(cameraPivotPointOffset);
118  }
119 
122  }
123 
124  viz::MarkerArrayPtr StereoCameraModelFilter::getVisualizationMarkerArray(uint32_t &sequence, double lifetime) {
125  this->copySettings();
126 
127  viz::MarkerArrayPtr leftMarkerArrayPtr = mLeftCameraModelFilter.getVisualizationMarkerArray(sequence, lifetime);
128  viz::MarkerArrayPtr rightMarkerArrayPtr = mRightCameraModelFilter.getVisualizationMarkerArray(sequence, lifetime);
129 
130  viz::MarkerArrayPtr markerArrayPtr = viz::MarkerArrayPtr(new viz::MarkerArray());
131  markerArrayPtr->markers = std::vector<viz::Marker>(leftMarkerArrayPtr->markers.size() + rightMarkerArrayPtr->markers.size());
132  std::copy(leftMarkerArrayPtr->markers.begin(), leftMarkerArrayPtr->markers.end(), markerArrayPtr->markers.begin());
133  std::copy(rightMarkerArrayPtr->markers.begin(), rightMarkerArrayPtr->markers.end(), markerArrayPtr->markers.begin() + leftMarkerArrayPtr->markers.size());
134 
135  return markerArrayPtr;
136  }
137 }
138 
SingleCameraModelFilter mRightCameraModelFilter
the right camera model filter.
void setRightCameraPivotPointOffset(const SimpleVector3 &cameraPivotPointOffset)
sets the left camera pivot offset
void setOrientation(const SimpleQuaternion &orientation)
sets the orientation of the pivot point
void setPivotPointPosition(const SimpleVector3 &position)
sets the position of the pivot point.
StereoCameraModelFilter(const SimpleVector3 &leftCameraPivotPointOffset=SimpleVector3(), const SimpleVector3 &rightCameraPivotPointOffset=SimpleVector3())
constructor for the StereoCameraModelFilter object
FilteringType mFilteringType
the filtering type.
void setFarClippingPlane(double fcp)
sets the far clipping plane. fcp the far clipping distance
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
Definition: typedef.hpp:53
void setNearClippingPlane(double ncp)
sets the near clipping plane.
virtual ObjectPointCloudPtr & getInputCloud()
Definition: CommonClass.cpp:31
void filter(IndicesPtr &indicesPtr)
Applies the filter on the indices.
viz::MarkerArrayPtr getVisualizationMarkerArray(uint32_t &sequence, double lifetime=30.0)
returns a array of markers containing the visualization of the camera frustum.
std::vector< int > Indices
Definition: typedef.hpp:117
virtual void setIndices(const IndicesPtr &indicesPtr)
setting the shared pointer to the active indices of the point cloud.
Definition: CommonClass.cpp:35
SingleCameraModelFilter mLeftCameraModelFilter
the left camera model filter.
void doFiltering(IndicesPtr &indicesPtr)
Does the filtering on the indices.
this namespace contains all generally usable classes.
viz::MarkerArrayPtr getVisualizationMarkerArray(uint32_t &sequence, double lifetime=30.0)
returns a array of markers containing the visualization of the camera frustum.
boost::shared_ptr< Indices > IndicesPtr
Definition: typedef.hpp:118
CameraModelFilter class was built to generalize the filtering for different camera models...
FilteringType
describes the filtering type of the filter.
void setLeftCameraPivotPointOffset(const SimpleVector3 &cameraPivotPointOffset)
sets the left camera pivot offset
virtual IndicesPtr & getIndices()
Definition: CommonClass.cpp:39
SingleCameraModelFilter class implements the frustum filter for a single camera.
void setFilteringType(FilteringType type)
sets the filtering type.
void setPivotPointOffset(const SimpleVector3 &pivotPointOffset)
sets the offset between the pivot point and the actual camera position.
virtual void setInputCloud(const ObjectPointCloudPtr &pointCloudPtr)
setting the input cloud.
Definition: CommonClass.cpp:27
void setVerticalFOV(double fovDegrees)
sets the vertical field of view.
void copySettings()
copies the settings of this objects to the settings of the two SingeCameraModelFilter objects...
void setHorizontalFOV(double fovDegrees)
sets the horizontal field of view.


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