Skip to content
Open
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
3 changes: 2 additions & 1 deletion meshroom/aliceVision/LidarDecimating.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from meshroom.core import desc
from meshroom.core.utils import VERBOSE_LEVEL
from pyalicevision import parallelization as avpar

class LidarDecimating(desc.AVCommandLineNode):
"""
Expand All @@ -15,7 +16,7 @@ class LidarDecimating(desc.AVCommandLineNode):

commandLine = "aliceVision_lidarDecimating {allParams}"

size = desc.StaticNodeSize(10)
size = avpar.DynamicLidarMeshingSize("input")
parallelization = desc.Parallelization(blockSize=1)
commandLineRange = "--rangeStart {rangeStart} --rangeSize {rangeFullSize}"

Expand Down
3 changes: 2 additions & 1 deletion meshroom/aliceVision/LidarMeshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

from meshroom.core import desc
from meshroom.core.utils import VERBOSE_LEVEL
from pyalicevision import parallelization as avpar

class LidarMeshing(desc.AVCommandLineNode):
"""This node creates a dense geometric surface representation of the Lidar measurements."""

commandLine = "aliceVision_lidarMeshing {allParams}"

size = desc.StaticNodeSize(10)
size = avpar.DynamicLidarMeshingSize("input")
parallelization = desc.Parallelization(blockSize=1)
commandLineRange = "--rangeStart {rangeStart} --rangeSize {rangeFullSize}"

Expand Down
61 changes: 47 additions & 14 deletions src/aliceVision/dataio/E57Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
: _paths(paths),
_idPath(-1),
_idMesh(-1),
_idMeshInFile(-1),
_countMeshesForFile(0),
_requiredIntensity(0.0)
{}
Expand All @@ -39,19 +40,23 @@
{
_idPath = -1;
_idMesh = -1;
_idMeshInFile = -1;
_countMeshesForFile = 0;
}

bool getNext(Eigen::Vector3d& sensorPosition, std::vector<PointInfo>& vertices, Eigen::Matrix<size_t, -1, -1>& grid)
{
// Go to next mesh of current file
_idMeshInFile++;

// Keep a unique counter for all files
_idMesh++;

// Load next file if needed
if (_idMesh >= static_cast<int>(_countMeshesForFile))
if (_idMeshInFile >= static_cast<int>(_countMeshesForFile))
{
_idPath++;
_idMesh = 0;
_idMeshInFile = 0;
if (_idPath >= static_cast<int>(_paths.size()))
{
return false;
Expand All @@ -74,7 +79,7 @@
_countMeshesForFile = _reader->GetData3DCount();
}

if (_idMesh >= static_cast<int>(_countMeshesForFile))
if (_idMeshInFile >= static_cast<int>(_countMeshesForFile))
{
return false;
}
Expand All @@ -86,9 +91,9 @@

// Get header
e57::Data3D scanHeader;
if (!_reader->ReadData3D(_idMesh, scanHeader))
if (!_reader->ReadData3D(_idMeshInFile, scanHeader))
{
ALICEVISION_LOG_ERROR("Error reading mesh #" << _idMesh);
ALICEVISION_LOG_ERROR("Error reading mesh #" << _idMeshInFile);
return false;
}

Expand All @@ -109,14 +114,14 @@
int64_t maxGroupSize = 0;
bool isColumnIndex;

if (!_reader->GetData3DSizes(0, maxRows, maxColumns, countPoints, countGroups, maxGroupSize, isColumnIndex))
if (!_reader->GetData3DSizes(_idMeshInFile, maxRows, maxColumns, countPoints, countGroups, maxGroupSize, isColumnIndex))
{
ALICEVISION_LOG_ERROR("Error reading content of mesh #" << _idMesh);
ALICEVISION_LOG_ERROR("Error reading content of mesh #" << _idMeshInFile);
return false;
}

e57::Data3DPointsFloat data3DPoints(scanHeader);
e57::CompressedVectorReader datareader = _reader->SetUpData3DPointsData(_idMesh, countPoints, data3DPoints);
e57::CompressedVectorReader datareader = _reader->SetUpData3DPointsData(_idMeshInFile, countPoints, data3DPoints);

// Prepare list of vertices
vertices.clear();
Expand All @@ -129,6 +134,27 @@
unsigned int readCount = 0;
while ((readCount = datareader.read()) > 0)
{
ALICEVISION_LOG_DEBUG("cartesianInvalidState pointer: " << static_cast<void*>(data3DPoints.cartesianInvalidState));
ALICEVISION_LOG_DEBUG("cartesianX pointer: " << static_cast<void*>(data3DPoints.cartesianX));
ALICEVISION_LOG_DEBUG("cartesianY pointer: " << static_cast<void*>(data3DPoints.cartesianY));
ALICEVISION_LOG_DEBUG("cartesianZ pointer: " << static_cast<void*>(data3DPoints.cartesianZ));
ALICEVISION_LOG_DEBUG("colorBlue pointer: " << static_cast<void*>(data3DPoints.colorBlue));
ALICEVISION_LOG_DEBUG("colorGreen pointer: " << static_cast<void*>(data3DPoints.colorGreen));
ALICEVISION_LOG_DEBUG("colorRed pointer: " << static_cast<void*>(data3DPoints.colorRed));
ALICEVISION_LOG_DEBUG("columnIndex pointer: " << static_cast<void*>(data3DPoints.columnIndex));
ALICEVISION_LOG_DEBUG("intensity pointer: " << static_cast<void*>(data3DPoints.intensity));
ALICEVISION_LOG_DEBUG("isColorInvalid pointer: " << static_cast<void*>(data3DPoints.isColorInvalid));
ALICEVISION_LOG_DEBUG("isIntensityInvalid pointer: " << static_cast<void*>(data3DPoints.isIntensityInvalid));
ALICEVISION_LOG_DEBUG("isTimeStampInvalid pointer: " << static_cast<void*>(data3DPoints.isTimeStampInvalid));
ALICEVISION_LOG_DEBUG("returnCount pointer: " << static_cast<void*>(data3DPoints.returnCount));
ALICEVISION_LOG_DEBUG("returnIndex pointer: " << static_cast<void*>(data3DPoints.returnIndex));
ALICEVISION_LOG_DEBUG("rowIndex pointer: " << static_cast<void*>(data3DPoints.rowIndex));
ALICEVISION_LOG_DEBUG("sphericalAzimuth pointer: " << static_cast<void*>(data3DPoints.sphericalAzimuth));
ALICEVISION_LOG_DEBUG("sphericalElevation pointer: " << static_cast<void*>(data3DPoints.sphericalElevation));
ALICEVISION_LOG_DEBUG("sphericalInvalidState pointer: " << static_cast<void*>(data3DPoints.sphericalInvalidState));
ALICEVISION_LOG_DEBUG("sphericalRange pointer: " << static_cast<void*>(data3DPoints.sphericalRange));
ALICEVISION_LOG_DEBUG("timeStamp pointer: " << static_cast<void*>(data3DPoints.timeStamp));

// Check input compatibility
if (data3DPoints.sphericalRange != nullptr)
{
Expand All @@ -141,6 +167,7 @@
ALICEVISION_LOG_ERROR("Data contains no cartesian coordinates");
continue;
}


if (data3DPoints.columnIndex == nullptr)
{
Expand All @@ -159,10 +186,11 @@
ALICEVISION_LOG_ERROR("Data contains no intensities");
continue;
}


for (unsigned int pos = 0; pos < readCount; pos++)
{
if (data3DPoints.cartesianInvalidState[pos])
if (data3DPoints.cartesianInvalidState && data3DPoints.cartesianInvalidState[pos])

Check warning on line 193 in src/aliceVision/dataio/E57Reader.hpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"&&" right operand should have type 'bool'.

See more on https://sonarcloud.io/project/issues?id=alicevision_AliceVision&issues=AZ7aCbLwTKl4M7s-ld6-&open=AZ7aCbLwTKl4M7s-ld6-&pullRequest=2140

Check warning on line 193 in src/aliceVision/dataio/E57Reader.hpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"&&" left and right operands should have type 'bool'.

See more on https://sonarcloud.io/project/issues?id=alicevision_AliceVision&issues=AZ7aCbLwTKl4M7s-ld6_&open=AZ7aCbLwTKl4M7s-ld6_&pullRequest=2140
{
continue;
}
Expand All @@ -187,6 +215,7 @@
vertices.push_back(pi);
}
}
datareader.close();

sensorPosition = t;

Expand All @@ -196,13 +225,16 @@
bool getNext(Eigen::Vector3d& sensorPosition)
{
// Go to next mesh of current file
_idMeshInFile++;

// Keep a unique counter for all files
_idMesh++;

// Load next file if needed
if (_idMesh >= static_cast<int>(_countMeshesForFile))
if (_idMeshInFile >= static_cast<int>(_countMeshesForFile))
{
_idPath++;
_idMesh = 0;
_idMeshInFile = 0;
if (_idPath >= static_cast<int>(_paths.size()))
{
return false;
Expand All @@ -225,7 +257,7 @@
_countMeshesForFile = _reader->GetData3DCount();
}

if (_idMesh >= static_cast<int>(_countMeshesForFile))
if (_idMeshInFile >= static_cast<int>(_countMeshesForFile))
{
return false;
}
Expand All @@ -237,9 +269,9 @@

// Get header
e57::Data3D scanHeader;
if (!_reader->ReadData3D(_idMesh, scanHeader))
if (!_reader->ReadData3D(_idMeshInFile, scanHeader))
{
ALICEVISION_LOG_ERROR("Error reading mesh #" << _idMesh);
ALICEVISION_LOG_ERROR("Error reading mesh #" << _idMeshInFile);
return false;
}

Expand All @@ -264,6 +296,7 @@

int _idPath;
int _idMesh;
int _idMeshInFile;
size_t _countMeshesForFile;
double _requiredIntensity;
};
Expand Down
16 changes: 8 additions & 8 deletions src/aliceVision/fuseCut/Octree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ class SimpleNode
return;
}

for (auto& item : _nodes)
{
if (item)
{
item->regroup(maxPointsPerNode);
}
}

if (count < maxPointsPerNode)
{
_count = count;
Expand All @@ -148,14 +156,6 @@ class SimpleNode

return;
}

for (auto& item : _nodes)
{
if (item)
{
item->regroup(maxPointsPerNode);
}
}
}

const size_t getCount() const
Expand Down
42 changes: 41 additions & 1 deletion src/aliceVision/python/parallelization.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,44 @@ def __call__(self, node):
if not valid:
raise RuntimeError(f"Failed to load file : {param.value}")

return max(1, len(imlist))
return max(1, len(imlist))

class DynamicLidarMeshingSize(object):
"""Compute parallelization size based on a JSON file containing an array of items.

