Table Of Contents

Previous topic

Autocalibration

Next topic

Seam Estimation

Images Warping

detail::RotationWarper

class detail::RotationWarper

Rotation-only model image warper interface.

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

    virtual Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) = 0;

    virtual Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) = 0;

    virtual Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
                       OutputArray dst) = 0;

    virtual void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
                              Size dst_size, OutputArray dst) = 0;

    virtual Rect warpRoi(Size src_size, InputArray K, InputArray R) = 0;
};

detail::RotationWarper::warpPoint

Projects the image point.

C++: Point2f detail::RotationWarper::warpPoint(const Point2f& pt, InputArray K, InputArray R)
Parameters:
  • pt – Source point
  • K – Camera intrinsic parameters
  • R – Camera rotation matrix
Returns:

Projected point

detail::RotationWarper::buildMaps

Builds the projection maps according to the given camera data.

C++: Rect detail::RotationWarper::buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap)
Parameters:
  • src_size – Source image size
  • K – Camera intrinsic parameters
  • R – Camera rotation matrix
  • xmap – Projection map for the x axis
  • ymap – Projection map for the y axis
Returns:

Projected image minimum bounding box

detail::RotationWarper::warp

Projects the image.

C++: Point detail::RotationWarper::warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst)
Parameters:
  • src – Source image
  • K – Camera intrinsic parameters
  • R – Camera rotation matrix
  • interp_mode – Interpolation mode
  • border_mode – Border extrapolation mode
  • dst – Projected image
Returns:

Project image top-left corner

detail::RotationWarper::warpBackward

Projects the image backward.

C++: void detail::RotationWarper::warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, Size dst_size, OutputArray dst)
Parameters:
  • src – Projected image
  • K – Camera intrinsic parameters
  • R – Camera rotation matrix
  • interp_mode – Interpolation mode
  • border_mode – Border extrapolation mode
  • dst_size – Backward-projected image size
  • dst – Backward-projected image

detail::RotationWarper::warpRoi

C++: Rect detail::RotationWarper::warpRoi(Size src_size, InputArray K, InputArray R)
Parameters:
  • src_size – Source image bounding box
  • K – Camera intrinsic parameters
  • R – Camera rotation matrix
Returns:

Projected image minimum bounding box

detail::ProjectorBase

struct detail::ProjectorBase

Base class for warping logic implementation.

struct CV_EXPORTS ProjectorBase
{
    void setCameraParams(InputArray K = Mat::eye(3, 3, CV_32F),
                        InputArray R = Mat::eye(3, 3, CV_32F),
                        InputArray T = Mat::zeros(3, 1, CV_32F));

    float scale;
    float k[9];
    float rinv[9];
    float r_kinv[9];
    float k_rinv[9];
    float t[3];
};

detail::RotationWarperBase

class detail::RotationWarperBase

Base class for rotation-based warper using a detail::ProjectorBase derived class.

template <class P>
class CV_EXPORTS RotationWarperBase : public RotationWarper
{
public:
    Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R);

    Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap);

    Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
            OutputArray dst);

    void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
                    Size dst_size, OutputArray dst);

    Rect warpRoi(Size src_size, InputArray K, InputArray R);

protected:

    // Detects ROI of the destination image. It's correct for any projection.
    virtual void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br);

    // Detects ROI of the destination image by walking over image border.
    // Correctness for any projection isn't guaranteed.
    void detectResultRoiByBorder(Size src_size, Point &dst_tl, Point &dst_br);

    P projector_;
};

detail::PlaneWarper

class detail::PlaneWarper : public detail::RotationWarperBase<PlaneProjector>

Warper that maps an image onto the z = 1 plane.

class CV_EXPORTS PlaneWarper : public RotationWarperBase<PlaneProjector>
{
public:
    PlaneWarper(float scale = 1.f) { projector_.scale = scale; }

    void setScale(float scale) { projector_.scale = scale; }

    Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R, InputArray T);

    Rect buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, OutputArray xmap, OutputArray ymap);

    Point warp(InputArray src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode,
               OutputArray dst);

    Rect warpRoi(Size src_size, InputArray K, InputArray R, InputArray T);

protected:
    void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br);
};

detail::PlaneWarper::PlaneWarper

Construct an instance of the plane warper class.

C++: void detail::PlaneWarper::PlaneWarper(float scale=1.f)
Parameters:
  • scale – Projected image scale multiplier

detail::SphericalWarper

class detail::SphericalWarper : public detail::RotationWarperBase<SphericalProjector>

Warper that maps an image onto the unit sphere located at the origin.

class CV_EXPORTS SphericalWarper : public RotationWarperBase<SphericalProjector>
{
public:
    SphericalWarper(float scale) { projector_.scale = scale; }

protected:
    void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br);
};

detail::SphericalWarper::SphericalWarper

Construct an instance of the spherical warper class.

C++: void detail::SphericalWarper::SphericalWarper(float scale)
Parameters:
  • scale – Projected image scale multiplier

detail::CylindricalWarper

class detail::CylindricalWarper : public detail::RotationWarperBase<CylindricalProjector>

Warper that maps an image onto the x*x + z*z = 1 cylinder.

class CV_EXPORTS CylindricalWarper : public RotationWarperBase<CylindricalProjector>
{
public:
    CylindricalWarper(float scale) { projector_.scale = scale; }

protected:
    void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br)
    {
        RotationWarperBase<CylindricalProjector>::detectResultRoiByBorder(src_size, dst_tl, dst_br);
    }
};

detail::CylindricalWarper::CylindricalWarper

Construct an instance of the cylindrical warper class.

C++: void detail::CylindricalWarper::CylindricalWarper(float scale)
Parameters:
  • scale – Projected image scale multiplier