2012-01-18 21:43:34 +08:00
Rotation Estimation
===================
.. highlight :: cpp
detail::Estimator
-----------------
.. ocv:class :: detail::Estimator
2012-05-30 19:13:07 +08:00
Rotation estimator base class. It takes features of all images, pairwise matches between all images and estimates rotations of all cameras.
2012-01-18 21:43:34 +08:00
2012-05-30 19:13:07 +08:00
.. note :: The coordinate system origin is implementation-dependent, but you can always normalize the rotations in respect to the first camera, for instance.
2012-01-18 21:43:34 +08:00
::
class CV_EXPORTS Estimator
{
public:
virtual ~Estimator() {}
2013-07-04 21:41:39 +08:00
bool operator ()(const std::vector<ImageFeatures> &features, const std::vector<MatchesInfo> &pairwise_matches,
std::vector<CameraParams> &cameras);
2012-01-18 21:43:34 +08:00
protected:
2013-07-04 21:41:39 +08:00
virtual bool estimate(const std::vector<ImageFeatures> &features, const std::vector<MatchesInfo> &pairwise_matches,
2012-01-18 21:43:34 +08:00
std::vector<CameraParams> &cameras) = 0;
};
2012-01-26 19:47:33 +08:00
detail::Estimator::operator()
-----------------------------
Estimates camera parameters.
2013-07-05 14:16:22 +08:00
.. ocv:function :: bool detail::Estimator::operator ()(const std::vector<ImageFeatures> &features, const std::vector<MatchesInfo> &pairwise_matches, std::vector<CameraParams> &cameras)
2012-01-26 19:47:33 +08:00
:param features: Features of images
:param pairwise_matches: Pairwise matches of images
:param cameras: Estimated camera parameters
2013-07-04 21:41:39 +08:00
:return: True in case of success, false otherwise
2012-01-26 19:47:33 +08:00
detail::Estimator::estimate
---------------------------
This method must implement camera parameters estimation logic in order to make the wrapper `detail::Estimator::operator()`_ work.
2013-07-05 14:16:22 +08:00
.. ocv:function :: bool detail::Estimator::estimate(const std::vector<ImageFeatures> &features, const std::vector<MatchesInfo> &pairwise_matches, std::vector<CameraParams> &cameras)
2012-01-26 19:47:33 +08:00
:param features: Features of images
:param pairwise_matches: Pairwise matches of images
:param cameras: Estimated camera parameters
2013-07-04 21:41:39 +08:00
:return: True in case of success, false otherwise
2012-01-18 21:43:34 +08:00
detail::HomographyBasedEstimator
--------------------------------
2012-05-30 19:13:07 +08:00
.. ocv:class :: detail::HomographyBasedEstimator : public detail::Estimator
2012-01-18 21:43:34 +08:00
Homography based rotation estimator. ::
class CV_EXPORTS HomographyBasedEstimator : public Estimator
{
public:
HomographyBasedEstimator(bool is_focals_estimated = false)
: is_focals_estimated_(is_focals_estimated) {}
2012-01-26 19:47:33 +08:00
private:
/* hidden * /
2012-01-18 21:43:34 +08:00
};
detail::BundleAdjusterBase
--------------------------
2012-05-30 19:13:07 +08:00
.. ocv:class :: detail::BundleAdjusterBase : public detail::Estimator
2012-01-18 21:43:34 +08:00
Base class for all camera parameters refinement methods. ::
class CV_EXPORTS BundleAdjusterBase : public Estimator
{
public:
const Mat refinementMask() const { return refinement_mask_.clone(); }
2012-05-30 19:13:07 +08:00
void setRefinementMask(const Mat &mask)
{
2012-01-18 21:43:34 +08:00
CV_Assert(mask.type() == CV_8U && mask.size() == Size(3, 3));
2012-05-30 19:13:07 +08:00
refinement_mask_ = mask.clone();
2012-01-18 21:43:34 +08:00
}
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:
2012-05-30 19:13:07 +08:00
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)
{
2012-01-18 21:43:34 +08:00
setRefinementMask(Mat::ones(3, 3, CV_8U));
2012-05-30 19:13:07 +08:00
setConfThresh(1.);
2012-01-18 21:43:34 +08:00
setTermCriteria(cvTermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 1000, DBL_EPSILON));
}
// Runs bundle adjustment
2012-05-30 19:13:07 +08:00
virtual void estimate(const std::vector<ImageFeatures> &features,
2012-01-18 21:43:34 +08:00
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_;
};
2012-01-26 20:02:45 +08:00
.. seealso :: :ocv:class: `detail::Estimator`
2012-01-26 19:47:33 +08:00
detail::BundleAdjusterBase::BundleAdjusterBase
----------------------------------------------
Construct a bundle adjuster base instance.
.. ocv:function :: detail::BundleAdjusterBase::BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement)
:param num_params_per_cam: Number of parameters per camera
2012-05-30 19:13:07 +08:00
2012-01-26 19:47:33 +08:00
:param num_errs_per_measurement: Number of error terms (components) per match
2012-01-18 21:43:34 +08:00
2012-01-26 20:02:45 +08:00
detail::BundleAdjusterBase::setUpInitialCameraParams
----------------------------------------------------
Sets initial camera parameter to refine.
2012-01-26 20:44:32 +08:00
.. ocv:function :: void detail::BundleAdjusterBase::setUpInitialCameraParams(const std::vector<CameraParams> &cameras)
2012-01-26 20:02:45 +08:00
:param cameras: Camera parameters
detail::BundleAdjusterBase::calcError
-------------------------------------
Calculates error vector.
2012-01-26 20:44:32 +08:00
.. ocv:function :: void detail::BundleAdjusterBase::calcError(Mat &err)
2012-01-26 20:02:45 +08:00
:param err: Error column-vector of length ``total_num_matches * num_errs_per_measurement``
detail::BundleAdjusterBase::calcJacobian
----------------------------------------
Calculates the cost function jacobian.
2012-01-26 20:44:32 +08:00
.. ocv:function :: void detail::BundleAdjusterBase::calcJacobian(Mat &jac)
2012-01-26 20:02:45 +08:00
:param 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.
2012-01-26 20:44:32 +08:00
.. ocv:function :: void detail::BundleAdjusterBase::obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const
2012-01-26 20:02:45 +08:00
:param cameras: Refined camera parameters
2012-01-18 21:43:34 +08:00
detail::BundleAdjusterReproj
----------------------------
2012-05-30 19:13:07 +08:00
.. ocv:class :: detail::BundleAdjusterReproj : public detail::BundleAdjusterBase
2012-01-18 21:43:34 +08:00
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 * /
};
2012-01-26 20:44:32 +08:00
.. seealso :: :ocv:class: `detail::BundleAdjusterBase` , :ocv:class: `detail::Estimator`
2012-01-18 21:43:34 +08:00
detail::BundleAdjusterRay
-------------------------
2012-05-30 19:13:07 +08:00
.. ocv:class :: detail::BundleAdjusterRay : public detail::BundleAdjusterBase
2012-01-18 21:43:34 +08:00
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 * /
};
.. seealso :: :ocv:class: `detail::BundleAdjusterBase`
detail::WaveCorrectKind
-----------------------
2013-02-19 18:19:59 +08:00
Wave correction kind.
2012-01-18 21:43:34 +08:00
2013-02-19 18:19:59 +08:00
.. ocv:enum :: detail::WaveCorrectKind
.. ocv:emember :: WAVE_CORRECT_HORIZ
.. ocv:emember :: WAVE_CORRECT_VERT
2012-01-18 21:43:34 +08:00
detail::waveCorrect
-------------------
2012-04-14 03:04:44 +08:00
Tries to make panorama more horizontal (or vertical).
2012-01-18 21:43:34 +08:00
2012-05-30 19:13:07 +08:00
.. ocv:function :: void detail::waveCorrect(std::vector<Mat> &rmats, WaveCorrectKind kind)
2012-01-18 21:43:34 +08:00
:param rmats: Camera rotation matrices.
2013-02-19 18:19:59 +08:00
:param kind: Correction kind, see :ocv:enum:`detail::WaveCorrectKind`.