::CameraGeometry() {
-
-}
-
-/// \brief Construct from projection
-template ::CameraGeometry(const sm::PropertyTree & config)
- : _projection(sm::PropertyTree(config, "projection")),
- _shutter(sm::PropertyTree(config, "shutter")),
- _mask(sm::PropertyTree(config, "mask")) {
-
-}
-
-/// \brief Construct from projection
-template ::CameraGeometry(const projection_t & projection)
- : _projection(projection) {
-
-}
-
-/// \brief Construct from projection and shutter
-template ::CameraGeometry(const projection_t & projection,
- const shutter_t & shutter)
- : _projection(projection),
- _shutter(shutter) {
-
-}
-
-/// \brief Construct from projection, shutter, and mask
-template ::CameraGeometry(const projection_t & projection,
- const shutter_t & shutter,
- const mask_t & mask)
- : _projection(projection),
- _shutter(shutter),
- _mask(mask) {
-
-}
-
-/// \brief simple destructor
-template ::~CameraGeometry() {
-
-}
-
-template ::vsEuclideanToKeypoint(
- const Eigen::Vector3d & p, Eigen::VectorXd & outKeypoint) const {
- bool valid = _projection.euclideanToKeypoint(p, outKeypoint);
- return valid && _mask.isValid(outKeypoint);
-}
-
-template ::vsEuclideanToKeypoint(
- const Eigen::Vector3d & p, Eigen::VectorXd & outKeypoint,
- Eigen::MatrixXd & outJacobian) const {
- bool valid = _projection.euclideanToKeypoint(p, outKeypoint, outJacobian);
- return valid && _mask.isValid(outKeypoint);
-}
-
-template ::vsHomogeneousToKeypoint(
- const Eigen::Vector4d & ph, Eigen::VectorXd & outKeypoint) const {
- bool valid = _projection.homogeneousToKeypoint(ph, outKeypoint);
- return valid && _mask.isValid(outKeypoint);
-}
-
-template ::vsHomogeneousToKeypoint(
- const Eigen::Vector4d & ph, Eigen::VectorXd & outKeypoint,
- Eigen::MatrixXd & outJacobian) const {
- bool valid = _projection.homogeneousToKeypoint(ph, outKeypoint, outJacobian);
- return valid && _mask.isValid(outKeypoint);
-}
-
-template ::vsKeypointToEuclidean(
- const Eigen::VectorXd & keypoint, Eigen::Vector3d & outPoint) const {
- return _projection.keypointToEuclidean(keypoint, outPoint)
- && _mask.isValid(keypoint);
-}
-
-template ::vsKeypointToEuclidean(
- const Eigen::VectorXd & keypoint, Eigen::VectorXd & outPoint,
- Eigen::MatrixXd & outJacobian) const {
- return _projection.keypointToEuclidean(keypoint, outPoint, outJacobian)
- && _mask.isValid(keypoint);
-}
-
-template ::vsKeypointToHomogeneous(
- Eigen::VectorXd const & keypoint, Eigen::VectorXd & outPoint) const {
- return _projection.keypointToHomogeneous(keypoint, outPoint)
- && _mask.isValid(keypoint);
-}
-
-template ::vsKeypointToHomogeneous(
- Eigen::VectorXd const & keypoint, Eigen::VectorXd & outPoint,
- Eigen::MatrixXd & outJacobian) const {
- return _projection.keypointToHomogeneous(keypoint, outPoint, outJacobian)
- && _mask.isValid(keypoint);
-}
-
-template ::vsIsValid(
- const Eigen::VectorXd & keypoint) const {
- return isValid(keypoint);
-}
-
-template ::vsIsEuclideanVisible(
- const Eigen::Vector3d & p) const {
- return _projection.isEuclideanVisible(p);
-}
-
-template ::vsIsHomogeneousVisible(
- const Eigen::Vector4d & ph) const {
- return _projection.isHomogeneousVisible(ph);
-}
-
-// The amount of time elapsed between the start of the image and the
-// keypoint. For a global shutter camera, this can return Duration(0).
-template ::vsTemporalOffset(
- const Eigen::VectorXd & keypoint) const {
- return _shutter.temporalOffset(keypoint);
-}
-
-/// \brief get the camera id.
-template ::id() const {
- return _id;
-}
-
-/// \brief set the camera id.
-template ::setId(CameraId id) {
- _id = id;
-}
-
-/// \brief the length of a keypoint
-template ::keypointDimension() const {
- return P::KeypointDimension;
-}
-
-// \brief creates a random valid keypoint.
-template ::createRandomKeypoint() const {
- return _projection.createRandomKeypoint();
-}
-
-// \brief creates a random visible point. Negative depth means random between 0 and 100 meters.
-template ::createRandomVisiblePoint(
- double depth) const {
- return _projection.createRandomVisiblePoint(depth);
-}
-
-template ::euclideanToKeypoint(
- const Eigen::MatrixBase ::euclideanToKeypoint(
- const Eigen::MatrixBase ::euclideanToKeypointFiniteDifference(
- const Eigen::MatrixBase ::homogeneousToKeypoint(
- const sm::kinematics::UncertainHomogeneousPoint & p,
- const Eigen::MatrixBase ::homogeneousToKeypoint(
- const sm::kinematics::HomogeneousPoint & p,
- const Eigen::MatrixBase ::homogeneousToKeypoint(
- const Eigen::MatrixBase ::homogeneousToKeypoint(
- const Eigen::MatrixBase ::homogeneousToKeypointFiniteDifference(
- const Eigen::MatrixBase ::keypointToEuclidean(
- const Eigen::MatrixBase ::keypointToEuclidean(
- const Eigen::MatrixBase ::keypointToEuclideanFiniteDifference(
- const Eigen::MatrixBase ::keypointToHomogeneous(
- const Eigen::MatrixBase ::keypointToHomogeneous(
- const Eigen::MatrixBase ::keypointToHomogeneousFiniteDifference(
- const Eigen::MatrixBase ::euclideanToKeypointIntrinsicsJacobian(
- const Eigen::MatrixBase ::euclideanToKeypointDistortionJacobian(
- const Eigen::MatrixBase ::homogeneousToKeypointIntrinsicsJacobian(
- const Eigen::MatrixBase ::homogeneousToKeypointDistortionJacobian(
- const Eigen::MatrixBase ::euclideanToKeypointIntrinsicsJacobianFiniteDifference(
- const Eigen::MatrixBase ::homogeneousToKeypointIntrinsicsJacobianFiniteDifference(
- const Eigen::MatrixBase ::euclideanToKeypointDistortionJacobianFiniteDifference(
- const Eigen::MatrixBase ::homogeneousToKeypointDistortionJacobianFiniteDifference(
- const Eigen::MatrixBase ::Duration(0).
-template ::temporalOffset(
- const Eigen::MatrixBase ::temporalOffset(
- const Eigen::VectorXd& keypoint) const {
- return _shutter.temporalOffset(keypoint);
-}
-
-//////////////////////////////////////////////////////////////
-// VALIDITY TESTING
-//////////////////////////////////////////////////////////////
-
-template ::isValid(
- const Eigen::MatrixBase ::isEuclideanVisible(
- const Eigen::MatrixBase ::isHomogeneousVisible(
- const Eigen::MatrixBase ::isProjectionInvertible() const {
- return _projection.isProjectionInvertible();
-}
-
-template ::isBinaryEqual(
- const CameraGeometry & rhs) const {
- return SM_CHECKMEMBERSSAME(rhs, _id) && SM_CHECKMEMBERSSAME(rhs, _projection)
- && SM_CHECKMEMBERSSAME(rhs, _shutter) && SM_CHECKMEMBERSSAME(rhs, _mask);
-}
-
-template CameraGeometry ::getTestGeometry() {
- CameraGeometry camera(projection_t::getTestProjection(),
- shutter_t::getTestShutter(), mask_t());
- camera.setId(CameraId(rand()));
- return camera;
-}
-
-/// \brief initialize the intrinsics based on list of views of a gridded calibration target
-
-template ::initializeIntrinsics(const std::vector ::estimateTransformation(
- const GridCalibrationTargetObservation & obs,
- sm::kinematics::Transformation & out_T_t_c) const {
- return _projection.estimateTransformation(obs, out_T_t_c);
-}
-
-template ::createUninitializedFrame() const {
-
- boost::shared_ptr < frame_t > frame(new frame_t);
- return frame;
-
-}
-
-template ::createUninitializedFrameBase() const {
-
- boost::shared_ptr < FrameBase > frame(new frame_t);
- return frame;
-
-}
-
-template ::minimalDimensionsProjection() const {
- return _projection.minimalDimensions();
-}
-
-/// \brief the minimal dimensions of the distortion parameters
-template ::minimalDimensionsDistortion() const {
- return _projection.distortion().minimalDimensions();
-}
-
-template ::minimalDimensionsShutter() const {
- return _shutter.minimalDimensions();
-}
-
-/// \brief update the intrinsics
-template ::update(const double * v, bool estimateProjection,
- bool estimateDistortion,
- bool estimateShutter) {
- if (estimateProjection) {
- _projection.update(v);
- v += _projection.minimalDimensions();
- }
-
- if (estimateDistortion) {
- _projection.distortion().update(v);
- v += _projection.distortion().minimalDimensions();
- }
-
- if (estimateShutter) {
- _shutter.update(v);
- }
-}
-
-/// \brief Get the total number of dimensions of the intrinsic parameters
-template ::minimalDimensions(bool estimateProjection,
- bool estimateDistortion,
- bool estimateShutter) const {
- int dim = 0;
- if (estimateProjection) {
- dim += _projection.minimalDimensions();
- }
-
- if (estimateDistortion) {
- dim += _projection.distortion().minimalDimensions();
- }
-
- if (estimateShutter) {
- dim += _shutter.minimalDimensions();
- }
- return dim;
-}
-
-/// \brief get the intrinsic parameters.
-template ::getParameters(Eigen::MatrixXd & params,
- bool estimateProjection,
- bool estimateDistortion,
- bool estimateShutter) const {
- Eigen::MatrixXd Pp, Pd, Ps;
- int rows = 0, cols = 0;
- if (estimateProjection) {
- _projection.getParameters(Pp);
- rows += Pp.rows();
- cols = std::max(cols, (int) Pp.cols());
- }
-
- if (estimateDistortion) {
- _projection.distortion().getParameters(Pd);
- rows += Pd.rows();
- cols = std::max(cols, (int) Pd.cols());
- }
-
- if (estimateShutter) {
- _shutter.getParameters(Ps);
- rows += Ps.rows();
- cols = std::max(cols, (int) Ps.cols());
- }
-
- params = Eigen::MatrixXd::Zero(rows, cols);
- int row = 0;
-
- if (estimateProjection) {
- params.block(row, 0, Pp.rows(), Pp.cols()) = Pp;
- row += Pp.rows();
- }
-
- if (estimateDistortion) {
- params.block(row, 0, Pd.rows(), Pd.cols()) = Pd;
- row += Pd.rows();
- }
-
- if (estimateShutter) {
- params.block(row, 0, Ps.rows(), Ps.cols()) = Ps;
- row += Ps.rows();
- }
-
-}
-
-/// \brief set the intrinsic parameters.
-template ::setParameters(const Eigen::MatrixXd & params,
- bool estimateProjection,
- bool estimateDistortion,
- bool estimateShutter) {
- // Ugh...I wish I had used a vector, not a matrix.
- int row = 0;
- if (estimateProjection) {
- Eigen::Vector2i sz = _projection.parameterSize();
- _projection.setParameters(params.block(row, 0, sz[0], sz[1]));
- row += sz[0];
- }
-
- if (estimateDistortion) {
- Eigen::Vector2i sz = _projection.distortion().parameterSize();
- _projection.distortion().setParameters(params.block(row, 0, sz[0], sz[1]));
- row += sz[0];
- }
-
- if (estimateShutter) {
- Eigen::Vector2i sz = _shutter.parameterSize();
- _shutter.setParameters(params.block(row, 0, sz[0], sz[1]));
- row += sz[0];
- }
-
-}
-
-/// \brief return the Jacobian of the projection with respect to the intrinsics.
-template ::euclideanToKeypointIntrinsicsJacobian(
- const Eigen::Vector3d & p, Eigen::MatrixXd & outJi, bool estimateProjection,
- bool estimateDistortion, bool estimateShutter) const {
- // Here I have to stack the answers. The resulting matrix should be
- // KeypointDimension x minimalDimensions()
- outJi = Eigen::MatrixXd::Zero(
- KeypointDimension,
- minimalDimensions(estimateProjection, estimateDistortion,
- estimateShutter));
-
- int col = 0;
- if (estimateProjection) {
- Eigen::MatrixXd J;
- _projection.euclideanToKeypointIntrinsicsJacobian(p, J);
- outJi.block(col, 0, KeypointDimension, _projection.minimalDimensions()) = J;
- col += _projection.minimalDimensions();
- }
-
- if (estimateDistortion) {
- Eigen::MatrixXd J;
- _projection.euclideanToKeypointDistortionJacobian(p, J);
- outJi.block(col, 0, KeypointDimension,
- _projection.distortion().minimalDimensions()) = J;
- col += _projection.distortion().minimalDimensions();
- }
-
- if (estimateShutter) {
- // Uh...nothing. The shutter acts on the keypoint time.
- // At least for any example I can think of.
- }
-
-}
-
-/// \brief return the Jacobian of the projection with respect to the intrinsics.
-template ::homogeneousToKeypointIntrinsicsJacobian(
- const Eigen::Vector4d & p, Eigen::MatrixXd & outJi, bool estimateProjection,
- bool estimateDistortion, bool estimateShutter) const {
- // Here I have to stack the answers. The resulting matrix should be
- // KeypointDimension x minimalDimensions()
- outJi = Eigen::MatrixXd::Zero(
- KeypointDimension,
- minimalDimensions(estimateProjection, estimateDistortion,
- estimateShutter));
-
- int col = 0;
- if (estimateProjection) {
- Eigen::MatrixXd J;
- _projection.homogeneousToKeypointIntrinsicsJacobian(p, J);
- outJi.block(0, col, KeypointDimension, _projection.minimalDimensions()) = J;
- col += _projection.minimalDimensions();
- }
-
- if (estimateDistortion) {
- Eigen::MatrixXd J;
- _projection.homogeneousToKeypointDistortionJacobian(p, J);
- outJi.block(0, col, KeypointDimension,
- _projection.distortion().minimalDimensions()) = J;
- col += _projection.distortion().minimalDimensions();
- }
-
- if (estimateShutter) {
- // Uh...nothing. The shutter acts on the keypoint time.
- // At least for any example I can think of.
- }
-
-}
-
-/// \brief return the temporal offset with respect to the intrinsics.
-template ::temporalOffsetIntrinsicsJacobian(
- const Eigen::VectorXd & keypoint, Eigen::MatrixXd & outJi,
- bool estimateProjection, bool estimateDistortion,
- bool estimateShutter) const {
- // Here I have to stack the answers. The resulting matrix should be
- // 1 x totalparameterSize
- outJi = Eigen::MatrixXd::Zero(
- 1,
- minimalDimensions(estimateProjection, estimateDistortion,
- estimateShutter));
-
- int col = 0;
- if (estimateProjection) {
- col += _projection.minimalDimensions();
- }
-
- if (estimateDistortion) {
- col += _projection.distortion().minimalDimensions();
- }
-
- if (estimateShutter) {
- _shutter.temporalOffsetIntrinsicsJacobian(
- keypoint, outJi.block(0, col, 1, _shutter.minimalDimensions()));
- }
-}
-
-} // namespace cameras
+ namespace cameras {
+
+ /// \brief default constructor
+ template ::CameraGeometry() {
+
+ }
+
+ /// \brief Construct from projection
+ template ::CameraGeometry(const sm::PropertyTree & config)
+ : _projection(sm::PropertyTree(config, "projection")),
+ _shutter(sm::PropertyTree(config, "shutter")),
+ _mask(sm::PropertyTree(config, "mask")) {
+
+ }
+
+ /// \brief Construct from projection
+ template ::CameraGeometry(const projection_t & projection)
+ : _projection(projection) {
+
+ }
+
+ /// \brief Construct from projection and shutter
+ template