Skip to content

Commit

Permalink
debug done
Browse files Browse the repository at this point in the history
  • Loading branch information
171930433 committed Mar 20, 2024
1 parent 867b81e commit 64ddb34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 8 additions & 6 deletions src/example/message/zpointcloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ static pcl::io::OctreePointCloudCompression<pcl::PointXYZIT> s_compress;

::zhito::inner_class::ZPointCloudXYZIT StructToClass(zhito::inner_struct::sp_cZPointCloudXYZIT const& in) {
::zhito::inner_class::ZPointCloudXYZIT result;
*result.mutable_header() = StructToClass(*(std::shared_ptr<zhito::inner_struct::ZFrame const>)in);
std::shared_ptr<zhito::inner_struct::ZFrame const> base1 = in;
zhito::inner_struct::ZPointCloudXYZIT::ConstPtr base2 = in;
*result.mutable_header() = StructToClass(*base1);
// 压缩点云
std::stringstream compressed_pcl_pointcloud;
s_compress.encodePointCloud(in, compressed_pcl_pointcloud);
s_compress.encodePointCloud(base2, compressed_pcl_pointcloud);
result.set_pcl_compressed_pc(compressed_pcl_pointcloud.str());
// std::cout <<" compress size = " << compressed_pcl_pointcloud.str().size() <<"\n";
return result;
Expand All @@ -30,13 +32,13 @@ ::zhito::inner_class::ZPointCloudXYZIT StructToClass(zhito::inner_struct::sp_cZP
// ClassToStruct declaration
zhito::inner_struct::spZPointCloudXYZIT ClassToStruct(::zhito::inner_class::ZPointCloudXYZIT const& in) {
::zhito::inner_struct::spZPointCloudXYZIT result = std::make_shared<zhito::inner_struct::ZPointCloudXYZIT>();
*(std::shared_ptr<::zhito::inner_struct::ZFrame>)result = ClassToStruct(in.header());
std::shared_ptr<zhito::inner_struct::ZFrame> base1 = result;
zhito::inner_struct::ZPointCloudXYZIT::Ptr base2 = result;
*base1 = ClassToStruct(in.header());
// 解压点云
std::stringstream compressed_pcl_pointcloud(in.pcl_compressed_pc());
// std::cout <<" compressed_pcl_pointcloud size = " << compressed_pcl_pointcloud.str().size() << "\n";
// decodePointCloud 的参数定义成了智能指针的引用, 所以不能存在转换. 只有是 const T& 和 std::shared_ptr<T>, 可以使用多态,即直接使用子类对象或者子类智能指针
s_compress.decodePointCloud(compressed_pcl_pointcloud, (pcl::PointCloud<pcl::PointXYZIT>::Ptr&)result);
// std::cout <<" compressed_pcl_pointcloud size = " << compressed_pcl_pointcloud.str().size() << " done \n";
s_compress.decodePointCloud(compressed_pcl_pointcloud, base2);

return result;
}
Expand Down
12 changes: 6 additions & 6 deletions src/example/tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ void PointcloudDemo() {
p2.x += (rand() % 10000 * 0.0001);
pc->push_back(p2);
}
// std::cout<< "11111111111\n";
std::cout<< "11111111111\n";
inner_class::ZPointCloudXYZIT pc2 = converter::StructToClass(pc);
// std::cout<< "2222222222222\n";
std::cout<< "2222222222222\n";

inner_struct::spZPointCloudXYZIT pc3 = converter::ClassToStruct(pc2);
// std::cout<< "33333\n";
std::cout<< "33333\n";

// pcl::io::savePCDFileBinaryCompressed("1.pcd", *pc3);

Expand Down Expand Up @@ -58,9 +58,9 @@ void ImageDemo() {
}

int main() {
ImuDemo();
// PointcloudDemo();
ImageDemo();
// ImuDemo();
PointcloudDemo();
// ImageDemo();

std::cout << "Done!!!" << std::endl;

Expand Down

0 comments on commit 64ddb34

Please sign in to comment.