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