#include "LvxReader.h"
#include <memory>
#include <tuple>
#include <iostream>
#include <time.h>
#include <assert.h>
#pragma region Global Container
map<DeviceType, string> DeviceTypeNameMap
{
{ kDeviceTypeHub,"LiDAR Hub"},
{ kDeviceTypeLidarMid40,"Mid-40/Mid-100"},
{ kDeviceTypeLidarTele,"Tele-15"},
{ kDeviceTypeLidarHorizon,"Horizon"},
{ kDeviceTypeLidarMid70,"Mid-70"},
{ kDeviceTypeLidarAvia,"Avia"}
};
map<TimestampType, string> TimestampTypeNameMap
{
// ref: https://github.com/Livox-SDK/Livox-SDK/wiki/Livox-SDK-Communication-Protocol
//3.2 Time Stamp {#timestamp}
{ kTimestampTypeNoSync, "No sync signal mode" },
{ kTimestampTypePtp, "1588v2.0 PTP sync mode" },
{ kTimestampTypeRsvd, "Reserved use" },
{ kTimestampTypePpsGps, "pps+gps sync mode" },
{ kTimestampTypePps, "pps only sync mode" },
{ kTimestampTypeUnknown,"Unknown mode" }
};
map< PointDataType, pair<uint16_t, uint32_t> > PointBytesInfoMap
{
{ kCartesian,{ RAW_POINT_NUM, sizeof(LivoxRawPoint) } },
{ kSpherical,{ RAW_POINT_NUM, sizeof(LivoxSpherPoint) } },
{ kExtendCartesian,{ SINGLE_POINT_NUM, sizeof(LivoxExtendRawPoint) } },
{ kExtendSpherical,{ SINGLE_POINT_NUM, sizeof(LivoxExtendSpherPoint) } },
{ kDualExtendCartesian,{ DUAL_POINT_NUM, sizeof(LivoxDualExtendRawPoint) } },
{ kDualExtendSpherical,{ DUAL_POINT_NUM, sizeof(LivoxDualExtendSpherPoint) } },
{ kTripleExtendCartesian,{ TRIPLE_POINT_NUM, sizeof(LivoxTripleExtendRawPoint) } },
{ kTripleExtendSpherical,{ TRIPLE_POINT_NUM, sizeof(LivoxTripleExtendSpherPoint) } },
{ kImu,{ IMU_POINT_NUM, sizeof(LivoxImuPoint) } }
// LivoxPoint, Standard point cloud format
};
map< PointDataType, string > PointTypeNameMap
{
{ kCartesian, "Cartesian coordinate point cloud" },
{ kSpherical, "Spherical coordinate point cloud" },
{ kExtendCartesian, "Extend cartesian coordinate point cloud" },
{ kExtendSpherical, "Extend spherical coordinate point cloud" },
{ kDualExtendCartesian, "Dual extend cartesian coordinate point cloud" },
{ kDualExtendSpherical, "Dual extend spherical coordinate point cloud" },
{ kTripleExtendCartesian, "Triple extend cartesian coordinate point cloud" },
{ kTripleExtendSpherical, "Triple extend spherical coordinate point cloud" },
{ kImu, "IMU data" },
{ kMaxPointDataType, "Max Point Data Type" }
};
#pragma endregion
LvxReader::LvxReader()
: cur_frame_index_(0),
cur_offset_(0),
total_points_num_(0),
frame_duration_(kDefaultFrameDurationTime)
{
}
LvxReader::LvxReader(string filename, LogMode mode)
: cur_frame_index_(0),
cur_offset_(0),
total_points_num_(0),
frame_duration_(kDefaultFrameDurationTime),
file_name_(filename),
logmode_(mode)
{
}
LvxReader::~LvxReader()
{
}
size_t LvxReader::getBinFileSize(string filepath)
{
FILE *fp=fopen(filepath.c_str(),"r");
//printf("getBinFileSize : %s\n", filepath.c_str());
if(!fp) return -1;
fseek(fp,0L,SEEK_END);
int size=ftell(fp);
fclose(fp);
//printf("getBinFileSize : %d\n", size);
return size;
}
bool LvxReader::InitLvxFileReader()
{
if (logmode_ > 0)
{
printf("Initial Lvx File Reader from %s ...\n", file_name_.c_str());
}
file_size_ = getBinFileSize(file_name_);
lvx_file_.open(file_name_, std::ios::in | std::ios::binary);
if (!lvx_file_.is_open()) {
return false;
}
if (logmode_ > 1)
{
printf(" file size: %.3f KB, %.3f MB, %.3f GB.\n",
file_size_ / 1024, file_size_ / (1024*1024), file_size_ / (powl(2, 30)));
}
if (logmode_ > 0)
{
printf("Initial Lvx File Reader from %s Done!\n", file_name_.c_str());
cout << endl;
}
return true;
}
void LvxReader::ReadLvxFileHeader()
{
if (logmode_ > 0)
cout << "Read Lvx File Header..." << endl;
int header_size = sizeof(LvxFilePublicHeader) + sizeof(LvxFilePrivateHeader);
std::unique_ptr<char[]> read_buffer(new char[READ_BUFFER_LEN]);
lvx_file_.read((char*)read_buffer.get(), header_size);
memcpy(&lvx_file_public_header_, read_buffer.get() + cur_offset_, sizeof(LvxFilePublicHeader));
cur_offset_ += sizeof(LvxFilePublicHeader);
if (logmode_ > 2)
{
printf(" File Signature: %s\n", lvx_file_public_header_.signature);
printf(" Version-A: %d\n", lvx_file_public_header_.version[0]);
printf(" Version-B: %d\n", lvx_file_public_header_.version[1]);
printf(" Version-C: %d\n", lvx_file_public_header_.version[2]);
printf(" Version-D: %d\n", lvx_file_public_header_.version[3]);
printf(" Magic Code: %x\n", lvx_file_public_header_.magic_code);
}
//assert(MAGIC_CODE == lvx_file_public_header_.magic_code);
memcpy(&lvx_file_private_header_, read_buffer.get() + cur_offset_, sizeof(LvxFilePrivateHeader));
cur_offset_ += sizeof(LvxFilePrivateHeader);
if (logmode_ > 1)
{
printf(" Per Frame Duration: %dms\n", lvx_file_private_header_.frame_duration);
printf(" Device Count: %d\n", lvx_file_private_header_.device_count);
}
int device_num = lvx_file_private_header_.device_count;
device_info_vec_.resize(device_num);
int device_info_size = device_num * sizeof(LvxDeviceInfo);
lvx_file_.read((char*)read_buffer.get() + cur_offset_, device_info_size);
if (logmode_ > 1)
{
printf(" LiDAR SN Code, Hub SN Code, Device Index, Device Type, Extrinsic Enable, Roll, Pitch, Yaw, X, Y, Z \n");
}
for (int i = 0; i < device_num; ++i)
{
memcpy(&device_info_vec_[i], read_buffer.get() + cur_offset_, sizeof(LvxDeviceInfo));
cur_offset_ += sizeof(LvxDeviceInfo);
if (logmode_ > 1)
{
// extrinsic is read from the lvx file
printf(" %s, %s, %d, %s, %s, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f \n",
device_info_vec_[i].lidar_broadcast_code,
device_info_vec_[i].hub_broadcast_code,
device_info_vec_[i].device_index,
DeviceTypeNameMap[DeviceType(device_info_vec_[i].device_type)].c_str(),
device_info_vec_[i].extrinsic_enable ? "Yes" : "No",
device_info_vec_[i].roll,
device_info_vec_[i].pitch,
device_info_vec_[i].yaw,
device_info_vec_[i].x,
device_info_vec_[i].y,
device_info_vec_[i].z
);
}
}
if (logmode_ > 0)
{
cout << "Read Lvx File Header Done!" << endl;
cout << endl;
}
}
void LvxReader::ReadFramesFromLvxFile()
{
if (logmode_ > 0)
printf("Read Frames From Lvx File %s...\n", file_name_.c_str());
while (cur_offset_ < file_size_)
{
// read �� memcpy ͬ�����֣����������
uint64_t cur_frame_offset = 0;
Frame cur_frame = { 0 };
std::unique_ptr<char[]> read_buffer(new char[READ_BUFFER_LEN]);
lvx_file_.read((char*)read_buffer.get(), sizeof(FrameHeader));
memcpy(&cur_frame.header, read_buffer.get(), sizeof(FrameHeader));
cur_frame_offset += sizeof(FrameHeader);
assert(cur_offset_ == cur_frame.current_offset);
// read each package from package 0 - package N
while (cur_offset_ + cur_frame_offset < cur_frame.next_offset)
{
LvxBasePackDetail_parse cur_pack;
lvx_file_.read((char*)read_buffer.get() + cur_frame_offset, sizeof(LvxBasePackHeader));
memcpy(&cur_pack.header, read_buffer.get() + cur_frame_offset, sizeof(LvxBasePackHeader));
cur_frame_offset += sizeof(LvxBasePackHeader);
int data_type = cur_pack.data_type;
uint32_t points_byte_size = 0;
/*switch (data_type)
{
case PointDataType::kCartesian:
points_byte_size = RAW_POINT_NUM * sizeof(LivoxRawPoint);
total_points_num_ += RAW_POINT_NUM;
break;
case PointDataType::kSpherical:
points_byte_size = RAW_POINT_NUM * sizeof(LivoxSpherPoint);
total_points_num_ += RAW_POINT_NUM;
break;
case PointDataType::kExtendCartesian:
points_byte_size = SINGLE_POINT_NUM * sizeof(LivoxExtendRawPoint);
total_points_num_ += SINGLE_POINT_NUM;
break;
case PointDataType::kExtendSphe
没有合适的资源?快使用搜索试试~ 我知道了~
livox-SDK lvx格式转pcd、las、txt
5星 · 超过95%的资源 需积分: 0 62 下载量 145 浏览量
2023-06-07
17:36:52
上传
评论 2
收藏 12.05MB GZ 举报
温馨提示
共394个文件
h:278个
hpp:72个
cpp:4个
livox-SDK lvx格式转pcd、las、txt
资源推荐
资源详情
资源评论
收起资源包目录
livox-SDK lvx格式转pcd、las、txt (394个子文件)
liblas.a 3.97MB
Cholesky 1KB
CholmodSupport 2KB
Core 18KB
LvxReader.cpp 15KB
LvxTransformer.cpp 13KB
las_write.cpp 8KB
main.cpp 737B
Dense 122B
Eigen 35B
Eigenvalues 2KB
Geometry 2KB
lapacke.h 1.01MB
GeneralBlockPanelKernel.h 80KB
Eigen_Colamd.h 61KB
CoreEvaluators.h 61KB
Transform.h 59KB
SparseMatrix.h 51KB
ProductEvaluators.h 50KB
PacketMath.h 50KB
BDCSVD.h 49KB
livox_sdk.h 46KB
PlainObjectBase.h 44KB
MathFunctions.h 40KB
Memory.h 40KB
Macros.h 37KB
AssignEvaluator.h 37KB
PacketMath.h 37KB
BlockMethods.h 37KB
TriangularMatrix.h 36KB
PacketMath.h 35KB
PacketMathHalf.h 35KB
XprHelper.h 34KB
SuperLUSupport.h 34KB
SelfAdjointEigenSolver.h 33KB
JacobiSVD.h 32KB
FullPivLU.h 32KB
Quaternion.h 32KB
PacketMath.h 32KB
CwiseNullaryOp.h 31KB
blas.h 30KB
VectorwiseOp.h 29KB
PacketMath.h 28KB
SparseQR.h 28KB
UnaryFunctors.h 27KB
SparseLU.h 27KB
PacketMath.h 27KB
DenseBase.h 27KB
GeneralMatrixVector.h 26KB
SparseCwiseBinaryOp.h 25KB
SparseSelfAdjointView.h 25KB
SparseBlock.h 25KB
FullPivHouseholderQR.h 25KB
ColPivHouseholderQR.h 24KB
LDLT.h 24KB
Half.h 24KB
DenseCoeffsBase.h 24KB
SimplicialCholesky.h 23KB
RealQZ.h 23KB
MatrixBase.h 23KB
EigenSolver.h 22KB
Tridiagonalization.h 22KB
CholmodSupport.h 22KB
PaStiXSupport.h 22KB
DenseStorage.h 22KB
GenericPacketMath.h 22KB
Constants.h 21KB
PartialPivLU.h 21KB
Meta.h 21KB
GeneralProduct.h 21KB
TriangularMatrixMatrix.h 20KB
CompleteOrthogonalDecomposition.h 20KB
RealSchur.h 20KB
PermutationMatrix.h 20KB
HouseholderSequence.h 20KB
Homogeneous.h 20KB
SelfadjointMatrixMatrix.h 20KB
PardisoSupport.h 20KB
Complex.h 19KB
BlasUtil.h 19KB
Matrix.h 19KB
MathFunctions.h 18KB
GeneralMatrixMatrix.h 18KB
LLT.h 18KB
BinaryFunctors.h 18KB
Block.h 18KB
Complex.h 18KB
SparseMatrixBase.h 18KB
Redux.h 17KB
MathFunctions.h 17KB
Complex.h 17KB
ComplexSchur.h 17KB
UmfPackSupport.h 17KB
GeneralizedEigenSolver.h 17KB
ArrayCwiseUnaryOps.h 17KB
Complex.h 16KB
Amd.h 16KB
UpperBidiagonalization.h 16KB
Jacobi.h 16KB
GeneralMatrixMatrixTriangular.h 16KB
共 394 条
- 1
- 2
- 3
- 4
资源评论
- shuiniao_2023-10-27这个下载哇 livoxviewer直接有了么,刚发现应用上可以直接转,是自带的还是因为我下了这个啊
W*.
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功