[pcl::VoxelGrid::applyFilter] Leaf size is too small for the input dataset. Integer indices would ov
1. 报错日志:
Python-pcl 点云下采样时报错如下:
[pcl::VoxelGrid::applyFilter] Leaf size is too small for the input dataset. Integer indices would overflow.[pcl::VoxelGrid::applyFilter] Leaf size is too small for the input dataset. Integer indices would overflow
首先得了解下采样/抽稀的原理:
点云VoxelGridFilter,称为体素格下采样,也叫抽稀。下采样是一种能显著减少点云的数据量,并保持其形状特征和空间结构信息与原始点云基本没差别的算法。
其核心是: 将点云分割成一个个微小的立方体,落在立方体内的所有点用一个重心点来最终表示,对所有的小立方体处理后得到最终的点云结果。
- 取重心点比所有点取平均值的算法稍慢,但是其结果更准确;
下采样设置的voxelGridFilter.set_leaf_size(rate,rate,rate) 值越大,最后保留的点云越少。
2. 报错原因:
虽然用的是python-pcl的api调用下采样算法,实质上调用的仍然是C++的VoxelGridFilter算法。划分的立方体格子的个数index是int32位,由于输入的点云的x,y,z跨度太大,导致划分的立方体个数超出了int32的最大大小,因此报错。
故需要对原始点云进行一点小小的操作。
3. 解决:
- 下采样前输入点云数据的 x,y,z分别减去各自的偏移量;下采样结果返回之后再分别加上其偏移量;
- 对点云进行分组处理,比如每100万点进行一次下采样,之后结果合并;
完美解决;
import pcl
import math
import time
from laspy.file import File
import numpy as np# 初始文件路径 输出文件路径 抽稀参数(单位m)
def cx(filePath, outputPath, rate):end1 = time.time()f = File(filePath, mode='r')total = len(f.points)print('points: ', total)# 获取偏移量offset = f.header.offsetx0 = offset[0]y0 = offset[1]z0 = offset[2]inFile = np.vstack((f.x - x0, f.y - y0, f.z - z0, f.intensity)).transpose()sp = math.ceil(len(inFile) / 1000000)cloud = pcl.PointCloud_PointXYZI()m2 = []for i in range(0, sp):end = (i + 1) * 1000000start = i * 1000000clPoints = inFile[start:end]cloud.from_array(np.array(clPoints, dtype=np.float32))# 抽稀sor = cloud.make_voxel_grid_filter()sor.set_leaf_size(rate, rate, rate)cloud_filtered = sor.filter()for i in range(0, cloud_filtered.size):m2.append((cloud_filtered[i][0] + x0, cloud_filtered[i][1] + y0, cloud_filtered[i][2] + z0, cloud_filtered[i][3]))x = [k[0] for k in m2]y = [k[1] for k in m2]z = [k[2] for k in m2]c = [k[3] for k in m2]print('【outputPath】', outputPath)cxlen = len(x)outFile = File(outputPath, mode='w', header=f.header)outFile.x = np.array(x)outFile.y = np.array(y)outFile.z = np.array(z)outFile.intensity = np.array(c)outFile.header.set_pointrecordscount(cxlen)outFile.close()print('cx ' + str(rate) + ' success...')print('total: ', total, 'cx: ', cxlen)print('percent: {:.2%}'.format(cxlen / total))end2 = time.time()print("cx 耗时:%.2f秒" % (end2 - end1))return cxlendef main():cx('D:/project/las/1001140020191217.las','D:/project/las/1001140020191217_cx.las', 0.03)if __name__ == "__main__":main()
[pcl::VoxelGrid::applyFilter] Leaf size is too small for the input dataset. Integer indices would ov相关推荐
- PCL voxelgrid实现
体素滤波器可以达到向下采样同时不破坏点云本身几何结构的功能,但是会移动点的位置. 此外体素滤波器可以去除一定程度的噪音点及离群点.主要功能是用来进行降采样. (1)它的原理是根据输入的点云,首先计算一 ...
- pcl——VoxelGrid滤波器
点云入门第六章--入门使用VoxelGrid滤波器对点云进行下采样: 原理: pcl的VoxelGrid在输入点云数据上创建一个3D 体素网格(将体素网格视为空间中的一组微小的 空间三维立方体的集合) ...
- RuntimeError: Given groups=1, weight of size [1, 1, 3, 3], expected input[1, 3, 1402, 1200] to have
RuntimeError: Given groups=1, weight of size [1, 1, 3, 3], expected input[1, 3, 1402, 1200] to have ...
- Pytorch RuntimeERROR: Given groups=1 weights of size [256,64,1,1] expected input[1,16,256,256] to
错误 Pytorch RuntimeERROR: Given groups=1 weights of size [256,64,1,1] expected input[1,16,256,256] to ...
- 在跑SC-LEGO-LOAM时报错[pcl::KdTreeFLANN::setInputCloud] Cannot create a KDTree with an empty input cloude
错误类型: [pcl::KdTreeFLANN::setInputCloud] Cannot create a KDTree with an empty input cloud! SC-LEGO-LO ...
- (36)RuntimeError: Given groups=4, weight of size [4, 1, 11, 11], expected input xxxxxxxxx
问题描述: 在测试AODNet去雾网络时,计算测试集的指标ssim和psnr,从test_loader中读取测试集的清晰图像和去雾之后的图像,作为ssim的输入进行计算,原文代码如下: for ite ...
- RuntimeError: Given groups=1, weight of size [14, 464, 1, 1], expected input问题解决
BUG解决:RuntimeError: Given groups=1, weight of size [14, 464, 1, 1], expected input[16, 116, 56, 1] t ...
- 使用Python爬取CSDN历史博客文章列表,并生成目录
使用Python爬取CSDN历史博客文章列表,并生成目录 这篇博客将介绍如何使用Python爬取CSDN历史博客文章列表,并生成目录. 2020年 2020年04月 cv2.threshold() 阈 ...
- PCL之体素网格滤波器--VoxelGrid
作用:使用体素化网格方法实现下采样,可在保持点云形状特征的情况下减少点云的数量:在提高配准.曲面重建.形状识别等算法的速度. 原理:PCL实现的VoxelGrid类通过输入的点云数据创建一个三维体素栅 ...
最新文章
- Visual Studio2005无法启动web调试的真正原因
- linux /proc目录文件详解
- Angular学习(7)- 模板2
- Shebang来Java了吗?
- Liunx下使用Nginx负载均衡
- tomcat 启用NIO
- 不同浏览器input file样式不一样
- 95-080-046-源码-启动-flink-daemon.sh
- 发现身边90%的朋友都是负债累累,是什么情况?
- labimage 怎样旋转图片_西安匠艺工坊丨别克gl8内饰改装床车图片,精湛工艺,空间力量...
- 计算机组成原理(第三版)唐朔飞-课后习题(完整版)
- 微信公众号网页开发,登录授权和微信支付
- 2019 Java 全栈工程师进阶路线图,一定要收藏!
- 设计模式学习 — 代理模式
- AD20的一些基本操作
- 什么样的企业可以称之为初创企业?
- LeetCode LCP 19 秋叶收藏集 HERODING的LeetCode之路
- Wireshark的作用
- 计算机网络基础知识点三
- DevExpress控件汉化类 z
热门文章
- 2021年大数据ELK(九):使用VSCode测试分词器
- FastAdmin扩展PHPEXCEL,PHP7.3高版本兼容问题
- Django Response对象3.4
- [JavaScript] Set类型在JavaScript中的使用
- java.lang.IllegalArgumentException: columnNames.length = 3, columnValues.length = 4
- Android SharedPreferences 的使用
- CF525D Arthur and Walls
- 开源组件websocket-sharp中基于webapi的httpserver使用体验
- unity3d-----Collider 组件参考
- 170222、使用Spring Session和Redis解决分布式Session跨域共享问题