-
-
Notifications
You must be signed in to change notification settings - Fork 822
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
Coordinate system alignment to specific markers or between scenes #695
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
80fbb54
[sfm] retrieve markers ID and store it in landmark color
fabiencastan da5c13d
[software] sfmTransform: new option to align on specific markers
fabiencastan b6d35f3
[feature] fix minor cctag warning
fabiencastan ca90716
[mesh] texturing: throw an exception if the ref input is empty
fabiencastan 053b161
[software] sfmTransform: simplify parsing of command line args
fabiencastan 8118393
[software] SfMAlignment: support multiple matching methods for alignm…
fabiencastan 0fef959
[sfm] alignment: can only compute similarity from reconstructed views
fabiencastan 23d4d81
[software] new SfMTransform software to retrieve poses and intrinsics…
fabiencastan de1c3e3
[sfm] alignment: build fixes for g++
fabiencastan 141c4ad
[sfm] bug fix: tracksPerView should have a key for each view
fabiencastan b3762bc
[sfm] fix: this is not an error if we have a calibration in input
fabiencastan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// This file is part of the AliceVision project. | ||
// Copyright (c) 2019 AliceVision contributors. | ||
// This Source Code Form is subject to the terms of the Mozilla Public License, | ||
// v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
#pragma once | ||
|
||
#include "ReconstructionEngine.hpp" | ||
|
||
#include <aliceVision/feature/RegionsPerView.hpp> | ||
#include <aliceVision/sfm/pipeline/regionsIO.hpp> | ||
|
||
|
||
namespace aliceVision { | ||
namespace sfm { | ||
|
||
|
||
void retrieveMarkersId(sfmData::SfMData& sfmData) | ||
{ | ||
std::set<feature::EImageDescriberType> allMarkerDescTypes; | ||
#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_CCTAG) | ||
allMarkerDescTypes.insert(feature::EImageDescriberType::CCTAG3); | ||
allMarkerDescTypes.insert(feature::EImageDescriberType::CCTAG4); | ||
#endif | ||
if (allMarkerDescTypes.empty()) | ||
return; | ||
|
||
std::set<feature::EImageDescriberType> usedDescTypes = sfmData.getLandmarkDescTypes(); | ||
|
||
std::vector<feature::EImageDescriberType> markerDescTypes; | ||
std::set_intersection(allMarkerDescTypes.begin(), allMarkerDescTypes.end(), | ||
usedDescTypes.begin(), usedDescTypes.end(), | ||
std::back_inserter(markerDescTypes)); | ||
|
||
std::set<feature::EImageDescriberType> markerDescTypes_set(markerDescTypes.begin(), markerDescTypes.end()); | ||
|
||
if(markerDescTypes.empty()) | ||
return; | ||
|
||
// load the corresponding view regions | ||
feature::RegionsPerView regionPerView; | ||
std::set<IndexT> filter; | ||
// It could be optimized by loading only the minimal number of desc files, | ||
// but as we are only retrieving them for markers, the performance impact is limited. | ||
if (!sfm::loadRegionsPerView(regionPerView, sfmData, sfmData.getFeaturesFolders(), markerDescTypes, filter)) | ||
{ | ||
ALICEVISION_THROW_ERROR("Error while loading markers regions."); | ||
} | ||
for (auto& landmarkIt : sfmData.getLandmarks()) | ||
{ | ||
auto& landmark = landmarkIt.second; | ||
if (landmark.observations.empty()) | ||
continue; | ||
if (markerDescTypes_set.find(landmark.descType) == markerDescTypes_set.end()) | ||
continue; | ||
landmark.rgb = image::BLACK; | ||
|
||
const auto obs = landmark.observations.begin(); | ||
const feature::Regions& regions = regionPerView.getRegions(obs->first, landmark.descType); | ||
const feature::CCTAG_Regions& cctagRegions = dynamic_cast<const feature::CCTAG_Regions&>(regions); | ||
const auto& d = cctagRegions.Descriptors()[obs->second.id_feat]; | ||
for (int i = 0; i < d.size(); ++i) | ||
{ | ||
if (d[i] == 255) | ||
{ | ||
ALICEVISION_LOG_TRACE("Found marker: " << i << " (landmarkId: " << landmarkIt.first << ")."); | ||
landmark.rgb.r() = i; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
} // namespace sfm | ||
} // namespace aliceVision |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we just add another field to landmark like
markerId
always initialized to a dummy value (for all the other features that are not markers)?Using the color attribute is a kind of workaround. Also, it is limited to 255 values, which is limiting in case other types of markers will be integrated in the future (eg. aruco &C).
Ok we need to change all the IO functions of sfmdata but I think it's better than "hiding" data in the same structure. And I think we can still preserve backcompatibility with other sfmdata files that has not that field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I explained in the PR summary, it will be a waste of space as most of the landmarks are not markers. I agree that it looks hackish. I was considering using an union between
RGBColor
andint
but that represents many changes in IOs and creates complexity.The correct long-term solution is probably to have landmarks per descType, but that's a major change that I cannot afford for now.