mirror of https://github.com/opencv/opencv.git
Open Source Computer Vision Library
https://opencv.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.5 KiB
74 lines
1.5 KiB
#ifndef __OPENCV_STITCHING_UTIL_INL_HPP__ |
|
#define __OPENCV_STITCHING_UTIL_INL_HPP__ |
|
|
|
#include <queue> |
|
#include "util.hpp" // Make your IDE see declarations |
|
|
|
template <typename B> |
|
B Graph::forEach(B body) const |
|
{ |
|
for (int i = 0; i < numVertices(); ++i) |
|
{ |
|
std::list<GraphEdge>::const_iterator edge = edges_[i].begin(); |
|
for (; edge != edges_[i].end(); ++edge) |
|
body(*edge); |
|
} |
|
return body; |
|
} |
|
|
|
|
|
template <typename B> |
|
B Graph::walkBreadthFirst(int from, B body) const |
|
{ |
|
std::vector<bool> was(numVertices(), false); |
|
std::queue<int> vertices; |
|
|
|
was[from] = true; |
|
vertices.push(from); |
|
|
|
while (!vertices.empty()) |
|
{ |
|
int vertex = vertices.front(); |
|
vertices.pop(); |
|
|
|
std::list<GraphEdge>::const_iterator edge = edges_[vertex].begin(); |
|
for (; edge != edges_[vertex].end(); ++edge) |
|
{ |
|
if (!was[edge->to]) |
|
{ |
|
body(*edge); |
|
was[edge->to] = true; |
|
vertices.push(edge->to); |
|
} |
|
} |
|
} |
|
|
|
return body; |
|
} |
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////// |
|
// Some auxiliary math functions |
|
|
|
static inline |
|
float normL2(const cv::Point3f& a, const cv::Point3f& b) |
|
{ |
|
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z); |
|
} |
|
|
|
|
|
static inline |
|
double normL2sq(const cv::Mat &m) |
|
{ |
|
return m.dot(m); |
|
} |
|
|
|
|
|
template <typename T> |
|
static inline |
|
T sqr(T x) |
|
{ |
|
return x * x; |
|
} |
|
|
|
#endif // __OPENCV_STITCHING_UTIL_INL_HPP__
|
|
|