github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/opencv4/include/opencv2/stitching/detail/util.hpp (about)

     1  /*M///////////////////////////////////////////////////////////////////////////////////////
     2  //
     3  //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
     4  //
     5  //  By downloading, copying, installing or using the software you agree to this license.
     6  //  If you do not agree to this license, do not download, install,
     7  //  copy or use the software.
     8  //
     9  //
    10  //                          License Agreement
    11  //                For Open Source Computer Vision Library
    12  //
    13  // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
    14  // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
    15  // Third party copyrights are property of their respective owners.
    16  //
    17  // Redistribution and use in source and binary forms, with or without modification,
    18  // are permitted provided that the following conditions are met:
    19  //
    20  //   * Redistribution's of source code must retain the above copyright notice,
    21  //     this list of conditions and the following disclaimer.
    22  //
    23  //   * Redistribution's in binary form must reproduce the above copyright notice,
    24  //     this list of conditions and the following disclaimer in the documentation
    25  //     and/or other materials provided with the distribution.
    26  //
    27  //   * The name of the copyright holders may not be used to endorse or promote products
    28  //     derived from this software without specific prior written permission.
    29  //
    30  // This software is provided by the copyright holders and contributors "as is" and
    31  // any express or implied warranties, including, but not limited to, the implied
    32  // warranties of merchantability and fitness for a particular purpose are disclaimed.
    33  // In no event shall the Intel Corporation or contributors be liable for any direct,
    34  // indirect, incidental, special, exemplary, or consequential damages
    35  // (including, but not limited to, procurement of substitute goods or services;
    36  // loss of use, data, or profits; or business interruption) however caused
    37  // and on any theory of liability, whether in contract, strict liability,
    38  // or tort (including negligence or otherwise) arising in any way out of
    39  // the use of this software, even if advised of the possibility of such damage.
    40  //
    41  //M*/
    42  
    43  #ifndef OPENCV_STITCHING_UTIL_HPP
    44  #define OPENCV_STITCHING_UTIL_HPP
    45  
    46  #include <list>
    47  #include "opencv2/core.hpp"
    48  
    49  namespace cv {
    50  namespace detail {
    51  
    52  //! @addtogroup stitching
    53  //! @{
    54  
    55  class CV_EXPORTS DisjointSets
    56  {
    57  public:
    58      DisjointSets(int elem_count = 0) { createOneElemSets(elem_count); }
    59  
    60      void createOneElemSets(int elem_count);
    61      int findSetByElem(int elem);
    62      int mergeSets(int set1, int set2);
    63  
    64      std::vector<int> parent;
    65      std::vector<int> size;
    66  
    67  private:
    68      std::vector<int> rank_;
    69  };
    70  
    71  
    72  struct CV_EXPORTS GraphEdge
    73  {
    74      GraphEdge(int from, int to, float weight);
    75      bool operator <(const GraphEdge& other) const { return weight < other.weight; }
    76      bool operator >(const GraphEdge& other) const { return weight > other.weight; }
    77  
    78      int from, to;
    79      float weight;
    80  };
    81  
    82  inline GraphEdge::GraphEdge(int _from, int _to, float _weight) : from(_from), to(_to), weight(_weight) {}
    83  
    84  
    85  class CV_EXPORTS Graph
    86  {
    87  public:
    88      Graph(int num_vertices = 0) { create(num_vertices); }
    89      void create(int num_vertices) { edges_.assign(num_vertices, std::list<GraphEdge>()); }
    90      int numVertices() const { return static_cast<int>(edges_.size()); }
    91      void addEdge(int from, int to, float weight);
    92      template <typename B> B forEach(B body) const;
    93      template <typename B> B walkBreadthFirst(int from, B body) const;
    94  
    95  private:
    96      std::vector< std::list<GraphEdge> > edges_;
    97  };
    98  
    99  
   100  //////////////////////////////////////////////////////////////////////////////
   101  // Auxiliary functions
   102  
   103  CV_EXPORTS_W bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi);
   104  CV_EXPORTS_W Rect resultRoi(const std::vector<Point> &corners, const std::vector<UMat> &images);
   105  CV_EXPORTS_W Rect resultRoi(const std::vector<Point> &corners, const std::vector<Size> &sizes);
   106  CV_EXPORTS_W Rect resultRoiIntersection(const std::vector<Point> &corners, const std::vector<Size> &sizes);
   107  CV_EXPORTS_W Point resultTl(const std::vector<Point> &corners);
   108  
   109  // Returns random 'count' element subset of the {0,1,...,size-1} set
   110  CV_EXPORTS_W void selectRandomSubset(int count, int size, std::vector<int> &subset);
   111  
   112  CV_EXPORTS_W int& stitchingLogLevel();
   113  
   114  //! @}
   115  
   116  } // namespace detail
   117  } // namespace cv
   118  
   119  #include "util_inl.hpp"
   120  
   121  #endif // OPENCV_STITCHING_UTIL_HPP