www.gusucode.com > vision 源码程序 matlab案例代码 > vision/DetectSphereInPointCloudExample.m
%% Detect Sphere in Point Cloud % %% % Load point cloud. % Copyright 2015 The MathWorks, Inc. load('object3d.mat'); %% % Display point cloud. figure pcshow(ptCloud) xlabel('X(m)') ylabel('Y(m)') zlabel('Z(m)') title('Detect a sphere in a point cloud') %% % Set the maximum point-to-sphere distance (1cm), for sphere fitting. maxDistance = 0.01; %% % Set the region of interest to constrain the search. roi = [-inf, 0.5; 0.2, 0.4; 0.1, inf]; sampleIndices = findPointsInROI(ptCloud, roi); %% % Detect the globe in the point cloud and extract it. model = pcfitsphere(ptCloud, maxDistance, 'SampleIndices', sampleIndices); %% % Plot the sphere. hold on plot(model)