Skip to content

Commit 4565187

Browse files
Merge pull request #1996 from alicevision/dev/remapLandmarks
Node to remap landmarks to tracks
2 parents fcacd11 + e3b6688 commit 4565187

File tree

3 files changed

+141
-1
lines changed

3 files changed

+141
-1
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
__version__ = "1.0"
2+
3+
from meshroom.core import desc
4+
from meshroom.core.utils import VERBOSE_LEVEL
5+
6+
7+
class SfMLandmarksRemapping(desc.AVCommandLineNode):
8+
commandLine = "aliceVision_sfmLandmarksRemapping {allParams}"
9+
size = desc.DynamicNodeSize("input")
10+
11+
category = "Utils"
12+
documentation = """
13+
A landmark is created using a track. Both have ids. It is assumed in many nodes that the source track id is the landmark id.
14+
In this node, we update the landmark id to match its track id. It may have change over operations on tracks.
15+
"""
16+
17+
inputs = [
18+
desc.File(
19+
name="input",
20+
label="SfMData",
21+
description="SfMData file.",
22+
value="",
23+
),
24+
desc.File(
25+
name="tracksFilename",
26+
label="Tracks File",
27+
description="Tracks file.",
28+
value="",
29+
),
30+
desc.ChoiceParam(
31+
name="verboseLevel",
32+
label="Verbose Level",
33+
description="Verbosity level (fatal, error, warning, info, debug, trace).",
34+
values=VERBOSE_LEVEL,
35+
value="info",
36+
),
37+
]
38+
outputs = [
39+
desc.File(
40+
name="output",
41+
label="SfMData",
42+
description="Path to the output SfMData file.",
43+
value="{nodeCacheFolder}/sfmData.sfm",
44+
)
45+
]

src/software/utils/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ if (ALICEVISION_BUILD_SFM)
320320
Boost::program_options
321321
Boost::json
322322
)
323-
323+
324324
# SfM Survey Injecting
325325
alicevision_add_software(aliceVision_sfmSurveyInjecting
326326
SOURCE main_sfmSurveyInjecting.cpp
@@ -347,6 +347,20 @@ if (ALICEVISION_BUILD_SFM)
347347
Boost::json
348348
)
349349

350+
# Track from depthmap
351+
alicevision_add_software(aliceVision_sfmLandmarksRemapping
352+
SOURCE main_sfmLandmarksRemapping.cpp
353+
FOLDER ${FOLDER_SOFTWARE_UTILS}
354+
LINKS aliceVision_system
355+
aliceVision_cmdline
356+
aliceVision_sfmData
357+
aliceVision_sfmDataIO
358+
aliceVision_track
359+
aliceVision_sfm
360+
Boost::program_options
361+
Boost::json
362+
)
363+
350364
# SfM split reconstructed
351365
alicevision_add_software(aliceVision_sfmSplitReconstructed
352366
SOURCE main_sfmSplitReconstructed.cpp
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// This file is part of the AliceVision project.
2+
// Copyright (c) 2025 AliceVision contributors.
3+
// This Source Code Form is subject to the terms of the Mozilla Public License,
4+
// v. 2.0. If a copy of the MPL was not distributed with this file,
5+
// You can obtain one at https://mozilla.org/MPL/2.0/.
6+
7+
#include <aliceVision/types.hpp>
8+
#include <aliceVision/config.hpp>
9+
#include <aliceVision/system/Logger.hpp>
10+
#include <aliceVision/system/main.hpp>
11+
#include <aliceVision/cmdline/cmdline.hpp>
12+
13+
#include <aliceVision/sfmDataIO/sfmDataIO.hpp>
14+
#include <aliceVision/sfm/pipeline/expanding/ExpansionProcess.hpp>
15+
#include <aliceVision/track/TracksHandler.hpp>
16+
17+
#include <boost/program_options.hpp>
18+
#include <boost/json.hpp>
19+
20+
// These constants define the current software version.
21+
// They must be updated when the command line is changed.
22+
#define ALICEVISION_SOFTWARE_VERSION_MAJOR 1
23+
#define ALICEVISION_SOFTWARE_VERSION_MINOR 0
24+
25+
using namespace aliceVision;
26+
namespace po = boost::program_options;
27+
28+
int aliceVision_main(int argc, char** argv)
29+
{
30+
// command-line parameters
31+
std::string sfmDataFilename;
32+
std::string sfmDataOutputFilename;
33+
std::string tracksFilename;
34+
35+
// clang-format off
36+
po::options_description requiredParams("Required parameters");
37+
requiredParams.add_options()
38+
("input,i", po::value<std::string>(&sfmDataFilename)->required(),
39+
"Input SfMData file.")
40+
("output,o", po::value<std::string>(&sfmDataOutputFilename)->required(),
41+
"SfMData output file with the remapped landmarks.")
42+
("tracksFilename,t", po::value<std::string>(&tracksFilename)->required(), "Tracks file.");
43+
// clang-format on
44+
45+
CmdLine cmdline("AliceVision Landmarks Remapping");
46+
47+
cmdline.add(requiredParams);
48+
if (!cmdline.execute(argc, argv))
49+
{
50+
return EXIT_FAILURE;
51+
}
52+
53+
// Set maxThreads
54+
HardwareContext hwc = cmdline.getHardwareContext();
55+
omp_set_num_threads(hwc.getMaxThreads());
56+
57+
// Load input SfMData scene
58+
ALICEVISION_LOG_INFO("Load SfmData from " << sfmDataFilename);
59+
sfmData::SfMData sfmData;
60+
if (!sfmDataIO::load(sfmData, sfmDataFilename, sfmDataIO::ESfMData::ALL))
61+
{
62+
ALICEVISION_LOG_ERROR("The input SfMData file '" + sfmDataFilename + "' cannot be read.");
63+
return EXIT_FAILURE;
64+
}
65+
66+
ALICEVISION_LOG_INFO("Load tracks");
67+
track::TracksHandler tracksHandler;
68+
if (!tracksHandler.load(tracksFilename, sfmData.getViewsKeys()))
69+
{
70+
ALICEVISION_LOG_ERROR("The input tracks file '" + tracksFilename + "' cannot be read.");
71+
return EXIT_FAILURE;
72+
}
73+
74+
ALICEVISION_LOG_INFO("Remap landmarks");
75+
sfm::ExpansionProcess::remapExistingLandmarks(sfmData, tracksHandler);
76+
77+
ALICEVISION_LOG_INFO("Save SfmData to " << sfmDataOutputFilename);
78+
sfmDataIO::save(sfmData, sfmDataOutputFilename, sfmDataIO::ESfMData::ALL);
79+
80+
return EXIT_SUCCESS;
81+
}

0 commit comments

Comments
 (0)