Clear Filters
Clear Filters

pcregistericp using GPU Support

7 views (last 30 days)
Reza
Reza on 18 Apr 2024
Commented: Steven Lord on 18 Apr 2024
Has anyone tried using the function pcregistericp (which registers two point clouds using the itterative closest point method) on a GPU via Cuda?
The help for the function clearly says it does support
GPU Code Generation
(Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.)
But my attempt fails. Here's the code in which I create the point cloud from a gpuArray set of points:
clc; clearvars;
load pcSet.mat % some point clouds here
%% First Pointcloud
pc1 = pointCloud(gpuArray(PC{1}.Location));
% create point clouds with gpuArray locations
%% Crfeating the second pointcloud with a small transformation
rot = eye(3); trans = [-3, 1, 2];
T = [rot;trans]; T = ([T, [0; 0; 0; 1]]); tf = rigid3d(T);
pc2 = pctransform(pc1, tf);
pcshowpair(pc1, pc2); % Two close point clouds can be seen here
%% ICP
[tform, pcm] = pcregistericp(pc2, pc1); % ERROR here
The error says:
Error using images.geotrans.internal.rigidtform3dImpl (line 62)
Translation must be a real, double or single vector with three elements.
Error in rigidtform3d (line 8)
self = self@images.geotrans.internal.rigidtform3dImpl(varargin{:});
Error in vision.internal.pc.parseICPInputs (line 26)
initTform = rigidtform3d([0 0 0], t);
Error in pcregistericp (line 9)
[unorgMoving, unorgFixed, configOptions, doExtrapolate, metric] = vision.internal.pc.parseICPInputs( ...
Error in gputest (line 16)
[pcm, tform] = pcregistericp(pc2, pc1); % ERROR here

Accepted Answer

Steven Lord
Steven Lord on 18 Apr 2024
Note that "GPU Code Generation" and "GPU Arrays" are two different Extended Capabilities. For example, in MATLAB there are 200 functions that support GPU Code Generation and 520 functions that accept GPU Arrays as inputs. All but 6 of the functions supporting GPU Code Generation also support GPU Arrays (bin2dec is one example of a function that supports GPU Code Generation but does not accept GPU Arrays). But there are a number of functions that accept GPU Arrays but are not supported for GPU Code Generation.
What about pcregistericp? It supports GPU Code Generation but does not support GPU Arrays. You can see this from the two lists of functions on this documentation page. According to that documentation page 48 functions support GPU Code Generation but only 12 support GPU Arrays.
If having this particular function support GPU Arrays would be beneficial to your workflow, I recommend contacting Technical Support to ask them to request that the function be enhanced to support this capability. Describing how you would use that support would be useful as it would help Development consider actual use cases when prioritizing this enhancement or determining how it should work.
  2 Comments
Reza
Reza on 18 Apr 2024
Thank you very much for your response. Does this mean I can use gpuCoder to create a gpu code that contains this function? And if doing so, does this function get faster?
Steven Lord
Steven Lord on 18 Apr 2024
With the limitations given in the GPU Code Generation item in the Extended Capabilities section on the pcregistericp function documentation page, I believe the answer to your first question is yes.
I don't know the answer to your second question. I don't know that the answer is always yes or always no. I think it may depend on the size of the data on which you're operating, given the last note in the GPU Code Generation item in the Extended Capabilities section on the pointCloud documentation page: "For very large inputs, the memory requirements of the algorithm may exceed the GPU device limits. In such cases, consider reducing the input size to proceed with code generation."

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with GPU Coder in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!