Fuse image information to lidar point cloud
The function crops the fused point cloud,
ptCloudOut, so that it
contains only the points present in the field of view of the camera.
returns a fused point cloud of the same size as the input point cloud. The function uses the
ptCloudOut = fuseCameraToLidar(___,
nonoverlapcolor for points that are outside the field
of view of the camera in addition to any combination of input arguments from previous
returns linear indices of the points in the fused point cloud that are in the field of view
of the camera in addition to any combination of arguments from previous syntaxes.
indices] = fuseCameraToLidar(___)
Load a MAT-file containing ground truth data into the workspace. Extract the image and point cloud from data.
dataPath = fullfile(toolboxdir('lidar'),'lidardata','lcc','sampleColoredPtCloud.mat'); gt = load(dataPath); im = gt.im; ptCloud = gt.ptCloud;
Plot the extracted point cloud.
pcshow(ptCloud) title('Original Point Cloud')
Extract the lidar to camera transformation matrix and camera intrinsic parameters from the ground truth data.
intrinsics = gt.camParams; camToLidar = gt.tform;
Fuse the image to the point cloud.
ptCloudOut = fuseCameraToLidar(im,ptCloud,intrinsics,camToLidar);
Visualize the fused point cloud.
pcshow(ptCloudOut) title('Colored Point Cloud')
I— Color or grayscale image
Color or grayscale image, specified as an H-by-W-by-C array.
H — This specifies the height of the image.
W — This specifies the width of the image.
C — This specifies the number of color channels in the image. The function supports up to three color channels in an image.
intrinsics— Camera intrinsic parameters
Camera intrinsic parameters, specified as a
tform— Camera to lidar rigid transformation
Camera to lidar rigid transformation, specified as a
nonoverlapcolor— Color specification for points outside camera field of view
Color specification for points outside the camera field of view, specified as a color name, short color name, or RGB triplet.
custom color, specify an RGB triplet. An RGB triplet is a three-element row vector whose
elements specify the intensities of the red, green, and blue components of the color. The
intensities must be in the range
[0,1]; for example,
0.7]. Alternatively, you can specify some common colors by name. This table lists
the named color options and the equivalent RGB triplet values.
|Color Name||Color Short Name||RGB Triplet||Appearance|
ptCloudOut— Fused point cloud
Fused point cloud, returned as a
colormap— Point cloud color map
0, 1] | M-by-N-by-3 array of real values in the range [
Point cloud color map, returned as one of these options:
M-by-3 matrix — For unorganized point clouds
M-by-N-by-3 array — For organized point clouds
Each row of the matrix or channel of the array contains the RGB triplet
for the corresponding point in the point cloud. The function returns them as real values
in the range [
0, 1]. If you do not specify a
nonoverlapcolor argument, then the color value for points outside
the field of view of the camera is
[0 0 0] (black).
indices— Linear indices of fused point cloud points in camera field of view
Linear indices of the fused point cloud points in the camera field of view, returned as a vector of positive integers.