Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/aliceVision/mvsUtils/MultiViewParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ MultiViewParams::MultiViewParams(const sfmData::SfMData& sfmData,
{
const sfmData::View& view = *(viewPair.second.get());

if (!sfmData.isPoseAndIntrinsicDefined(&view))
if (!sfmData.isPoseAndIntrinsicDefined(view))
continue;

std::string path = view.getImage().getImagePath();
Expand Down
2 changes: 1 addition & 1 deletion src/aliceVision/sfm/bundle/BundleAdjustmentCeres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void BundleAdjustmentCeres::addIntrinsicsToProblem(const sfmData::SfMData& sfmDa
if (intrinsicsUsage.find(view.getIntrinsicId()) == intrinsicsUsage.end())
intrinsicsUsage[view.getIntrinsicId()] = 0;

if (sfmData.isPoseAndIntrinsicDefined(&view))
if (sfmData.isPoseAndIntrinsicDefined(view))
++intrinsicsUsage.at(view.getIntrinsicId());
}

Expand Down
1 change: 1 addition & 0 deletions src/aliceVision/sfm/pipeline/relativePoses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <aliceVision/numeric/numeric.hpp>
#include <aliceVision/dataio/json.hpp>
#include <aliceVision/geometry/lie.hpp>
#include <aliceVision/geometry/Pose3.hpp>

namespace aliceVision {
namespace sfm {
Expand Down
6 changes: 3 additions & 3 deletions src/aliceVision/sfm/utils/alignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ void computeNewCoordinateSystemFromCamerasXAxis(const sfmData::SfMData& sfmData,
{
const sfmData::View& view = *viewIt.second.get();

if (sfmData.isPoseAndIntrinsicDefined(&view))
if (sfmData.isPoseAndIntrinsicDefined(view))
{
const sfmData::EEXIFOrientation orientation = view.getImage().getMetadataOrientation();
const sfmData::CameraPose camPose = sfmData.getPose(view);
Expand Down Expand Up @@ -804,7 +804,7 @@ void computeNewCoordinateSystemFromCamerasXAxis(const sfmData::SfMData& sfmData,
{
const sfmData::View& view = *viewIt.second.get();

if (sfmData.isPoseAndIntrinsicDefined(&view))
if (sfmData.isPoseAndIntrinsicDefined(view))
{
const sfmData::EEXIFOrientation orientation = view.getImage().getMetadataOrientation();
const sfmData::CameraPose camPose = sfmData.getPose(view);
Expand Down Expand Up @@ -1010,7 +1010,7 @@ IndexT getCenterCameraView(const sfmData::SfMData& sfmData)
for (auto& viewIt : sfmData.getViews())
{
const sfmData::View& v = *viewIt.second;
if (!sfmData.isPoseAndIntrinsicDefined(&v))
if (!sfmData.isPoseAndIntrinsicDefined(v))
continue;
const auto& pose = sfmData.getPose(v);
const double dist = (pose.getTransform().center() - camerasCenter).norm();
Expand Down
16 changes: 16 additions & 0 deletions src/aliceVision/sfmData/CameraPose.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,27 @@ class CameraPose

void setState(EEstimatorParameterState state) { _state = state; }

bool isRotationOnly() const
{
return _rotationOnly;
}

/**
* Set the flag for partial state
* Partial flag set to on means the camera translation is not known
*/
void setRotationOnly(bool partial)
{
_rotationOnly = partial;
}

private:
/// camera 3d transformation
geometry::Pose3 _transform;
/// camera lock
bool _locked = false;
/// Only rotation is solved
bool _rotationOnly = false;
/// Estimator state
EEstimatorParameterState _state = EEstimatorParameterState::REFINED;
};
Expand Down
51 changes: 48 additions & 3 deletions src/aliceVision/sfmData/SfMData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,50 @@ class SfMData
return isIntrinsicDefined(*_views.at(viewId));
}

/**
* @brief Check if the given view have defined intrinsi
* @param[in] view The given view
* @return true if intrinsic and pose defined
*/
bool isPoseAndIntrinsicDefined(const View & view) const
{
const IndexT poseId = view.getPoseId();
if (poseId == UndefinedIndexT)
{
return false;
}

const IndexT intrinsicId = view.getIntrinsicId();
if (intrinsicId == UndefinedIndexT)
{
return false;
}

if (_intrinsics.find(view.getIntrinsicId()) == _intrinsics.end())
{
return false;
}

auto it = _poses.find(poseId);
if (it == _poses.end())
{
return false;
}

if (it->second.isRotationOnly())
{
return false;
}

bool rigValid = ((!view.isPartOfRig() || view.isPoseIndependant() || getRigSubPose(view).status != ERigSubPoseStatus::UNINITIALIZED));
if (!rigValid)
{
return false;
}

return true;
}

/**
* @brief Check if the given view have defined intrinsi
* @param[in] view The given view
Expand All @@ -288,10 +332,11 @@ class SfMData
bool isPoseAndIntrinsicDefined(const View* view) const
{
if (view == nullptr)
{
return false;
return (view->getIntrinsicId() != UndefinedIndexT && view->getPoseId() != UndefinedIndexT &&
(!view->isPartOfRig() || view->isPoseIndependant() || getRigSubPose(*view).status != ERigSubPoseStatus::UNINITIALIZED) &&
_intrinsics.find(view->getIntrinsicId()) != _intrinsics.end() && _poses.find(view->getPoseId()) != _poses.end());
}

return isPoseAndIntrinsicDefined(*view);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/aliceVision/sfmDataIO/AlembicExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ void AlembicExporter::DataImpl::addCamera(const std::string& name,
if (pose != nullptr)
{
OBoolProperty(userProps, "mvg_poseLocked").set(pose->isLocked());
OBoolProperty(userProps, "mvg_rotationOnly").set(pose->isRotationOnly());

// Convert from computer vision convention to computer graphics (opengl-like)
Eigen::Matrix4d M = Eigen::Matrix4d::Identity();
Expand Down Expand Up @@ -397,7 +398,7 @@ void AlembicExporter::addSfMSingleCamera(const sfmData::SfMData& sfmData, const
const std::shared_ptr<camera::IntrinsicBase> intrinsic =
(flagsPart & ESfMData::INTRINSICS) ? sfmData.getIntrinsicSharedPtr(view.getIntrinsicId()) : nullptr;

if (sfmData.isPoseAndIntrinsicDefined(&view) && (flagsPart & ESfMData::EXTRINSICS))
if (sfmData.isPoseAndIntrinsicDefined(view) && (flagsPart & ESfMData::EXTRINSICS))
_dataImpl->addCamera(name, view, pose, intrinsic, nullptr, &_dataImpl->_mvgCameras);
else
_dataImpl->addCamera(name, view, pose, intrinsic, nullptr, &_dataImpl->_mvgCamerasUndefined);
Expand Down
9 changes: 8 additions & 1 deletion src/aliceVision/sfmDataIO/AlembicImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ bool readCamera(const Version& abcVersion,
IndexT resectionId = UndefinedIndexT;
bool intrinsicLocked = false;
bool poseLocked = false;
bool rotationOnly = false;
bool poseIndependant = true;
bool lockRatio = true;
bool lockOffset = false;
Expand Down Expand Up @@ -489,6 +490,10 @@ bool readCamera(const Version& abcVersion,
{
poseLocked = getAbcProp<Alembic::Abc::IBoolProperty>(userProps, *propHeader, "mvg_poseLocked", sampleFrame);
}
if (const Alembic::Abc::PropertyHeader* propHeader = userProps.getPropertyHeader("mvg_rotationOnly"))
{
rotationOnly = getAbcProp<Alembic::Abc::IBoolProperty>(userProps, *propHeader, "mvg_rotationOnly", sampleFrame);
}
if (const Alembic::Abc::PropertyHeader* propHeader = userProps.getPropertyHeader("mvg_poseIndependant"))
{
poseIndependant = getAbcProp<Alembic::Abc::IBoolProperty>(userProps, *propHeader, "mvg_poseIndependant", sampleFrame);
Expand Down Expand Up @@ -805,7 +810,9 @@ bool readCamera(const Version& abcVersion,
}
else
{
sfmData.setPose(*view, sfmData::CameraPose(pose, poseLocked));
sfmData::CameraPose cp(pose, poseLocked);
cp.setRotationOnly(rotationOnly);
sfmData.setPose(*view, cp);
}
}

Expand Down
Binary file not shown.
Loading
Loading