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

All the 3D coordinates are zeros when using CUDA to transform depth maps to point clouds. #10904

Closed
Shannon-Law opened this issue Sep 15, 2022 · 18 comments
Labels

Comments

@Shannon-Law
Copy link

In my C++ program, I transform depth maps to point clouds with CUDA when I use the codes from https://github.com/IntelRealSense/librealsense/blob/d5e775b75f7adbf75c911b7c85a4afd2f16defcb/src/cuda/cuda-pointcloud.cu. But, all the 3D coordinates of the point clouds are zeros. Why is that and how to solve it?

@MartyG-RealSense
Copy link
Collaborator

Hi @Shannon-Law There should not be a need to use code from the quoted script to generate a CUDA-enabled point cloud. If CUDA support is enabled in librealsense then CUDA acceleration should be applied to the pointcloud automatically when it is generated in librealsense or in the RealSense ROS wrapper.

CUDA support will be included if librealsense is installed from Debian packages, or if it is built from source code with CMake with the build flag DBUILD_WITH_CUDA=true included in the CMake build instruction.

CUDA support is not included if librealsense was built from packages using the 'Method 1' instructions of the RealSense ROS wrapper though.

@Shannon-Law
Copy link
Author

Hi, @MartyG-RealSense, I used "apt-get" to install RealSense SDK according to https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md. Because of the fact that the SDK does not support the function rscuda::deproject_depth_cuda, I added the source codes above to my program to generate point clouds.

@Shannon-Law
Copy link
Author

Shannon-Law commented Sep 15, 2022

By the way, when I use the codes from https://github.com/IntelRealSense/librealsense/blob/d5e775b75f7adbf75c911b7c85a4afd2f16defcb/src/cuda/cuda-pointcloud.cu, I add the function printf() in the kernel function, yet printf() does not execute.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Sep 15, 2022

CUDA support in the SDK provides acceleration for pointclouds, depth-color alignment and color conversion and does not accelerate any other type of operation.

If you are using the rs2::pointcloud instruction like you do in #10672 (comment) then the pointcloud generation should be receiving the benefit of CUDA acceleration automatically if you have built from packages.

If you are using Jetson then the distribution_linux.md instructions are not suited for Jetson. Instead, the package installation procedure at the link below should be used to install librealsense on Jetson.

https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_jetson.md#4-install-with-debian-packages

@Shannon-Law
Copy link
Author

Now I run the program in my laptop.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Sep 15, 2022

CUDA support requires an Nvidia GPU and will not work with any other brand of GPU. Jetsons have an Nvidia GPU built into them.

If your laptop does not have an Nvidia GPU then the SDK provides an alternative acceleration system called GLSL which can work with any GPU brand. You can enable GLSL support in your program by changing rs2::pointcloud references to rs2::gl::pointcloud

@Shannon-Law
Copy link
Author

I have an NVIDIA GPU in my laptop.

@MartyG-RealSense
Copy link
Collaborator

Thank you for the confirmation that you have an Nvidia GPU.

Have you confirmed that CUDA acceleration is working on your laptop by trying another type of CUDA acceleration operation supported in the SDK such as depth-color alignment?

@Shannon-Law
Copy link
Author

Shannon-Law commented Sep 15, 2022

No, I have not. I just need to generate point clouds with CUDA.

@MartyG-RealSense
Copy link
Collaborator

The SDK's CUDA acceleration is almost always used with Jetson boards rather than PCs with an Nvidia GPU (built-in or video card). So it is important to determine whether the SDK's CUDA support is working on your Nvidia-equipped laptop.

#9619 is an example of a laptop with an Nvidia GPU that had problems with CUDA. The RealSense user in that case posted the solution for their particular situation at #9619 (comment)

@Shannon-Law
Copy link
Author

When I run the program in my Jetson board, the same problem remains.

@MartyG-RealSense
Copy link
Collaborator

Can you tell me more please about how your pointcloud program works and why you need to change the cuda-pointcloud.cu code.

It sounds as though you want to use deprojection to generate a 3D pointcloud and then get the XYZ values of the pointcloud. You also want to use CUDA to accelerate that pointcloud. Is that correct, please?

Given that your previous case at #10672 also had a problem with zero values from the pointcloud, perhaps this case is a continuation of the same problem?

@Shannon-Law
Copy link
Author

Yes, you are right. I add cuda-pointcloud.cu to my C++ project to generate 3D point clouds in a fast way. In this project, the cu file is the only CUDA source file.

This problem is different from the previous case at #10672, due to the fact that the functions of generating point clouds are different though.

@MartyG-RealSense
Copy link
Collaborator

The only librealsense case that I know of related to cuda-pointcloud.cu and obtaining pointcloud coordinates is #6443 (comment)

@Shannon-Law
Copy link
Author

Shannon-Law commented Sep 18, 2022

When I deleted the statement "set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -gencode arch=compute_60,code=sm_60)" in the file CMakeLists.txt of my program, all the results were normal with using the file "cuda-pointcloud.cu" in my program.

@MartyG-RealSense
Copy link
Collaborator

That's excellent news @Shannon-Law that you achieved a solution. Thanks very much for the update :)

@Shannon-Law
Copy link
Author

@MartyG-RealSense You're welcome!

@MartyG-RealSense
Copy link
Collaborator

Case closed due to solution achieved and no further comments received.

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

2 participants