Ocean
AdvancedPointTracker.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_TRACKING_POINT_ADVANCED_POINT_TRACKER_H
9 #define META_OCEAN_TRACKING_POINT_ADVANCED_POINT_TRACKER_H
10 
14 
16 
18 
21 #include "ocean/math/Vector2.h"
22 
23 #include "ocean/tracking/DataContainer.h"
24 
25 namespace Ocean
26 {
27 
28 namespace Tracking
29 {
30 
31 namespace Point
32 {
33 
34 /**
35  * This class implements an advanced point tracker.
36  * @ingroup trackingpoint
37  */
38 template <unsigned int tSuccessiveFrames>
40 {
41  protected:
42 
43  class Candidate
44  {
45  protected:
46 
48 
51 
54 
57 
58  public:
59 
60  inline Candidate(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& firstPose, const Vector2& firstImagePoint, const bool useCameraDistortionParameters, const unsigned int firstPoseId);
61 
62  inline void replace(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& firstPose, const Vector2& firstImagePoint, const bool useCameraDistortionParameters, const unsigned int firstPoseId);
63 
64  inline bool isValid() const;
65 
66  PosePointPairsObject newPose(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& pose, const HomogenousMatrix4& poseIF, const unsigned int poseId, const Vectors2& imagePoints, const bool useCameraDistortionParameters, const Geometry::SpatialDistribution::DistributionArray& imagePointsDistribution, const Scalar searchRadius, const Scalar sqrProjectionDistanceconst);
67 
68  inline void add2OccupancyArray(Geometry::SpatialDistribution::OccupancyArray& occupancyArray) const;
69 
70  //protected:
71 
73 
75 
77 
79  };
80 
81  typedef std::vector<Candidate> Candidates;
82 
83  public:
84 
86 
87  PosePointPairsObjects newPose(const PinholeCamera& pinholeCamera, const unsigned int poseId, const Vectors2& imagePoints, const bool useCameraDistortionParameters, Geometry::SpatialDistribution::OccupancyArray* externalOccupancyArray = nullptr, const bool updateOccupancyArray = true);
88 
89  protected:
90 
91  Geometry::SpatialDistribution::OccupancyArray determineOccupancyArray(const PinholeCamera& pinholeCamera, const unsigned int horizontalBins, const unsigned int verticalBins);
92 
93  protected:
94 
96 
98 
100 
102 };
103 
104 template <unsigned int tSuccessiveFrames>
105 inline AdvancedPointTracker<tSuccessiveFrames>::Candidate::Candidate(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& firstPose, const Vector2& firstImagePoint, const bool useCameraDistortionParameters, const unsigned int firstPoseId) :
106  candidatePoseIds(firstPoseId),
107  candidateIsValid(true)
108 {
109  ocean_assert(pinholeCamera.isValid() && firstPose.isValid());
110 
112  candidateSuccessiveImagePoints.back().pushBack(firstImagePoint);
113 
115 
116  if (useCameraDistortionParameters)
117  {
118  const Vector2 firstUndistortedImagePoint(pinholeCamera.undistort<true>(firstImagePoint));
119  ocean_assert(firstImagePoint.sqrDistance(pinholeCamera.distort<true>(firstUndistortedImagePoint)) < 1);
120 
121  candidateSuccessiveRays.back().pushBack(pinholeCamera.ray(firstUndistortedImagePoint, firstPose));
122  }
123  else
124  candidateSuccessiveRays.back().pushBack(pinholeCamera.ray(firstImagePoint, firstPose));
125 }
126 
127 template <unsigned int tSuccessiveFrames>
128 inline void AdvancedPointTracker<tSuccessiveFrames>::Candidate::replace(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& firstPose, const Vector2& firstImagePoint, const bool useCameraDistortionParameters, const unsigned int firstPoseId)
129 {
130  ocean_assert(!isValid());
131  ocean_assert(pinholeCamera.isValid() && firstPose.isValid());
132 
133  ocean_assert(candidateSuccessiveImagePoints.size() == candidateSuccessiveRays.size());
134  for (size_t n = 0; n < candidateSuccessiveImagePoints.size(); ++n)
135  {
136  candidateSuccessiveImagePoints[n].weakClear();
137  candidateSuccessiveRays[n].weakClear();
138  }
139 
140  candidateSuccessiveRays.weakResize(1);
141 
142  if (useCameraDistortionParameters)
143  {
144  const Vector2 firstUndistortedImagePoint(pinholeCamera.undistort<true>(firstImagePoint));
145  ocean_assert(firstImagePoint.sqrDistance(pinholeCamera.distort<true>(firstUndistortedImagePoint)) < 1);
146 
147  candidateSuccessiveRays.front().pushBack(pinholeCamera.ray(firstUndistortedImagePoint, firstPose));
148  }
149  else
150  candidateSuccessiveRays.front().pushBack(pinholeCamera.ray(firstImagePoint, firstPose));
151 
152  candidatePoseIds.weakResize(1);
153  candidatePoseIds.front() = firstPoseId;
154 
155  candidateIsValid = true;
156 
157  candidateSuccessiveImagePoints.weakResize(1);
158  candidateSuccessiveImagePoints.front().pushBack(firstImagePoint);
159 }
160 
161 template <unsigned int tSuccessiveFrames>
163 {
164  return candidateIsValid;
165 }
166 
167 template <unsigned int tSuccessiveFrames>
168 PosePointPairsObject AdvancedPointTracker<tSuccessiveFrames>::Candidate::newPose(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& pose, const HomogenousMatrix4& poseIF, const unsigned int poseId, const Vectors2& imagePoints, const bool useCameraDistortionParameters, const Geometry::SpatialDistribution::DistributionArray& imagePointsDistribution, const Scalar searchRadius, const Scalar sqrProjectionDistance)
169 {
170  ocean_assert(candidateIsValid);
171  ocean_assert(pinholeCamera.isValid() && poseIF.isValid());
172  ocean_assert(!candidateSuccessiveImagePoints.empty());
173  ocean_assert(!candidateSuccessiveImagePoints.occupied());
174 
175  // find new point candidates according to the position of the previous point candidates
176  const StaticVectors2& previousImagePoints = candidateSuccessiveImagePoints.back();
177 
178  StaticVector<unsigned int, 10u> currentCandidateIndices;
179 
180  for (size_t n = 0; n < previousImagePoints.size(); ++n)
181  {
182  const Indices32 indices(Geometry::SpatialDistribution::determineNeighbors(previousImagePoints[n], imagePoints.data(), (unsigned int)imagePoints.size(), searchRadius, imagePointsDistribution));
183 
184  for (Indices32::const_iterator i = indices.begin(); !currentCandidateIndices.occupied() && i != indices.end(); ++i)
185  {
186  bool found = false;
187 
188  for (size_t t = 0; t < currentCandidateIndices.size(); ++t)
189  if (*i == currentCandidateIndices[t])
190  {
191  found = true;
192  break;
193  }
194 
195  if (!found)
196  currentCandidateIndices.pushBack(*i);
197  }
198  }
199 
200  StaticVectors2 currentCandidates;
201 
202  for (size_t n = 0; n < currentCandidateIndices.size(); ++n)
203  currentCandidates.pushBack(imagePoints[currentCandidateIndices[n]]);
204 
205  // projected the 3D rays from the previous frames into the camera by application of the current pose
206  StaticLines2Set previousProjectedRays;
207  previousProjectedRays.weakResize(candidateSuccessiveRays.size());
208 
209  for (size_t a = 0; a < candidateSuccessiveRays.size(); ++a)
210  {
211  previousProjectedRays[a].weakResize(candidateSuccessiveRays[a].size());
212 
213  for (size_t b = 0; b < candidateSuccessiveRays[a].size(); ++b)
214  previousProjectedRays[a][b] = pinholeCamera.projectToImageIF<true>(poseIF, candidateSuccessiveRays[a][b], useCameraDistortionParameters);
215  }
216 
217  // filter the point candidates according to previous projected rays
218  for (size_t c = 0; c < currentCandidates.size(); /* noop */)
219  {
220  const Vector2& candidate = currentCandidates[c];
221 
222  size_t nearToLineCounter = 0;
223 
224  for (size_t a = 0; a < previousProjectedRays.size(); ++a)
225  for (size_t b = 0; b < previousProjectedRays[a].size(); ++b)
226  {
227  const Line2& projectedRay = previousProjectedRays[a][b];
228 
229  if (projectedRay && projectedRay.sqrDistance(candidate) <= sqrProjectionDistance)
230  {
231  nearToLineCounter++;
232  break;
233  }
234  }
235 
236  if (nearToLineCounter == previousProjectedRays.size())
237  c++;
238  else
239  currentCandidates.unstableErase(c);
240  }
241 
242  candidateSuccessiveImagePoints.pushBack(currentCandidates);
243 
244  // create 3D rays for the current candidates and pose
245 
246  candidateSuccessiveRays.weakResize(candidateSuccessiveRays.size() + 1);
247  for (size_t n = 0; n < currentCandidates.size(); ++n)
248  {
249  const Vector2 undistortedCandidate(pinholeCamera.undistort<true>(currentCandidates[n]));
250  ocean_assert(currentCandidates[n].sqrDistance(pinholeCamera.distort<true>(undistortedCandidate)) < 1);
251 
252  candidateSuccessiveRays.back().securePushBack(pinholeCamera.ray(undistortedCandidate, pose));
253  }
254 
255  // filter previous projected rays (and their corresponding points) according to the just filtered point candidates
256 
257  ocean_assert(previousProjectedRays.size() + 1 == candidateSuccessiveImagePoints.size());
258  ocean_assert(previousProjectedRays.size() >= 1);
259 
260  for (size_t a = 0; a < previousProjectedRays.size() - 1; ++a)
261  {
262  StaticLines2& projectedRays = previousProjectedRays[a];
263 
264  ocean_assert(projectedRays.size() == candidateSuccessiveImagePoints[a].size());
265 
266  for (size_t b = 0; b < projectedRays.size(); /* noop */)
267  {
268  const Line2& projectedRay = projectedRays[b];
269 
270  bool hasFound = false;
271 
272  for (size_t c = 0; c < currentCandidates.size(); ++c)
273  if (projectedRay.sqrDistance(currentCandidates[c]) <= sqrProjectionDistance)
274  {
275  hasFound = true;
276  break;
277  }
278 
279  if (hasFound)
280  b++;
281  else
282  {
283  projectedRays.unstableErase(b);
284  candidateSuccessiveRays[a].unstableErase(b);
285  candidateSuccessiveImagePoints[a].unstableErase(b);
286  }
287  }
288 
289  // if the current level is empty, the entire candidate is invalidated
290  if (projectedRays.empty())
291  {
292  candidateIsValid = false;
293  return PosePointPairsObject();
294  }
295  }
296 
297  candidatePoseIds.pushBack(poseId);
298 
299 #ifdef OCEAN_DEBUG
300 
301  const StaticVectors2& _imagePoints = candidateSuccessiveImagePoints.back();
302 
303  for (size_t a = 0; a + 1 < _imagePoints.size(); ++a)
304  for (size_t b = a + 1; b < _imagePoints.size(); ++b)
305  ocean_assert(_imagePoints[a] != _imagePoints[b]);
306 #endif
307 
308  // check whether enough poses have been investigated
309  if (candidateSuccessiveImagePoints.size() >= tSuccessiveFrames)
310  {
311  for (unsigned int n = 0u; n < candidateSuccessiveImagePoints.size(); ++n)
312  if (candidateSuccessiveImagePoints[n].size() != 1)
313  {
314  candidateIsValid = false;
315  return PosePointPairsObject();
316  }
317 
318  // we have enough unique successive image points to create an initial 3D position
319 
321  for (size_t n = 0; n < candidateSuccessiveRays.size(); ++n)
322  rays.pushBack(candidateSuccessiveRays[n].front());
323 
324  Vector3 initialObjectPoint;
325 
326  if (!Utilities::determineInitialObjectPoint(pinholeCamera, rays.data(), (unsigned int)rays.size(), initialObjectPoint, true))
327  {
328  candidateIsValid = false;
329  return PosePointPairsObject();
330  }
331 
332  ocean_assert(candidatePoseIds.size() == candidateSuccessiveRays.size());
333 
334  DataContainer& dataContainer = DataContainer::get();
335 
338 
339  for (size_t n = 0; n < candidatePoseIds.size(); ++n)
340  {
341  ocean_assert(dataContainer.hasPose<true>(candidatePoseIds[n]));
342  posesIF.pushBack(dataContainer.poseIF<true>(candidatePoseIds[n]));
343 
344  imagePoints.pushBack(candidateSuccessiveImagePoints[n].front());
345  }
346 
347  Vector3 optimizedObjectPoint;
348  Scalar finalError = 0;
349  if (!Utilities::optimizeObjectPointIF(pinholeCamera, posesIF.data(), imagePoints.data(), (unsigned int)imagePoints.size(), initialObjectPoint, optimizedObjectPoint, &finalError) || finalError > Scalar(0.7 * 0.7))
350  {
351  candidateIsValid = false;
352  return PosePointPairsObject();
353  }
354 
355  PosePointPairs posePointPairs;
356  posePointPairs.reserve(imagePoints.size());
357 
358  for (size_t n = 0; n < imagePoints.size(); ++n)
359  {
360  const unsigned int imageId = dataContainer.registerImagePoint<true>(imagePoints[n]);
361  posePointPairs.push_back(PosePointPair(candidatePoseIds[n], imageId));
362  }
363 
364  const unsigned int objectId = dataContainer.registerObjectPoint<true>(optimizedObjectPoint);
365 
366  candidateIsValid = false;
367  return PosePointPairsObject(objectId, std::move(posePointPairs));
368  }
369 
370 #ifdef OCEAN_DEBUG
371  ocean_assert(candidateSuccessiveImagePoints.size() == candidateSuccessiveRays.size());
372  for (size_t n = 0; n < candidateSuccessiveImagePoints.size(); ++n)
373  ocean_assert(candidateSuccessiveImagePoints[n].size() == candidateSuccessiveRays[n].size());
374 #endif
375 
376  return PosePointPairsObject();
377 }
378 
379 template <unsigned int tSuccessiveFrames>
381 {
382  ocean_assert(!candidateSuccessiveImagePoints.empty());
383 
384  for (size_t n = 0; n < candidateSuccessiveImagePoints.back().size(); ++n)
385  occupancyArray += candidateSuccessiveImagePoints.back()[n];
386 }
387 
388 template <unsigned int tSuccessiveFrames>
392 {
393  // nothing to do here
394 }
395 
396 template <unsigned int tSuccessiveFrames>
397 PosePointPairsObjects AdvancedPointTracker<tSuccessiveFrames>::newPose(const PinholeCamera& pinholeCamera, const unsigned int poseId, const Vectors2& imagePoints, const bool useCameraDistortionParameters, Geometry::SpatialDistribution::OccupancyArray* externalOccupancyArray, const bool updateExternalOccupancyArray)
398 {
399  ocean_assert(DataContainer::get().hasPose<true>(poseId));
400 
401  const HomogenousMatrix4 pose(DataContainer::get().pose<true>(poseId));
402  const HomogenousMatrix4 poseIF(DataContainer::get().poseIF<true>(poseId));
403 
404  PosePointPairsObjects posePointPairsObjects;
405 
406  // try to retrack the current candidates
407  if (!trackerCandidates.empty())
408  {
409  const Geometry::SpatialDistribution::DistributionArray imagePointsDistibution(Geometry::SpatialDistribution::distributeToArray<20u>(imagePoints.data(), (unsigned int)imagePoints.size(), Scalar(0), Scalar(0), Scalar(pinholeCamera.width()), Scalar(pinholeCamera.height()), trackerSearchRadius));
410 
411  for (size_t n = 0; n < trackerCandidates.size(); ++n)
412  {
413  Candidate& candidate = trackerCandidates[n];
414 
415  if (candidate.isValid())
416  {
417  PosePointPairsObject posePointPairsObject(candidate.newPose(pinholeCamera, pose, poseIF, poseId, imagePoints, useCameraDistortionParameters, imagePointsDistibution, trackerSearchRadius, trackerSqrProjectionDistance));
418 
419  if (posePointPairsObject)
420  posePointPairsObjects.push_back(std::move(posePointPairsObject));
421 
422  // check whether the candidate point has become invalid
423  if (!candidate.isValid())
424  trackerInvalidCandidates.push_back((unsigned int)n);
425  }
426  }
427  }
428 
429  // internal occupancy array
430  Geometry::SpatialDistribution::OccupancyArray internalOccupancyArray(determineOccupancyArray(pinholeCamera, 50u, 50u)); // **TODO**
431 
432  // try to add new candidates in free image areas
433 
434  if (trackerCandidates.empty())
435  trackerCandidates.reserve(imagePoints.size());
436 
437  //Frame frame(FrameType(pinholeCamera.width(), pinholeCamera.height(), FrameType::FORMAT_RGB24, FrameType::ORIGIN_UPPER_LEFT));
438  //memset(frame.data(), 0xFF, frame.size());
439 
440  if (externalOccupancyArray)
441  {
442  for (Vectors2::const_iterator i = imagePoints.begin(); i != imagePoints.end(); ++i)
443  //if (!internalOccupancyArray(*i))
444  if (!internalOccupancyArray.isOccupiedNeighborhood9(*i))
445  //if (!internalOccupancyArray.isOccupiedNeighborhood9(*i))
446  {
447  /*const unsigned int externalHorizontalBin = externalOccupancyArray->horizontalBin(i->x());
448  const unsigned int externalVerticalBin = externalOccupancyArray->verticalBin(i->y());
449 
450  unsigned char& isExternalOccupied = (*externalOccupancyArray)(externalHorizontalBin, externalVerticalBin);
451 
452  if (!isExternalOccupied)*/
453 
454  if (!externalOccupancyArray->isOccupiedNeighborhood9(*i))
455  //if (!(*externalOccupancyArray)(*i))
456  {
457  //const unsigned char color[3] = {0x00, 0x00, 0x00};
458  //CV::Canvas::ellipticRegion(frame, CV::PixelPosition(int(i->x()), int(i->y())), 7u, 7u, color);
459 
460  if (trackerInvalidCandidates.empty())
461  trackerCandidates.push_back(Candidate(pinholeCamera, pose, *i, useCameraDistortionParameters, poseId));
462  else
463  {
464  trackerCandidates[trackerInvalidCandidates.back()].replace(pinholeCamera, pose, *i, useCameraDistortionParameters, poseId);
465  trackerInvalidCandidates.pop_back();
466  }
467 
468  internalOccupancyArray += *i;
469 
470  //if (updateExternalOccupancyArray)
471  // isExternalOccupied = 1u;
472  }
473  }
474  }
475  else
476  {
477  for (Vectors2::const_iterator i = imagePoints.begin(); i != imagePoints.end(); ++i)
478  if (!internalOccupancyArray.isOccupiedNeighborhood9(*i))
479  {
480  if (trackerInvalidCandidates.empty())
481  trackerCandidates.push_back(Candidate(pinholeCamera, pose, *i, useCameraDistortionParameters, poseId));
482  else
483  {
484  trackerCandidates[trackerInvalidCandidates.back()].replace(pinholeCamera, pose, *i, useCameraDistortionParameters, poseId);
485  trackerInvalidCandidates.pop_back();
486  }
487  }
488  }
489 
490  /*const unsigned char color[3] = {0x00, 0x00, 0x00};
491 
492  for (unsigned int y = 0u; y < externalOccupancyArray->verticalBins(); ++y)
493  for (unsigned int x = 0u; x < externalOccupancyArray->horizontalBins(); ++x)
494  {
495  if ((*externalOccupancyArray)(x, y))
496  {
497  const int x0 = int(x) * int(pinholeCamera.width()) / int(externalOccupancyArray->horizontalBins());
498  const int y0 = int(y) * int(pinholeCamera.height()) / int(externalOccupancyArray->verticalBins());
499 
500  const int x1 = int(x + 1) * int(pinholeCamera.width()) / int(externalOccupancyArray->horizontalBins());
501  const int y1 = int(y + 1) * int(pinholeCamera.height()) / int(externalOccupancyArray->verticalBins());
502 
503  CV::Canvas::line(frame, x0, y0, x1, y1, color);
504  CV::Canvas::line(frame, x1, y0, x0, y1, color);
505  }
506  }
507 
508 
509  for (size_t n = 0; n < trackerCandidates.size(); ++n)
510  {
511  Candidate& candidate = trackerCandidates[n];
512 
513  if (candidate.isValid())
514  {
515  for (size_t n = 0; n < candidate.candidateSuccessiveImagePoints.back().size(); ++n)
516  CV::Canvas::ellipticRegion(frame, CV::PixelPosition(int(candidate.candidateSuccessiveImagePoints.back()[n].x()), int(candidate.candidateSuccessiveImagePoints.back()[n].y())), 7u, 7u, color);
517  }
518  }*/
519 
520  //Platform::Win::Utilities::desktopFrameOutput(2000, 0, frame);
521  //Sleep(1000);
522 
523  return posePointPairsObjects; // **TODO**
524 }
525 
526 template <unsigned int tSuccessiveFrames>
527 Geometry::SpatialDistribution::OccupancyArray AdvancedPointTracker<tSuccessiveFrames>::determineOccupancyArray(const PinholeCamera& pinholeCamera, const unsigned int horizontalBins, const unsigned int verticalBins)
528 {
529  ocean_assert(pinholeCamera.isValid());
530  ocean_assert(horizontalBins >= 0u && verticalBins >= 0u);
531 
532  Geometry::SpatialDistribution::OccupancyArray occupancyArray(Scalar(0), Scalar(0), Scalar(pinholeCamera.width()), Scalar(pinholeCamera.height()), horizontalBins, verticalBins);
533 
534  for (Candidates::const_iterator i = trackerCandidates.begin(); i != trackerCandidates.end(); ++i)
535  if (i->isValid())
536  i->add2OccupancyArray(occupancyArray);
537 
538  return occupancyArray;
539 }
540 
541 }
542 
543 }
544 
545 }
546 
547 #endif // META_OCEAN_TRACKING_POINT_ADVANCED_POINT_TRACKER_H
This class implements a distribution array.
Definition: SpatialDistribution.h:228
This class implements an occupancy array.
Definition: SpatialDistribution.h:370
bool isOccupiedNeighborhood9(const unsigned int horizontal, const unsigned int vertical) const
Returns whether at least one bin in the 8-neighborhood or the specified bin itself is occupied.
Definition: SpatialDistribution.h:1328
static Indices32 determineNeighbors(const ImagePoint &imagePoint, const ImagePoint *candidatePoints, const size_t numberCandidatePoints, const Scalar radius, const DistributionArray &distributionCandidatePoints)
Determines all candidate points for a given image point (interest point) lying inside a specified cir...
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
This class implements an infinite line in 2D space.
Definition: Line2.h:83
T sqrDistance(const VectorT2< T > &point) const
Returns the square distance between the line and a given point.
Definition: Line2.h:498
unsigned int width() const
Returns the width of the camera image.
Definition: PinholeCamera.h:1300
LineT3< T > ray(const VectorT2< T > &position, const HomogenousMatrixT4< T > &world_T_camera, const T zoom=T(1)) const
Returns a ray starting at the camera's center and intersection a given 2D point on the image plane.
Definition: PinholeCamera.h:2378
VectorT2< T > distort(const VectorT2< T > &undistorted) const
Returns the distorted position of a given undistorted position defined in pixel coordinates.
Definition: PinholeCamera.h:1418
VectorT2< T > undistort(const VectorT2< T > &distorted, const unsigned int iterations=10u, const T zoom=T(1)) const
Returns the undistorted position of a given distorted position defined in pixel coordinates.
Definition: PinholeCamera.h:1373
bool isValid() const
Returns whether this camera is valid.
Definition: PinholeCamera.h:1572
unsigned int height() const
Returns the height of the camera image.
Definition: PinholeCamera.h:1306
VectorT2< T > projectToImageIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > &objectPoint, const bool distortImagePoint, const T zoom=T(1)) const
Projects a 3D object point to the 2D image plane of the camera by a given inverse camera pose.
Definition: PinholeCamera.h:1816
const T * data() const
Returns the buffer data pointer.
Definition: StaticBuffer.h:240
size_t size() const
Returns the size of this vector.
Definition: StaticVector.h:340
bool occupied() const
Returns whether no free space is left.
Definition: StaticVector.h:346
void unstableErase(const size_t index)
Erases one element from this vector.
Definition: StaticVector.h:506
void weakResize(const size_t size)
Resizes this vector.
Definition: StaticVector.h:534
bool empty() const
Returns whether this vector hold no element.
Definition: StaticVector.h:487
void pushBack(const T &value)
Adds a new element to this vector.
Definition: StaticVector.h:352
const T & back() const
Returns the last elements of this vector.
Definition: StaticVector.h:471
Definition: AdvancedPointTracker.h:44
bool candidateIsValid
Definition: AdvancedPointTracker.h:78
void add2OccupancyArray(Geometry::SpatialDistribution::OccupancyArray &occupancyArray) const
Definition: AdvancedPointTracker.h:380
StaticVector< StaticVectors2, tSuccessiveFrames > StaticVectors2Set
Definition: AdvancedPointTracker.h:50
void replace(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &firstPose, const Vector2 &firstImagePoint, const bool useCameraDistortionParameters, const unsigned int firstPoseId)
Definition: AdvancedPointTracker.h:128
bool isValid() const
Definition: AdvancedPointTracker.h:162
StaticLines3Set candidateSuccessiveRays
Definition: AdvancedPointTracker.h:74
StaticVector< Line2, 10u > StaticLines2
Definition: AdvancedPointTracker.h:52
PosePointPairsObject newPose(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &pose, const HomogenousMatrix4 &poseIF, const unsigned int poseId, const Vectors2 &imagePoints, const bool useCameraDistortionParameters, const Geometry::SpatialDistribution::DistributionArray &imagePointsDistribution, const Scalar searchRadius, const Scalar sqrProjectionDistanceconst)
Definition: AdvancedPointTracker.h:168
StaticVector< Vector2, 10u > StaticVectors2
Definition: AdvancedPointTracker.h:49
StaticVectors2Set candidateSuccessiveImagePoints
Definition: AdvancedPointTracker.h:72
StaticPoseIndices candidatePoseIds
Definition: AdvancedPointTracker.h:76
Candidate(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &firstPose, const Vector2 &firstImagePoint, const bool useCameraDistortionParameters, const unsigned int firstPoseId)
Definition: AdvancedPointTracker.h:105
StaticVector< unsigned int, tSuccessiveFrames > StaticPoseIndices
Definition: AdvancedPointTracker.h:47
StaticVector< StaticLines2, tSuccessiveFrames > StaticLines2Set
Definition: AdvancedPointTracker.h:53
StaticVector< Line3, 10u > StaticLines3
Definition: AdvancedPointTracker.h:55
StaticVector< StaticLines3, tSuccessiveFrames > StaticLines3Set
Definition: AdvancedPointTracker.h:56
This class implements an advanced point tracker.
Definition: AdvancedPointTracker.h:40
AdvancedPointTracker()
Definition: AdvancedPointTracker.h:389
Scalar trackerSqrProjectionDistance
Definition: AdvancedPointTracker.h:97
PosePointPairsObjects newPose(const PinholeCamera &pinholeCamera, const unsigned int poseId, const Vectors2 &imagePoints, const bool useCameraDistortionParameters, Geometry::SpatialDistribution::OccupancyArray *externalOccupancyArray=nullptr, const bool updateOccupancyArray=true)
Definition: AdvancedPointTracker.h:397
std::vector< Candidate > Candidates
Definition: AdvancedPointTracker.h:81
Geometry::SpatialDistribution::OccupancyArray determineOccupancyArray(const PinholeCamera &pinholeCamera, const unsigned int horizontalBins, const unsigned int verticalBins)
Definition: AdvancedPointTracker.h:527
Candidates trackerCandidates
Definition: AdvancedPointTracker.h:99
Scalar trackerSearchRadius
Definition: AdvancedPointTracker.h:95
Indices32 trackerInvalidCandidates
Definition: AdvancedPointTracker.h:101
Definition of a simple struct combining a pose and an image point id.
Definition: PosePointPair.h:51
Definition of an object that combines an object id with the pairs of poses and image points.
Definition: PosePointPair.h:100
static bool determineInitialObjectPoint(const Line3 *rays, const size_t numberRays, Vector3 &objectPoint, const bool checkFrontPosition=true)
Determines an initial 3D position from several 3D rays that start at the camera center and intersect ...
T sqrDistance(const VectorT2< T > &right) const
Returns the square distance between this 2D position and a second 2D position.
Definition: Vector2.h:633
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition: base/Utilities.h:1089
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition: Base.h:96
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
std::vector< PosePointPair > PosePointPairs
Definition of a vector holding pose point pairs.
Definition: PosePointPair.h:29
std::vector< PosePointPairsObject > PosePointPairsObjects
Definition of a vector holding pose objects.
Definition: PosePointPair.h:38
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15