解决问题:‘const struct pcl::PCLPointCloud2’ has no member named ‘__getMD5Sum’

在发布ROS的点云话题时,出现报错:‘const struct pcl::PCLPointCloud2’ has no member named ‘__getMD5Sum’

环境:Ubuntn20.04 PCL1.12.1(当前最新的)

非常坑的是,PCL1.12.1作者应该对common/include下面的头文件进行了修改,找不到point_trait.h了,这个在上一个版本PCL1.12.0中还存在。
在发布点云消息的时候,你可以借用PCL_ROS库,这个相当于是一个数据接口,会调用point_cloud.h,之后是point_trait.h,上面报错就是因为缺少这个。
另外,我尝试使用sensor::msgs、toROSMsg对数据进行转换,但还是避不开这个问题。

解决方案

1.PCL版本 <= 1.12.0,在你的cpp文件中添加头文件

#include <pcl_ros/point_cloud.h>

2.PCL版本是1.12.1或者之后的,建议降低pcl版本,因为1.12.1中pcl_ros下的point_cloud.h文件会调用pcl/point_trait.h,但是pcl目录下并没有这个文件,应该是作者进行了修改,也不能直接copy过来。我目前还没找到解决方案,欢迎大佬评论区指导。

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
对不起,我之前提供的代码中有一处错误。在libjpeg库中,`struct jpeg_compress_struct`确实没有名为`image_quality`的成员。正确的代码应该是使用`struct jpeg_compress_struct`的`jpeg_set_quality`函数来设置图像的压缩质量。请使用以下修正后的代码: ```c void compress_image(const char* input_image, const char* output_image, int quality) { struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; FILE* infile, *outfile; JSAMPROW row_pointer[1]; int row_stride; if ((infile = fopen(input_image, "rb")) == NULL) { fprintf(stderr, "Can't open %s\n", input_image); return; } if ((outfile = fopen(output_image, "wb")) == NULL) { fprintf(stderr, "Can't create %s\n", output_image); fclose(infile); return; } cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); jpeg_stdio_dest(&cinfo, outfile); jpeg_read_header(&cinfo, TRUE); jpeg_set_quality(&cinfo, quality, TRUE); // 设置压缩质量 jpeg_start_compress(&cinfo, TRUE); row_stride = cinfo.image_width * cinfo.input_components; unsigned char* buffer = (unsigned char*)malloc(row_stride); while (cinfo.next_scanline < cinfo.image_height) { row_pointer[0] = &buffer[cinfo.next_scanline * row_stride]; jpeg_write_scanlines(&cinfo, row_pointer, 1); } free(buffer); jpeg_finish_compress(&cinfo); fclose(outfile); jpeg_destroy_compress(&cinfo); fclose(infile); } ``` 在修正后的代码中,我使用了`jpeg_set_quality`函数来设置压缩质量。你可以传递一个介于0和100之间的整数值作为`quality`参数,其中0表示最低质量,100表示最高质量。 非常抱歉给你带来困扰,希望这次修正后的代码能够帮助到你。如果还有其他问题,请随时提问。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值