High Level Functionality — OpenCV 2.4.13.0 documentation

### Navigation

- index
- next |
- previous |
- OpenCV 2.4.13.0 documentation »
- OpenCV API Reference »
- stitching. Images stitching »

# High Level Functionality

## Stitcher

class `Stitcher`

High level image stitcher. It’s possible to use this class without being aware of the entire stitching pipeline. However, to be able to achieve higher stitching stability and quality of the final images at least being familiar with the theory is recommended (see Stitching Pipeline).

    class CV_EXPORTS Stitcher
    {
    public:
        enum { ORIG_RESOL = -1 };
        enum Status { OK, ERR_NEED_MORE_IMGS };

        // Creates stitcher with default parameters
        static Stitcher createDefault(bool try_use_gpu = false);

        Status estimateTransform(InputArray images);
        Status estimateTransform(InputArray images, const std::vector<std::vector<Rect> > &rois);

        Status composePanorama(OutputArray pano);
        Status composePanorama(InputArray images, OutputArray pano);

        Status stitch(InputArray images, OutputArray pano);
        Status stitch(InputArray images, const std::vector<std::vector<Rect> > &rois, OutputArray pano);

        double registrationResol() const { return registr_resol_; }
        void setRegistrationResol(double resol_mpx) { registr_resol_ = resol_mpx; }

        double seamEstimationResol() const { return seam_est_resol_; }
        void setSeamEstimationResol(double resol_mpx) { seam_est_resol_ = resol_mpx; }

        double compositingResol() const { return compose_resol_; }
        void setCompositingResol(double resol_mpx) { compose_resol_ = resol_mpx; }

        double panoConfidenceThresh() const { return conf_thresh_; }
        void setPanoConfidenceThresh(double conf_thresh) { conf_thresh_ = conf_thresh; }

        bool waveCorrection() const { return do_wave_correct_; }
        void setWaveCorrection(bool flag) { do_wave_correct_ = flag; }

        detail::WaveCorrectKind waveCorrectKind() const { return wave_correct_kind_; }
        void setWaveCorrectKind(detail::WaveCorrectKind kind) { wave_correct_kind_ = kind; }

        Ptr<detail::FeaturesFinder> featuresFinder() { return features_finder_; }
        const Ptr<detail::FeaturesFinder> featuresFinder() const { return features_finder_; }
        void setFeaturesFinder(Ptr<detail::FeaturesFinder> features_finder)
            { features_finder_ = features_finder; }

        Ptr<detail::FeaturesMatcher> featuresMatcher() { return features_matcher_; }
        const Ptr<detail::FeaturesMatcher> featuresMatcher() const { return features_matcher_; }
        void setFeaturesMatcher(Ptr<detail::FeaturesMatcher> features_matcher)
            { features_matcher_ = features_matcher; }

        const cv::Mat& matchingMask() const { return matching_mask_; }
        void setMatchingMask(const cv::Mat &mask)
        {
            CV_Assert(mask.type() == CV_8U && mask.cols == mask.rows);
            matching_mask_ = mask.clone();
        }

        Ptr<detail::BundleAdjusterBase> bundleAdjuster() { return bundle_adjuster_; }
        const Ptr<detail::BundleAdjusterBase> bundleAdjuster() const { return bundle_adjuster_; }
        void setBundleAdjuster(Ptr<detail::BundleAdjusterBase> bundle_adjuster)
            { bundle_adjuster_ = bundle_adjuster; }

        Ptr<WarperCreator> warper() { return warper_; }
        const Ptr<WarperCreator> warper() const { return warper_; }
        void setWarper(Ptr<WarperCreator> warper) { warper_ = warper; }

        Ptr<detail::ExposureCompensator> exposureCompensator() { return exposure_comp_; }
        const Ptr<detail::ExposureCompensator> exposureCompensator() const { return exposure_comp_; }
        void setExposureCompensator(Ptr<detail::ExposureCompensator> exposure_comp)
            { exposure_comp_ = exposure_comp; }

        Ptr<detail::SeamFinder> seamFinder() { return seam_finder_; }
        const Ptr<detail::SeamFinder> seamFinder() const { return seam_finder_; }
        void setSeamFinder(Ptr<detail::SeamFinder> seam_finder) { seam_finder_ = seam_finder; }

        Ptr<detail::Blender> blender() { return blender_; }
        const Ptr<detail::Blender> blender() const { return blender_; }
        void setBlender(Ptr<detail::Blender> blender) { blender_ = blender; }

    private:
        /* hidden */
    };

