0%

流编辑器 Sed

sed 是一种流编辑器,它是文本处理中非常重要的工具,能够完美的配合正则表达式使用,功能不同凡响。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用 sed 命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有 改变,除非你使用重定向存储输出。Sed 主要用来自动编辑一个或多个文件;简化对文件的反复操作;编写转换程序等。

阅读全文 »

PCL 中有两种表示点云的数据结构,分别为 PointCloud<PointT>PCLPointCloud2。官方注释中常称为 a pcl::PointCloud<T> object 以及 a PCLPointCloud2 binary data blob

两者的最大区别是储存数据的方式

  • PointCloud<PointT> 为模板类,其中指定了每个点的数据类型 PointT独立储存每个点的数据。这种存储方式使得数据非常清晰,可以很方便地对某一个点或是某个点的某一字段进行访问,但无法选择存储或删除某一字段。

    1
    2
    3
    4
    5
    6
    template <typename PointT>
    class PointCloud {
    public:
    std::vector<PointT, Eigen::aligned_allocator<PointT>> points;
    ...
    };
  • PCLPointCloud2 则没有指定点的数据类型,而是在 fields 里记录每个点中有哪些字段(比如 rgba , x , normal_x 等),并以 std::uint8_t 将它们按顺序连续存储。这种存储方式理论上更通用,能够存储各种类型的点云数据,而不仅是 PCL中定义好的常见格式;可以灵活地对数据进行直接处理,选择存储或删除某一字段;当然也使得数据变得不太直观。

    1
    2
    3
    4
    5
    6
    struct PCLPointCloud2{
    std::vector<::pcl::PCLPointField> fields;
    uindex_t point_step = 0;
    std::vector<std::uint8_t> data;
    ...
    };
阅读全文 »

在调用 StatisticalOutlierRemoval 时遇到 double free or corruption

我在 PCL 源代码中加入了一些log,具体如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2: [INFO]1712543988.313661216: filter - CropBox
2: --- FilterIndices h - filter indices - start ---
2: --- PCLBase - initCompute - indices size:1228800 ---
2: --- FilterIndices h - call applyFilter(indices)
2: ----- CropBox hpp - applyFilter indices - start -------
2: ----- CropBox hpp - applyFilter indices - finish -------
2: --- FilterIndices h - call deinitCompute()
2: --- PCLBase hpp - deinitCompute ---
2: --- FilterIndices h - filter indices - finish ---

2: [INFO]1712543988.372619178: filter - StatisticalOutlierRemoval
2: --- FilterIndices h - filter indices - start ---
2: --- PCLBase - initCompute - indices size:2568 ---
2: --- FilterIndices h - call applyFilter(indices)
2: --- StatisticalOutlierRemoval h - applyFilter indices ---
2: ----- StatisticalOutlierRemoval hpp - applyFilterIndices - start -------
2: ----- StatisticalOutlierRemoval hpp - applyFilterIndices - finish -------
2: --- FilterIndices h - call deinitCompute()
2: double free or corruption (out)
阅读全文 »

查看两个目录的结构

1
$ tree test_a/ test_b/
1
2
3
4
5
test_a/
└── test.txt
test_b/
├── test_b.txt
└── test.txt

使用 diff 逐行比较

1
$ diff -aur test_a/ test_b/
1
2
3
4
5
6
7
Only in test_b/: test_b.txt
diff -aur test_a/test.txt test_b/test.txt
--- test_a/test.txt 2024-04-01 19:29:35.024777745 +0800
+++ test_b/test.txt 2024-04-01 19:36:22.759553212 +0800
@@ -1 +1 @@
-test_a
+test_b
阅读全文 »

使用 pcl-tools 1.12.1 显示点云后出现 segmentation fault

image-1

使用 libpcl-dev-1.12.1 显示点云后显示一大串关于 vtk 的警告且最后出现 sgmentation fault

1
2
3
2024-03-27 07:06:36.626 (   1.903s) [        1B11AC80]vtkOpenGLPolyDataMapper:328   WARN| vtkOpenGLPolyDataMapper::SetGeometryShaderCode was deprecated for VTK 9.0 and will be removed in a future version.  Use vtkOpenGLShaderProperty::SetGeometryShaderCode instead.
2024-03-27 07:06:36.626 ( 1.903s) [ 1B11AC80]vtkOpenGLPolyDataMapper:321 WARN| vtkOpenGLPolyDataMapper::GetFragmentShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::GetFragmentShaderCode instead.
2024-03-27 07:06:36.626 ( 1.903s) [ 1B11AC80]vtkOpenGLPolyDataMapper:313 WARN| vtkOpenGLPolyDataMapper::SetFragmentShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::SetFragmentShaderCode instead.
阅读全文 »

安装 Git

1
2
3
sudo apt install git
git config --global user.name "Your Name"
git config --global user.email "youremail@domain.com"

配置防火墙

1
2
3
4
5
sudo apt install ufw
sudo ufw allow "OpenSSH"
sudo ufw enable
sudo ufw allow http
sudo ufw allow https
阅读全文 »

点云的表示方式

pcl里的点云多种表示方式:

1
2
3
4
5
6
7
8
9
10
11
12
// const
ConstCloudIterator<PointT> cloud_iterator;

pcl::PointCloud<PointT> cloud;

// with indices
pcl::PointCloud<PointT> cloud;
std::vector<int> indices;

// with indices
pcl::PointCloud<PointT> cloud;
pcl::PointIndices indices;
阅读全文 »

低通滤波: 通常使用来去噪

常见滤波类型

均值滤波

math-4

高斯滤波 (权重与距离相关)

math-5

中值滤波

顾名思义取中值

具体代码例子

高斯的模糊/去噪效果
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Read in the image
image = cv2.imread('images/brain_MR.jpg')

# Convert to grayscale for filtering
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Create a Gaussian blurred image
gray_blur = cv2.GaussianBlur(gray, (9, 9), 0)

# use custom kernal
# gaussian = (1/16)*np.array([[1, 2, 1],
# [2, 4, 2],
# [1, 2, 1]])
#
# gray_blur = cv2.filter2D(gray, -1, gaussian)

f, (ax1, ax2) = plt.subplots(1, 2, figsize=(20,10))
ax1.set_title('original gray'),ax1.imshow(gray, cmap='gray')
ax2.set_title('blurred image'),ax2.imshow(gray_blur, cmap='gray')
阅读全文 »