-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Point cloud loaders (LAS and TXT) #978
base: release-candidate
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## release-candidate #978 +/- ##
=====================================================
- Coverage 39.93% 39.56% -0.38%
=====================================================
Files 345 349 +4
Lines 22928 23146 +218
=====================================================
Hits 9157 9157
- Misses 13771 13989 +218
Help us with your feedback. Take ten seconds to tell us how you rate us. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round of reviews
ypos++; | ||
zpos++; | ||
|
||
/*retrieving x y z time attribut positions and column count*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this implementation, your loader can only load the x,y,z and time fields.
I would be better to load all the fields, then aggregate x,y,z, and add the position, and custom fields in the Radium datastructure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated implementation to load all attributes as custom and aggregate x y z properties only
src/IO/LasLoader/lasloader.cpp
Outdated
|
||
// checking for colors | ||
bool colors = false; | ||
auto handle_color = geometry->getGeometry().vertexAttribs().addAttrib<Ra::Core::Vector4>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if colors exist in file before adding them as vertexAttrib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for gps info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if they are not in file, i delete them at the end (lines 220-227)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks sub-optimal.
Can't you just move the attrib creation after the check ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case I would need a temporary vector to store colors and gps_time in the data reading loop, and that is what we tried to avoid in the first place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so.
You can call addAttrib
at line 137, ie. when setting colors to true.
In fact you don't need the colors
variable: you can only check if handle_color
is valid, using
handle_color.idx().isValid()
See https://storm-irit.github.io/Radium-Engine/release-candidate/classRa_1_1Core_1_1Utils_1_1AttribHandle.html#af86250020bb2831ce80a811c17d3a6c5
and https://storm-irit.github.io/Radium-Engine/release-candidate/Index_8hpp_source.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated code to call findAttrib every iteration, please check if it's the suitable behaviour (i did not use idx()...)
Co-authored-by: Nicolas Mellado <nmellado0@gmail.com>
for more information, see https://pre-commit.ci
Co-authored-by: Nicolas Mellado <nmellado0@gmail.com>
Co-authored-by: Nicolas Mellado <nmellado0@gmail.com>
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
src/IO/LasLoader/lasloader.cpp
Outdated
bool colors = false; | ||
if ( data_format == 2 || data_format == 3 || ( minor >= 3 && data_format == 5 ) ) { | ||
auto handle_color = geometry->getGeometry().vertexAttribs().addAttrib<Ra::Core::Vector4>( | ||
Ra::Core::Geometry::getAttribName( Ra::Core::Geometry::MeshAttrib::VERTEX_COLOR ) ); | ||
colors = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool colors = false; | |
if ( data_format == 2 || data_format == 3 || ( minor >= 3 && data_format == 5 ) ) { | |
auto handle_color = geometry->getGeometry().vertexAttribs().addAttrib<Ra::Core::Vector4>( | |
Ra::Core::Geometry::getAttribName( Ra::Core::Geometry::MeshAttrib::VERTEX_COLOR ) ); | |
colors = true; | |
Ra::Core::Utils::AttribHandle< Ra::Core::Vector4 > handle_color; | |
if ( data_format == 2 || data_format == 3 || ( minor >= 3 && data_format == 5 ) ) { | |
handle_color = geometry->getGeometry().vertexAttribs().addAttrib<Ra::Core::Vector4>( | |
Ra::Core::Geometry::getAttribName( Ra::Core::Geometry::MeshAttrib::VERTEX_COLOR ) ); |
src/IO/LasLoader/lasloader.cpp
Outdated
vertices.emplace_back( Scalar( x ), Scalar( y ), Scalar( z ) ); | ||
|
||
// computing colors if found | ||
if ( colors ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( colors ) { | |
if ( handle_colors.idx().isValid() ) { |
src/IO/LasLoader/lasloader.cpp
Outdated
auto handle_colors = | ||
geometry->getGeometry().vertexAttribs().findAttrib<Ra::Core::Vector4>( | ||
Ra::Core::Geometry::getAttribName( | ||
Ra::Core::Geometry::MeshAttrib::VERTEX_COLOR ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto handle_colors = | |
geometry->getGeometry().vertexAttribs().findAttrib<Ra::Core::Vector4>( | |
Ra::Core::Geometry::getAttribName( | |
Ra::Core::Geometry::MeshAttrib::VERTEX_COLOR ) ); |
src/IO/LasLoader/lasloader.cpp
Outdated
geometry->getGeometry() | ||
.vertexAttribs() | ||
.getDataWithLock( handle_colors ) | ||
.emplace_back( Scalar( red ), Scalar( green ), Scalar( blue ), 1_ra ); | ||
geometry->getGeometry().vertexAttribs().unlock( handle_colors ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be more efficient to look for the attrib only once.
Note that you can do
auto& attr = geometry->getGeometry(). getAttrib( handle_colors );
I think that I now understand why you need your temporary arrays, my bad.
So:
- use temporary std::vector for colors (and other attributes)
- after reading, copy them using
geometry->getGeometry(). getAttrib( handle_colors ).setData()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
( (int)i == timepos ) ) { | ||
continue; | ||
} | ||
auto handle2 = geometry->getGeometry().vertexAttribs().findAttrib<Scalar>( tokens[i] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it would be better to store the handle in an array, it would be easier to lock/unlock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
* | ||
* example: Time X Y Z Roll Pitch Heading sdX sdY sdZ | ||
* | ||
* X, Y, Z and Time properties (case sensitive) are mandatory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we could relax the constraint on the time field: it could be useful to load point-clouds with xyz coordinates, even if we don't have the time field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. now only position properties are mandatory
src/IO/LasLoader/lasloader.cpp
Outdated
blue = *(unsigned short*)( point.data() + 24 ); | ||
} | ||
|
||
colors.emplace_back( Scalar( red ), Scalar( green ), Scalar( blue ), 1_ra ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you can see here https://storm-irit.github.io/Radium-Engine/release-candidate/classRa_1_1Core_1_1Utils_1_1ColorBase.html
Colors have values between 0 and 1.
As you cast unsigned short to float, you will always have values > 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so do I need to perform a division by 2¹⁶?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to be sure what is the maximum value in practice. Usually it is 255.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it says in the specification that color channels are coded on 16 bits and that it should always be normalized to be so
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Be aware that the PR request cannot be accepted if it doesn't pass the Continuous Integration tests.
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
feature
What is the current behavior? (You can also link to an open issue here)
no support in radium to load .las and .txt point clouds
What is the new behavior (if this is a feature change)?
add file loaders for .las and .txt file formats
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
no
Other information: