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

Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++ label:L515 #9071

Closed
Ziling169BENZHI opened this issue May 21, 2021 · 16 comments
Labels

Comments

@Ziling169BENZHI
Copy link

Ziling169BENZHI commented May 21, 2021

  • Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):

  • All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open a new issue, even if they haven't followed any of the suggestions above :)


Required Info
Camera Model { L515}
Firmware Version (01.05.05.00)
Operating System & Version {Win (8.1/10)
Kernel Version (Linux Only) (e.g. 4.14.13)
Platform PC
SDK Version { legacy / 2.44 }
Language {C++/python }
Segment {Robot/Smartphone/VR/AR/others }

Issue Description

<Describe your issue / question / feature request / etc..>

the reason to start this problem is the ply file exported from RSviewer and save_to_ply.py both came out as the same form
1elements with 9 properties, but each line only contains 3 elements, so a bit confusing to load the data in python or CPP.

Hi, I have been working on export my ply file with CPP API for about a week; I expect to export the ply file with RGB, meshed point cloud data and normals like in RealsenseViewer.

I have looked through many helpful issues in the community already ( such as #8656, #6979 and #2832)
Based on their help, I can export the point cloud with the colourized depth and mesh it like this:

CaptureMyface

And I tried to play around with rs2::save_to_ply, but I am not sure how to do that. Can anyone take a look at my code and gives me some help?
Capturecode

1>-----
my idea is to use
rs2::save_to_ply exporter(fname,pc); // because save_to_ply can provide set_options then using
exporter.process(colorized) // this will help me process the saving procedure

But I can only put colourized depth frames in the exporter.process() method, I am not sure why I cannot put the colour frame inside.

2>--------
I also tried to use points.export_to_ply(fname, colour) directly to export the file. However, this will help me export the data with RGB texture, but it didn't provide me options to select mesh or normals.
Also, this method only saves the points in binary form, it will be really helpful if anyone can provide me with a way to export in ASCII form.
CaptureMess

Thank you for all the help @MartyG-RealSense @RealSenseSupport

@Ziling169BENZHI
Copy link
Author

Ziling169BENZHI commented May 27, 2021

also I m confused whether the XYZ coordinates are pixel coordinates or 3D coordinates in the Camera frame @MartyG-RealSense @RealSense-Customer-Engineering @RealSenseSupport

@Ziling169BENZHI Ziling169BENZHI changed the title Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++#Python May 27, 2021
@Ziling169BENZHI Ziling169BENZHI changed the title Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++#Python Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++#Python /L515 May 28, 2021
@Ziling169BENZHI Ziling169BENZHI changed the title Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++#Python /L515 Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++#Python L515:L515 May 28, 2021
@Ziling169BENZHI Ziling169BENZHI changed the title Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++#Python L515:L515 Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++#Python May 28, 2021
@Ziling169BENZHI Ziling169BENZHI changed the title Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++#Python Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++#Python label:pythons May 28, 2021
@Ziling169BENZHI Ziling169BENZHI changed the title Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++#Python label:pythons Problems with output Point Cloud of the C++API with RGB texture(LIdar Camera L515) #L515 #C++ label:L515 May 28, 2021
@MartyG-RealSense
Copy link
Collaborator

Hi @Ziling169BENZHI Did you manage to find a solution for the problem in this case, please?

@Ziling169BENZHI
Copy link
Author

Hi @Ziling169BENZHI Did you manage to find a solution for the problem in this case, please?

Hi MartyG-RealSense, sorry I still have the same problem with
rs2:: save_to_ply exporter("",pc);

On the other side, for points.export_to_ply("",color); I figured out the problem is the binary data type reader, do you have any idea, how can I change the format to " format ascii 1.0" ??

@Ziling169BENZHI
Copy link
Author

Hi @Ziling169BENZHI Did you manage to find a solution for the problem in this case, please?

Also, I am trying to change the minimum range from default to 0, however, I am bit confused about how to implement the sensor control example from SDK2.0 on point cloud example, Can you give me some hints?

Thanks a lot.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jul 5, 2021

When using save_to_ply, setting OPTION_PLY_BINARY to a value of '0' should result in the ply being exported in ASCII format.

#4906

An example of a C++ script for doing so is here:

#6677 (comment)

If you wish to shorten minimum range on L515, the link below suggests loading a Visual Preset (json) camera configuration such as Short Range.

#7731

I also located a Python script example for setting the L515's minimum distance to '0' using code.

#8244 (comment)

@Ziling169BENZHI
Copy link
Author

When using save_to_ply, setting OPTION_PLY_BINARY to a value of '0' should result in the ply being exported in ASCII format.

#4906

An example of a C++ script for doing so is here:

#6677 (comment)

If you wish to shorten minimum range on L515, the link below suggests loading a Visual Preset (json) camera configuration such as Short Range.

#7731

I also located a Python script example for setting the L515's minimum distance to '0' using code.

#8244 (comment)

Hi Marty,

I am sorry I guess I didn't explain my question more clearly.
So First I tried with
rs2::save_to_ply exporter("mesh_face.ply", pc);
exporter.set_option(rs2::save_to_ply::OPTION_PLY_MESH, 1.f);
exporter.set_option(rs2::save_to_ply::OPTION_PLY_NORMALS, 1.f);
exporter.set_option(rs2::save_to_ply::OPTION_PLY_BINARY, 0.f);
//exporter.invoke(depth);
exporter.export_to_ply(points, color);
However, this exporter doesn't have exporter.export_to_ply() function:
problems

Since I already know there exist two method to export the point cloud to ply file. To change the binary option, I would like to know how to implement this option with method of points.export_to_ply("anotherface.ply", color);

Best
Ziling

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jul 6, 2021

The RealSense user who created #6979 shared a Python script in a later case that exported the ply with binary = false using the save_to_ply instruction. The script did not export color though.

#7747 (comment)

I recalled that there was a case in the link below where a RealSense user created a script for export a color ply with export_to_ply for the purposes of accessing it as ASCII.

https://community.intel.com/t5/Items-with-no-label/Capturing-data-from-realsense-D435-exporting-coloured-depth-to/td-p/692227

auto depth = frames.get_depth_frame();
points = pc.calculate(depth);
auto color = frames.get_color_frame();
pc.map_to(color);
 
...
const string st ="filename.ply";
points.export_to_ply(st.c_str(), color);

My understanding of that case is that once the RealSense user exported the color ply then they opened the ply file in the open-source MeshLab software package and exported the mesh as ASCII.

https://www.meshlab.net/

A guide to importing a RealSense ply file into MeshLab and performing further work on it is here:

https://www.andreasjakl.com/capturing-3d-point-cloud-intel-realsense-converting-mesh-meshlab/

@MartyG-RealSense
Copy link
Collaborator

Hi @Ziling169BENZHI Do you require further assistance with this case, please? Thanks!

@Ziling169BENZHI
Copy link
Author

Hi @Ziling169BENZHI Do you require further assistance with this case, please? Thanks!

Hi, Marty Thank you very much, unfortunately, I still need some assistance, I am trying to load the Json file into my code, I am using the method from #6739 and #4046.

Currently, I felt bit confuse about how this works:
auto advanced_mode_dev = serializable_device(this->p->get_active_profile().get_device());
std::ifstream t(myFile);
std::string preset_json((std::istreambuf_iterator(t)), std::istreambuf_iterator());
if (auto advanced_mode_dev = p->get_active_profile().get_device().as<serializable_device>();)
{
advanced_mode_dev.load_json(preset_json);
....
}

Besides that, I am wondering how to set the mode to Short Range Set in C++?

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jul 12, 2021

Setting up the loading of a camera configuration json can be a little awkward. Let's focus on trying to set up the Short Range preset first. Fortunately the code for doing so is simpler than for custom made presets. Intel provide a guide for doing so in C++ in the link below.

https://www.intel.com/content/www/us/en/support/articles/000028416/emerging-technologies/intel-realsense-technology.html

If the second of the two methods in that guide is used:

auto sensor = profile.get_device().firstrs2::depth_sensor();
sensor.set_option(rs2_option::RS2_OPTION_VISUAL_PRESET,
rs2_rs400_visual_preset::RS2_RS400_VISUAL_PRESET_HIGH_ACCURACY);

To define the L515 Short Range preset, please try changing this instruction:

rs2_rs400_visual_preset::RS2_RS400_VISUAL_PRESET_HIGH_ACCURACY

To this:

rs2_l500_visual_preset::RS2_L500_VISUAL_PRESET_SHORT_RANGE

@Ziling169BENZHI
Copy link
Author

Setting up the loading of a camera configuration json can be a little awkward. Let's focus on trying to set up the Short Range preset first. Fortunately the code for doing so is simpler than for custom made presets. Intel provide a guide for doing so in C++ in the link below.

https://www.intel.com/content/www/us/en/support/articles/000028416/emerging-technologies/intel-realsense-technology.html

If the second of the two methods in that guide is used:

auto sensor = profile.get_device().firstrs2::depth_sensor();
sensor.set_option(rs2_option::RS2_OPTION_VISUAL_PRESET,
rs2_rs400_visual_preset::RS2_RS400_VISUAL_PRESET_HIGH_ACCURACY);

To define the L515 Short Range preset, please try changing this instruction:

rs2_rs400_visual_preset::RS2_RS400_VISUAL_PRESET_HIGH_ACCURACY

To this:

rs2_l500_visual_preset::RS2_L500_VISUAL_PRESET_SHORT_RANGE

thank you so much, Marty I am able to change the Short-range set. I also have some questions about setting the resolution of the L515, do you have any recommended issue I can use?

@MartyG-RealSense
Copy link
Collaborator

The code for setting the resolution for L515 in C++ will be the same as with other RealSense cameras, except for selecting resolutions that are supported by L515. You can set up cfg configuration instructions just before the pipe start line of the script, and then place 'cfg' in the brackets of the pipe start instruction so that the script knows to use that custom configuration instead of the L515's default stream configuration.

Here's a simple example of such code that is taken from an L515 case for defining depth and color streams:

rs2::config cfg;
cfg.enable_stream(RS2_STREAM_DEPTH, 1024, 768, RS2_FORMAT_Z16, 30); 
cfg.enable_stream(RS2_STREAM_COLOR, 1920, 1080, RS2_FORMAT_RGB8, 30); 
rs2::pipeline pipe;
pipe.start(cfg);

@MartyG-RealSense
Copy link
Collaborator

Hi @Ziling169BENZHI Do you require further assistance with this case, please? Thanks!

@MartyG-RealSense
Copy link
Collaborator

Case closed due to no further comments received.

@Ziling169BENZHI
Copy link
Author

Hi @Ziling169BENZHI Do you require further assistance with this case, please? Thanks!

Sorry I got sick for few weeks. Thank you for all the help.

@MartyG-RealSense
Copy link
Collaborator

No problem at all, @Ziling169BENZHI - you are very welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants