-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Adding Export to PLY to API #928
Conversation
… second call to calculate
@@ -416,6 +419,15 @@ namespace rs2 | |||
return (const vertex*)res; | |||
} | |||
|
|||
void export_to_ply(const std::string& fname, video_frame texture) |
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.
Indentation is off...
src/archive.cpp
Outdated
int y = std::min(std::max(int(v*h + .5f), 0), h - 1); | ||
int idx = x * ptr->get_bpp() / 8 + y * ptr->get_stride(); | ||
const auto texture_data = reinterpret_cast<const uint8_t*>(ptr->get_frame_data()); | ||
return std::tuple<uint8_t, uint8_t, uint8_t>( |
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.
Consider using std::make_tuple(...)
src/archive.cpp
Outdated
{ | ||
const auto vertices = get_vertices(); | ||
const auto texcoords = get_texture_coordinates(); | ||
//const auto tex = reinterpret_cast<const uint8_t*>(texture.get_data()); |
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.
Remove redundant comments
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.
And in the rest of the file as well
src/archive.cpp
Outdated
// LOG_INFO("Vertex count: " << get_vertex_count()); | ||
assert(get_vertex_count()); | ||
for (size_t i = 0; i < get_vertex_count(); ++i) | ||
if (std::abs(vertices[i].x) >= 1e-6 || std::abs(vertices[i].y) >= 1e-6 || std::abs(vertices[i].z) >= 1e-6) |
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.
Please extract magic number (1e-9) to some constant with meaningful name
src/archive.cpp
Outdated
{ | ||
//out.write(reinterpret_cast<const char*>(&(new_texcoords[i].u)), sizeof(float)); | ||
//out.write(reinterpret_cast<const char*>(&(new_texcoords[i].v)), sizeof(float)); | ||
out.write(reinterpret_cast<const char*>(&(std::get<0>(new_tex[i]))), sizeof(uint8_t)); |
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.
Consider using std::tie(x,y,z)
src/proc/pointcloud.h
Outdated
@@ -16,17 +16,17 @@ namespace librealsense | |||
|
|||
const rs2_intrinsics* _depth_intrinsics_ptr; | |||
const float* _depth_units_ptr; | |||
const rs2_intrinsics* _mapped_intrinsics_ptr; | |||
const rs2_intrinsics* _other_intrinsics_ptr; |
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.
Consider using librealsense::optional_value
instead of a pointer and value type. See align
for reference
## Copyright(c) 2017 Intel Corporation. All Rights Reserved. | ||
|
||
##################################################### | ||
## Align Depth to 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.
Change the title to match example name
# Tell pointcloud object to map to this color frame | ||
pc.map_to(color); | ||
|
||
export_to_ply("1.ply", 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.
Is this a free function? Shouldn't it be points.export_to_ply(...)
?
try: | ||
while True: | ||
# Wait for the next set of frames from the camera | ||
frames = pipe.wait_for_frames(); |
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.
remove ;
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.
and for the rest of the file
export_to_ply("1.ply", color) | ||
|
||
finally: | ||
pipeline.stop() |
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.
should be pipe
.stop()
… type, python example file fixed
Addressing #862
export_to_ply
to API.export_to_ply
to python wrapper.export_to_ply_example.py
.pointcloud
, which was causing texture coordinates be all zeros before callingcalculate
for the second time, now coordinates are valid after the first call (possibly related to Pointcloud : Texture coordinates are always {0.0, 0.0} #900).