8000 union_find problem · Issue #1550 · openMVG/openMVG · GitHub
[go: up one dir, main page]

Skip to content

union_find problem #1550

@zjulsy

Description

@zjulsy

in sfm_data_filters.cpp, some functions uses union_find maybe wrong. such as bool IsTracksOneCC(const SfM_Data & sfm_data)

they use union_find.union(i, j), then count the number of CC as following:

  // Count the number of CC
  const std::set<unsigned int> parent_id(uf_tree.m_cc_parent.cbegin(), uf_tree.m_cc_parent.cend());
  return parent_id.size() == 1;

but error is showed as below:

#include <iostream>
#include "test_f.h"

#include <openMVG/tracks/union_find.hpp>
using namespace std;
using namespace openMVG;

int main()
{
     UnionFind uf;
     uf.InitSets(5);

     uf.Union(0, 1);
     uf.Union(1,2);
     uf.Union(3,4);
     uf.Union(1,3);

    for(int i=0; i<5; ++i)
    {
        cout << uf.m_cc_parent[i] << " ";
        // 0 0 0 0 3
}
}

so, there is a error. we cannot use parent_id.size() to judge whether it is a CC

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0