69 const Eigen::Affine3d& pose,
71 if (local_cloud ==
nullptr) {
75 world_cloud->reserve(local_cloud->size());
76 for (
size_t i = 0; i < local_cloud->size(); ++i) {
77 auto& pt = local_cloud->at(i);
78 Eigen::Vector3d trans_point(pt.x, pt.y, pt.z);
79 trans_point = pose * trans_point;
81 world_point.
x = trans_point(0);
82 world_point.
y = trans_point(1);
83 world_point.
z = trans_point(2);
85 world_cloud->push_back(world_point, local_cloud->points_timestamp(i),
86 std::numeric_limits<float>::max(),
87 local_cloud->points_beam_id()[i], 0);
93 std::string pcd_folder = FLAGS_pcd_path;
94 std::vector<std::string> pcd_file_names;
96 AERROR <<
"pcd_folder: " << pcd_folder <<
" get file list error.";
100 std::sort(pcd_file_names.begin(), pcd_file_names.end(),
101 [](
const std::string& lhs,
const std::string& rhs) {
102 if (lhs.length() != rhs.length()) {
103 return lhs.length() < rhs.length();
108 for (
size_t i = 0; i < pcd_file_names.size(); ++i) {
109 AINFO <<
"***************** Frame " << i <<
" ******************";
110 AINFO << pcd_file_names[i];
113 if (frame->cloud ==
nullptr) {
114 frame->cloud = base::PointFCloudPool::Instance().Get();
116 if (frame->world_cloud ==
nullptr) {
117 frame->world_cloud = base::PointDCloudPool::Instance().Get();
119 LoadPCLPCD(pcd_file_names[i], frame->cloud.get());
121 TransformCloud(frame->cloud, frame->lidar2world_pose, frame->world_cloud);
122 AINFO <<
"Read point cloud from " << pcd_file_names[i]
123 <<
" with cloud size: " << frame->cloud->size();
125 LidarDetectorOptions detection_options;
126 if (!
detector_->Detect(detection_options, frame.get())) {
127 AERROR <<
"Lidar detector detect error!";
131 ObjectBuilderOptions builder_options;
132 if (!
builder_->Build(builder_options, frame.get())) {
133 AERROR <<
"Lidar detector, object builder error.";
137 std::string output_path = FLAGS_output_path;
145 const std::string& path) {
147 AERROR <<
"Failed to create: " << path;
151 fout.open(absl::StrCat(path,
"/", frame_id,
".txt"));
155 fout <<
"velodyne_64"
156 <<
" " <<
object->id <<
" " <<
object->track_id <<
" "
157 <<
object->lidar_supplement.is_background <<
" "
158 << std::setprecision(8) <<
object->confidence <<
" ";
160 std::string type =
"unknow";
173 double yaw = atan2(object->direction(1), object->direction(0));
174 auto& object_cloud =
object->lidar_supplement.cloud;
176 fout << type <<
" " <<
object->center(0) <<
" " <<
object->center(1)
177 <<
" " <<
object->center(2) <<
" " <<
object->size(0) <<
" "
178 <<
object->size(1) <<
" " <<
object->size(2) <<
" "
179 << yaw <<
" " << 0 <<
" " << 0 <<
" "
180 << 0 <<
" " << 0 <<
" "
181 <<
object->velocity(0) <<
" " <<
object->velocity(1) <<
" "
182 <<
object->velocity(2) <<
" ";
183 fout << object_cloud.size() <<
" ";
184 for (
size_t i = 0; i < object_cloud.size(); ++i) {
185 auto& pt = object_cloud.at(i);
186 fout << std::setprecision(8) << pt.x <<
" " << pt.y <<
" " << pt.z
187 <<
" " << pt.intensity <<
" ";
191 int polygon_size = -
static_cast<int>(
object->polygon.size());
192 fout << polygon_size <<
" ";
193 for (
size_t i = 0; i <
object->polygon.size(); ++i) {
194 const auto& pt =
object->polygon[i];
195 fout << std::setprecision(8) << pt.x <<
" " << pt.y <<
" " << pt.z