Program Listing for File distortion-fisheye.h

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

#ifndef ASLAM_FISHEYE_DISTORTION_H_
#define ASLAM_FISHEYE_DISTORTION_H_

#include <Eigen/Core>
#include <glog/logging.h>

#include <aslam/common/crtp-clone.h>
#include <aslam/cameras/distortion.h>
#include <aslam/common/macros.h>

namespace aslam {

class FisheyeDistortion : public aslam::Cloneable<Distortion, FisheyeDistortion> {
 public:
  enum { kNumOfParams = 1 };

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


  explicit FisheyeDistortion(const Eigen::VectorXd& distortionParams);

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

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


 public:
  virtual void distortUsingExternalCoefficients(const Eigen::VectorXd* dist_coeffs,
                                                Eigen::Vector2d* point,
                                                Eigen::Matrix2d* out_jacobian) const;

  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;

  virtual void distortParameterJacobian(const Eigen::VectorXd* dist_coeffs,
                                        const Eigen::Vector2d& point,
                                        Eigen::Matrix<double, 2, Eigen::Dynamic>* out_jacobian) const;



  virtual void undistortUsingExternalCoefficients(const Eigen::VectorXd& dist_coeffs,
                                                  Eigen::Vector2d* point) const;



  static FisheyeDistortion::UniquePtr createTestDistortion() {
    Eigen::VectorXd params(1); params << 1.1;
    return FisheyeDistortion::UniquePtr(new FisheyeDistortion(params));
  }



  static bool areParametersValid(const Eigen::VectorXd& parameters);

  virtual bool distortionParametersValid(const Eigen::VectorXd& dist_coeffs) const;

  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;



  static double getMinValidW() {return kMinValidW; }
  static double getMaxValidW() { return kMaxValidW; }
 private:
  static constexpr double kMaxValidAngle = (89.0 * M_PI / 180.0);
  static constexpr double kMinValidW = 0.5;
  static constexpr double kMaxValidW = 1.5;

};

} // namespace aslam

#include "distortion-fisheye-inl.h"

#endif /* ASLAM_FISHEYE_DISTORTION_H_ */