Program Listing for File distortion-null.h

Return to documentation for file (aslam_cv2/aslam_cv_cameras/include/aslam/cameras/distortion-null.h)

#ifndef ASLAM_NULL_DISTORTION_H_
#define ASLAM_NULL_DISTORTION_H_

#include <Eigen/Core>
#include <aslam/cameras/distortion.h>
#include <aslam/common/crtp-clone.h>
#include <aslam/common/macros.h>
#include <glog/logging.h>

namespace aslam {

class NullDistortion : public aslam::Cloneable<Distortion, NullDistortion> {
 public:
  enum { kNumOfParams = 0 };

  enum { CLASS_SERIALIZATION_VERSION = 1 };
  ASLAM_POINTER_TYPEDEFS(NullDistortion);


  NullDistortion() : Base(Eigen::VectorXd(), Distortion::Type::kNoDistortion) {}

  friend std::ostream& operator<<(
      std::ostream& out, const NullDistortion& distortion);

 public:
  NullDistortion(const NullDistortion&) = default;
  void operator=(const NullDistortion&) = delete;


 public:
  virtual void distortUsingExternalCoefficients(
      const Eigen::VectorXd* /* dist_coeffs */, Eigen::Vector2d* /* point */,
      Eigen::Matrix2d* out_jacobian) const {
    if (out_jacobian) {
      out_jacobian->setIdentity();
    }
  }

  template <typename ScalarType, typename MDistortion>
  void distortUsingExternalCoefficients(
      const Eigen::MatrixBase<MDistortion>& /* dist_coeffs */,
      const Eigen::Matrix<ScalarType, 2, 1>& point,
      Eigen::Matrix<ScalarType, 2, 1>* out_point) const {
    CHECK_NOTNULL(out_point);
    *out_point = point;
  }

  virtual void distortParameterJacobian(
      const Eigen::VectorXd* /* dist_coeffs */,
      const Eigen::Vector2d& /* point */,
      Eigen::Matrix<double, 2, Eigen::Dynamic>* out_jacobian) const {
    if (out_jacobian) {
      out_jacobian->resize(2, 0);
    }
  }



  virtual void undistortUsingExternalCoefficients(
      const Eigen::VectorXd& /*dist_coeffs*/,
      Eigen::Vector2d* /*point*/) const {}



  static NullDistortion::UniquePtr createTestDistortion() {
    return NullDistortion::UniquePtr(new NullDistortion());
  }



  static bool areParametersValid(const Eigen::VectorXd& /*parameters*/) {
    // As the parameters do not have an impact, all parameters are valid.
    return true;
  }

  virtual bool distortionParametersValid(
      const Eigen::VectorXd& /*dist_coeffs*/) const {
    // As the parameters do not have an impact, all parameters are valid.
    return true;
  }

  inline static constexpr size_t parameterCount() {
    return kNumOfParams;
  }

  virtual int getParameterSize() const {
    return kNumOfParams;
  }

  virtual void printParameters(
      std::ostream& out, const std::string& text) const {
    out << text << std::endl;
    out << "Distortion: (NullDistortion) " << std::endl;
  }
};

inline std::ostream& operator<<(
    std::ostream& out, const NullDistortion& distortion) {
  distortion.printParameters(out, std::string(""));
  return out;
}

}  // namespace aslam

#endif  // ASLAM_NULL_DISTORTION_H_