-
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
export_to_ply sometimes save wrong point cloud #6560
Comments
Hi @EmmanuelCos I could not identify where in your program you are changing the temporal filter. If you are doing it after alignment though then it is recommended that post-processing filters are applied before alignment to help avoid distortions such as aliasing (jagged lines). |
Hello MartyG.
catch (const rs2::error & e) |
I read through your script carefully. I note that you are using poll_for_frames, which is appropriate for a multicam setup. You need to be careful about when to put the CPU to sleep and for how long though when using this instruction, so that CPU percent usage is not maxed out (which could introduce problems as processing jams up). |
Thank you for the answer. Actually I don't put the CPU to sleep. How should I do that? |
A sleep instruction typically takes this form: std::this_thread::sleep_for(std::chrono::milliseconds(10)); Where the number value in brackets is the number of milliseconds (10 in this example) that you want the CPU to sleep for. |
Ok but should I systematically use sleep after pole_for_frame? How long should I set the CPU to sleep? |
I found a multicam example from Dorodnic that uses sleep just after poll_for_frames, and uses a value of 1 millisecond: |
Comparing your wrong and correct images, visually it looks as though something may be going wrong in the application of the Decimation filter and rendering the image at 1/4 scale. I wonder if when it goes wrong, it is applying decimation after align instead of before. |
Actually I don't apply any decimation filter, and the alignment is done after I set all the parameters. Here it looks like there is a 1/4 scale, but sometimes it is much more different than that, can be ~1/10, etc... |
The minimum depth scale is 0.0001. So 0.0003 (larger than 0.0001) should be within allowable bounds. The depth unit scale can cause scale problems when viewing an exported ply in an external 3D modeling program such as MeshLab, Blender or Maya though. If the scale set in RealSense when the ply was created is not the same as the scale set in the 3D software package being used to view the ply then the imported point cloud can appear mis-scaled and distorted. So if you created the point cloud with a 0.0003 depth unit scale then any program being used to view the ply should be set to that too. |
Yes but it still doesn't explain the non alignment between color and depth, and why it only accurs from time to time. |
Does your project involve starting, stopping and then re-starting the streams? |
The function, tryPolForFrame above, uses |
Okay, I was just asking because doing start-stop-start in the same program session can cause the SDK to become confused, especially if more than one stream is toggled on and off (e.g depth on, IR off, depth on). |
Hi @EmmanuelCos Do you still require sssistance with this case please? Thanks! |
Hello MartyG, |
I had dealt with a depth units question earlier today, and had come across an example from a RealSense team member for setting the depth units with C++. It looks as though you have written the instruction correctly, and have also correctly put the instruction before the pipeline starts. Maybe the above link will give a useful insight for your own program though. |
Hello MartyG, They advice to set depth options before streaming. So I will try this way. I also noticed that they use enable_stream(), while I only use enable_device. Do you know what is the difference exactly and what is the best practise? Thank you, Emmanuel |
My understanding is that enable_device is used to make queries to the camera hardware, such as retrieving its serial number, whilst enable_stream is used to define the streams if you are defining a custom stream configuration instead of using the camera's default configuration. For example, to define a custom depth stream in C++: config.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_BGR8, 30); |
I am not sure if it's still possible to do it this way nowadays because this line |
Yes I did that too, but it doesn't work for me because firstrs2 isn't a member of rs2::device. |
The example script I linked to is the only place I can find where the instruction is formatted as dev.firstrs2::depth_sensor(); ... most of the other examples seems to format it as a variation on this line: auto sensor = profile.get_device().firstrs2::depth_sensor(); This is similar to the format in your own script, which was: auto depth_sensor = selected_device.firstrs2::depth_sensor(); The main difference that I see is that instead of using profile directly, you use the selected_device variable that is equal to profile.get_device() Does it make any difference if you take out selected_device and put in the full device definition instead? auto depth_sensor = profile.get_device().firstrs2::depth_sensor(); I appreciate your patience of my programming knowledge limitations! |
Ah I understand it's because the <> were delited when writting it here in github... |
Hi @EmmanuelCos Do you still require assistance with this case please, or can it be closed? Thanks! |
Case closed due to no further comments received. |
Hello,
I am using the rs-multicam with two cameras. At the end of the process, when the user leaves the app, I save the point clouds with export_to_ply.
Most of the time it works good, but sometimes the point cloud have wrong scale, and color not aligned with depth (without changing anything to the code...).
What I am doing differently from the standard program is that I do some retry for the poll_for_frames, and then when I have my frameset, I change several parameters (like temporal filter etc...).
Here is what I am doing to save the point clouds :
The text was updated successfully, but these errors were encountered: