MCPcopy Create free account
hub / github.com/LimHyungTae/patchwork / cloud

Method cloud

include/tools/pcd_loader.hpp:30–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 size_t size() const { return num_frames_; }
29
30 typename pcl::PointCloud<T>::ConstPtr cloud(size_t i) const {
31 std::string filename = (boost::format("%s/%06d.bin") % pcd_path_ % i).str();
32 FILE *file = fopen(filename.c_str(), "rb");
33 if (!file) {
34 std::cerr << "error: failed to load " << filename << std::endl;
35 return nullptr;
36 }
37
38 std::vector<float> buffer(1000000);
39 size_t num_points =
40 fread(reinterpret_cast<char *>(buffer.data()), sizeof(float), buffer.size(), file) / 4;
41 fclose(file);
42
43 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());
44 cloud->resize(num_points);
45
46 for (int i = 0; i < num_points; i++) {
47 auto &pt = cloud->at(i);
48 pt.x = buffer[i * 4];
49 pt.y = buffer[i * 4 + 1];
50 pt.z = buffer[i * 4 + 2];
51 // pt.intensity = buffer[i * 4 + 3];
52 }
53
54 return cloud;
55 }
56
57 private:
58 int num_frames_;

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected