Items with no label
3335 Discussions

Converting RealSense D415 bag file to PCD

AMahm3
Beginner
13,381 Views

I've received my RealSense D415 10 days ago (I'm not a developer) and I was trying to use it for room scanning. I've recorded a *.bag file through the viewer and the Unity wrapper and I'm trying to convert the .bag file to a point cloud; I've tried using ROS:

rosrun pcl_ros bag_to_pcd

But the output directory is always empty, so is there a way that I can use to get a point cloud (then create a mesh) from the D415?

BTW: I've tried the *.PLY in the viewer and that's not a 3D scan it's simply a depth snap/shot of what is directly in-front of the camera not a real 3D scan. RecFusion can be used but it has limitations on the size of the object you want to scan.

Thanks in advance.

0 Kudos
59 Replies
MartyG
Honored Contributor III
3,681 Views

The link below contains a long discussion about converting RealSense point cloud data to PCD.

Alternatively, once you have a .ply point cloud recorded then you can convert it to a solid mesh in 3D software such as MeshLab or Blender. The link below has linkages to guides to doing so in MeshLab.

0 Kudos
AMahm3
Beginner
3,681 Views

Thanks MartyG for your reply, I've found these two links in my research and both don't address the problem I'm trying to solve:

1. The first link doesn't address converting the bag file to PCD, it's only covering using the PCL and from dabbling with it, i reckon that it only covers a single frame not multiple frames.

2. The second link (as I've said in my question) covers the .PLY which is for a single frame and that has nothing to do with scanning an object (front, back sides) and creating a model for it.

I want to convert the bag to PCD to be able to create a mesh from all of the frames recorded in the bag file not from a single frame.

Thanks again, please if you've a solution for that inform me about it, I'd be very grateful.

0 Kudos
MartyG
Honored Contributor III
3,681 Views

Might the SDK's 'Convert' tool for converting a bag into other formats (e.g bag to ply) suit your needs?

https://github.com/IntelRealSense/librealsense/tree/master/tools/convert librealsense/tools/convert at master · IntelRealSense/librealsense · GitHub

0 Kudos
AMahm3
Beginner
3,681 Views

Thanks MartyG haven't seen that one:-) I'm going to try it and state the outcome here, as that might be helpful for others in the community, thanks again :-)

0 Kudos
MartyG
Honored Contributor III
3,681 Views

Looking forward to your test results - thanks so much, and good luck!

0 Kudos
AMahm3
Beginner
3,681 Views

Hello MartyG , I've been trying from yesterday and I don't know what I should actually do, forgive my ignorance as I'm not a developer,

1. I've tried using CMake GUI to create/generate an executable but I get an error "Error in the configuration process, project files may be invalid"

2. I've tried opening the converter directly through visual studio but I couldn't compile and run it.

I'd appreciate any guidance and again sorry for my ignorance:-).

0 Kudos
MartyG
Honored Contributor III
3,681 Views

I admit I have never compiled a RealSense program (or any program) in Visual Studio, so I could not locate any information that could usefully guide you in compiling the Convert tool. Unlike other tools, a pre-made executable of it is not included in the SDK's folders.

A member of Intel's support team may be able to assist you once they resume their forum hours on Monday. I do apologize.

0 Kudos
AMahm3
Beginner
3,681 Views

Thanks MartyG , it has CMakeList file so I think it should go through CMake to create binaries, waiting for someone who can help, thanks again.

0 Kudos
idata
Employee
3,681 Views

Hello GamesMechanic,

Thank you for your interest in the Intel RealSense D415 camera.

You are indeed right, you will need to use CMAKE GUI in order to create the binaries for the project.

You can follow in the instructions from https://github.com/IntelRealSense/librealsense/tree/master/wrappers/opencv librealsense/wrappers/opencv at master · IntelRealSense/librealsense · GitHub in order to create them. If you don't plan on using the OpenCV wrappers, you can skip to step number 9 (also, don't follow steps 11 and 12).

You will have the rs-convert.cpp file under Tool folder.

Please let us know the outcome!

Kindest regards,

 

Eliza
0 Kudos
AMahm3
Beginner
3,681 Views

Thanks Intel Corporation (Eliza), as I've said I've tried CMake and I'm getting an error "Error in the configuration process, project files may be invalid" , appreciate your help,

by the way on the ROS forums (answers.ros.org) I've been informed by a community member that I can't generate a PCD directly from the bag that was generated from the RealSense D415 as it doesn't have a direct topic for point cloud, I've first to use Nodelet to associate (RGB to Depth) and then generate the PointCloud, then the PCD, I still don't know how to do that either.

