123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #ifndef OPENCV_VIDEOSTAB_FAST_MARCHING_HPP
- #define OPENCV_VIDEOSTAB_FAST_MARCHING_HPP
- #include <cmath>
- #include <queue>
- #include <algorithm>
- #include "opencv2/core.hpp"
- namespace cv
- {
- namespace videostab
- {
- class CV_EXPORTS FastMarchingMethod
- {
- public:
- FastMarchingMethod() : inf_(1e6f), size_(0) {}
-
- template <typename Inpaint>
- Inpaint run(const Mat &mask, Inpaint inpaint);
-
- Mat distanceMap() const { return dist_; }
- private:
- enum { INSIDE = 0, BAND = 1, KNOWN = 255 };
- struct DXY
- {
- float dist;
- int x, y;
- DXY() : dist(0), x(0), y(0) {}
- DXY(float _dist, int _x, int _y) : dist(_dist), x(_x), y(_y) {}
- bool operator <(const DXY &dxy) const { return dist < dxy.dist; }
- };
- float solve(int x1, int y1, int x2, int y2) const;
- int& indexOf(const DXY &dxy) { return index_(dxy.y, dxy.x); }
- void heapUp(int idx);
- void heapDown(int idx);
- void heapAdd(const DXY &dxy);
- void heapRemoveMin();
- float inf_;
- cv::Mat_<uchar> flag_;
- cv::Mat_<float> dist_;
- cv::Mat_<int> index_;
- std::vector<DXY> narrowBand_;
- int size_;
- };
- }
- }
- #include "fast_marching_inl.hpp"
- #endif
|