8 #ifndef META_OCEAN_TRACKING_DATABASE_H
9 #define META_OCEAN_TRACKING_DATABASE_H
79 static inline Vector3 invalidObjectPoint();
128 inline Index32 imagePointId()
const;
134 inline void setImagePointId(
const Index32 imagePointId);
159 inline Index32 objectPointId()
const;
165 inline void setObjectPointId(
const Index32 objectPointId);
196 inline void setPoseId(
const Index32 poseId);
261 template <
bool tThreadSafe>
278 virtual size_t size()
const;
285 virtual const Vector2& operator[](
const size_t& index)
const;
300 template <
bool tThreadSafe>
317 virtual size_t size()
const;
324 virtual const Vector2& operator[](
const size_t& index)
const;
339 template <
bool tThreadSafe>
356 virtual size_t size()
const;
363 virtual const Vector3& operator[](
const size_t& index)
const;
378 template <
bool tThreadSafe>
395 virtual size_t size()
const;
417 template <
bool tThreadSafe>
434 virtual size_t size()
const;
478 inline const Vector2& point()
const;
490 inline Index32 objectPointId()
const;
496 inline void setPoint(
const Vector2& point);
502 inline void setPoseId(
const Index32 poseId);
508 inline void setObjectPointId(
const Index32 objectPointId);
533 inline const IndexSet32& imagePointIds()
const;
539 inline void registerImagePoint(
const Index32 imagePointId);
545 inline void unregisterImagePoint(
const Index32 imagePointId);
577 inline Scalar fov()
const;
589 inline void setFov(
const Scalar fov);
618 inline const Vector3& point()
const;
624 inline Scalar priority()
const;
630 inline void setPoint(
const Vector3& point);
636 inline void setPriority(
const Scalar priority);
702 template <
bool tThreadSafe>
703 inline bool isEmpty()
const;
709 template <
bool tThreadSafe>
710 inline size_t poseNumber()
const;
716 template <
bool tThreadSafe>
717 inline size_t objectPointNumber()
const;
723 template <
bool tThreadSafe>
724 inline size_t imagePointNumber()
const;
733 template <
bool tThreadSafe>
734 inline const Vector2& imagePoint(
const Index32 imagePointId)
const;
742 template <
bool tThreadSafe>
751 template <
bool tThreadSafe>
763 template <
bool tThreadSafe>
773 template <
bool tThreadSafe>
774 inline const Vector3& objectPoint(
const Index32 objectPointId)
const;
784 template <
bool tThreadSafe>
785 inline const Vector3& objectPoint(
const Index32 objectPointId,
Scalar& objectPointPriority)
const;
794 template <
bool tThreadSafe>
795 inline Scalar objectPointPriority(
const Index32 objectPointId)
const;
802 template <
bool tThreadSafe>
803 inline Vectors3 objectPoints()
const;
815 template <
bool tThreadSafe,
bool tMatchPosition>
824 template <
bool tThreadSafe>
835 template <
bool tThreadSafe>
846 template <
bool tThreadSafe>
858 template <
bool tThreadSafe>
870 template <
bool tThreadSafe,
bool tMatchPose>
881 template <
bool tThreadSafe>
893 template <
bool tThreadSafe,
bool tMatchPose>
905 template <
bool tThreadSafe>
906 inline bool poseBorders(
Index32& lowerPoseId,
Index32& upperPoseId)
const;
917 template <
bool tThreadSafe>
918 inline bool validPoseBorders(
Index32& rangeLowerPoseId,
Index32& rangeUpperPoseId)
const;
931 template <
bool tThreadSafe>
944 template <
bool tThreadSafe>
945 inline bool largestValidPoseRange(
const Index32 lowerPoseId,
const Index32 upperPoseId,
Index32& rangeLowerPoseId,
Index32& rangeUpperPoseId)
const;
960 template <
bool tThreadSafe,
bool tMatchPosition,
bool tNeedVal
idPose>
961 inline bool poseWithMostCorrespondences(
const Index32 lowerPoseId,
const Index32 upperPoseId,
Index32* poseId =
nullptr,
unsigned int* correspondences =
nullptr,
const Vector3& referenceObjectPoint = invalidObjectPoint())
const;
975 template <
bool tThreadSafe,
bool tMatchPosition,
bool tNeedVal
idPose>
976 inline bool poseWithLeastCorrespondences(
const Index32 lowerPoseId,
const Index32 upperPoseId,
Index32* poseId =
nullptr,
unsigned int* correspondences =
nullptr,
const Vector3& referenceObjectPoint = invalidObjectPoint())
const;
991 template <
bool tThreadSafe>
1001 template <
bool tThreadSafe>
1002 inline unsigned int numberObservations(
const Index32 poseId,
const Indices32& objectPointIds)
const;
1014 template <
bool tThreadSafe,
bool tMatchPosition,
bool tNeedVal
idPose>
1015 inline unsigned int numberCorrespondences(
const Index32 poseId,
const Vector3& referenceObjectPoint,
const Scalar minimalPriority =
Scalar(-1))
const;
1029 template <
bool tThreadSafe,
bool tMatchPosition,
bool tNeedVal
idPose>
1039 template <
bool tThreadSafe>
1040 inline bool hasImagePoint(
const Index32 imagePointId,
Vector2* imagePoint =
nullptr)
const;
1048 template <
bool tThreadSafe>
1057 template <
bool tThreadSafe>
1058 inline void removeImagePoint(
const Index32 imagePointId);
1067 template <
bool tThreadSafe>
1068 inline bool hasObjectPoint(
const Index32 objectPointId,
Vector3* objectPoint =
nullptr)
const;
1079 template <
bool tThreadSafe>
1093 template <
bool tThreadSafe>
1109 inline Index32 addObjectPointFromDatabase(
const Database& secondDatabase,
const Index32 secondDatabaseObjectPointId,
const SquareMatrix3& imagePointTransformation =
SquareMatrix3(
true),
const Index32 newObjectPointId = invalidId,
const Index32 secondDatabaseLowerPoseId = invalidId,
const Index32 secondDatabaseUpperPoseId = invalidId,
const bool forExistingPosesOnly =
false);
1117 template <
bool tThreadSafe>
1118 inline void removeObjectPoint(
const Index32 objectPointId);
1125 template <
bool tThreadSafe>
1126 void removeObjectPointAndAttachedImagePoints(
const Index32 objectPointId);
1135 template <
bool tThreadSafe>
1136 inline void renameObjectPoint(
const Index32 oldObjectPointId,
const Index32 newObjectPointId);
1147 template <
bool tThreadSafe>
1148 inline void mergeObjectPoints(
const Index32 remainingObjectPointId,
const Index32 removingObjectPointId,
const Vector3& newPoint,
const Scalar newPriority);
1157 template <
bool tThreadSafe>
1168 template <
bool tThreadSafe>
1177 template <
bool tThreadSafe>
1178 inline void removePose(
const Index32 poseId);
1188 template <
bool tThreadSafe>
1189 inline Index32 poseFromImagePoint(
const Index32 imagePointId)
const;
1197 template <
bool tThreadSafe>
1198 inline size_t numberImagePointsFromObjectPoint(
const Index32 objectPointId)
const;
1208 template <
bool tThreadSafe>
1220 template <
bool tThreadSafe>
1231 template <
bool tThreadSafe>
1232 inline Index32 objectPointFromImagePoint(
const Index32 imagePointId)
const;
1241 template <
bool tThreadSafe>
1251 template <
bool tThreadSafe>
1252 inline const IndexSet32& imagePointsFromObjectPoint(
const Index32 objectPointId)
const;
1260 template <
bool tThreadSafe>
1269 template <
bool tThreadSafe>
1270 inline void attachImagePointToObjectPoint(
const Index32 imagePointId,
const Index32 objectPointId);
1276 template <
bool tThreadSafe>
1277 inline void detachImagePointFromObjectPoint(
const Index32 imagePointId);
1285 template <
bool tThreadSafe>
1286 inline void attachImagePointToPose(
const Index32 imagePointId,
const Index32 poseId);
1292 template <
bool tThreadSafe>
1293 inline void detachImagePointFromPose(
const Index32 imagePointId);
1301 template <
bool tThreadSafe>
1302 inline void setImagePoint(
const Index32 imagePointId,
const Vector2& imagePoint);
1311 template <
bool tThreadSafe>
1312 inline void setObjectPoint(
const Index32 objectPointId,
const Vector3& objectPoint);
1322 template <
bool tThreadSafe>
1323 inline void setObjectPoints(
const Index32* objectPointIds,
const Vector3* objectPoints,
const size_t number);
1334 template <
bool tThreadSafe>
1335 inline void setObjectPoints(
const Index32* objectPointIds,
const size_t number,
const Vector3& referenceObjectPoint);
1343 template <
bool tThreadSafe>
1344 inline void setObjectPoints(
const Vector3& objectPoint = invalidObjectPoint());
1353 template <
bool tThreadSafe>
1354 inline void setObjectPoint(
const Index32 objectPointId,
const Vector3& objectPoint,
const Scalar priority);
1362 template <
bool tThreadSafe>
1363 inline void setObjectPointPriority(
const Index32 objectPointId,
const Scalar priority);
1371 template <
bool tThreadSafe>
1382 template <
bool tThreadSafe>
1391 template <
bool tThreadSafe>
1400 template <
bool tThreadSafe>
1409 template <
bool tThreadSafe>
1419 template <
bool tThreadSafe>
1429 template <
bool tThreadSafe>
1438 template <
bool tThreadSafe>
1448 template <
bool tThreadSafe>
1457 template <
bool tThreadSafe>
1466 template <
bool tThreadSafe>
1479 template <
bool tThreadSafe,
bool tMatchPosition>
1492 template <
bool tThreadSafe,
bool tMatchPosition>
1505 template <
bool tThreadSafe,
bool tMatchPosition>
1515 template <
bool tThreadSafe>
1528 template <
bool tThreadSafe,
bool tMatchPosition>
1538 template <
bool tThreadSafe>
1554 template <
bool tThreadSafe,
bool tMatchPosition,
bool tVisibleInAllPoses>
1569 template <
bool tThreadSafe,
bool tMatchPosition,
bool tVisibleInAllPoses>
1580 template <
bool tThreadSafe>
1593 template <
bool tThreadSafe>
1607 template <
bool tThreadSafe>
1622 template <
bool tThreadSafe>
1633 template <
bool tThreadSafe>
1645 template <
bool tThreadSafe>
1646 IdIdPointPairsMap imagePoints(
const Index32 poseId,
const bool previous,
const size_t minimalObservations = 2,
const size_t maximalObservations = 0)
const;
1657 template <
bool tThreadSafe>
1672 template <
bool tThreadSafe,
bool tMatchPosition>
1673 void imagePointsObjectPoints(
const Index32 poseId,
Vectors2& imagePoints,
Vectors3& objectPoints,
const Vector3& referencePosition = invalidObjectPoint(),
const size_t minimalObservations = 0,
Indices32* imagePointIds =
nullptr,
Indices32* objectPointIds =
nullptr)
const;
1694 template <
bool tThreadSafe,
bool tMatchPosition>
1695 void imagePointsObjectPoints(
const Index32 poseId,
const IndexSet32& priorityIds,
Vectors2& priorityImagePoints,
Vectors3& priorityObjectPoints,
Vectors2& remainingImagePoints,
Vectors3& remainingObjectPoints,
const Vector3& referencePosition = invalidObjectPoint(),
const size_t minimalObservations = 0,
Indices32* priorityImagePointIds =
nullptr,
Indices32* priorityObjectPointIds =
nullptr,
Indices32* remainingImagePointIds =
nullptr,
Indices32* remainingObjectPointIds =
nullptr)
const;
1710 template <
bool tThreadSafe,
bool tMatchPose>
1719 template <
bool tThreadSafe>
1726 template <
bool tThreadSafe>
1727 inline void clear();
1736 template <
bool tThreadSafe>
1754 template <
typename T,
bool tThreadSafe>
1755 void reset(
const size_t numberPoses,
const Index32* poseIds,
const HomogenousMatrixT4<T>* poses,
const size_t numberObjectPoints,
const Index32* objectPointIds,
const VectorT3<T>* objectPoints,
const T* objectPointPriorities,
const size_t numberImagePoints,
const Index32* imagePointIds,
const VectorT2<T>* imagePoints,
const Index32* topologyPoseIds,
const Index32* topologyObjectPointIds);
1787 static inline Indices32 reliableObjectPoints(
const TopologyTriples& topologyTriples,
const unsigned int minimalObservations);
1815 explicit inline operator bool()
const;
1830 template <
bool tMatchPosition,
bool tNeedVal
idPose>
1831 void numberCorrespondencesSubset(
const Index32 lowerPoseId,
const Vector3* referenceObjectPoint,
const Scalar minimalPriority,
unsigned int* correspondences,
const unsigned int firstPose,
const unsigned int numberPoses)
const;
1845 template <
bool tMatchPosition>
1846 void objectPointIdsWithNumberOfObservationsSubset(
const Index32* objectPointIds,
const Vector3* referencePosition,
const Scalar minimalPriority,
IndexPairs32* pairs,
Lock* lock,
const unsigned int firstObjectPoint,
const unsigned int numberObjectPoints)
const;
1854 inline unsigned int numberValidPoses(
const Index32 objectPointId,
const IndexSet32& imagePointIds)
const;
1910 template <
bool tThreadSafe>
1912 accessorDatabase(database),
1913 accessorImagePointIds(imagePointIds)
1918 template <
bool tThreadSafe>
1921 return accessorImagePointIds.size();
1924 template <
bool tThreadSafe>
1927 ocean_assert(index < accessorImagePointIds.size());
1928 return accessorDatabase.imagePoint<tThreadSafe>(accessorImagePointIds[index]);
1931 template <
bool tThreadSafe>
1933 accessorDatabase(database),
1934 accessorTopology(topology)
1939 template <
bool tThreadSafe>
1942 return accessorTopology.size();
1945 template <
bool tThreadSafe>
1948 ocean_assert(index < accessorTopology.size());
1949 return accessorDatabase.imagePoint<tThreadSafe>(accessorTopology[index].imagePointId());
1952 template <
bool tThreadSafe>
1954 accessorDatabase(database),
1960 template <
bool tThreadSafe>
1963 return accessorObjectPointIds.size();
1966 template <
bool tThreadSafe>
1969 ocean_assert(index < accessorObjectPointIds.size());
1970 return accessorDatabase.objectPoint<tThreadSafe>(accessorObjectPointIds[index]);
1973 template <
bool tThreadSafe>
1975 accessorDatabase(database),
1981 template <
bool tThreadSafe>
1984 return accessorPoseIds.size();
1987 template <
bool tThreadSafe>
1990 ocean_assert(index < accessorPoseIds.size());
1991 return accessorDatabase.pose<tThreadSafe>(accessorPoseIds[index]);
1994 template <
bool tThreadSafe>
1996 accessorDatabase(database),
1997 accessorTopology(topology)
2002 template <
bool tThreadSafe>
2005 return accessorTopology.size();
2008 template <
bool tThreadSafe>
2011 ocean_assert(index < accessorTopology.size());
2012 return accessorDatabase.pose<tThreadSafe>(accessorTopology[index].poseId());
2016 objectImagePointId(imagePointId)
2023 return objectImagePointId;
2028 objectImagePointId = imagePointId;
2032 objectObjectPointId(objectPointId)
2039 return objectObjectPointId;
2044 objectObjectPointId = objectPointId;
2048 objectPoseId(poseId)
2055 return objectPoseId;
2060 objectPoseId = poseId;
2089 dataObjectPointId(objectPointId)
2106 return dataObjectPointId;
2116 dataPoseId = poseId;
2121 dataObjectPointId = objectPointId;
2126 return dataImagePointIds;
2131 ocean_assert(dataImagePointIds.find(imagePointId) == dataImagePointIds.end());
2132 dataImagePointIds.insert(imagePointId);
2137 ocean_assert(dataImagePointIds.find(imagePointId) != dataImagePointIds.end());
2138 dataImagePointIds.erase(imagePointId);
2142 world_T_camera_(world_T_camera),
2150 return world_T_camera_;
2160 world_T_camera_ = world_T_camera;
2170 dataPriority(priority)
2182 return dataPriority;
2192 dataPriority = priority;
2204 databasePoseMap(database.databasePoseMap),
2205 databaseObjectPointMap(database.databaseObjectPointMap),
2206 databaseImagePointMap(database.databaseImagePointMap),
2207 databasePoseObjectPointMap(database.databasePoseObjectPointMap),
2208 databasePoses(database.databasePoses),
2209 databaseObjectPointIdCounter(database.databaseObjectPointIdCounter),
2210 databaseImagePointIdCounter(database.databaseImagePointIdCounter)
2216 databasePoseMap(std::move(database.databasePoseMap)),
2217 databaseObjectPointMap(std::move(database.databaseObjectPointMap)),
2218 databaseImagePointMap(std::move(database.databaseImagePointMap)),
2219 databasePoseObjectPointMap(std::move(database.databasePoseObjectPointMap)),
2220 databasePoses(database.databasePoses),
2221 databaseObjectPointIdCounter(database.databaseObjectPointIdCounter),
2222 databaseImagePointIdCounter(database.databaseImagePointIdCounter)
2224 database.databasePoses = 0u;
2225 database.databaseObjectPointIdCounter = invalidId;
2226 database.databaseImagePointIdCounter = invalidId;
2234 template <
bool tThreadSafe>
2242 template <
bool tThreadSafe>
2250 template <
bool tThreadSafe>
2258 template <
bool tThreadSafe>
2266 template <
bool tThreadSafe>
2269 ocean_assert(imagePointId !=
invalidId);
2277 template <
bool tThreadSafe>
2296 template <
bool tThreadSafe>
2315 template <
bool tThreadSafe>
2327 if (!point && !pointId)
2334 *point = iI->second.point();
2337 *pointId = iI->first;
2342 template <
bool tThreadSafe>
2345 ocean_assert(objectPointId !=
invalidId);
2353 template <
bool tThreadSafe>
2356 ocean_assert(objectPointId !=
invalidId);
2364 return i->second.point();
2367 template <
bool tThreadSafe>
2370 ocean_assert(objectPointId !=
invalidId);
2378 template <
bool tThreadSafe>
2392 template <
bool tThreadSafe,
bool tMatchPosition>
2408 if (i->second.priority() >= minimalPriority && ((tMatchPosition && i->second.point() == referencePosition) || (!tMatchPosition && i->second.point() != referencePosition)))
2417 if (i->second.priority() >= minimalPriority && ((tMatchPosition && i->second.point() == referencePosition) || (!tMatchPosition && i->second.point() != referencePosition)))
2424 template <
bool tThreadSafe>
2443 template <
bool tThreadSafe>
2454 template <
bool tThreadSafe>
2457 ocean_assert(
poseIds !=
nullptr && size != 0);
2462 result.reserve(size);
2464 for (
size_t n = 0; n < size; ++n)
2473 template <
bool tThreadSafe>
2476 ocean_assert(
poseIds !=
nullptr && size != 0);
2481 result.reserve(size);
2483 for (
size_t n = 0; n < size; ++n)
2496 template <
bool tThreadSafe,
bool tMatchPose>
2512 if ((tMatchPose && i->second.pose() == referencePose) || (!tMatchPose && i->second.pose() != referencePose))
2514 poses.push_back(i->second.pose());
2521 if ((tMatchPose && i->second.pose() == referencePose) || (!tMatchPose && i->second.pose() != referencePose))
2522 poses.push_back(i->second.pose());
2528 template <
bool tThreadSafe>
2531 ocean_assert(lowerPoseId <= upperPoseId);
2536 poses.reserve(upperPoseId - lowerPoseId + 1u);
2538 for (
unsigned int n = lowerPoseId; n <= upperPoseId; ++n)
2543 poses.push_back(i->second.pose());
2551 template <
bool tThreadSafe,
bool tMatchPose>
2567 if ((tMatchPose && i->second.pose() == referencePose) || (!tMatchPose && i->second.pose() != referencePose))
2570 poses->push_back(i->second.pose());
2576 if ((tMatchPose && i->second.pose() == referencePose) || (!tMatchPose && i->second.pose() != referencePose))
2583 template <
bool tThreadSafe>
2597 template <
bool tThreadSafe>
2609 if (i->second.pose().isValid())
2611 rangeLowerPoseId = i->first;
2619 if (i->second.pose().isValid())
2621 rangeUpperPoseId = i->first;
2625 ocean_assert(rangeLowerPoseId <= rangeUpperPoseId);
2629 template <
bool tThreadSafe>
2633 ocean_assert_and_suppress_unused(lowerPoseId <= startPoseId && startPoseId <= upperPoseId, lowerPoseId);
2641 rangeLowerPoseId = startPoseId;
2642 rangeUpperPoseId = startPoseId;
2644 for (
unsigned int id = startPoseId - 1;
id != (
unsigned int)(-1); --id)
2651 rangeLowerPoseId = id;
2654 for (
unsigned int id = startPoseId + 1u;
id <= upperPoseId; ++id)
2661 rangeUpperPoseId = id;
2667 template <
bool tThreadSafe>
2670 ocean_assert(lowerPoseId <= upperPoseId);
2672 if (lowerPoseId > upperPoseId)
2679 unsigned int bestRangeSize = 0u;
2680 unsigned int firstIndex = (
unsigned int)(-1);
2682 for (
unsigned int n = 0u; n < rangePoses.size(); ++n)
2685 if (rangePoses[n].isValid())
2688 else if (!rangePoses[n].isValid())
2690 const unsigned int lastIndex = n - 1u;
2691 ocean_assert(
firstIndex >= 0u && lastIndex < (
unsigned int)rangePoses.size());
2693 const unsigned int rangeSize = lastIndex -
firstIndex + 1u;
2695 if (rangeSize > bestRangeSize)
2697 bestRangeSize = rangeSize;
2699 rangeUpperPoseId = lastIndex + lowerPoseId;
2702 if (rangePoses.size() - n < bestRangeSize)
2710 return bestRangeSize != 0u;
2712 const unsigned int lastIndex = (
unsigned int)rangePoses.size() - 1u;
2713 ocean_assert(
firstIndex >= 0u && lastIndex < (
unsigned int)rangePoses.size());
2715 const unsigned int rangeSize = lastIndex -
firstIndex + 1u;
2716 if (rangeSize > bestRangeSize)
2719 rangeUpperPoseId = lastIndex + lowerPoseId;
2721 bestRangeSize = rangeSize;
2724 ocean_assert(bestRangeSize != 0u);
2728 template <
bool tThreadSafe,
bool tMatchPosition,
bool tNeedVal
idPose>
2732 ocean_assert(lowerPoseId <= upperPoseId);
2737 unsigned int bestCorrespondences = 0u;
2739 for (
unsigned int id = lowerPoseId;
id <= upperPoseId; ++id)
2741 const unsigned int value = numberCorrespondences<false, tMatchPosition, tNeedValidPose>(
id, referenceObjectPoint);
2742 if (value > bestCorrespondences)
2744 bestCorrespondences = value;
2750 *poseId = bestPoseId;
2752 if (correspondences)
2753 *correspondences = bestCorrespondences;
2755 return bestCorrespondences != 0u;
2758 template <
bool tThreadSafe,
bool tMatchPosition,
bool tNeedVal
idPose>
2762 ocean_assert(lowerPoseId <= upperPoseId);
2767 unsigned int worstCorrespondences = (
unsigned int)(-1);
2771 for (
unsigned int id = lowerPoseId;
id <= upperPoseId; ++id)
2773 if (tNeedValidPose && (!hasPose<false>(
id, &
pose) || !
pose.
isValid()))
2776 const unsigned int value = numberCorrespondences<false, tMatchPosition, false>(
id, referenceObjectPoint);
2777 if (value < worstCorrespondences)
2779 worstCorrespondences = value;
2785 *poseId = worstPoseId;
2787 if (correspondences)
2788 *correspondences = worstCorrespondences;
2790 return worstCorrespondences != (
unsigned int)(-1);
2793 template <
bool tThreadSafe>
2796 ocean_assert(!poseCandidates.empty());
2797 ocean_assert(!majorObjectPointIds.empty());
2799 if (majorObjectPointIds.empty())
2804 unsigned int bestMajorCount = 0u;
2805 unsigned int bestMinorCount = 0u;
2809 for (IndexSet32::const_iterator iP = poseCandidates.begin(); iP != poseCandidates.end(); ++iP)
2813 unsigned int majorCount = 0u;
2814 unsigned int remaining = (
unsigned int)majorObjectPointIds.size();
2816 for (IndexSet32::const_iterator i = majorObjectPointIds.begin(); majorCount + remaining >= bestMajorCount && i != majorObjectPointIds.end(); ++i)
2824 if (majorCount >= bestMajorCount)
2826 unsigned int minorCount = 0u;
2827 remaining = (
unsigned int)minorObjectPointIds.size();
2829 for (IndexSet32::const_iterator i = minorObjectPointIds.begin(); minorCount + remaining >= bestMinorCount && i != minorObjectPointIds.end(); ++i)
2837 if (majorCount > bestMajorCount || minorCount > bestMinorCount)
2839 bestPoseId = poseId;
2840 bestMajorCount = majorCount;
2841 bestMinorCount = minorCount;
2851 if (visibleMajorObjectPointIds)
2853 ocean_assert(visibleMajorObjectPointIds->empty());
2854 visibleMajorObjectPointIds->clear();
2855 visibleMajorObjectPointIds->reserve(bestMajorCount);
2857 for (IndexSet32::const_iterator i = majorObjectPointIds.begin(); i != majorObjectPointIds.end(); ++i)
2859 visibleMajorObjectPointIds->push_back(*i);
2861 ocean_assert(bestMajorCount == visibleMajorObjectPointIds->size());
2864 if (visibleMinorObjectPointIds)
2866 ocean_assert(visibleMinorObjectPointIds->empty());
2867 visibleMinorObjectPointIds->clear();
2868 visibleMinorObjectPointIds->reserve(minorObjectPointIds.size());
2870 for (IndexSet32::const_iterator i = minorObjectPointIds.begin(); i != minorObjectPointIds.end(); ++i)
2872 visibleMinorObjectPointIds->push_back(*i);
2874 ocean_assert(bestMinorCount == visibleMinorObjectPointIds->size());
2880 template <
bool tThreadSafe>
2887 unsigned int number = 0u;
2896 template <
bool tThreadSafe,
bool tMatchPosition,
bool tNeedVal
idPose>
2904 if (iP ==
databasePoseMap.end() || (tNeedValidPose && !(iP->second.pose().isValid())))
2907 unsigned int count = 0u;
2918 if (iO->second.priority() >= minimalPriority && ((tMatchPosition && iO->second.point() == referenceObjectPoint) || (!tMatchPosition && iO->second.point() != referenceObjectPoint)))
2925 template <
bool tThreadSafe,
bool tMatchPosition,
bool tNeedVal
idPose>
2928 ocean_assert(lowerPoseId <= upperPoseId);
2930 const unsigned int frames = upperPoseId - lowerPoseId + 1u;
2936 if (worker && frames >= 20u)
2938 result.resize(frames);
2940 worker->
executeFunction(
Worker::Function::create(*
this, &Database::numberCorrespondencesSubset<tMatchPosition, tNeedValidPose>, lowerPoseId, &referenceObjectPoint, minimalPriority, result.
data(), 0u, 0u), 0u, frames);
2944 result.reserve(frames);
2946 for (
unsigned int n = lowerPoseId; n <= upperPoseId; ++n)
2947 result.push_back(numberCorrespondences<false, tMatchPosition, tNeedValidPose>(n, referenceObjectPoint, minimalPriority));
2953 template <
bool tThreadSafe>
2969 template <
bool tThreadSafe>
2978 template <
bool tThreadSafe>
2981 ocean_assert(imagePointId !=
invalidId);
2996 iP->second.unregisterImagePoint(imagePointId);
3004 iO->second.unregisterImagePoint(imagePointId);
3010 template <
bool tThreadSafe>
3026 template <
bool tThreadSafe>
3037 template <
bool tThreadSafe>
3050 ocean_assert(secondDatabase.
hasObjectPoint<
false>(secondDatabaseObjectPointId));
3051 ocean_assert(!imagePointTransformation.
isSingular());
3052 ocean_assert(secondDatabaseLowerPoseId ==
invalidId || secondDatabaseUpperPoseId ==
invalidId || secondDatabaseLowerPoseId <= secondDatabaseUpperPoseId);
3062 ocean_assert(newObjectPointId ==
invalidId || hasObjectPoint<false>(newObjectPointId) ==
false);
3065 if (hasObjectPoint<false>(newObjectPointId))
3071 thisDatabaseObjectPointId = newObjectPointId;
3082 for (IndexSet32::const_iterator i = secondDatabaseImagePointIds.cbegin(); i != secondDatabaseImagePointIds.cend(); ++i)
3084 const Index32& secondDatabaseImagePointId = *i;
3092 if ((secondDatabaseLowerPoseId !=
invalidId && poseId < secondDatabaseLowerPoseId)
3093 || (secondDatabaseUpperPoseId !=
invalidId && poseId > secondDatabaseUpperPoseId))
3099 if (!hasPose<false>(poseId))
3101 if (forExistingPosesOnly)
3111 const bool addPoseResult = addPose<false>(poseId,
pose);
3112 ocean_assert_and_suppress_unused(addPoseResult, addPoseResult);
3121 const Index32 thisDatabaseImagePointId = addImagePoint<false>(imagePointTransformation *
imagePoint);
3123 attachImagePointToObjectPoint<false>(thisDatabaseImagePointId, thisDatabaseObjectPointId);
3124 attachImagePointToPose<false>(thisDatabaseImagePointId, poseId);
3127 return thisDatabaseObjectPointId;
3130 template <
bool tThreadSafe>
3133 ocean_assert(objectPointId !=
invalidId);
3161 template <
bool tThreadSafe>
3164 ocean_assert(objectPointId !=
invalidId);
3180 if (iImagePoint->second.poseId() !=
invalidId)
3186 const Index32 poseId = iImagePoint->second.poseId();
3191 iPose->second.unregisterImagePoint(imagePointId);
3199 template <
bool tThreadSafe>
3218 ocean_assert(iIData->second.objectPointId() == oldObjectPointId);
3219 iIData->second.setObjectPointId(newObjectPointId);
3232 template <
bool tThreadSafe>
3235 ocean_assert(remainingObjectPointId !=
invalidId && removingObjectPointId !=
invalidId && remainingObjectPointId != removingObjectPointId);
3242 ObjectPointMap::const_iterator iObjectPointRemoving =
databaseObjectPointMap.find(removingObjectPointId);
3246 const IndexSet32 debugPoseIdsRemaining = posesFromObjectPoint<false>(remainingObjectPointId);
3247 const IndexSet32 debugPoseIdsRemoving = posesFromObjectPoint<false>(removingObjectPointId);
3251 for (
const Index32& imagePointIdRemoving : iObjectPointRemoving->second.imagePointIds())
3253 iObjectPointRemaining->second.registerImagePoint(imagePointIdRemoving);
3258 const Index32 poseIdRemoving = iImagePointRemoving->second.poseId();
3266 iImagePointRemoving->second.setObjectPointId(remainingObjectPointId);
3269 iObjectPointRemaining->second.setPoint(newPoint);
3270 iObjectPointRemaining->second.setPriority(newPriority);
3275 template <
bool tThreadSafe>
3287 *
pose = i->second.pose();
3292 template <
bool tThreadSafe>
3300 ocean_assert(
false &&
"Invalid pose id!");
3311 template <
bool tThreadSafe>
3336 template <
bool tThreadSafe>
3339 ocean_assert(imagePointId !=
invalidId);
3346 return i->second.poseId();
3349 template <
bool tThreadSafe>
3352 ocean_assert(objectPointId !=
invalidId);
3359 const IndexSet32& ids = iO->second.imagePointIds();
3364 template <
bool tThreadSafe>
3367 ocean_assert(objectPointId !=
invalidId);
3376 const IndexSet32& ids = iO->second.imagePointIds();
3384 for (IndexSet32::const_iterator i = ids.begin(); i != ids.end(); ++i)
3391 poseIds.push_back(iI->second.poseId());
3400 template <
bool tThreadSafe>
3403 ocean_assert(objectPointId !=
invalidId);
3404 ocean_assert(!poseIdCandidates.empty() && validPoseIndices.empty());
3411 for (
size_t n = 0; n < poseIdCandidates.size(); ++n)
3413 const Index32 poseId = poseIdCandidates[n];
3419 validPoseIndices.push_back((
unsigned int)n);
3433 template <
bool tThreadSafe>
3436 ocean_assert(imagePointId !=
invalidId);
3443 return i->second.objectPointId();
3446 template <
bool tThreadSafe>
3456 return i->second.imagePointIds();
3459 template <
bool tThreadSafe>
3462 ocean_assert(objectPointId !=
invalidId);
3469 return i->second.imagePointIds();
3472 template <
bool tThreadSafe>
3475 ocean_assert(objectPointId !=
invalidId);
3484 for (
const Index32& imagePointId : iObjectPoint->second.imagePointIds())
3489 result.emplace(iImagePoint->second.poseId());
3495 template <
bool tThreadSafe>
3504 ocean_assert(iI->second.objectPointId() ==
invalidId);
3506 iI->second.setObjectPointId(objectPointId);
3511 iO->second.registerImagePoint(imagePointId);
3515 const Index64 poseObjectPointId(
index64(iI->second.poseId(), objectPointId));
3522 template <
bool tThreadSafe>
3525 ocean_assert(imagePointId !=
invalidId);
3532 const Index32 objectPointId = iI->second.objectPointId();
3533 ocean_assert(objectPointId !=
invalidId);
3540 iO->second.unregisterImagePoint(imagePointId);
3544 const Index64 poseObjectPointId(
index64(iI->second.poseId(), objectPointId));
3551 template <
bool tThreadSafe>
3560 ocean_assert(iI->second.poseId() ==
invalidId);
3562 iI->second.setPoseId(poseId);
3567 iP->second.registerImagePoint(imagePointId);
3569 if (iI->second.objectPointId() !=
invalidId)
3571 const Index64 poseObjectPointId(
index64(poseId, iI->second.objectPointId()));
3578 template <
bool tThreadSafe>
3581 ocean_assert(imagePointId !=
invalidId);
3588 const Index32 poseId = iI->second.poseId();
3596 iP->second.unregisterImagePoint(imagePointId);
3598 if (iI->second.objectPointId() !=
invalidId)
3600 const Index64 poseObjectPointId(
index64(poseId, iI->second.objectPointId()));
3607 template <
bool tThreadSafe>
3610 ocean_assert(imagePointId !=
invalidId);
3620 template <
bool tThreadSafe>
3623 ocean_assert(objectPointId !=
invalidId);
3633 template <
bool tThreadSafe>
3640 for (
size_t n = 0; n < number; ++ n)
3649 template <
bool tThreadSafe>
3656 for (
size_t n = 0; n < number; ++ n)
3661 i->second.setPoint(referenceObjectPoint);
3665 template <
bool tThreadSafe>
3674 template <
bool tThreadSafe>
3677 ocean_assert(objectPointId !=
invalidId);
3685 i->second.setPriority(priority);
3688 template <
bool tThreadSafe>
3691 ocean_assert(objectPointId !=
invalidId);
3698 i->second.setPriority(priority);
3701 template <
bool tThreadSafe>
3711 i->second.setPose(
pose);
3714 template <
bool tThreadSafe>
3721 for (
size_t n = 0; n < number; ++n)
3726 i->second.setPose(
poses[n]);
3730 template <
bool tThreadSafe>
3737 ocean_assert(n >= 0);
3738 const unsigned int poseId = (
unsigned int)n;
3743 i->second.setPose(
poses[n]);
3747 template <
bool tThreadSafe>
3753 i->second.setPose(
pose);
3756 template <
bool tThreadSafe>
3766 return i->second.imagePointIds();
3769 template <
bool tThreadSafe>
3791 ids.push_back(iPO->second);
3792 validObjectPointIds.push_back(*i);
3800 template <
bool tThreadSafe>
3812 result.emplace_back(i->first);
3821 result.emplace_back(i->first);
3828 template <
bool tThreadSafe>
3843 result.emplace_back(i->first);
3852 result.emplace_back(i->first);
3856 if (priorities !=
nullptr)
3858 priorities->clear();
3863 priorities->emplace_back(i->second.priority());
3870 template <
bool tThreadSafe>
3873 if (outlierObjectPointIds.empty())
3874 return objectPointIds<tThreadSafe>();
3882 if (outlierObjectPointIds.find(i->first) == outlierObjectPointIds.end())
3883 result.push_back(i->first);
3888 template <
bool tThreadSafe>
3896 if (world_T_cameras !=
nullptr)
3898 world_T_cameras->clear();
3903 result.emplace_back(i->first);
3905 world_T_cameras->emplace_back(i->second.pose());
3912 result.emplace_back(i->first);
3919 template <
bool tThreadSafe>
3931 result.reserve(iP->second.imagePointIds().size());
3936 for (IndexSet32::const_iterator i = iP->second.imagePointIds().begin(); i != iP->second.imagePointIds().end(); ++i)
3943 result.push_back(iI->second.point());
3952 template <
bool tThreadSafe,
bool tMatchPosition>
3965 if (i->second.priority() >= minimalPriority && ((tMatchPosition && i->second.point() == referencePosition) || (!tMatchPosition && i->second.point() != referencePosition)))
3974 if (i->second.priority() >= minimalPriority && ((tMatchPosition && i->second.point() == referencePosition) || (!tMatchPosition && i->second.point() != referencePosition)))
3981 template <
bool tThreadSafe,
bool tMatchPosition>
3994 if (i->second.priority() >= minimalPriority && ((tMatchPosition && i->second.point() == referencePosition) || (!tMatchPosition && i->second.point() != referencePosition))
3995 && outlierObjectPointIds.find(i->first) == outlierObjectPointIds.end())
4004 if (i->second.priority() >= minimalPriority && ((tMatchPosition && i->second.point() == referencePosition) || (!tMatchPosition && i->second.point() != referencePosition))
4005 && outlierObjectPointIds.find(i->first) == outlierObjectPointIds.end())
4012 template <
bool tThreadSafe,
bool tMatchPosition>
4029 worker->
executeFunction(
Worker::Function::create(*
this, &Database::objectPointIdsWithNumberOfObservationsSubset<tMatchPosition>, (
const Index32*)
objectPointIds.data(), &referencePosition, minimalPriority, &result, &
lock, 0u, 0u), 0u, (
unsigned int)
objectPointIds.size());
4032 objectPointIdsWithNumberOfObservationsSubset<tMatchPosition>((
const Index32*)
objectPointIds.data(), &referencePosition, minimalPriority, &result,
nullptr, 0u, (
unsigned int)
objectPointIds.size());
4037 template <
bool tThreadSafe>
4063 const Index32 objectPointId = iI->second.objectPointId();
4067 result.push_back(objectPointId);
4077 ocean_assert(
IndexSet32(result.begin(), result.end()).size() == result.size());
4082 template <
bool tThreadSafe,
bool tMatchPosition>
4108 const Index32 objectPointId = iI->second.objectPointId();
4117 if (iO->second.priority() >= minimalPriority && ((tMatchPosition &&
objectPoint == referencePosition) || (!tMatchPosition &&
objectPoint != referencePosition)))
4119 result.push_back(objectPointId);
4127 ocean_assert(
IndexSet32(result.begin(), result.end()).size() == result.size());
4132 template <
bool tThreadSafe>
4135 ocean_assert(!
poseIds.empty());
4142 for (Indices32::const_iterator iP =
poseIds.begin(); iP !=
poseIds.end(); ++iP)
4156 const Index32 objectPointId = iI->second.objectPointId();
4174 result.push_back(*i);
4184 template <
bool tThreadSafe,
bool tMatchPosition,
bool tVisibleInAllPoses>
4187 ocean_assert(lowerPoseId <= upperPoseId);
4192 if constexpr (tVisibleInAllPoses)
4196 const PoseMap::const_iterator iPM =
databasePoseMap.find(lowerPoseId);
4211 const Index32 objectPointId = iI->second.objectPointId();
4218 if (iO->second.priority() >= minimalPriority && ((tMatchPosition && iO->second.point() == referencePosition) || (!tMatchPosition && iO->second.point() != referencePosition)))
4220 bool visibleInAllPoses =
true;
4221 for (
unsigned int n = lowerPoseId + 1u; visibleInAllPoses && n <= upperPoseId; ++n)
4224 if (visibleInAllPoses)
4226 result.push_back(objectPointId);
4235 ocean_assert(
IndexSet32(result.begin(), result.end()).size() == result.size());
4245 for (
unsigned int n = lowerPoseId; n <= upperPoseId; ++n)
4260 const Index32 objectPointId = iI->second.objectPointId();
4269 if (iO->second.priority() >= minimalPriority && ((tMatchPosition && iO->second.point() == referencePosition) || (!tMatchPosition && iO->second.point() != referencePosition)))
4271 result.push_back(objectPointId);
4281 ocean_assert(
IndexSet32(result.begin(), result.end()).size() == result.size());
4288 template <
bool tThreadSafe,
bool tMatchPosition,
bool tVisibleInAllPoses>
4299 if constexpr (tVisibleInAllPoses)
4318 const Index32 objectPointId = iI->second.objectPointId();
4325 if (iO->second.priority() >= minimalPriority && ((tMatchPosition && iO->second.point() == referencePosition) || (!tMatchPosition && iO->second.point() != referencePosition)))
4327 bool visibleInAllPoses =
true;
4328 for (
size_t n = 1; n <
poseIds.size(); ++n)
4331 if (visibleInAllPoses)
4333 result.push_back(objectPointId);
4342 ocean_assert(
IndexSet32(result.begin(), result.end()).size() == result.size());
4352 for (
size_t n = 0; n <
poseIds.size(); ++n)
4367 const Index32 objectPointId = iI->second.objectPointId();
4376 if (iO->second.priority() >= minimalPriority && ((tMatchPosition && iO->second.point() == referencePosition) || (!tMatchPosition && iO->second.point() != referencePosition)))
4378 result.push_back(objectPointId);
4388 ocean_assert(
IndexSet32(result.begin(), result.end()).size() == result.size());
4395 template <
bool tThreadSafe>
4424 if (iI->second.objectPointId() !=
invalidId)
4426 result.push_back(iI->second.point());
4436 template <
bool tThreadSafe>
4461 points.push_back(iI->second.point());
4462 validObjectPointIds.push_back(*i);
4473 template <
bool tThreadSafe>
4483 template <
bool tThreadSafe>
4493 points.reserve(numberObjectPointIds);
4495 for (
size_t n = 0; n < numberObjectPointIds; ++n)
4507 points.push_back(iI->second.point());
4508 validIndices.push_back((
unsigned int)n);
4518 template <
bool tThreadSafe>
4521 ocean_assert(!
poseIds.empty());
4528 for (Indices32::const_iterator iP =
poseIds.begin(); iP !=
poseIds.end(); ++iP)
4540 if (i->second.objectPointId() !=
invalidId)
4541 intermediate[i->second.objectPointId()].push_back(i->second.point());
4547 for (ImagePointsMap::iterator i = intermediate.begin(); i != intermediate.end(); ++i)
4548 if (i->second.size() ==
poseIds.size())
4552 for (
size_t n = 0; n <
poseIds.size(); ++n)
4553 result[n].push_back(i->second[n]);
4559 template <
bool tThreadSafe>
4563 ocean_assert(maximalObservations == 0 || minimalObservations <= maximalObservations);
4572 const PoseData& poseData = iP->second;
4579 const Index32 objectPointId = i->second.objectPointId();
4584 imagePointPairs.push_back(std::make_pair(*iI, i->second.point()));
4589 while (((previous && pId-- != 0u) || (!previous && ++pId <
databasePoses)) && (maximalObservations == 0 || imagePointPairs.size() < maximalObservations))
4599 imagePointPairs.push_back(std::make_pair(iPO->second, otherPO->second.point()));
4602 if (minimalObservations == 0 || imagePointPairs.size() >= minimalObservations)
4603 result[objectPointId] = imagePointPairs;
4610 template <
bool tThreadSafe>
4614 ocean_assert(pose0 != pose1);
4616 ocean_assert(points0.size() == points1.size());
4623 const PoseData& poseData0 = iP0->second;
4630 ocean_assert(iI0->second.poseId() == pose0);
4631 if (iI0->second.objectPointId() !=
invalidId)
4640 points0.push_back(iI0->second.point());
4641 points1.push_back(iI1->second.point());
4650 template <
bool tThreadSafe,
bool tMatchPosition>
4664 const PoseData& poseData = iPose->second;
4684 if (iImagePoint->second.objectPointId() !=
invalidId)
4686 const ObjectPointMap::const_iterator iObjectPoint =
databaseObjectPointMap.find(iImagePoint->second.objectPointId());
4689 if (((tMatchPosition && iObjectPoint->second.point() == referencePosition) || (!tMatchPosition && iObjectPoint->second.point() != referencePosition)) && (minimalObservations == 0 || iObjectPoint->second.imagePointIds().size() >= minimalObservations))
4691 imagePoints.push_back(iImagePoint->second.point());
4708 template <
bool tThreadSafe,
bool tMatchPosition>
4709 void Database::imagePointsObjectPoints(
const Index32 poseId,
const IndexSet32& priorityIds,
Vectors2& priorityImagePoints,
Vectors3& priorityObjectPoints,
Vectors2& remainingImagePoints,
Vectors3& remainingObjectPoints,
const Vector3& referencePosition,
const size_t minimalObservations,
Indices32* priorityImagePointIds,
Indices32* priorityObjectPointIds,
Indices32* remainingImagePointIds,
Indices32* remainingObjectPointIds)
const
4712 ocean_assert(priorityImagePoints.empty() && priorityObjectPoints.empty());
4713 ocean_assert(remainingImagePoints.empty() && remainingObjectPoints.empty());
4715 ocean_assert(priorityImagePointIds ==
nullptr || priorityImagePointIds->empty());
4716 ocean_assert(priorityObjectPointIds ==
nullptr || priorityObjectPointIds->empty());
4717 ocean_assert(remainingImagePointIds ==
nullptr || remainingImagePointIds->empty());
4718 ocean_assert(remainingObjectPointIds ==
nullptr || remainingObjectPointIds->empty());
4720 ocean_assert(!priorityIds.empty());
4727 const PoseData& poseData = iP->second;
4729 priorityImagePoints.reserve(poseData.
imagePointIds().size());
4730 priorityObjectPoints.reserve(poseData.
imagePointIds().size());
4732 remainingImagePoints.reserve(poseData.
imagePointIds().size());
4733 remainingObjectPoints.reserve(poseData.
imagePointIds().size());
4735 if (priorityImagePointIds)
4736 priorityImagePointIds->reserve(poseData.
imagePointIds().size());
4738 if (priorityObjectPointIds)
4739 priorityObjectPointIds->reserve(poseData.
imagePointIds().size());
4741 if (remainingImagePointIds)
4742 remainingImagePointIds->reserve(poseData.
imagePointIds().size());
4744 if (remainingObjectPointIds)
4745 remainingObjectPointIds->reserve(poseData.
imagePointIds().size());
4752 if (iI->second.objectPointId() !=
invalidId)
4757 if (((tMatchPosition && iO->second.point() == referencePosition) || (!tMatchPosition && iO->second.point() != referencePosition)) && (minimalObservations == 0 || iO->second.imagePointIds().size() >= minimalObservations))
4759 ocean_assert(iO->first == iI->second.objectPointId());
4761 if (priorityIds.find(iO->first) != priorityIds.end())
4763 priorityImagePoints.push_back(iI->second.point());
4764 priorityObjectPoints.push_back(iO->second.point());
4766 if (priorityImagePointIds)
4767 priorityImagePointIds->push_back(iI->first);
4769 if (priorityObjectPointIds)
4770 priorityObjectPointIds->push_back(iI->second.objectPointId());
4774 remainingImagePoints.push_back(iI->second.point());
4775 remainingObjectPoints.push_back(iO->second.point());
4777 if (remainingImagePointIds)
4778 remainingImagePointIds->push_back(iI->first);
4780 if (remainingObjectPointIds)
4781 remainingObjectPointIds->push_back(iI->second.objectPointId());
4788 template <
bool tThreadSafe,
bool tMatchPose>
4791 ocean_assert(objectPointId !=
invalidId);
4802 const IndexSet32& imagePointCandidateIds = iO->second.imagePointIds();
4804 poses.reserve(imagePointCandidateIds.size());
4805 imagePoints.reserve(imagePointCandidateIds.size());
4808 poseIds->reserve(imagePointCandidateIds.size());
4813 for (IndexSet32::const_iterator i = imagePointCandidateIds.begin(); i != imagePointCandidateIds.end(); ++i)
4819 const Index32 poseId = iI->second.poseId();
4821 if (poseId ==
invalidId || (lowerPoseId !=
invalidId && poseId < lowerPoseId) || (upperPoseId !=
invalidId && poseId > upperPoseId))
4829 if ((tMatchPose &&
pose == referencePose) || (!tMatchPose &&
pose != referencePose))
4845 template <
bool tThreadSafe>
4848 ocean_assert(!
poseIds.empty());
4854 for (Indices32::const_iterator iiP =
poseIds.begin(); iiP !=
poseIds.end(); ++iiP)
4859 const IndexSet32& poseImagePoints = iP->second.imagePointIds();
4861 for (IndexSet32::const_iterator iI = poseImagePoints.begin(); iI != poseImagePoints.end(); ++iI)
4866 const Index32 objectPointId = i->second.objectPointId();
4876 template <
bool tThreadSafe>
4892 template <
bool tThreadSafe>
4899 i->second.setPoint(referenceObjectPoint);
4904 i->second.setPose(referencePose);
4908 template <
typename T,
bool tThreadSafe>
4909 void Database::reset(
const size_t numberPoses,
const Index32* poseIds,
const HomogenousMatrixT4<T>* poses,
const size_t numberObjectPoints,
const Index32* objectPointIds,
const VectorT3<T>* objectPoints,
const T* objectPointPriorities,
const size_t numberImagePoints,
const Index32* imagePointIds,
const VectorT2<T>* imagePoints,
const Index32* topologyPoseIds,
const Index32* topologyObjectPointIds)
4919 for (
size_t n = 0; n < numberPoses; ++n)
4933 for (
size_t n = 0; n < numberObjectPoints; ++n)
4950 ocean_assert(objectPointId !=
invalidId);
4957 for (
size_t n = 0; n < numberImagePoints; ++n)
4962 const Index32& topologyPoseId = topologyPoseIds[n];
4963 const Index32& topologyObjectPointId = topologyObjectPointIds[n];
4981 ocean_assert(imagePointId !=
invalidId);
4988 ocean_assert(!
poseIds.empty());
4995 result.push_back(n);
5009 result.push_back(n);
5023 result.push_back(n);
5035 ocean_assert(i->objectPointId() !=
invalidId);
5036 objectPointCounterMap[i->objectPointId()]++;
5042 for (Index32To32Map::const_iterator i = objectPointCounterMap.begin(); i != objectPointCounterMap.end(); ++i)
5043 if (i->second >= minimalObservations)
5051 if (
this != &database)
5068 if (
this != &database)
5070 databasePoseMap = std::move(database.databasePoseMap);
5071 databaseObjectPointMap = std::move(database.databaseObjectPointMap);
5072 databaseImagePointMap = std::move(database.databaseImagePointMap);
5073 databasePoseObjectPointMap = std::move(database.databasePoseObjectPointMap);
5075 databasePoses = database.databasePoses;
5076 databaseObjectPointIdCounter = database.databaseObjectPointIdCounter;
5077 databaseImagePointIdCounter = database.databaseImagePointIdCounter;
5079 database.databasePoses = 0u;
5080 database.databaseObjectPointIdCounter = invalidId;
5081 database.databaseImagePointIdCounter = invalidId;
5087 inline Database::operator bool()
const
5089 return !isEmpty<false>();
5092 template <
bool tMatchPosition,
bool tNeedVal
idPose>
5095 ocean_assert(numberPoses >= 1u);
5096 ocean_assert(referenceObjectPoint && correspondences);
5098 for (
unsigned int n = firstPose; n < firstPose + numberPoses; ++n)
5099 correspondences[n] = numberCorrespondences<false, tMatchPosition, tNeedValidPose>(lowerPoseId + n, *referenceObjectPoint, minimalPriority);
5102 template <
bool tMatchPosition>
5108 localPairs.reserve(numberObjectPoints);
5110 for (
unsigned int n = firstObjectPoint; n < firstObjectPoint + numberObjectPoints; ++n)
5113 if (i->second.priority() >= minimalPriority && ((tMatchPosition && i->second.point() == *referencePosition) || (!tMatchPosition && i->second.point() != *referencePosition)))
5114 localPairs.push_back(std::make_pair(i->first,
numberValidPoses(i->first, i->second.imagePointIds())));
5120 pairs->insert(pairs->end(), localPairs.begin(), localPairs.end());
5123 *pairs = std::move(localPairs);
5128 ocean_assert_and_suppress_unused(objectPointId !=
invalidId, objectPointId);
5133 unsigned int validPoses = 0u;
5140 const Index32 poseId = iI->second.poseId();
5156 return Index32(index & 0xFFFFFFFFull);
static Caller< void > create(CT &object, typename MemberFunctionPointerMaker< CT, void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a member function with no function parameter.
Definition: Caller.h:3023
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition: Accessor.h:241
SquareMatrixT3< T > rotationMatrix() const
Returns the rotation matrix of the transformation.
Definition: HomogenousMatrix4.h:1493
VectorT3< T > translation() const
Returns the translation of the transformation.
Definition: HomogenousMatrix4.h:1381
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
This class implements a recursive lock object.
Definition: Lock.h:31
This class provides basic numeric functionalities.
Definition: Numeric.h:57
static constexpr T minValue()
Returns the min scalar value.
Definition: Numeric.h:3250
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
This class implements a vector with shifted elements.
Definition: ShiftVector.h:27
std::ptrdiff_t Index
Definition of an element index.
Definition: ShiftVector.h:38
bool isSingular() const
Returns whether this matrix is singular (and thus cannot be inverted).
Definition: SquareMatrix3.h:1341
static bool hasIntersectingElement(const TIterator &firstA, const TIterator &endA, const TIterator &firstB, const TIterator &endB)
Determines whether two (ordered) sets have at least one intersecting element.
Definition: Subset.h:977
This class implements a recursive scoped lock object that is activated by a boolean template paramete...
Definition: Lock.h:178
This class implements an accessor object for image points based on a set of image point ids.
Definition: Database.h:263
virtual size_t size() const
Returns the number of image points of this accessor.
Definition: Database.h:1919
ConstImagePointAccessorIds(const Database &database, const Indices32 &imagePointIds)
Creates a new accessor object by providing the references of the database and the image point ids.
Definition: Database.h:1911
const Indices32 & accessorImagePointIds
The reference to the image point ids.
Definition: Database.h:293
virtual const Vector2 & operator[](const size_t &index) const
Returns a specific image point identified by the index within from the specified image point ids.
Definition: Database.h:1925
const Database & accessorDatabase
The reference to the database holding the individual image points.
Definition: Database.h:290
This class implements an accessor object for image points based on a topology between poses and image...
Definition: Database.h:302
virtual size_t size() const
Returns the number of image points of this accessor.
Definition: Database.h:1940
const PoseImagePointTopology & accessorTopology
The topology between poses and image points.
Definition: Database.h:332
const Database & accessorDatabase
The reference to the database holding the individual image points.
Definition: Database.h:329
ConstImagePointAccessorTopology(const Database &database, const PoseImagePointTopology &topology)
Creates a new accessor object by providing the references of the database and the topology.
Definition: Database.h:1932
virtual const Vector2 & operator[](const size_t &index) const
Returns a specific image point identified by the index within from the specified topology.
Definition: Database.h:1946
This class implements an accessor object for object points based on a set of object point ids.
Definition: Database.h:341
ConstObjectPointAccessorIds(const Database &database, const Indices32 &objectPointIds)
Creates a new accessor object by providing the references of the database and the object point ids.
Definition: Database.h:1953
const Database & accessorDatabase
The reference to the database holding the individual object points.
Definition: Database.h:368
const Indices32 & accessorObjectPointIds
The reference to the object point ids.
Definition: Database.h:371
virtual const Vector3 & operator[](const size_t &index) const
Returns a specific object point identified by the index within from the specified object point ids.
Definition: Database.h:1967
virtual size_t size() const
Returns the number of object points of this accessor.
Definition: Database.h:1961
This class implements an accessor object for poses based on a set of pose ids.
Definition: Database.h:380
const Indices32 & accessorPoseIds
The reference to the pose ids.
Definition: Database.h:410
virtual size_t size() const
Returns the number of poses of this accessor.
Definition: Database.h:1982
virtual const HomogenousMatrix4 & operator[](const size_t &index) const
Returns a specific pose identified by the index within from the specified pose ids.
Definition: Database.h:1988
const Database & accessorDatabase
The reference to the database holding the individual object points.
Definition: Database.h:407
ConstPoseAccessorIds(const Database &database, const Indices32 &poseIds)
Creates a new accessor object by providing the references of the database and the pose ids.
Definition: Database.h:1974
This class implements an accessor object for poses based on a topology between poses and image points...
Definition: Database.h:419
ConstPoseAccessorTopology(const Database &database, const PoseImagePointTopology &topology)
Creates a new accessor object by providing the references of the database and the topology.
Definition: Database.h:1995
virtual const HomogenousMatrix4 & operator[](const size_t &index) const
Returns a specific pose identified by the index within from the specified topology.
Definition: Database.h:2009
virtual size_t size() const
Returns the number of poses of this accessor.
Definition: Database.h:2003
const Database & accessorDatabase
The reference to the database holding the individual image points.
Definition: Database.h:446
const PoseImagePointTopology & accessorTopology
The topology between poses and image points.
Definition: Database.h:449
The base class for all data object storing a set of image point ids.
Definition: Database.h:526
const IndexSet32 & imagePointIds() const
Returns the image point ids of this object.
Definition: Database.h:2124
IndexSet32 dataImagePointIds
The set of registered image point ids of this object.
Definition: Database.h:550
void registerImagePoint(const Index32 imagePointId)
Registers (adds) a new image point id at this data object.
Definition: Database.h:2129
void unregisterImagePoint(const Index32 imagePointId)
Unregisters (removes) an image point id from this data object.
Definition: Database.h:2135
This class implements a data object storing the information connected with an id of an image point.
Definition: Database.h:458
Index32 poseId() const
Returns the id of the pose which belongs to the image point of this object.
Definition: Database.h:2099
Vector2 dataPoint
The location of the 2D image point of this object.
Definition: Database.h:513
ImagePointData()
Creates a default object.
Definition: Database.h:2078
void setPoint(const Vector2 &point)
Sets the location of the image point of this object.
Definition: Database.h:2109
Index32 dataObjectPointId
The id of the object point which belongs to this object.
Definition: Database.h:519
Index32 objectPointId() const
Returns the ids of the 3D object point which belongs to the image point of this object.
Definition: Database.h:2104
void setPoseId(const Index32 poseId)
Sets the id of the pose belonging to this image point object.
Definition: Database.h:2114
Index32 dataPoseId
The id of the pose which belongs to this object.
Definition: Database.h:516
void setObjectPointId(const Index32 objectPointId)
Sets the id of the object point belonging to this image point object.
Definition: Database.h:2119
const Vector2 & point() const
Returns the 2D location of the image point of this object.
Definition: Database.h:2094
This class implements an object storing an id of an image point.
Definition: Database.h:115
ImagePointObject(const Index32 imagePointId=invalidId)
Creates a new object.
Definition: Database.h:2015
Index32 objectImagePointId
The image point id of this object.
Definition: Database.h:139
void setImagePointId(const Index32 imagePointId)
Sets or changes the id of the image point of this object.
Definition: Database.h:2026
Index32 imagePointId() const
Returns the id of the image point of this object.
Definition: Database.h:2021
The data object encapsulating a 3D object point.
Definition: Database.h:604
void setPoint(const Vector3 &point)
Sets (changes) the 3D object point of this object.
Definition: Database.h:2185
ObjectPointData(const Vector3 &point=invalidObjectPoint(), const Scalar priority=-1)
Creates an object with invalid object point.
Definition: Database.h:2168
void setPriority(const Scalar priority)
Sets (changes) the priority value of this object.
Definition: Database.h:2190
Vector3 dataPoint
The 3D object point of this object.
Definition: Database.h:641
Scalar dataPriority
The priority value of this object.
Definition: Database.h:644
Scalar priority() const
Returns the priority value of this object.
Definition: Database.h:2180
const Vector3 & point() const
Returns the 3D object point of this object.
Definition: Database.h:2175
This class implements an object storing an id of an object point.
Definition: Database.h:146
Index32 objectObjectPointId
The object point id of this object.
Definition: Database.h:170
Index32 objectPointId() const
Returns the id of the object point of this object.
Definition: Database.h:2037
ObjectPointObject(const Index32 objectPointId=invalidId)
Creates a new object.
Definition: Database.h:2031
void setObjectPointId(const Index32 objectPointId)
Sets or changes the id of the object point of this object.
Definition: Database.h:2042
The data object encapsulating a 6DOF camera pose.
Definition: Database.h:557
Scalar dataFov
The field of view value of this object.
Definition: Database.h:597
PoseData(const HomogenousMatrix4 &world_T_camera=HomogenousMatrix4(false), const Scalar fov=-1)
Creates a new object with specified pose.
Definition: Database.h:2141
void setPose(const HomogenousMatrix4 &world_T_camera)
Sets (changes) the pose of this object.
Definition: Database.h:2158
const HomogenousMatrix4 & pose() const
Returns the pose of this object.
Definition: Database.h:2148
void setFov(const Scalar fov)
Sets (changes) the field of view value of this object.
Definition: Database.h:2163
Scalar fov() const
Returns the field of view value of this object.
Definition: Database.h:2153
HomogenousMatrix4 world_T_camera_
The pose of this object.
Definition: Database.h:594
This class stores a pair of pose id and image point id.
Definition: Database.h:231
PoseImagePointPair(const Index32 poseId=invalidId, const Index32 imagePointId=invalidId)
Creates a new pair object.
Definition: Database.h:2071
This class implements an object storing an id of an pose object.
Definition: Database.h:177
PoseObject(const Index32 poseId=invalidId)
Creates a new object.
Definition: Database.h:2047
Index32 objectPoseId
The camera pose id of this object.
Definition: Database.h:201
void setPoseId(const Index32 poseId)
Sets or changes the id of the camera pose of this object.
Definition: Database.h:2058
Index32 poseId() const
Returns the id of the camera pose of this object.
Definition: Database.h:2053
This class defines the topology between a camera pose id, an object point id and an image point id.
Definition: Database.h:213
TopologyTriple(const Index32 poseId=invalidId, const Index32 objectPointId=invalidId, const Index32 imagePointId=invalidId)
Creates a new topology object.
Definition: Database.h:2063
This class implements a database for 3D object points, 2D image points and 6DOF camera poses.
Definition: Database.h:67
bool hasObjectPoint(const Index32 objectPointId, Vector3 *objectPoint=nullptr) const
Returns whether this database holds a specified object point.
Definition: Database.h:3011
bool hasObservation(const Index32 poseId, const Index32 objectPointId, Vector2 *point=nullptr, Index32 *pointId=nullptr) const
Returns whether an object point is visible in a specified frame, and optional the location and id of ...
Definition: Database.h:2316
std::unordered_map< Index64, Index32 > Index64To32Map
Definition of an (unordered) map mapping 64 bit ids to 32 bit ids.
Definition: Database.h:670
unsigned int numberCorrespondences(const Index32 poseId, const Vector3 &referenceObjectPoint, const Scalar minimalPriority=Scalar(-1)) const
Counts the number of correspondences (e.g., valid or invalid) between image and object points for a s...
Definition: Database.h:2897
std::map< Index32, PoseData > PoseMap
Definition of an (ordered) map mapping pose ids to pose data objects, we use an ordered map as poses ...
Definition: Database.h:650
void numberCorrespondencesSubset(const Index32 lowerPoseId, const Vector3 *referenceObjectPoint, const Scalar minimalPriority, unsigned int *correspondences, const unsigned int firstPose, const unsigned int numberPoses) const
Counts the number of valid correspondences between image and object points for a subset of several po...
Definition: Database.h:5093
Lock databaseLock
The lock for the entire database.
Definition: Database.h:1902
std::vector< std::pair< Index32, PoseImagePointTopology > > PoseImagePointTopologyGroups
Definition of a vector holding several groups of pairs of pose and image point ids.
Definition: Database.h:250
void renameObjectPoint(const Index32 oldObjectPointId, const Index32 newObjectPointId)
Renames an object point, changes the id of the object point respectively.
Definition: Database.h:3200
void setObjectPoint(const Index32 objectPointId, const Vector3 &objectPoint)
Sets (changes) an object point without modifying the priority value of the object point.
Definition: Database.h:3621
void setObjectPoints(const Index32 *objectPointIds, const Vector3 *objectPoints, const size_t number)
Sets (changes) a set of object points without modifying the priority value of the object points.
Definition: Database.h:3634
void removeObjectPoint(const Index32 objectPointId)
Removes an object point from this database.
Definition: Database.h:3131
Indices32 objectPointIds(Vectors3 *objectPoints=nullptr, Scalars *priorities=nullptr) const
Returns the ids of all object points that are part of this database.
Definition: Database.h:3829
const IndexSet32 & imagePointIds(const Index32 poseId) const
Returns the ids of all image points visible in a specified camera pose (camera frame).
Definition: Database.h:3757
void clear()
Clears the database including all camera poses, object points, image points and any topology.
Definition: Database.h:4877
IndexPairs32 objectPointIdsWithNumberOfObservations(const Vector3 &referencePosition, const Scalar minimalPriority=Scalar(-1), Worker *worker=nullptr) const
Returns pairs of object point ids combined with counts of valid observations.
Definition: Database.h:4013
std::map< Index32, Vector2 > IdPointMap
Definition of a map mapping ids to 2D image point object.
Definition: Database.h:84
void attachImagePointToPose(const Index32 imagePointId, const Index32 poseId)
Attaches an existing image point to an existing camera pose (defines the topology between an image po...
Definition: Database.h:3552
std::vector< TopologyTriple > TopologyTriples
Definition of a vector holding object of topology triple.
Definition: Database.h:255
std::vector< Vectors2 > ImagePointGroups
Definition of a vector holding 2D vectors.
Definition: Database.h:109
void detachImagePointFromObjectPoint(const Index32 imagePointId)
Detaches an image point from an object point (withdraws the topology).
Definition: Database.h:3523
Vectors2 imagePointsFromObjectPoints(const Index32 poseId, Indices32 &objectPointIds, Indices32 *imagePointIds=nullptr) const
Returns all image points which are located in a specified frame and which are projections of a set of...
Definition: Database.h:4437
bool hasImagePoint(const Index32 imagePointId, Vector2 *imagePoint=nullptr) const
Returns whether this database holds a specified image point.
Definition: Database.h:2954
TopologyTriples topologyTriples(const Indices32 &poseIds) const
Returns topology triples with valid image points ids, object points ids and pose ids for a set of giv...
Definition: Database.h:4846
PoseMap databasePoseMap
The map mapping unique pose ids to pose data instances.
Definition: Database.h:1881
Index32 databaseImagePointIdCounter
The counter for unique image point ids.
Definition: Database.h:1899
const Vector2 & imagePoint(const Index32 imagePointId) const
Returns the location of an image point which is specified by the id of the image point.
Definition: Database.h:2267
static Index64 index64(const Index32 first, const Index32 second)
Returns the 64 bit index composed of two 32 bit indices.
Definition: Database.h:5164
size_t numberImagePointsFromObjectPoint(const Index32 objectPointId) const
Returns the number of image point observations which belong to a given object point.
Definition: Database.h:3350
void setObjectPointPriority(const Index32 objectPointId, const Scalar priority)
Sets (changes) the priority value of an object point.
Definition: Database.h:3689
HomogenousMatrices4 poses(const Index32 *poseIds, const size_t size) const
Returns the 6DOF pose values for all specified pose ids.
Definition: Database.h:2455
void imagePointsObjectPoints(const Index32 poseId, Vectors2 &imagePoints, Vectors3 &objectPoints, const Vector3 &referencePosition=invalidObjectPoint(), const size_t minimalObservations=0, Indices32 *imagePointIds=nullptr, Indices32 *objectPointIds=nullptr) const
Returns corresponding object points and image points for a given camera pose.
Definition: Database.h:4651
static Indices32 filterTopologyTriplesObjectPoints(const TopologyTriples &topologyTriples, const IndexSet32 &objectPointIds)
Filters a set of given topology triples due to a set of given object point ids.
Definition: Database.h:5000
const IndexSet32 & imagePointsFromPose(const Index32 poseId) const
Returns all image points which belong to a given camera pose.
Definition: Database.h:3447
std::vector< IdPointPair > IdPointPairs
Definition of a vector holding pairs of ids and 2D image points.
Definition: Database.h:94
Indices32 poseIds(const HomogenousMatrix4 &referencePose, HomogenousMatrices4 *poses=nullptr) const
Returns the ids of specific 6DOF poses.
Definition: Database.h:2552
ImagePointMap databaseImagePointMap
The map mapping unique image points ids to image point data instances.
Definition: Database.h:1887
static const Index32 invalidId
Definition of an invalid id.
Definition: Database.h:73
void removePose(const Index32 poseId)
Removes a pose from this database.
Definition: Database.h:3312
void removeImagePoint(const Index32 imagePointId)
Removes an image point from this database.
Definition: Database.h:2979
unsigned int numberObservations(const Index32 poseId, const Indices32 &objectPointIds) const
Counts the number of observations of a given set of object point ids for a specific camera frame.
Definition: Database.h:2881
const HomogenousMatrix4 & pose(const Index32 poseId) const
Returns the 6DOF pose of a camera frame which is specified by the id of the pose.
Definition: Database.h:2444
bool hasPose(const Index32 poseId, HomogenousMatrix4 *pose=nullptr) const
Returns whether this database holds a specified camera pose.
Definition: Database.h:3276
void removeObjectPointAndAttachedImagePoints(const Index32 objectPointId)
Removes an object point from this database and also removes all image points attached to the object p...
Definition: Database.h:3162
bool validPoseBorders(Index32 &rangeLowerPoseId, Index32 &rangeUpperPoseId) const
Returns the smallest id (the id of the lower frame border) and the largest id (the id of the upper fr...
Definition: Database.h:2598
std::unordered_map< Index32, Index32 > Index32To32Map
Definition of an (unordered) map mapping 32 bit ids to 32 bit ids.
Definition: Database.h:665
static Index32 secondIndex(const Index64 index)
Returns the second 32 bit index of a 64 bit index.
Definition: Database.h:5159
bool largestValidPoseRange(const Index32 lowerPoseId, const Index32 upperPoseId, Index32 &rangeLowerPoseId, Index32 &rangeUpperPoseId) const
Determines the largest pose id range for which the database holds valid poses.
Definition: Database.h:2668
void observationsFromObjectPoint(const Index32 objectPointId, Indices32 &poseIds, Indices32 &imagePointIds, Vectors2 *imagePoints=nullptr) const
Returns all observations (combination of poses and image points) which belong to a given object point...
Definition: Database.h:3365
void attachImagePointToObjectPoint(const Index32 imagePointId, const Index32 objectPointId)
Attaches an existing image point to an existing object points (defines the topology between an image ...
Definition: Database.h:3496
Database & operator=(const Database &database)
Assign operator copying a second database to this database object.
Definition: Database.h:5049
size_t imagePointNumber() const
Returns the number of image point ids in this database.
Definition: Database.h:2259
SquareMatrices3 rotationalPoses(const Index32 *poseIds, const size_t size) const
Returns the 3DOF rotational part of the 6DOF pose values for all specified pose ids.
Definition: Database.h:2474
Index32 addObjectPoint(const Vector3 &objectPoint, const Scalar priority=Scalar(-1))
Adds a new 3D object point to this database.
Definition: Database.h:3027
const Vector3 & objectPoint(const Index32 objectPointId) const
Returns the location of an object point which is specified by the id of the object point.
Definition: Database.h:2343
ObjectPointMap databaseObjectPointMap
The map mapping unique object point ids to object point data instances.
Definition: Database.h:1884
void reset(const Vector3 &referenceObjectPoint=invalidObjectPoint(), const HomogenousMatrix4 &referencePose=HomogenousMatrix4(false))
Resets the geometric information of this database for 3D object points and 6DOF camera poses.
Definition: Database.h:4893
void setImagePoint(const Index32 imagePointId, const Vector2 &imagePoint)
Sets (changes) an image point.
Definition: Database.h:3608
const IndexSet32 & imagePointsFromObjectPoint(const Index32 objectPointId) const
Returns all image points which belong to a given object point.
Definition: Database.h:3460
Vectors3 objectPoints() const
Returns the positions of all 3D object points.
Definition: Database.h:2379
Index32 addImagePoint(const Vector2 &imagePoint)
Adds a new 2D image point to this database.
Definition: Database.h:2970
std::map< Index32, IdPointPairs > IdIdPointPairsMap
Definition of a map mapping ids to 2D image point id pairs.
Definition: Database.h:99
unsigned int numberValidPoses(const Index32 objectPointId, const IndexSet32 &imagePointIds) const
Counts the number of valid poses of a given object point.
Definition: Database.h:5126
bool poseWithLeastCorrespondences(const Index32 lowerPoseId, const Index32 upperPoseId, Index32 *poseId=nullptr, unsigned int *correspondences=nullptr, const Vector3 &referenceObjectPoint=invalidObjectPoint()) const
Determines the pose id for which the database holds the least number of point correspondences (betwee...
Definition: Database.h:2759
bool addPose(const Index32 poseId, const HomogenousMatrix4 &pose=HomogenousMatrix4(false))
Adds a new camera pose by specifying the unique id of the new pose.
Definition: Database.h:3293
std::unordered_map< Index32, ObjectPointData > ObjectPointMap
Definition of an (unordered) map mapping object point ids to object point data objects.
Definition: Database.h:655
void setPoses(const Index32 *poseIds, const HomogenousMatrix4 *poses, const size_t number)
Sets (changes) a set of poses.
Definition: Database.h:3715
Index32 objectPointFromImagePoint(const Index32 imagePointId) const
Returns the object point which belongs to a given image point.
Definition: Database.h:3434
bool isEmpty() const
Returns whether this database holds at least one image point, one object point or one camera pose.
Definition: Database.h:2235
IndexSet32 posesFromObjectPoint(const Index32 objectPointId) const
Returns all poses which belong to a given object point.
Definition: Database.h:3473
void objectPointIdsWithNumberOfObservationsSubset(const Index32 *objectPointIds, const Vector3 *referencePosition, const Scalar minimalPriority, IndexPairs32 *pairs, Lock *lock, const unsigned int firstObjectPoint, const unsigned int numberObjectPoints) const
Returns pairs of object point ids combined with counts of valid observations.
Definition: Database.h:5103
bool poseWithMostObservations(const IndexSet32 &poseCandidates, const IndexSet32 &majorObjectPointIds, const IndexSet32 &minorObjectPointIds, Index32 &poseId, Indices32 *visibleMajorObjectPointIds=nullptr, Indices32 *visibleMinorObjectPointIds=nullptr) const
Determines the pose id from a set of given pose id candidates for which the database holds the most o...
Definition: Database.h:2794
size_t poseNumber() const
Returns the number of poses of this database.
Definition: Database.h:2243
Index64To32Map databasePoseObjectPointMap
The map mapping a pair of pose id and object point id to image point ids.
Definition: Database.h:1890
Index32 databaseObjectPointIdCounter
The counter for unique object point ids.
Definition: Database.h:1896
std::unordered_map< Index32, ImagePointData > ImagePointMap
Definition of an (unordered) map mapping image point ids to image point data objects.
Definition: Database.h:660
void setPose(const Index32 poseId, const HomogenousMatrix4 &pose)
Sets (changes) a pose.
Definition: Database.h:3702
Lock & lock()
Returns a reference to the lock object of this database object.
Definition: Database.h:2229
void posesImagePoints(const Index32 objectPointId, HomogenousMatrices4 &poses, Vectors2 &imagePoints, const HomogenousMatrix4 &referencePose=HomogenousMatrix4(false), Indices32 *poseIds=nullptr, Indices32 *imagePointIds=nullptr, const Index32 lowerPoseId=invalidId, const Index32 upperPoseId=invalidId) const
Returns corresponding poses and image points for a given object point from the entire range of possib...
Definition: Database.h:4789
bool poseWithMostCorrespondences(const Index32 lowerPoseId, const Index32 upperPoseId, Index32 *poseId=nullptr, unsigned int *correspondences=nullptr, const Vector3 &referenceObjectPoint=invalidObjectPoint()) const
Determines the pose id for which the database holds the most number of point correspondences (between...
Definition: Database.h:2729
static Index32 firstIndex(const Index64 index)
Returns the first 32 bit index of a 64 bit index.
Definition: Database.h:5154
static Indices32 reliableObjectPoints(const TopologyTriples &topologyTriples, const unsigned int minimalObservations)
Determines reliable object points from a set of given topology triples (by determining all object poi...
Definition: Database.h:5028
Scalar objectPointPriority(const Index32 objectPointId) const
Returns the priority of an object point which is specified by the id of the object point.
Definition: Database.h:2368
bool poseBorders(Index32 &lowerPoseId, Index32 &upperPoseId) const
Returns the smallest id (the id of the lower frame border) and the largest id (the id of the upper fr...
Definition: Database.h:2584
Database()
Creates a new empty database object.
Definition: Database.h:2195
static Vector3 invalidObjectPoint()
Returns an invalid object point.
Definition: Database.h:1905
size_t objectPointNumber() const
Returns the number of object point ids in this database.
Definition: Database.h:2251
std::vector< PoseImagePointPair > PoseImagePointTopology
Definition of a vector holding several pairs of pose and image point ids.
Definition: Database.h:245
void detachImagePointFromPose(const Index32 imagePointId)
Detaches an image point from a camera pose (withdraws the topology).
Definition: Database.h:3579
Index32 poseFromImagePoint(const Index32 imagePointId) const
Determines the camera pose (camera frame) in which a specified image point is visible (to which the i...
Definition: Database.h:3337
static PoseImagePointTopologyGroups objectPointTopology(const TopologyTriples &topologyTriples, const Indices32 *indices=nullptr)
Converts the set of topology triples into a representation which is forced/oriented by object points ...
bool validPoseRange(const Index32 lowerPoseId, const Index32 startPoseId, const Index32 upperPoseId, Index32 &rangeLowerPoseId, Index32 &rangeUpperPoseId) const
Determines the pose id range (around a specified start frame) for which the database holds valid pose...
Definition: Database.h:2630
unsigned int databasePoses
The number of poses.
Definition: Database.h:1893
Index32 addObjectPointFromDatabase(const Database &secondDatabase, const Index32 secondDatabaseObjectPointId, const SquareMatrix3 &imagePointTransformation=SquareMatrix3(true), const Index32 newObjectPointId=invalidId, const Index32 secondDatabaseLowerPoseId=invalidId, const Index32 secondDatabaseUpperPoseId=invalidId, const bool forExistingPosesOnly=false)
Adds an object point from another database, adds all connected image points, registers unknown poses,...
Definition: Database.h:3048
ImagePointGroups imagePointGroups(const Indices32 poseIds, Indices32 &objectPointIds) const
Determines the groups of image points matching to unique object points in individual camera poses.
Definition: Database.h:4519
Vectors2 imagePoints(const Indices32 &imagePointIds) const
Returns the positions of 2D image points specified by the ids of the image points.
Definition: Database.h:2278
static Indices32 filterTopologyTriplesPoses(const TopologyTriples &topologyTriples, const IndexSet32 &poseIds)
Filters a set of given topology triples due to a set of given pose ids.
Definition: Database.h:4986
void mergeObjectPoints(const Index32 remainingObjectPointId, const Index32 removingObjectPointId, const Vector3 &newPoint, const Scalar newPriority)
Merges two object points together, afterwards one object point will be removed.
Definition: Database.h:3233
std::map< Index32, Vectors2 > ImagePointsMap
Definition of a map mapping ids to 2D vectors.
Definition: Database.h:104
Vectors2 imagePointsWithObjectPoints(const Index32 poseId, Indices32 &objectPointIds) const
Returns all image points which are located in a specified frame and are projections of object points.
Definition: Database.h:4396
std::pair< Index32, Vector2 > IdPointPair
Definition of a pair of ids and 2D image points.
Definition: Database.h:89
static Indices32 filterTopologyTriplesImagePoints(const TopologyTriples &topologyTriples, const IndexSet32 &imagePointIds)
Filters a set of given topology triples due to a set of given image point ids.
Definition: Database.h:5014
bool isNull() const
Returns whether this vector is a null vector up to a small epsilon.
Definition: Vector3.h:854
const T * data() const noexcept
Returns an pointer to the vector elements.
Definition: Vector3.h:842
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
std::vector< IndexPair32 > IndexPairs32
Definition of a vector holding 32 bit index pairs.
Definition: Base.h:144
std::set< Index32 > IndexSet32
Definition of a set holding 32 bit indices.
Definition: Base.h:114
uint64_t Index64
Definition of a 64 bit index value.
Definition: Base.h:90
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition: Base.h:96
uint32_t Index32
Definition of a 32 bit index value.
Definition: Base.h:84
SquareMatrixT3< Scalar > SquareMatrix3
Definition of the SquareMatrix3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with ...
Definition: SquareMatrix3.h:35
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< HomogenousMatrix4 > HomogenousMatrices4
Definition of a vector holding HomogenousMatrix4 objects.
Definition: HomogenousMatrix4.h:73
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition: Math.h:144
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition: Vector3.h:22
std::vector< SquareMatrix3 > SquareMatrices3
Definition of a vector holding SquareMatrix3 objects.
Definition: SquareMatrix3.h:71
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition: HomogenousMatrix4.h:37
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition: Vector3.h:65
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition: Vector2.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15