0 Kudos
idata
Employee
3,681 Views

Hello GamesMechanic,

 

 

Could you please provide us the full error text marked in red on CMAKE GUI in order to guide you how to solve it?

 

 

The rs-covert.cpp tool can convert a .bag file to a .ply file.

 

You can use the following code in order to convert the .ply file to a .pcd file: https://github.com/PointCloudLibrary/pcl/blob/master/tools/ply2pcd.cpp PLY 2 PCD

 

 

Hope this information helps!

 

Please let us know the outcome!

 

 

Kindest regards,

 

Eliza
0 Kudos
AMahm3
Beginner
3,681 Views

Hello Eliza,

Thanks for your reply, as I've said the .ply generated by RealSense SDK is for a single frame, which isn't what I want as you can't use that to scan any objects.

The error I'm getting is:

CMake:

Visual Studio:

Severity Code Description Project File Line Suppression State

Error C1083 Cannot open include file: 'librealsense2/rs.hpp': No such file or directory rs-convert c:\users\computerGM\desktop\librealsense-master\tools\convert\rs-convert.cpp 6

Appreciate your help, thanks.

0 Kudos
idata
Employee
3,681 Views

Hello GamesMechanic,

 

 

Thank you for the screenshot.

 

Please make sure that the "Where is the source code" and "where to build the binaries" look like the picture below. The build folder needs to be located right under librealsense-master folder:

 

 

After you have done that, you will be able to open the Project in Visual Studio. It will contain the folder Tool, where rs-capture is located, alongside with another samples codes.

 

 

I found a thread on the PCL community that might help you : http://www.pcl-users.org/conversion-bag-to-pcd-td2770573.html

 

 

Looking forward to hear from your side!

 

 

Thank you,

 

Eliza
0 Kudos
AMahm3
Beginner
3,681 Views

Hello Eliza,

Thanks for your reply, I've put the Build folder under the librealsense-master as you've advised and I've receivde the following errors in CMake:

Then after trying to run the generated binaries anyhow in visual studio, I've got 23 errors:

Regarding the link in your comment. as I've told you before the bag file generated from the RealSense camera can't be used directly with ROS/PCL we need first to use http://wiki.ros.org/depth_image_proc# depth_image_proc.2BAC8-point_cloud_xyzrgb depth_image_proc nodelet which I don't know how to use (still researching it), appreciate your reply, thanks.

0 Kudos
PNzie
Beginner
2,942 Views

Hello AMahm3,

 

I am looking for android code to convert a .bag file to .ply file.

Can you help me?

 

Thanks.

0 Kudos
AMahm3
Beginner
2,942 Views

PNzie unfortunately no, I can't still convert the .bag to ply on PC.

0 Kudos
GRedd
Novice
3,681 Views

I have a similar issue. I want to be able to get the point cloud data from every frame. Doesn't matter too much what format it is in, ply or pcd would be fine.

At the moment you can capture a .bag and play it back then manually export frames to ply by playing the file back in the viewer. But this is very tedious being a manual process, and you can't skip ahead frame by frame and the time given on the playback slider only lists seconds and not milliseconds, so it is not useful for anything requiring more than crude estimates. The frustrating thing is that all the data is their and having it output as a pointcloud at each time would be incredibly useful for many applications, but their appears no way of doing this easily.

The only partial solution I have found is in unity to collect the point could data over time and then save it to a csv. But I am running into memory limitations. And also in unity I can't easily turn on and off the various post processing filters easily like I can in the viewer.

A feature built into the viewer which allows a recorded .bag file to be export every frame as a ply would be extremely useful.

0 Kudos
AMahm3
Beginner
3,681 Views

Even the .ply file generated is for a mesh that you can't assemble, as there's no tool for assembling meshes to generate a final model, you can use RecFusion which isn't useful in my case as I'm dealing/want to deal with scanning large equipment. Hope Eliza ould find a solution that would allow me to use the converter.

0 Kudos
idata
Employee
3,681 Views

Hello GamesMechanic,

 

 

We are currently working on your request. As soon as we will have a resolution, we will comment on this thread.

 

 

Thank you,

 

Eliza
0 Kudos
AMahm3
Beginner
3,681 Views

Hello Eliza,

thanks for your reply, I'd like to resolve the CMake error for now to know whether the converter is the solution I'm seeking or should I continue with the ROS nodelet way. thanks in advance.

0 Kudos
Reply