 |
AliceVision
Photogrammetric Computer Vision Framework
|
10 #include <aliceVision/sfmData/SharedPtrMap.hpp>
11 #include <aliceVision/sfmData/CameraPose.hpp>
12 #include <aliceVision/sfmData/Landmark.hpp>
13 #include <aliceVision/sfmData/Constraint2D.hpp>
14 #include <aliceVision/sfmData/ConstraintPoint.hpp>
15 #include <aliceVision/sfmData/RotationPrior.hpp>
16 #include <aliceVision/sfmData/SurveyPoint.hpp>
17 #include <aliceVision/sfmData/ImageGroup.hpp>
18 #include <aliceVision/sfmData/View.hpp>
19 #include <aliceVision/sfmData/Rig.hpp>
20 #include <aliceVision/camera/camera.hpp>
21 #include <aliceVision/types.hpp>
31 using Views = SharedPtrMap<View>;
34 using ImageGroups = SharedPtrMap<ImageGroup>;
37 using ImageInfos = SharedPtrMap<ImageInfo>;
40 using Poses = SharedPtrMap<CameraPose>;
43 using Intrinsics = SharedPtrMap<camera::IntrinsicBase>;
46 using Landmarks = std::map<IndexT, Landmark>;
49 using Rigs = std::map<IndexT, Rig>;
52 using PosesUncertainty = std::map<IndexT, Vec6>;
55 using LandmarksUncertainty = std::map<IndexT, Vec3>;
58 using Constraints2D = std::vector<Constraint2D>;
61 using ConstraintsPoint = std::map<IndexT, ConstraintPoint>;
64 using SurveyPoints = std::map<IndexT, std::vector<SurveyPoint>>;
67 using RotationPriors = std::vector<RotationPrior>;
97 SfMData(
const SfMData & other,
const Eigen::Vector3d & bbMin,
const Eigen::Vector3d & bbMax);
100 bool operator==(
const SfMData& other)
const;
102 inline bool operator!=(
const SfMData& other)
const {
return !(*
this == other); }
132 Rigs&
getRigs() {
return _rigs; }
225 if (_intrinsics.count(intrinsicId))
226 return _intrinsics.at(intrinsicId).get();
236 if (_intrinsics.count(intrinsicId))
237 return _intrinsics.at(intrinsicId).get();
247 if (_intrinsics.count(intrinsicId))
248 return _intrinsics.at(intrinsicId);
260 if (_intrinsics.count(intrinsicId))
261 return _intrinsics.at(intrinsicId);
271 if (_intrinsics.count(intrinsicId))
272 return _intrinsics.at(intrinsicId);
284 if (_intrinsics.count(intrinsicId))
285 return _intrinsics.at(intrinsicId);
309 std::set<IndexT> viewKeys;
310 for (
auto v : _views)
311 viewKeys.insert(v.first);
344 if (poseId == UndefinedIndexT)
349 auto it = _poses.find(poseId);
350 if (it == _poses.end())
382 if (poseId == UndefinedIndexT)
388 if (intrinsicId == UndefinedIndexT)
398 auto it = _poses.find(poseId);
399 if (it == _poses.end())
435 if (viewId == UndefinedIndexT)
440 if (_views.find(viewId) == _views.end())
460 const View&
getView(IndexT viewId)
const {
return *(_views.at(viewId)); }
502 IndexT
findView(
const std::string & imageName)
const;
523 pose.setTransform(getRigSubPose(view).pose * pose.getTransform());
551 std::set<feature::EImageDescriberType> getLandmarkDescTypes()
const
553 std::set<feature::EImageDescriberType> output;
556 output.insert(s.second.getDescType());
561 std::map<feature::EImageDescriberType, int> getLandmarkDescTypesUsages()
const
563 std::map<feature::EImageDescriberType, int> output;
566 if (output.find(s.second.getDescType()) == output.end())
568 output[s.second.getDescType()] = 1;
572 ++output[s.second.getDescType()];
584 std::vector<ExposureSetting> cameraExposureList;
585 cameraExposureList.reserve(_views.size());
587 for (
const auto& view : _views)
589 const ExposureSetting ce = view.second->getImage().getCameraExposureSetting();
590 if (ce.isPartiallyDefined())
592 auto find = std::find(std::begin(cameraExposureList), std::end(cameraExposureList), ce);
593 if (find == std::end(cameraExposureList))
594 cameraExposureList.emplace_back(ce);
598 std::nth_element(cameraExposureList.begin(), cameraExposureList.begin() + cameraExposureList.size() / 2, cameraExposureList.end());
599 const ExposureSetting& ceMedian = cameraExposureList[cameraExposureList.size() / 2];
644 _featuresFolders.clear();
656 _matchesFolders.clear();
683 _poses.assign(poseId, pose);
693 auto it = _poses.find(poseId);
694 if (it != _poses.end())
700 throw std::out_of_range(std::string(
"Can't erase unfind pose ") + std::to_string(poseId));
709 for (
auto rigIt : _rigs)
711 rigIt.second.reset();
720 void addAncestor(IndexT ancestorId, std::shared_ptr<ImageInfo> image) { _ancestors.emplace(ancestorId, image); }
775 void getBoundingBox(Eigen::Vector3d & bbMin, Eigen::Vector3d & bbMax);
785 Landmarks _landmarks;
793 std::string _absolutePath;
795 std::vector<std::string> _featuresFolders;
797 std::vector<std::string> _matchesFolders;
803 Constraints2D _constraints2d;
805 ConstraintsPoint _constraintsPoint;
807 RotationPriors _rotationpriors;
809 SurveyPoints _surveyPoints;
840 CameraPose& getRigPose(
const View& view)
842 return *_poses.at(view.getPoseId());
850 RigSubPose& getRigSubPose(
const View& view)
852 assert(view.isPartOfRig());
853 Rig& rig = _rigs.at(view.getRigId());
858 using LandmarkIdSet = std::vector<std::size_t>;
859 using LandmarksPerView = stl::flat_map<std::size_t, LandmarkIdSet>;
861 LandmarksPerView getLandmarksPerViews(
const SfMData& sfmData);
const View::ptr getViewPtr(IndexT viewId) const
Gives the view of the input view id.
Definition: SfMData.hpp:474
void removeUnusedIntrinsics()
Remove intrinsics which are unused.
Definition: SfMData.cpp:429
const CameraPose & getAbsolutePose(IndexT poseId) const
Gives the pose with the given pose id.
Definition: SfMData.hpp:532
std::set< IndexT > getViewsKeys() const
Get a set of views keys.
Definition: SfMData.hpp:307
camera::IntrinsicBase * getIntrinsicPtr(IndexT intrinsicId)
Return a pointer to an intrinsic if available or nullptr otherwise.
Definition: SfMData.hpp:234
bool isIntrinsicDefined(const View &view) const
Check if the given view has defined intrinsic and pose.
Definition: SfMData.hpp:320
const Rigs & getRigs() const
Get rigs.
Definition: SfMData.hpp:131
std::set< IndexT > getValidViews() const
List the view indexes that have valid camera intrinsic and pose.
Definition: SfMData.cpp:247
ERigSubPoseStatus status
status of the sub-pose
Definition: Rig.hpp:72
const camera::IntrinsicBase * getIntrinsicPtr(IndexT intrinsicId) const
Return a pointer to an intrinsic if available or nullptr otherwise.
Definition: SfMData.hpp:223
void clear()
Remove everything in this sfmData.
Definition: SfMData.cpp:353
const Intrinsics & getIntrinsics() const
Get intrinsics.
Definition: SfMData.hpp:138
const ImageInfos & getAncestors() const
Get ancestors.
Definition: SfMData.hpp:117
const ImageGroups & getImageGroups() const
Get ImageGroups.
Definition: SfMData.hpp:180
View::ptr getViewPtr(IndexT viewId)
Gives the view of the input view id.
Definition: SfMData.hpp:481
const Poses & getPoses() const
Get poses.
Definition: SfMData.hpp:124
void setPose(const View &view, const CameraPose &pose)
Set the given pose for the given view if the view is part of a rig, this method update rig pose/sub-p...
Definition: SfMData.cpp:275
const std::shared_ptr< camera::IntrinsicBase > getIntrinsicSharedPtr(const View &v) const
Return a shared pointer to an intrinsic if available or nullptr otherwise.
Definition: SfMData.hpp:280
camera::IntrinsicBase & getIntrinsic(IndexT intrinsicId)
Gives the intrinsic of the input intrinsic id.
Definition: SfMData.hpp:301
IndexT getPoseId() const
Get the pose id.
Definition: View.hpp:137
void addAncestor(IndexT ancestorId, std::shared_ptr< ImageInfo > image)
Add an ancestor image.
Definition: SfMData.hpp:720
IndexT findView(const std::string &imageName) const
Retrieve the view id in the sfmData from the image filename.
Definition: SfMData.cpp:408
bool isPoseAndIntrinsicDefined(IndexT viewId) const
Check if the given view has defined intrinsic and pose.
Definition: SfMData.hpp:433
void getBoundingBox(Eigen::Vector3d &bbMin, Eigen::Vector3d &bbMax)
Definition: SfMData.cpp:390
const Landmarks & getLandmarks() const
Get landmarks.
Definition: SfMData.hpp:145
const RigSubPose & getSubPose(IndexT index) const
Get the sub-pose for the given sub-pose index.
Definition: Rig.hpp:156
const Views & getViews() const
Get views.
Definition: SfMData.hpp:110
void setAbsolutePose(IndexT poseId, const CameraPose &pose)
Set the given pose for the given poseId.
Definition: SfMData.hpp:681
LandmarksUncertainty _landmarksUncertainty
Uncertainty per landmark.
Definition: SfMData.hpp:81
CameraPose & getAbsolutePose(IndexT poseId)
Gives the pose with the given pose id.
Definition: SfMData.hpp:538
Definition: checkerDetector.cpp:32
A view define an image by a string and unique indexes for the view, the camera intrinsic,...
Definition: View.hpp:32
void addMatchesFolders(const std::vector< std::string > &folders)
Add the given folders to matches folders.
Definition: SfMData.cpp:232
const camera::IntrinsicBase & getIntrinsic(IndexT intrinsicId) const
Gives the intrinsic of the input intrinsic id.
Definition: SfMData.hpp:294
bool isPoseIndependant() const
If the view is part of a camera rig, the camera can be a sub-pose of the rig pose but can also be tem...
Definition: View.hpp:175
const Rig & getRig(const View &view) const
Get the rig of the given view.
Definition: SfMData.hpp:545
const RotationPriors & getRotationPriors() const
Get RotationPriors.
Definition: SfMData.hpp:173
void setFeaturesFolders(const std::vector< std::string > &folders)
Replace the current features folders by the given ones.
Definition: SfMData.hpp:642
void addFeaturesFolders(const std::vector< std::string > &folders)
Add the given folders to features folders.
Definition: SfMData.cpp:230
const std::vector< std::string > & getRelativeFeaturesFolders() const
Get relative features folder paths.
Definition: SfMData.hpp:187
void removeInvalidObservations()
Remove observations pointing to invalid views.
Definition: SfMData.cpp:461
IndexT getRigId() const
Get the rig id.
Definition: View.hpp:143
bool isPartOfRig() const
Return if true or false the view is part of a rig.
Definition: View.hpp:167
const Constraints2D & getConstraints2D() const
Get Constraints2D.
Definition: SfMData.hpp:152
const View::sptr getViewSharedPtr(IndexT viewId) const
Gives the view of the input view id.
Definition: SfMData.hpp:495
IndexT getIntrinsicId() const
Get the intrinsic id.
Definition: View.hpp:131
void removeUnusedLandmarks()
Remove landmarks without any observations.
Definition: SfMData.cpp:484
std::set< IndexT > getReconstructedIntrinsics() const
List the intrinsic indexes that have valid camera intrinsic and pose.
Definition: SfMData.cpp:261
const std::vector< std::string > & getRelativeMatchesFolders() const
Get relative matches folder paths.
Definition: SfMData.hpp:193
ExposureSetting getMedianCameraExposureSetting() const
Get the median Camera Exposure Setting.
Definition: SfMData.hpp:582
const std::shared_ptr< camera::IntrinsicBase > getIntrinsicSharedPtr(IndexT intrinsicId) const
Return a shared pointer to an intrinsic if available or nullptr otherwise.
Definition: SfMData.hpp:269
PosesUncertainty _posesUncertainty
Uncertainty per pose.
Definition: SfMData.hpp:79
bool isPoseDefined(IndexT viewId) const
Check if the given view has a defined pose.
Definition: SfMData.hpp:369
SfMData container Store structure and camera properties.
Definition: SfMData.hpp:75
const View & getView(IndexT viewId) const
Gives the view of the input view id.
Definition: SfMData.hpp:460
void addFeaturesFolder(const std::string &folder)
Add the given folder to features folders.
Definition: SfMData.hpp:610
void resetRigs()
Reset rigs sub-poses parameters.
Definition: SfMData.hpp:707
Definition: CameraPose.hpp:15
bool existsPose(const View &view) const
Check if the given view has an existing pose.
Definition: SfMData.hpp:453
void erasePose(IndexT poseId, bool noThrow=false)
Erase the pose for the given poseId.
Definition: SfMData.hpp:691
void repair()
repair the sfmData by removing everything that is unused or invalid
Definition: SfMData.cpp:511
void setAbsolutePath(const std::string &path)
Set the SfMData file absolute path.
Definition: SfMData.cpp:234
bool isFullyReconstructed() const
Definition: SfMData.cpp:520
std::vector< std::string > getFeaturesFolders() const
Get absolute features folder paths.
Definition: SfMData.cpp:226
std::shared_ptr< camera::IntrinsicBase > getIntrinsicSharedPtr(IndexT intrinsicId)
Return a shared pointer to an intrinsic if available or nullptr otherwise.
Definition: SfMData.hpp:245
Basis class for all intrinsic parameters of a camera.
Definition: IntrinsicBase.hpp:27
std::shared_ptr< camera::IntrinsicBase > getIntrinsicSharedPtr(const View &v)
Return a shared pointer to an intrinsic if available or nullptr otherwise.
Definition: SfMData.hpp:256
bool isIntrinsicDefined(IndexT viewId) const
Check if the given view has defined intrinsic and pose.
Definition: SfMData.hpp:331
void removeUnusedCameraPoses()
Remove poses which are unused.
Definition: SfMData.cpp:445
std::vector< std::string > getMatchesFolders() const
Get absolute matches folder paths.
Definition: SfMData.cpp:228
void setMatchesFolders(const std::vector< std::string > &folders)
Replace the current matches folders by the given ones.
Definition: SfMData.hpp:654
bool isPoseAndIntrinsicDefined(const View *view) const
Check if the given view has defined intrinsic.
Definition: SfMData.hpp:418
View & getView(IndexT viewId)
Gives the view of the input view id.
Definition: SfMData.hpp:467
Definition: ExposureSetting.hpp:15
void combine(const SfMData &sfmData)
Insert data from the given sfmData if possible. note: This operation doesn't override existing data.
Definition: SfMData.cpp:309
const ConstraintsPoint & getConstraintsPoint() const
Get ConstraintsPoints.
Definition: SfMData.hpp:159
View::sptr getViewSharedPtr(IndexT viewId)
Gives the view of the input view id.
Definition: SfMData.hpp:488
void addMatchesFolder(const std::string &folder)
Add the given folder to matches folders.
Definition: SfMData.hpp:626
IndexT getSubPoseId() const
Get the sub-pose id.
Definition: View.hpp:149
void resetParameterStates()
Definition: SfMData.cpp:371
bool isPoseAndIntrinsicDefined(const View &view) const
Check if the given view has defined intrinsic.
Definition: SfMData.hpp:379
void removeUnusedImageGroups()
Remove image groups which are unused.
Definition: SfMData.cpp:492
const SurveyPoints & getSurveyPoints() const
Get SurveyPoints.
Definition: SfMData.hpp:166
bool isPoseDefined(const View &view) const
Check if the given view has a valid pose.
Definition: SfMData.hpp:341
CameraPose getPose(const View &view) const
Gives the pose of the input view. If this view is part of a rig, it returns rigPose + rigSubPose.
Definition: SfMData.hpp:511