Main Content

readFrame

Read Hesai point cloud from file

Since R2022a

Description

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

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

example

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

example

ptCloud = readFrame(___,ReadMode=readMode) reads the points that belong to the specified return mode readMode.

Examples

collapse all

Download a ZIP file containing a Hesai packet capture (PCAP) file and then unzip the file.

zipFile = matlab.internal.examples.downloadSupportFile("lidar","data/hesai_BusyRoad.zip");
saveFolder = fileparts(zipFile);
pcapFileName = [saveFolder filesep 'hesai_BusyRoad.pcap'];
if ~exist(pcapFileName,"file")
    unzip(zipFile,saveFolder);
end

Create a hesaiFileReader object.

hesaiReader = hesaiFileReader(pcapFileName,"Pandar128E3X");

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

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

Display the point cloud.

pcshow(ptCloud(1))

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

Download a ZIP file containing a Hesai packet capture (PCAP) file and then unzip the file.

zipFile = matlab.internal.examples.downloadSupportFile("lidar","data/hesai_BusyRoad.zip");
saveFolder = fileparts(zipFile);
pcapFileName = [saveFolder filesep 'hesai_BusyRoad.pcap'];
if ~exist(pcapFileName,"file")
    unzip(zipFile,saveFolder);
end

Create a hesaiFileReader object.

hesaiReader = hesaiFileReader(pcapFileName,"Pandar128E3X");

Read the first Hesai PCAP point cloud frame from 3 seconds after the StartTime.

frameTime = hesaiReader.StartTime + seconds(3);
ptCloud = readFrame(hesaiReader,frameTime);

Display the point cloud.

pcshow(ptCloud(1))

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

Input Arguments

collapse all

Hesai file reader, specified as a hesaiFileReader 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.

Mode for reading data from the Hesai PCAP file, specified as a character vector, cell array of character vectors, string scalar, or a string array. This value must be a subset of the ReturnMode property of the hesaiFileReader object.

If you specify this argument as a cell array of character vectors or string array, then this function returns a point cloud array containing point clouds that belong to the specified modes in the same order.

Example: ReadMode="hesaiReader.ReturnMode" specifies the return mode to read point cloud data.

Output Arguments

collapse all

Point cloud, returned as a pointCloud object or array of pointCloud objects. The function returns an array of pointCloud objects only when you specify readMode as a cell array of character vectors or string array. The order of the pointCloud objects in the array corresponds to the order of the specified read modes in the readMode argument.

Version History

Introduced in R2022a