Skip to content
Draft
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
10 changes: 9 additions & 1 deletion meshroom/aliceVision/FeatureExtraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from meshroom.core.utils import COLORSPACES, DESCRIBER_TYPES, VERBOSE_LEVEL
from pyalicevision import parallelization as avpar

class FeatureExtraction(desc.AVCommandLineNode):
class FeatureExtraction(desc.AVCommandLineNode, desc.interface.FeatureProviderInterface):
"""
This node extracts distinctive groups of pixels that are, to some extent, invariant to changing camera viewpoints during image acquisition.
Hence, a feature in the scene should have similar feature descriptions in all images.
Expand Down Expand Up @@ -163,3 +163,11 @@ class FeatureExtraction(desc.AVCommandLineNode):
value="{nodeCacheFolder}",
),
]

def getFeaturesFolders(self, node) -> list:

return [node.output.value]

def getDescriberTypes(self, node) -> list:

return node.describerTypes.value
16 changes: 15 additions & 1 deletion meshroom/aliceVision/FeatureMatching.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from meshroom.core.utils import DESCRIBER_TYPES, VERBOSE_LEVEL
from pyalicevision import parallelization as avpar

class FeatureMatching(desc.AVCommandLineNode):
class FeatureMatching(desc.AVCommandLineNode,
desc.interface.FeatureProviderInterface,
desc.interface.MatchProviderInterface):
"""
This node performs the matching of all features between the candidate image pairs.

Expand Down Expand Up @@ -208,3 +210,15 @@ class FeatureMatching(desc.AVCommandLineNode):
value="{nodeCacheFolder}",
),
]

def getFeaturesFolders(self, node) -> list:

return [f.value for f in node.featuresFolders]

def getDescriberTypes(self, node) -> list:

return node.describerTypes.value

def getMatchesFolders(self, node) -> list:

return [node.output.value]
21 changes: 20 additions & 1 deletion meshroom/aliceVision/SfmBootstrapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from meshroom.core.utils import VERBOSE_LEVEL


class SfMBootStrapping(desc.AVCommandLineNode):
class SfMBootStrapping(desc.AVCommandLineNode,
desc.interface.FeatureProviderInterface,
desc.interface.TrackProviderInterface):
"""
Initialize the incremental Structure-from-Motion reconstruction by selecting the best initial image pair.

Expand Down Expand Up @@ -116,3 +118,20 @@ class SfMBootStrapping(desc.AVCommandLineNode):
value="{nodeCacheFolder}/cameras.sfm",
)
]



def getFeaturesFolders(self, node) -> list:
folders = []
for provider in self.upstreamNodesWithInterface(node, node.tracksFilename, "FeatureProviderInterface"):
folders.extend(provider.nodeDesc.getFeaturesFolders(provider))
return folders

def getDescriberTypes(self, node) -> list:
describerTypes = []
for provider in self.upstreamNodesWithInterface(node, node.tracksFilename, "FeatureProviderInterface"):
describerTypes.extend(provider.nodeDesc.getDescriberTypes(provider))
return describerTypes

def getTracksFile(self, node) -> str:
return node.tracksFilename.value
19 changes: 18 additions & 1 deletion meshroom/aliceVision/SfmExpanding.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from meshroom.core.utils import VERBOSE_LEVEL


class SfMExpanding(desc.AVCommandLineNode):
class SfMExpanding(desc.AVCommandLineNode,
desc.interface.FeatureProviderInterface,
desc.interface.TrackProviderInterface):
"""
Expand an incremental Structure-from-Motion reconstruction by localizing additional cameras.

Expand Down Expand Up @@ -343,3 +345,18 @@ def onUseTemporalConstraintChanged(self, node):
def onUseLocalBAChanged(self, node):
if node.useLocalBA.value:
node.useTemporalConstraint.value = False

def getFeaturesFolders(self, node) -> list:
folders = []
for provider in self.upstreamNodesWithInterface(node, node.tracksFilename, "FeatureProviderInterface"):
folders.extend(provider.nodeDesc.getFeaturesFolders(provider))
return folders

