Rotation Estimation

detail::Estimator

class detail::Estimator

Rotation estimator base class. It takes features of all images, pairwise matches between all images and estimates rotations of all cameras.

Note

The coordinate system origin is implementation-dependent, but you can always normalize the rotations in respect to the first camera, for instance.

class CV_EXPORTS Estimator
{
public:
    virtual ~Estimator() {}

    void operator ()(const std::vector<ImageFeatures> &features, const std::vector<MatchesInfo> &pairwise_matches,
                     std::vector<CameraParams> &cameras)
        { estimate(features, pairwise_matches, cameras); }

protected:
    virtual void estimate(const std::vector<ImageFeatures> &features, const std::vector<MatchesInfo> &pairwise_matches,
                          std::vector<CameraParams> &cameras) = 0;
};

detail::Estimator::operator()

Estimates camera parameters.

C++: detail::Estimator::operator()(const std::vector<ImageFeatures>& features, const std::vector<MatchesInfo>& pairwise_matches, std::vector<CameraParams>& cameras)
Parameters:
  • features – Features of images
  • pairwise_matches – Pairwise matches of images
  • cameras – Estimated camera parameters

detail::Estimator::estimate

This method must implement camera parameters estimation logic in order to make the wrapper detail::Estimator::operator() work.

C++: void detail::Estimator::estimate(const std::vector<ImageFeatures>& features, const std::vector<MatchesInfo>& pairwise_matches, std::vector<CameraParams>& cameras)
Parameters:
  • features – Features of images
  • pairwise_matches – Pairwise matches of images
  • cameras – Estimated camera parameters

detail::HomographyBasedEstimator

class detail::HomographyBasedEstimator : public detail::Estimator

Homography based rotation estimator.

class CV_EXPORTS HomographyBasedEstimator : public Estimator
{
public:
    HomographyBasedEstimator(bool is_focals_estimated = false)
        : is_focals_estimated_(is_focals_estimated) {}

private:
    /* hidden */
};

detail::BundleAdjusterBase

class detail::BundleAdjusterBase : public detail::Estimator

Base class for all camera parameters refinement methods.

class CV_EXPORTS BundleAdjusterBase : public Estimator
{
public:
    const Mat refinementMask() const { return refinement_mask_.clone(); }
    void setRefinementMask(const Mat &mask)
    {
        CV_Assert(mask.type() == CV_8U && mask.size() == Size(3, 3));
        refinement_mask_ = mask.clone();
    }

    double confThresh() const { return conf_thresh_; }
    void setConfThresh(double conf_thresh) { conf_thresh_ = conf_thresh; }

    CvTermCriteria termCriteria() { return term_criteria_; }
    void setTermCriteria(const CvTermCriteria& term_criteria) { term_criteria_ = term_criteria; }

protected:
    BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement)
        : num_params_per_cam_(num_params_per_cam),
          num_errs_per_measurement_(num_errs_per_measurement)
    {
        setRefinementMask(Mat::ones(3, 3, CV_8U));
        setConfThresh(1.);
        setTermCriteria(cvTermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 1000, DBL_EPSILON));
    }

    // Runs bundle adjustment
    virtual void estimate(const std::vector<ImageFeatures> &features,
                          const std::vector<MatchesInfo> &pairwise_matches,
                          std::vector<CameraParams> &cameras);

    virtual void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) = 0;
    virtual void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const = 0;
    virtual void calcError(Mat &err) = 0;
    virtual void calcJacobian(Mat &jac) = 0;

    // 3x3 8U mask, where 0 means don't refine respective parameter, != 0 means refine
    Mat refinement_mask_;

    int num_images_;
    int total_num_matches_;

    int num_params_per_cam_;
    int num_errs_per_measurement_;

    const ImageFeatures *features_;
    const MatchesInfo *pairwise_matches_;

    // Threshold to filter out poorly matched image pairs
    double conf_thresh_;

    //Levenberg–Marquardt algorithm termination criteria
    CvTermCriteria term_criteria_;

    // Camera parameters matrix (CV_64F)
    Mat cam_params_;

    // Connected images pairs
    std::vector<std::pair<int,int> > edges_;
};

detail::BundleAdjusterBase::BundleAdjusterBase

Construct a bundle adjuster base instance.

C++: detail::BundleAdjusterBase::BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement)
Parameters:
  • num_params_per_cam – Number of parameters per camera
  • num_errs_per_measurement – Number of error terms (components) per match

detail::BundleAdjusterBase::setUpInitialCameraParams

Sets initial camera parameter to refine.

C++: void detail::BundleAdjusterBase::setUpInitialCameraParams(const std::vector<CameraParams>& cameras)
Parameters:
  • cameras – Camera parameters

detail::BundleAdjusterBase::calcError

Calculates error vector.

C++: void detail::BundleAdjusterBase::calcError(Mat& err)
Parameters:
  • err – Error column-vector of length total_num_matches * num_errs_per_measurement

detail::BundleAdjusterBase::calcJacobian

Calculates the cost function jacobian.

C++: void detail::BundleAdjusterBase::calcJacobian(Mat& jac)
Parameters:
  • jac – Jacobian matrix of dimensions (total_num_matches * num_errs_per_measurement) x (num_images * num_params_per_cam)

detail::BundleAdjusterBase::obtainRefinedCameraParams

Gets the refined camera parameters.

C++: void detail::BundleAdjusterBase::obtainRefinedCameraParams(std::vector<CameraParams>& cameras) const
Parameters:
  • cameras – Refined camera parameters

detail::BundleAdjusterReproj

class detail::BundleAdjusterReproj : public detail::BundleAdjusterBase

Implementation of the camera parameters refinement algorithm which minimizes sum of the reprojection error squares.

class CV_EXPORTS BundleAdjusterReproj : public BundleAdjusterBase
{
public:
    BundleAdjusterReproj() : BundleAdjusterBase(7, 2) {}

private:
    /* hidden */
};

detail::BundleAdjusterRay

class detail::BundleAdjusterRay : public detail::BundleAdjusterBase

Implementation of the camera parameters refinement algorithm which minimizes sum of the distances between the rays passing through the camera center and a feature.

class CV_EXPORTS BundleAdjusterRay : public BundleAdjusterBase
{
public:
    BundleAdjusterRay() : BundleAdjusterBase(4, 3) {}

private:
    /* hidden */
};

detail::WaveCorrectKind

class detail::WaveCorrectKind

Wave correction kind.

enum CV_EXPORTS WaveCorrectKind
{
    WAVE_CORRECT_HORIZ,
    WAVE_CORRECT_VERT
};

detail::waveCorrect

Tries to make panorama more horizontal (or vertical).

C++: void detail::waveCorrect(std::vector<Mat>& rmats, WaveCorrectKind kind)
Parameters: