Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aout rajkataria / ReliableResectioning MDS initializing #2

Open
coder12333444 opened this issue Dec 15, 2021 · 3 comments
Open

aout rajkataria / ReliableResectioning MDS initializing #2

coder12333444 opened this issue Dec 15, 2021 · 3 comments

Comments

@coder12333444
Copy link

coder12333444 commented Dec 15, 2021

@lxxue
Hi,sorry to bother you. when mds initializing, is the database a new database or is it generated after image extracting and image matching?

@lxxue
Copy link
Collaborator

lxxue commented Dec 15, 2021

Hi, the author creates a new database (also overwrites the old one as they have the same name) and go over the correspondences as shown here:

Database database(database_path_ + "/database.db");
images = database.ReadAllImages();
for (std::vector<Image>::iterator it = images.begin(); it != images.end();
++it) {
image_names.push_back(it->Name());
}
std::sort(image_names.begin(), image_names.end());
CorrespondenceGraph sg = database_cache->CorrespondenceGraph();
for (auto const &im1 : image_names) {
std::map<std::string, float> im1_aam_map;
for (auto const &im2 : image_names) {
if (im1.compare(im2) == 0) {
im1_aam_map.insert(std::make_pair(im2, 0.0));
} else if (im1.compare(im2) > 0) {
im1_aam_map.insert(std::make_pair(
im2, aam_distances_map.find(im2)->second.find(im1)->second));
} else {
Image im1_ = database.ReadImageWithName(im1);
Image im2_ = database.ReadImageWithName(im2);
if (!sg.ExistsImage(im1_.ImageId()) ||
!sg.ExistsImage(im2_.ImageId())) {
continue;
}
colmap::FeatureMatches correspondences =
sg.FindCorrespondencesBetweenImages(im1_.ImageId(), im2_.ImageId());
colmap::FeatureMatches::iterator correspondence_itr;
double aam_matches = 0.0;
for (correspondence_itr = correspondences.begin();
correspondence_itr != correspondences.end();
++correspondence_itr) {
std::vector<CorrespondenceGraph::Correspondence>
point_correspondences = sg.FindCorrespondences(
im1_.ImageId(), (*correspondence_itr).point2D_idx1);
if (!sg.HasCorrespondences(im1_.ImageId(),
(*correspondence_itr).point2D_idx1)) {
continue;
}
if (!sg.HasCorrespondences(im2_.ImageId(),
(*correspondence_itr).point2D_idx2)) {
continue;
}
// tuned parameters
// aam_matches += pow(0.5, point_correspondences.size() - 1);
aam_matches += pow(0.3, point_correspondences.size() - 1);
}
im1_aam_map.insert(std::make_pair(im2, 1.0 / (aam_matches + 0.000001)));
}
}
aam_distances_map.insert(std::make_pair(im1, im1_aam_map));
}
std::cout
<< "******************************************************** Finished "
"Initializing MDS ************************************************"
<< std::endl;
}

I think the matches are in the DatabaseCache and not computed from scratch again.

@coder12333444
Copy link
Author

@lxxue
Hi,
if creates a new database,the " images = database.ReadAllImages(); " images.size ==0,then image_names.size ==0;the for (auto const &im1 : image_names) do not exec ,so I think the database.db is the result of image extracting and image matching,do you think?

@lxxue
Copy link
Collaborator

lxxue commented Dec 15, 2021

Sorry for the wrong answer: "the author creates a new database (also overwrites the old one".

Yes, you are right the author didn't create a new database. They just use the matches from database.db.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants