using namespace cv;
-CameraInfo CameraInfo::load(const string &path)
-{
- FileStorage fs(path, FileStorage::READ);
- CV_Assert(fs.isOpened());
-
- CameraInfo cam;
- if (!fs["R"].isNone())
- fs["R"] >> cam.R;
- if (!fs["K"].isNone())
- fs["K"] >> cam.K;
- return cam;
-}
+CameraParams::CameraParams() : focal(1), R(Mat::eye(3, 3, CV_64F)), t(Mat::zeros(3, 1, CV_64F)) {}
+CameraParams::CameraParams(const CameraParams &other) { *this = other; }
-void CameraInfo::save(const string &path)
+const CameraParams& CameraParams::operator =(const CameraParams &other)
{
- FileStorage fs(path, FileStorage::WRITE);
- CV_Assert(fs.isOpened());
-
- if (!R.empty())
- fs << "R" << R;
- if (!K.empty())
- fs << "K" << K;
+ focal = other.focal;
+ R = other.R.clone();
+ t = other.t.clone();
+ return *this;
}
\r
//////////////////////////////////////////////////////////////////////////////\r
\r
-CameraParams::CameraParams() : focal(1), R(Mat::eye(3, 3, CV_64F)), t(Mat::zeros(3, 1, CV_64F)) {}\r
-\r
-CameraParams::CameraParams(const CameraParams &other) { *this = other; }\r
-\r
-const CameraParams& CameraParams::operator =(const CameraParams &other)\r
-{\r
- focal = other.focal;\r
- R = other.R.clone();\r
- t = other.t.clone();\r
- return *this;\r
-}\r
-\r
-\r
-//////////////////////////////////////////////////////////////////////////////\r
-\r
struct IncDistance\r
{\r
IncDistance(vector<int> &dists) : dists(&dists[0]) {}\r
\r
const int num_images = static_cast<int>(pathes.size());\r
set<pair<int,int> > span_tree_edges;\r
- DjSets comps(num_images);\r
+ DisjointSets comps(num_images);\r
\r
for (int i = 0; i < num_images; ++i)\r
{\r
{\r
if (pairwise_matches[i*num_images + j].confidence < conf_threshold)\r
continue;\r
- int comp1 = comps.find(i);\r
- int comp2 = comps.find(j);\r
+ int comp1 = comps.findSetByElem(i);\r
+ int comp2 = comps.findSetByElem(j);\r
if (comp1 != comp2)\r
{\r
- comps.merge(comp1, comp2);\r
+ comps.mergeSets(comp1, comp2);\r
span_tree_edges.insert(make_pair(i, j));\r
}\r
}\r
\r
for (size_t i = 0; i < comps.size.size(); ++i)\r
{\r
- if (comps.size[comps.find(i)] == 1)\r
+ if (comps.size[comps.findSetByElem(i)] == 1)\r
{\r
string name = pathes[i];\r
size_t prefix_len = name.find_last_of("/\\");\r
{\r
const int num_images = static_cast<int>(features.size());\r
\r
- DjSets comps(num_images);\r
+ DisjointSets comps(num_images);\r
for (int i = 0; i < num_images; ++i)\r
{\r
for (int j = 0; j < num_images; ++j)\r
{\r
if (pairwise_matches[i*num_images + j].confidence < conf_threshold)\r
continue;\r
- int comp1 = comps.find(i);\r
- int comp2 = comps.find(j);\r
+ int comp1 = comps.findSetByElem(i);\r
+ int comp2 = comps.findSetByElem(j);\r
if (comp1 != comp2) \r
- comps.merge(comp1, comp2);\r
+ comps.mergeSets(comp1, comp2);\r
}\r
}\r
\r
vector<int> indices;\r
vector<int> indices_removed;\r
for (int i = 0; i < num_images; ++i)\r
- if (comps.find(i) == max_comp)\r
+ if (comps.findSetByElem(i) == max_comp)\r
indices.push_back(i); \r
else\r
indices_removed.push_back(i);\r
}\r
}\r
\r
- DjSets comps(num_images);\r
+ DisjointSets comps(num_images);\r
span_tree.create(num_images);\r
vector<int> span_tree_powers(num_images, 0);\r
\r
sort(edges.begin(), edges.end(), greater<GraphEdge>());\r
for (size_t i = 0; i < edges.size(); ++i)\r
{\r
- int comp1 = comps.find(edges[i].from);\r
- int comp2 = comps.find(edges[i].to);\r
+ int comp1 = comps.findSetByElem(edges[i].from);\r
+ int comp2 = comps.findSetByElem(edges[i].to);\r
if (comp1 != comp2)\r
{\r
- comps.merge(comp1, comp2);\r
+ comps.mergeSets(comp1, comp2);\r
span_tree.addEdge(edges[i].from, edges[i].to, edges[i].weight);\r
span_tree.addEdge(edges[i].to, edges[i].from, edges[i].weight);\r
span_tree_powers[edges[i].from]++;\r