Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions meshroom/aliceVision/FeatureMatching.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.0"
__version__ = "2.1"

from meshroom.core import desc
from meshroom.core.utils import DESCRIBER_TYPES, VERBOSE_LEVEL
Expand All @@ -8,7 +8,7 @@ class FeatureMatching(desc.AVCommandLineNode):
commandLine = "aliceVision_featureMatching {allParams}"
size = avpar.DynamicViewsSize("input")
parallelization = desc.Parallelization(blockSize=20)
commandLineRange = "--rangeStart {rangeStart} --rangeSize {rangeBlockSize}"
commandLineRange = "--rangeIteration {rangeIteration} --rangeBlocksCount {rangeBlocksCount}"

category = "Sparse Reconstruction"
documentation = """
Expand Down
88 changes: 31 additions & 57 deletions src/aliceVision/matchingImageCollection/ImagePairListIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,40 @@
namespace aliceVision {
namespace matchingImageCollection {

bool loadPairs(std::istream& stream, PairSet& pairs, int rangeStart, int rangeSize, bool useSymmetry)

bool loadPairsFromFile(const std::string& sFileName, // filename of the list file,
PairSet& pairs,
bool useSymmetry)
{
std::ifstream in(sFileName);
if (!in.is_open())
{
ALICEVISION_LOG_WARNING("loadPairsFromFile: Impossible to read the specified file: \"" << sFileName << "\".");
return false;
}

std::size_t nbLine = 0;
std::string sValue;

for (; std::getline(stream, sValue); ++nbLine)
for (; std::getline(in, sValue); ++nbLine)
{
if (rangeStart != -1 && rangeSize != 0)
{
if (nbLine < rangeStart)
continue;
if (nbLine >= rangeStart + rangeSize)
break;
}

std::vector<std::string> vec_str;
boost::trim(sValue);
boost::split(vec_str, sValue, boost::is_any_of("\t "), boost::token_compress_on);

const size_t str_size = vec_str.size();
if (str_size < 2)
{
ALICEVISION_LOG_WARNING("loadPairs: Invalid input file.");
ALICEVISION_LOG_WARNING("loadPairsFromFile: Invalid input file.");
return false;
}

std::stringstream oss;
oss.clear();
oss.str(vec_str[0]);
size_t I, J;
oss >> I;

for (size_t i = 1; i < str_size; ++i)
{
oss.clear();
Expand All @@ -61,26 +65,29 @@ bool loadPairs(std::istream& stream, PairSet& pairs, int rangeStart, int rangeSi
pairToInsert = std::make_pair(I, J);
}

if (pairs.find(pairToInsert) != pairs.end())
{
// There is no reason to have the same image pair twice in the list of image pairs
// to match.
ALICEVISION_LOG_WARNING("loadPairs: image pair (" << I << ", " << J << ") already added.");
}
ALICEVISION_LOG_TRACE("loadPairs: image pair (" << I << ", " << J << ") added.");
ALICEVISION_LOG_TRACE("loadPairsFromFile: image pair (" << I << ", " << J << ") added.");
pairs.insert(pairToInsert);
}
}

return true;
}

void savePairs(std::ostream& stream, const PairSet& pairs)
bool savePairsToFile(const std::string& sFileName, const PairSet& pairs)
{
std::ofstream outStream(sFileName);
if (!outStream.is_open())
{
ALICEVISION_LOG_WARNING("savePairsToFile: Impossible to open the output specified file: \"" << sFileName << "\".");
return false;
}

if (pairs.empty())
{
return;
return true;
}
Comment thread
servantftransperfect marked this conversation as resolved.
stream << pairs.begin()->first << " " << pairs.begin()->second;

outStream << pairs.begin()->first << " " << pairs.begin()->second;
IndexT previousIndex = pairs.begin()->first;

// Pairs is sorted so we will always receive elements with the same first pair ID in
Expand All @@ -89,48 +96,15 @@ void savePairs(std::ostream& stream, const PairSet& pairs)
{
if (it->first == previousIndex)
{
stream << " " << it->second;
outStream << " " << it->second;
}
else
{
stream << "\n" << it->first << " " << it->second;
outStream << "\n" << it->first << " " << it->second;
previousIndex = it->first;
}
}
stream << "\n";
}

bool loadPairsFromFile(const std::string& sFileName, // filename of the list file,
PairSet& pairs,
int rangeStart,
int rangeSize,
bool useSymmetry)
{
std::ifstream in(sFileName);
if (!in.is_open())
{
ALICEVISION_LOG_WARNING("loadPairsFromFile: Impossible to read the specified file: \"" << sFileName << "\".");
return false;
}

if (!loadPairs(in, pairs, rangeStart, rangeSize, useSymmetry))
{
ALICEVISION_LOG_WARNING("loadPairsFromFile: Failed to read file: \"" << sFileName << "\".");
return false;
}
return true;
}

bool savePairsToFile(const std::string& sFileName, const PairSet& pairs)
{
std::ofstream outStream(sFileName);
if (!outStream.is_open())
{
ALICEVISION_LOG_WARNING("savePairsToFile: Impossible to open the output specified file: \"" << sFileName << "\".");
return false;
}

savePairs(outStream, pairs);
outStream << "\n";

return !outStream.bad();
}
Expand Down
41 changes: 28 additions & 13 deletions src/aliceVision/matchingImageCollection/ImagePairListIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
// 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/.

/**
* @file ImagePairListIO.hpp
* @brief Input/Output functions for reading and writing image pair lists.
*
* This file provides utilities for loading and saving sets of image pairs
* to and from streams and files. Image pairs are used in the matching process
* to define which images should be compared for feature matching.
*/

#include <aliceVision/types.hpp>

#include <iosfwd>
Expand All @@ -13,23 +22,29 @@
namespace aliceVision {
namespace matchingImageCollection {

/// Load a set of PairSet from a stream
/// I J K L (pair that link I)
bool loadPairs(std::istream& stream, PairSet& pairs, int rangeStart = -1, int rangeSize = 0, bool useSymmetry = true);

/// Save a set of PairSet to a stream (one pair per line)
/// I J
/// I K
void savePairs(std::ostream& stream, const PairSet& pairs);

/// Same as loadPairs, but loads from a given file
/**
* @brief Load image pairs from a file.
*
* Reads image pair data from the specified file and populates the pairs set.
*
* @param[in] sFileName Path to the file containing the pair data
* @param[out] pairs Set of image pairs to be populated
* @param[in] useSymmetry If true, add (min(i,j), max(i,j)) instead of (i,j) (default: true)
* @return true if the file was opened and pairs were successfully loaded, false otherwise
*/
bool loadPairsFromFile(const std::string& sFileName, // filename of the list file,
PairSet& pairs,
int rangeStart = -1,
int rangeSize = 0,
bool useSymmetry = true);
Comment thread
servantftransperfect marked this conversation as resolved.

/// Same as savePairs, but saves to a given file
/**
* @brief Save image pairs to a file.
*
* Writes the image pair data to the specified file.
*
* @param[in] sFileName Path to the output file
* @param[in] pairs Set of image pairs to save
* @return true if the file was created and pairs were successfully saved, false otherwise
*/
bool savePairsToFile(const std::string& sFileName, const PairSet& pairs);
Comment on lines +39 to 48

Copilot AI Mar 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring states savePairsToFile is a wrapper around savePairs(), but the implementation no longer calls savePairs and writes a different grouped format. Please update the documentation to describe the actual file format that savePairsToFile produces (and avoid claiming it mirrors savePairs if it does not).

Copilot uses AI. Check for mistakes.

} // namespace matchingImageCollection
Expand Down
Loading
Loading