Skip to content
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

Merged
merged 8 commits into from
Dec 24, 2017

Conversation

AnnaRomanov
Copy link
Contributor

Addressing #862

  1. Added function export_to_ply to API.
  2. Added function export_to_ply to python wrapper.
  3. Added example file export_to_ply_example.py.
  4. Fixed bug in pointcloud, which was causing texture coordinates be all zeros before calling calculate 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).

zivsha
zivsha previously requested changes Dec 20, 2017
@@ -416,6 +419,15 @@ namespace rs2
return (const vertex*)res;
}

void export_to_ply(const std::string& fname, video_frame texture)
Copy link
Contributor

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>(
Copy link
Contributor

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());
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant comments

Copy link
Contributor

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)
Copy link
Contributor

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));
Copy link
Contributor

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)

@@ -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;
Copy link
Contributor

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 ##
Copy link
Contributor

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)
Copy link
Contributor

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();
Copy link
Contributor

Choose a reason for hiding this comment

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

remove ;

Copy link
Contributor

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()
Copy link
Contributor

Choose a reason for hiding this comment

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

should be pipe.stop()

@dorodnic dorodnic merged commit 21dca56 into IntelRealSense:development Dec 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants