All Downloads are FREE. Search and download functionalities are using the official Maven repository.

srcnativelibs.Include.OpenCV.opencv2.stitching.stitcher.hpp Maven / Gradle / Ivy

/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                          License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of the copyright holders may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/

#ifndef __OPENCV_STITCHING_STITCHER_HPP__
#define __OPENCV_STITCHING_STITCHER_HPP__

#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/stitching/warpers.hpp"
#include "opencv2/stitching/detail/matchers.hpp"
#include "opencv2/stitching/detail/motion_estimators.hpp"
#include "opencv2/stitching/detail/exposure_compensate.hpp"
#include "opencv2/stitching/detail/seam_finders.hpp"
#include "opencv2/stitching/detail/blenders.hpp"
#include "opencv2/stitching/detail/camera.hpp"

namespace cv {

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);

    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 featuresFinder() { return features_finder_; }
    const Ptr featuresFinder() const { return features_finder_; }
    void setFeaturesFinder(Ptr features_finder)
        { features_finder_ = features_finder; }

    Ptr featuresMatcher() { return features_matcher_; }
    const Ptr featuresMatcher() const { return features_matcher_; }
    void setFeaturesMatcher(Ptr 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 bundleAdjuster() { return bundle_adjuster_; }
    const Ptr bundleAdjuster() const { return bundle_adjuster_; }
    void setBundleAdjuster(Ptr bundle_adjuster)
        { bundle_adjuster_ = bundle_adjuster; }

    Ptr warper() { return warper_; }
    const Ptr warper() const { return warper_; }
    void setWarper(Ptr creator) { warper_ = creator; }

    Ptr exposureCompensator() { return exposure_comp_; }
    const Ptr exposureCompensator() const { return exposure_comp_; }
    void setExposureCompensator(Ptr exposure_comp)
        { exposure_comp_ = exposure_comp; }

    Ptr seamFinder() { return seam_finder_; }
    const Ptr seamFinder() const { return seam_finder_; }
    void setSeamFinder(Ptr seam_finder) { seam_finder_ = seam_finder; }

    Ptr blender() { return blender_; }
    const Ptr blender() const { return blender_; }
    void setBlender(Ptr b) { blender_ = b; }

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

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

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

    std::vector component() const { return indices_; }
    std::vector cameras() const { return cameras_; }
    double workScale() const { return work_scale_; }

private:
    Stitcher() {}

    Status matchImages();
    void estimateCameraParams();

    double registr_resol_;
    double seam_est_resol_;
    double compose_resol_;
    double conf_thresh_;
    Ptr features_finder_;
    Ptr features_matcher_;
    cv::Mat matching_mask_;
    Ptr bundle_adjuster_;
    bool do_wave_correct_;
    detail::WaveCorrectKind wave_correct_kind_;
    Ptr warper_;
    Ptr exposure_comp_;
    Ptr seam_finder_;
    Ptr blender_;

    std::vector imgs_;
    std::vector > rois_;
    std::vector full_img_sizes_;
    std::vector features_;
    std::vector pairwise_matches_;
    std::vector seam_est_imgs_;
    std::vector indices_;
    std::vector cameras_;
    double work_scale_;
    double seam_scale_;
    double seam_work_aspect_;
    double warped_image_scale_;
};

} // namespace cv

#endif // __OPENCV_STITCHING_STITCHER_HPP__




© 2015 - 2025 Weber Informatics LLC | Privacy Policy