Added optional derivatives to compose, between, and inverse for the two camera types
parent
5505483111
commit
857b0d0d8c
|
@ -81,14 +81,23 @@ namespace gtsam {
|
|||
/// return pose
|
||||
inline const Pose3& pose() const { return pose_; }
|
||||
|
||||
/// compose the poses
|
||||
inline const CalibratedCamera compose(const CalibratedCamera &c) const {
|
||||
return CalibratedCamera( pose_ * c.pose() ) ;
|
||||
/// compose the two camera poses: TODO Frank says this might not make sense
|
||||
inline const CalibratedCamera compose(const CalibratedCamera &c,
|
||||
boost::optional<Matrix&> H1=boost::none,
|
||||
boost::optional<Matrix&> H2=boost::none) const {
|
||||
return CalibratedCamera( pose_.compose(c.pose(), H1, H2) );
|
||||
}
|
||||
|
||||
/// invert the camera's pose
|
||||
inline const CalibratedCamera inverse() const {
|
||||
return CalibratedCamera( pose_.inverse() ) ;
|
||||
/// between the two camera poses: TODO Frank says this might not make sense
|
||||
inline const CalibratedCamera between(const CalibratedCamera& c,
|
||||
boost::optional<Matrix&> H1=boost::none,
|
||||
boost::optional<Matrix&> H2=boost::none) const {
|
||||
return CalibratedCamera( pose_.between(c.pose(), H1, H2) );
|
||||
}
|
||||
|
||||
/// invert the camera pose: TODO Frank says this might not make sense
|
||||
inline const CalibratedCamera inverse(boost::optional<Matrix&> H1=boost::none) const {
|
||||
return CalibratedCamera( pose_.inverse(H1) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -154,13 +154,55 @@ namespace gtsam {
|
|||
/// @{
|
||||
|
||||
/// compose two cameras: TODO Frank says this might not make sense
|
||||
inline const PinholeCamera compose(const Pose3 &c) const {
|
||||
return PinholeCamera( pose_ * c, K_ ) ;
|
||||
inline const PinholeCamera compose(const PinholeCamera &c,
|
||||
boost::optional<Matrix&> H1=boost::none,
|
||||
boost::optional<Matrix&> H2=boost::none) const {
|
||||
PinholeCamera result( pose_.compose(c.pose(), H1, H2), K_ );
|
||||
if(H1) {
|
||||
H1->conservativeResize(Dim(), Dim());
|
||||
H1->topRightCorner(Pose3::Dim(), Calibration::Dim()) = zeros(Pose3::Dim(),Calibration::Dim());
|
||||
H1->bottomRows(Calibration::Dim()) = zeros(Calibration::Dim(), Dim());
|
||||
}
|
||||
if(H2) {
|
||||
H2->conservativeResize(Dim(), Dim());
|
||||
H2->topRightCorner(Pose3::Dim(), Calibration::Dim()) = zeros(Pose3::Dim(),Calibration::Dim());
|
||||
H2->bottomRows(Calibration::Dim()) = zeros(Calibration::Dim(), Dim());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// between two cameras: TODO Frank says this might not make sense
|
||||
inline const PinholeCamera between(const PinholeCamera& c,
|
||||
boost::optional<Matrix&> H1=boost::none,
|
||||
boost::optional<Matrix&> H2=boost::none) const {
|
||||
PinholeCamera result( pose_.between(c.pose(), H1, H2), K_ );
|
||||
if(H1) {
|
||||
H1->conservativeResize(Dim(), Dim());
|
||||
H1->topRightCorner(Pose3::Dim(), Calibration::Dim()) = zeros(Pose3::Dim(),Calibration::Dim());
|
||||
H1->bottomRows(Calibration::Dim()) = zeros(Calibration::Dim(), Dim());
|
||||
}
|
||||
if(H2) {
|
||||
H2->conservativeResize(Dim(), Dim());
|
||||
H2->topRightCorner(Pose3::Dim(), Calibration::Dim()) = zeros(Pose3::Dim(),Calibration::Dim());
|
||||
H2->bottomRows(Calibration::Dim()) = zeros(Calibration::Dim(), Dim());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// inverse camera: TODO Frank says this might not make sense
|
||||
inline const PinholeCamera inverse(boost::optional<Matrix&> H1=boost::none) const {
|
||||
PinholeCamera result( pose_.inverse(H1), K_ );
|
||||
if(H1) {
|
||||
H1->conservativeResize(Dim(), Dim());
|
||||
H1->topRightCorner(Pose3::Dim(), Calibration::Dim()) = zeros(Pose3::Dim(),Calibration::Dim());
|
||||
H1->bottomRows(Calibration::Dim()) = zeros(Calibration::Dim(), Dim());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// compose two cameras: TODO Frank says this might not make sense
|
||||
inline const PinholeCamera inverse() const {
|
||||
return PinholeCamera( pose_.inverse(), K_ ) ;
|
||||
inline const PinholeCamera compose(const Pose3 &c) const {
|
||||
return PinholeCamera( pose_.compose(c), K_ );
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
|
Loading…
Reference in New Issue