def getDescriberTypes(self, node) -> list:
describerTypes = []
for provider in self.upstreamNodesWithInterface(node, node.tracksFilename, "FeatureProviderInterface"):
describerTypes.extend(provider.nodeDesc.getDescriberTypes(provider))
return describerTypes

def getTracksFile(self, node) -> str:
return node.tracksFilename.value
12 changes: 11 additions & 1 deletion meshroom/aliceVision/StructureFromMotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from meshroom.core.utils import DESCRIBER_TYPES, VERBOSE_LEVEL


class StructureFromMotion(desc.AVCommandLineNode):
class StructureFromMotion(desc.AVCommandLineNode,
desc.interface.FeatureProviderInterface,
desc.interface.MatchProviderInterface):
"""
This node will analyze feature matches to understand the geometric relationship behind all the 2D observations,
and infer the rigid scene structure (3D points) with the pose (position and orientation) and internal calibration of all cameras.
Expand Down Expand Up @@ -391,3 +393,11 @@ class StructureFromMotion(desc.AVCommandLineNode):
value="{nodeCacheFolder}",
),
]

def getFeaturesFolders(self, node) -> list:

return [f.value for f in node.featuresFolders]

def getMatchesFolders(self, node) -> list:

return [f.value for f in node.matchesFolder]
16 changes: 15 additions & 1 deletion meshroom/aliceVision/TracksBuilding.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from meshroom.core.utils import DESCRIBER_TYPES, VERBOSE_LEVEL


class TracksBuilding(desc.AVCommandLineNode):
class TracksBuilding(desc.AVCommandLineNode,
desc.interface.FeatureProviderInterface,
desc.interface.TrackProviderInterface):
"""
This node fuses all feature matches between image pairs into tracks.
Each track represents a candidate point in space, visible from multiple cameras.
Expand Down Expand Up @@ -96,3 +98,15 @@ class TracksBuilding(desc.AVCommandLineNode):
value="{nodeCacheFolder}/tracksFile.json",
),
]

def getFeaturesFolders(self, node) -> list:

return [f.value for f in node.featuresFolders]

def getDescriberTypes(self, node) -> list:

return node.describerTypes.value

def getTracksFile(self, node) -> str:

return node.output.value
2 changes: 1 addition & 1 deletion src/aliceVision/numeric/numeric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ Mat3 LookAt(const Vec3& center, const Vec3& up = Vec3::UnitY());

Mat3 LookAt2(const Vec3& eyePosition3D, const Vec3& center3D = Vec3::Zero(), const Vec3& upVector3D = Vec3::UnitY());

#define SUM_OR_DYNAMIC(x, y) (x == Eigen::Dynamic || y == Eigen::Dynamic) ? Eigen::Dynamic : (x + y)
#define SUM_OR_DYNAMIC(x, y) (x == Eigen::Dynamic || y == Eigen::Dynamic) ? Eigen::Dynamic : (int(x) + int(y))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Precedence and Casting Issues in Macro Definition

  1. Lack of Parenthesization: The macro arguments x and y are not parenthesized inside the macro body, and the entire macro expression is not wrapped in outer parentheses. This can lead to unexpected operator precedence bugs when the macro is used in larger expressions (for example, 5 + SUM_OR_DYNAMIC(a, b) or SUM_OR_DYNAMIC(a, b) * 2).
  2. C-style/Functional Casts: Using functional casts like int(x) is discouraged in C++. It is safer and more idiomatic to use static_cast<int>(x) to avoid potential casting issues and adhere to modern C++ standards.

Suggested Refactoring:
Wrap the macro arguments and the entire expression in parentheses, and use static_cast<int> for explicit type conversion.

Suggested change
#define SUM_OR_DYNAMIC(x, y) (x == Eigen::Dynamic || y == Eigen::Dynamic) ? Eigen::Dynamic : (int(x) + int(y))
#define SUM_OR_DYNAMIC(x, y) (((x) == Eigen::Dynamic || (y) == Eigen::Dynamic) ? Eigen::Dynamic : (static_cast<int>(x) + static_cast<int>(y)))


template<typename Derived1, typename Derived2>
struct hstack_return
Expand Down
Loading