145 {
147 AERROR <<
"Failed to create: " << path;
148 return false;
149 }
150 std::ofstream fout;
151 fout.open(absl::StrCat(path, "/", frame_id, ".txt"));
152 fout <<
frame_id <<
" " << frame->segmented_objects.size() << std::endl;
153
154 for (auto& object : frame->segmented_objects) {
155 fout << "velodyne_64"
156 << " " << object->id << " " << object->track_id << " "
157 << object->lidar_supplement.is_background << " "
158 << std::setprecision(8) << object->confidence << " ";
159
160 std::string type = "unknow";
164
166 type = "pedestrian";
168 type = "smallMot";
170 type = "nonMot";
171 }
172
173 double yaw = atan2(object->direction(1), object->direction(0));
174 auto& object_cloud = object->lidar_supplement.cloud;
175
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 << " ";
188 }
189
190
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
196 << " ";
197 }
198 fout << std::endl;
199 }
200
201 fout.close();
202 return true;
203 }
bool EnsureDirectory(const std::string &directory_path)
Check if a specified directory specified by directory_path exists.
std::string frame_id
Point cloud frame id