Reads the JSON file referenced by the given node parameter and returns the
number of elements in the root-level array. Returns 1 if the file cannot be
read, is not valid JSON, or its root element is not an array.

Args:
param: Name of the node attribute that holds the path to the JSON file.
"""

def __init__(self, param):
self._param = param

def __call__(self, node):
"""Compute the number of chunks from the JSON array size.

Args:
node: The processing node whose attribute *param* points to a JSON file.

Returns:
int: The number of elements in the root JSON array, or 1 if the file
cannot be loaded or the root is not an array.
"""

import json

param = node.attribute(self._param)

try:
with open(param.value, 'r') as f:
data = json.load(f)
except Exception:
return 1

if not isinstance(data, list):
return 1

return max(1, len(data))
6 changes: 3 additions & 3 deletions src/software/convert/main_importE57.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ int aliceVision_main(int argc, char** argv)
std::map<int, Eigen::Vector3d> cameras;
while (reader.getNext(sensorPosition))
{
cameras[reader.getIdMesh()] = sensorPosition;

// Create pose for sfmData
const int idMesh = reader.getIdMesh();

cameras[idMesh] = sensorPosition;

Eigen::Vector3d correctedSensorPosition;
correctedSensorPosition.x() = sensorPosition.x();
correctedSensorPosition.y() = -sensorPosition.z();
Expand Down Expand Up @@ -352,7 +352,7 @@ int aliceVision_main(int argc, char** argv)
std::vector<fuseCut::SimpleNode::ptr> list;
octree.visit(list);

ALICEVISION_LOG_INFO("Generating " << list.size() << "sub regions");
ALICEVISION_LOG_INFO("Generating " << list.size() << " sub regions");

fuseCut::InputSet inputs;

Expand Down
Loading