Items with no label
3335 Discussions

Getting pointcloud from D435

FGalh
Beginner
2,986 Views

Hello,

I'm curretnly trying to save a pointcloud from a D435 camera using the pyrealsense2 lib on Windows. I'm using basically the code from the exemple :

frames = pipeline.wait_for_frames()

depth_frame = frames.get_depth_frame()

color_frame = frames.get_color_frame()

points = rs.points

pc = rs.pointcloud

pc.map_to(color_frame)

points = pc.calculate(depth_frame)

print("Saving to 1.ply...")

points.export_to_ply("1.ply", color_frame)

print("Done")

But everytime I try to use it it gets me this error :

TypeError('map_to(): incompatible function arguments. The following argument types are supported:\n 1. (self: pyrealsense2.pointcloud, mapped: pyrealsense2.frame) -> None\n\nInvoked with: ')

Does anyone have any idea where this error comes from ?

0 Kudos
12 Replies
idata
Employee
832 Views

Hi FlavG,

 

 

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

 

Please make sure you followed all the instructions to install pyrealsense2 :

 

https://github.com/IntelRealSense/librealsense/tree/master/wrappers/python

 

Then try running this example:

 

https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/export_ply_example.py

 

 

Let me know if it works.

 

 

Regards,

 

Alexandra
0 Kudos
FGalh
Beginner
832 Views

Hello Alexandra,

Pyrealsense2 is installed correctly, I followed all the instructions. The example you gave me works fine without me having to change anything to it, I already tried it before to see if there was a problem with my pyrealsense2 install, that was the example I talked about in my question.

0 Kudos
idata
Employee
832 Views

Hi FlavG,

 

 

Do you still need help with this issue?

 

 

Regards,

 

Alexandra
0 Kudos
FGalh
Beginner
832 Views

Yes, I still have the error I copied in my first post wich I don't understand why it keeps happenig there and not in the examples you gave me

0 Kudos
idata
Employee
832 Views

Hi FlavG,

 

 

Could you be more specific?

 

Do you get that error when you are running export_ply_example.py ?

 

What happens when you run other examples? Do you get the same error?

 

 

Regards,

 

Alexandra
0 Kudos
FGalh
Beginner
832 Views

Hi,

Any other example I've tried works fine, it doesn't work only in my code. The main part I don't understand about this error is, if I'm not wrong and understood it correctly, that the frame type I try to map doesn't work with the map_to() function. But using a debugger on both the examples and my code to see which type were the frames, I found out that in both cases the frames are pyrealsense2.video_frame. That is why I don't understand why this error keeps happening only in my code.

0 Kudos
idata
Employee
832 Views

Hi FlavG,

 

 

Is your code file in the same directory as the librealsense python examples?

 

You have to make sure that your code is calling the same .lib, .pyd and .dlls that the examples use.

 

 

Regards,

 

Alexandra
0 Kudos
FGalh
Beginner
832 Views

Hi,

Yes, it is in the same folder and uses the same files, the other functions like streaming from the camera and getting the distance from a pixel are working, it's just the export to a .ply file that doesn't work.

0 Kudos
idata
Employee
832 Views

Hi FlavG,

 

 

Can you send us the whole code, not just a section?

 

 

Regards,

 

Alexandra
0 Kudos
FGalh
Beginner
832 Views

Hi,

Here is the whole code :

https://pastebin.com/mv9Ztz25 import pyrealsense2 as rs import numpy as np import cv2 # mouse callback - Pastebin.com

0 Kudos
idata
Employee
832 Views

Hi FlavG,

 

 

I managed to run your code.

 

You must add "()" to the function calls:

points = rs.points()

pc = rs.pointcloud()

 

 

Regards,

 

Alexandra
0 Kudos
FGalh
Beginner
832 Views

Hi,

Thank you for your help, it was such a dumb mistake and I didn't see it. Sorry for taking from your time to answer this question.

Best regards,

FlavG

0 Kudos
Reply