Main Content

readFrame

Read Ouster point cloud from file

Since R2022a

Description

ptCloud = readFrame(ousterReader) reads the next point cloud in sequence from the Ouster® PCAP file and returns a pointCloud object.

ptCloud = readFrame(ousterReader,frameNumber) reads the point cloud with the specified frame number from the file.

example

ptCloud = readFrame(ousterReader,frameTime) reads the first point cloud recorded at or after the given frameTime.

example

[ptCloud,pcAttributes] = readFrame(___) returns a structure, pcAttributes, containing attributes for each point using any combination of input arguments from previous syntaxes.

[___] = readFrame(___,ReadMode=rMode) additionally specifies which the return mode to read from the file.

example

Examples

collapse all

Download a ZIP file containing an Ouster packet capture (PCAP) file and the corresponding calibration file, and then unzip the file.

zipFile = matlab.internal.examples.downloadSupportFile("lidar","data/ouster_RoadIntersection.zip");
saveFolder = fileparts(zipFile);
pcapFileName = [saveFolder filesep 'ouster_RoadIntersection' filesep 'ouster_RoadIntersection.pcap'];
calibFileName = [saveFolder filesep 'ouster_RoadIntersection' filesep 'OS1-128U.json'];
if ~(exist(pcapFileName,"file") && exist(calibFileName,"file"))
    unzip(zipFile,saveFolder);
end

Create an ousterFileReader object.

ousterReader = ousterFileReader(pcapFileName,calibFileName);

Read the fifth frame of the Ouster PCAP point cloud data.

frameNumber = 5;
ptCloud = readFrame(ousterReader,frameNumber);

Display the point cloud.

pcshow(ptCloud)

Figure contains an axes object. The axes object contains an object of type scatter.

Download a ZIP file containing an Ouster packet capture (PCAP) file and the corresponding calibration file, and then unzip the file.

zipFile = matlab.internal.examples.downloadSupportFile("lidar","data/ouster_RoadIntersection.zip");
saveFolder = fileparts(zipFile);
pcapFileName = [saveFolder filesep 'ouster_RoadIntersection' filesep 'ouster_RoadIntersection.pcap'];
calibFileName = [saveFolder filesep 'ouster_RoadIntersection' filesep 'OS1-128U.json'];
if ~(exist(pcapFileName,"file") && exist(calibFileName,"file"))
    unzip(zipFile,saveFolder);
end

Create an ousterFileReader object.

ousterReader = ousterFileReader(pcapFileName,calibFileName);

Read the first Ouster PCAP point cloud frame from 3 seconds after start time.

frameTime = ousterReader.StartTime + seconds(3);
[ptCloud,pcatt] = readFrame(ousterReader,frameTime);

Display the point cloud.

pcshow(ptCloud)

Figure contains an axes object. The axes object contains an object of type scatter.

Download a ZIP file containing an Ouster packet capture (PCAP) file and the corresponding calibration file, and then unzip the file.

zipFile = matlab.internal.examples.downloadSupportFile("lidar","data/ouster_RoadIntersection.zip");
saveFolder = fileparts(zipFile);
pcapFileName = [saveFolder filesep 'ouster_RoadIntersection' filesep 'ouster_RoadIntersection.pcap'];
calibFileName = [saveFolder filesep 'ouster_RoadIntersection' filesep 'OS1-128U.json'];
if ~(exist(pcapFileName,"file") && exist(calibFileName,"file"))
    unzip(zipFile,saveFolder);
end

Create an ousterFileReader object.

ousterReader = ousterFileReader(pcapFileName,calibFileName);

Read the strongest return data from the tenth point cloud.

frameNumber = 10;
ptCloud = readFrame(ousterReader,frameNumber,ReadMode="strongest");

Display the point cloud.

pcshow(ptCloud)

Figure contains an axes object. The axes object contains an object of type scatter.

Input Arguments

collapse all

Ouster file reader, specified as ousterFileReader object.

Frame number of the desired point cloud in the file, specified as a positive integer. Frame numbers are sequential.

Frame time of the desired point cloud in the file, specified as a duration scalar in seconds. The function returns the first frame available at or after the specified frameTime.

Return mode of the data to read from the file, specified as a character vector, string scalar, cell array of character vectors, or string array. The value must be a subset of the ReturnMode property of the ousterFileReader object. By default, the function reads all the return modes stored in the file.

Output Arguments

collapse all

Point cloud, returned as a pointCloud object.

When you specify the rMode value to read multiple return modes, the function returns an array of point clouds in the same order of the specified return modes.

Point cloud attributes for each point, returned as a structure that contains these fields:

  • Range — Distance from the origin, specified as an M-by-N matrix, same as the size of Location property of pointCloud object ptCloud, in meters.

  • SignalPhoton — Signal intensity of photons in the signal return measurement, specified as an M-by-N matrix, same as the size of Location property of pointCloud object ptCloud.

  • NearInfrared — Near infrared (NIR) photons related to natural environmental illumination, specified as an M-by-N matrix, same as the size of Location property of pointCloud object ptCloud.

When you specify the rMode value to read multiple return modes, the function returns the point attributes as an array of structures, in the same order of the specified return modes.

Version History

Introduced in R2022a

expand all