Note

- A basic example on image stitching can be found at opencv_source_code/samples/cpp/stitching.cpp
- A detailed example on image stitching can be found at opencv_source_code/samples/cpp/stitching_detailed.cpp

## Stitcher::createDefault

Creates a stitcher with the default parameters.

C++:`` Stitcher `Stitcher::``createDefault`(bool try_use_gpu=false)

  Parameters: | try_use_gpu – Flag indicating whether GPU should be used whenever it’s possible.
  Returns: | Stitcher class instance.

## Stitcher::estimateTransform

These functions try to match the given images and to estimate rotations of each camera.

Note

Use the functions only if you’re aware of the stitching pipeline, otherwise use `Stitcher::stitch()`.

C++:`` Status `Stitcher::``estimateTransform`(InputArray images)

C++:`` Status `Stitcher::``estimateTransform`(InputArray images, const std::vector<std::vector<Rect>>& rois)

  Parameters: | images – Input images. rois – Region of interest rectangles.
  Returns: | Status code.

## Stitcher::composePanorama

These functions try to compose the given images (or images stored internally from the other function calls) into the final pano under the assumption that the image transformations were estimated before.

Note

Use the functions only if you’re aware of the stitching pipeline, otherwise use `Stitcher::stitch()`.

C++:`` Status `Stitcher::``composePanorama`(OutputArray pano)

C++:`` Status `Stitcher::``composePanorama`(InputArray images, OutputArray pano)

  Parameters: | images – Input images. pano – Final pano.
  Returns: | Status code.

## Stitcher::stitch

These functions try to stitch the given images.

C++:`` Status `Stitcher::``stitch`(InputArray images, OutputArray pano)

C++:`` Status `Stitcher::``stitch`(InputArray images, const std::vector<std::vector<Rect>>& rois, OutputArray pano)

  Parameters: | images – Input images. rois – Region of interest rectangles. pano – Final pano.
  Returns: | Status code.

## WarperCreator

class `WarperCreator`

Image warper factories base class.

    class WarperCreator
    {
    public:
        virtual ~WarperCreator() {}
        virtual Ptr<detail::RotationWarper> create(float scale) const = 0;
    };

## PlaneWarper

class `PlaneWarper` : public `WarperCreator`

Plane warper factory class.

    class PlaneWarper : public WarperCreator
    {
    public:
        Ptr<detail::RotationWarper> create(float scale) const { return new detail::PlaneWarper(scale); }
    };

See also

`detail::PlaneWarper`

## CylindricalWarper

class `CylindricalWarper` : public `WarperCreator`

Cylindrical warper factory class.

    class CylindricalWarper: public WarperCreator
    {
    public:
        Ptr<detail::RotationWarper> create(float scale) const { return new detail::CylindricalWarper(scale); }
    };

See also

`detail::CylindricalWarper`

## SphericalWarper

class `SphericalWarper` : public `WarperCreator`

Spherical warper factory class.

    class SphericalWarper: public WarperCreator
    {
    public:
        Ptr<detail::RotationWarper> create(float scale) const { return new detail::SphericalWarper(scale); }
    };

See also

`detail::SphericalWarper`

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 2.4.13.0 documentation »
- OpenCV API Reference »
- stitching. Images stitching »