123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #ifndef OPENCV_STITCHING_UTIL_HPP
- #define OPENCV_STITCHING_UTIL_HPP
- #include <list>
- #include "opencv2/core.hpp"
- namespace cv {
- namespace detail {
- class CV_EXPORTS DisjointSets
- {
- public:
- DisjointSets(int elem_count = 0) { createOneElemSets(elem_count); }
- void createOneElemSets(int elem_count);
- int findSetByElem(int elem);
- int mergeSets(int set1, int set2);
- std::vector<int> parent;
- std::vector<int> size;
- private:
- std::vector<int> rank_;
- };
- struct CV_EXPORTS GraphEdge
- {
- GraphEdge(int from, int to, float weight);
- bool operator <(const GraphEdge& other) const { return weight < other.weight; }
- bool operator >(const GraphEdge& other) const { return weight > other.weight; }
- int from, to;
- float weight;
- };
- inline GraphEdge::GraphEdge(int _from, int _to, float _weight) : from(_from), to(_to), weight(_weight) {}
- class CV_EXPORTS Graph
- {
- public:
- Graph(int num_vertices = 0) { create(num_vertices); }
- void create(int num_vertices) { edges_.assign(num_vertices, std::list<GraphEdge>()); }
- int numVertices() const { return static_cast<int>(edges_.size()); }
- void addEdge(int from, int to, float weight);
- template <typename B> B forEach(B body) const;
- template <typename B> B walkBreadthFirst(int from, B body) const;
- private:
- std::vector< std::list<GraphEdge> > edges_;
- };
- CV_EXPORTS bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi);
- CV_EXPORTS Rect resultRoi(const std::vector<Point> &corners, const std::vector<UMat> &images);
- CV_EXPORTS Rect resultRoi(const std::vector<Point> &corners, const std::vector<Size> &sizes);
- CV_EXPORTS Rect resultRoiIntersection(const std::vector<Point> &corners, const std::vector<Size> &sizes);
- CV_EXPORTS Point resultTl(const std::vector<Point> &corners);
- CV_EXPORTS void selectRandomSubset(int count, int size, std::vector<int> &subset);
- CV_EXPORTS int& stitchingLogLevel();
- }
- }
- #include "util_inl.hpp"
- #endif
|