Skip to content

Commit 49854cb

Browse files
Fabien Servantcbentejac
authored andcommitted
Camera type casting as functions
1 parent c07e178 commit 49854cb

File tree

8 files changed

+28
-0
lines changed

8 files changed

+28
-0
lines changed

src/aliceVision/camera/Equidistant.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
namespace aliceVision {
1313
namespace camera {
1414

15+
std::shared_ptr<Equidistant> Equidistant::cast(std::shared_ptr<IntrinsicBase> sptr)
16+
{
17+
return std::dynamic_pointer_cast<Equidistant>(sptr);
18+
}
19+
1520
Vec2 Equidistant::transformProject(const Eigen::Matrix4d& pose, const Vec4& pt, bool applyDistortion) const
1621
{
1722
const double rsensor = std::min(sensorWidth(), sensorHeight());

src/aliceVision/camera/Equidistant.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class Equidistant : public IntrinsicScaleOffsetDisto
5959

6060
Equidistant* clone() const override { return new Equidistant(*this); }
6161

62+
static std::shared_ptr<Equidistant> cast(std::shared_ptr<IntrinsicBase> sptr);
63+
6264
void assign(const IntrinsicBase& other) override { *this = dynamic_cast<const Equidistant&>(other); }
6365

6466
bool isValid() const override { return _scale(0) > 0 && IntrinsicBase::isValid(); }

src/aliceVision/camera/IntrinsicScaleOffset.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ bool IntrinsicScaleOffset::operator==(const IntrinsicBase& otherBase) const
2828
return _scale.isApprox(other._scale) && _offset.isApprox(other._offset);
2929
}
3030

31+
std::shared_ptr<IntrinsicScaleOffset> IntrinsicScaleOffset::cast(std::shared_ptr<IntrinsicBase> sptr)
32+
{
33+
return std::dynamic_pointer_cast<IntrinsicScaleOffset>(sptr);
34+
}
35+
3136
Vec2 IntrinsicScaleOffset::cam2ima(const Vec2& p) const { return p.cwiseProduct(_scale) + getPrincipalPoint(); }
3237

3338
Eigen::Matrix2d IntrinsicScaleOffset::getDerivativeCam2ImaWrtScale(const Vec2& p) const

src/aliceVision/camera/IntrinsicScaleOffset.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class IntrinsicScaleOffset : public IntrinsicBase
2626

2727
~IntrinsicScaleOffset() override = default;
2828

29+
static std::shared_ptr<IntrinsicScaleOffset> cast(std::shared_ptr<IntrinsicBase> sptr);
30+
2931
void copyFrom(const IntrinsicScaleOffset& other) { *this = other; }
3032

3133
bool operator==(const IntrinsicBase& otherBase) const override;

src/aliceVision/camera/IntrinsicScaleOffsetDisto.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
namespace aliceVision {
1010
namespace camera {
1111

12+
std::shared_ptr<IntrinsicScaleOffsetDisto> IntrinsicScaleOffsetDisto::cast(std::shared_ptr<IntrinsicBase> sptr)
13+
{
14+
return std::dynamic_pointer_cast<IntrinsicScaleOffsetDisto>(sptr);
15+
}
16+
1217
bool IntrinsicScaleOffsetDisto::operator==(const IntrinsicBase& otherBase) const
1318
{
1419
if (!IntrinsicScaleOffset::operator==(otherBase))

src/aliceVision/camera/IntrinsicScaleOffsetDisto.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class IntrinsicScaleOffsetDisto : public IntrinsicScaleOffset
5959
}
6060
}
6161

62+
static std::shared_ptr<IntrinsicScaleOffsetDisto> cast(std::shared_ptr<IntrinsicBase> sptr);
63+
6264
void assign(const IntrinsicBase& other) override { *this = dynamic_cast<const IntrinsicScaleOffsetDisto&>(other); }
6365

6466
bool operator==(const IntrinsicBase& otherBase) const override;

src/aliceVision/camera/Pinhole.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
namespace aliceVision {
1010
namespace camera {
1111

12+
std::shared_ptr<Pinhole> Pinhole::cast(std::shared_ptr<IntrinsicBase> sptr)
13+
{
14+
return std::dynamic_pointer_cast<Pinhole>(sptr);
15+
}
16+
1217
Mat3 Pinhole::K() const
1318
{
1419
Mat3 K;

src/aliceVision/camera/Pinhole.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class Pinhole : public IntrinsicScaleOffsetDisto
4949

5050
void assign(const IntrinsicBase& other) override { *this = dynamic_cast<const Pinhole&>(other); }
5151

52+
static std::shared_ptr<Pinhole> cast(std::shared_ptr<IntrinsicBase> sptr);
53+
5254
double getFocalLengthPixX() const { return _scale(0); }
5355

5456
double getFocalLengthPixY() const { return _scale(1); }

0 commit comments

Comments
 (0)