MTF
IST.h
1 #ifndef MTF_IST_H
2 #define MTF_IST_H
3 
4 #include "ProjectiveBase.h"
5 #include "SSMEstimator.h"
6 #include "SSMEstimatorParams.h"
7 
8 _MTF_BEGIN_NAMESPACE
9 
11  bool debug_mode;
12  ISTParams(const SSMParams *ssm_params, bool _debug_mode);
13  ISTParams(const ISTParams *params = nullptr);
14 };
15 
16 class ISTEstimator : public SSMEstimator{
17 public:
18  ISTEstimator(int modelPoints, bool _use_boost_rng);
19 
20  int runKernel(const CvMat* m1, const CvMat* m2, CvMat* model) override;
21  bool refine(const CvMat* m1, const CvMat* m2,
22  CvMat* model, int maxIters) override;
23 protected:
24  void computeReprojError(const CvMat* m1, const CvMat* m2,
25  const CvMat* model, CvMat* error) override;
26 };
27 
29 class IST : public ProjectiveBase{
30 public:
31 
32  typedef ISTParams ParamType;
33 
34  IST(const ParamType *params_in = nullptr);
35 
36  void setState(const VectorXd &ssm_state) override;
37  void compositionalUpdate(const VectorXd& state_update) override;
38 
39  void getInitPixGrad(Matrix2Xd &ssm_grad, int pix_id) override;
40  // Gradient is independent of the current values of the warp parameters
41  void getCurrPixGrad(Matrix2Xd &ssm_grad, int pix_id) override {
42  getInitPixGrad(ssm_grad, pix_id);
43  }void cmptInitPixJacobian(MatrixXd &jacobian_prod, const PixGradT &am_jacobian) override;
44  // Jacobian is independent of the current values of the warp parameters
45  void cmptPixJacobian(MatrixXd &jacobian_prod, const PixGradT &am_jacobian) override{
46  cmptInitPixJacobian(jacobian_prod, am_jacobian);
47  }
48  void cmptApproxPixJacobian(MatrixXd &jacobian_prod,
49  const PixGradT &pix_jacobian) override;
50  void cmptWarpedPixJacobian(MatrixXd &dI_dp, const PixGradT &dI_dx) override;
51 
52 
53  void cmptInitPixHessian(MatrixXd &pix_hess_ssm, const PixHessT &pix_hess_coord,
54  const PixGradT &pix_grad) override;
55  // Hessian is independent of the current values of the warp parameters
56  void cmptPixHessian(MatrixXd &pix_hess_ssm, const PixHessT &pix_hess_coord,
57  const PixGradT &pix_grad) override {
58  cmptInitPixHessian(pix_hess_ssm, pix_hess_coord, pix_grad);
59  }
60  void cmptWarpedPixHessian(MatrixXd &d2I_dp2, const PixHessT &d2I_dw2,
61  const PixGradT &dI_dw) override;
62 
63  void estimateWarpFromCorners(VectorXd &state_update, const Matrix24d &in_corners,
64  const Matrix24d &out_corners) override;
65  void estimateWarpFromPts(VectorXd &state_update, vector<uchar> &mask,
66  const vector<cv::Point2f> &in_pts, const vector<cv::Point2f> &out_pts,
67  const EstimatorParams &est_params) override;
68 
69  void updateGradPts(double grad_eps) override;
70  void updateHessPts(double hess_eps) override;
71 
72  void applyWarpToCorners(Matrix24d &warped_corners, const Matrix24d &orig_corners,
73  const VectorXd &state_update) override;
74  void applyWarpToPts(Matrix2Xd &warped_pts, const Matrix2Xd &orig_pts,
75  const VectorXd &state_update) override;
76 
77  void getWarpFromState(Matrix3d &warp_mat, const VectorXd& ssm_state) override;
78  void getStateFromWarp(VectorXd &state_vec, const Matrix3d& warp_mat) override;
79 
80 #ifndef DISABLE_SPI
81  bool supportsSPI() override{ return true; }
82 #endif
83 protected:
84  ParamType params;
85  cv::Mat estimateIST(cv::InputArray _points1, cv::InputArray _points2,
86  cv::OutputArray _mask, const SSMEstimatorParams &est_params);
87 
88  int estimateIST(const CvMat* in_pts, const CvMat* out_pts,
89  CvMat* __H, CvMat* mask, const SSMEstimatorParams &est_params);
90 };
91 
92 
93 
94 _MTF_END_NAMESPACE
95 
96 #endif
Definition: IST.h:16
Isotropic Scaling and Translation.
Definition: IST.h:29
Definition: StateSpaceModel.h:35
Definition: SSMEstimatorParams.h:9
Base class for robust estimators for different SSMs adapted from CvModelEstimator2 defined in _modelt...
Definition: SSMEstimator.h:14
Definition: IST.h:10
base class for all SSMs that can be expressed by homogeneous multiplication with a 3x3 projective tra...
Definition: ProjectiveBase.h:14