PCL庫學習筆記 連線兩個點雲

2021-08-21 07:34:54 字數 3039 閱讀 9237

本篇將展示如何串聯兩個不同點雲的點。此處強加的約束是兩個資料集中的字段型別和數量必須相等。後面還將展示如何連線兩個不同點雲的字段 (例如, 維度)。此處強加的約束是兩個資料集中的點數必須相等。

#include #include #include int

main (int argc, char** argv)

// 定義三個輸入的點雲

pcl::pointcloudcloud_a, cloud_b, cloud_c;

pcl::pointcloudn_cloud_b;

pcl::pointcloudp_n_cloud_c;

// 填充點雲

cloud_a.width = 5;

cloud_a.height = cloud_b.height = n_cloud_b.height = 1;

cloud_a.points.resize (cloud_a.width * cloud_a.height);

if (strcmp(argv[1], "-p") == 0)

else

for (size_t i = 0; i < cloud_a.points.size (); ++i)

if (strcmp(argv[1], "-p") == 0)

for (size_t i = 0; i < cloud_b.points.size (); ++i)

else

for (size_t i = 0; i < n_cloud_b.points.size (); ++i)

std::cerr << "cloud a: " << std::endl;

for (size_t i = 0; i < cloud_a.points.size (); ++i)

std::cerr << " " << cloud_a.points[i].x << " " << cloud_a.points[i].y << " " << cloud_a.points[i].z << std::endl;

std::cerr << "cloud b: " << std::endl;

if (strcmp(argv[1], "-p") == 0)

for (size_t i = 0; i < cloud_b.points.size (); ++i)

std::cerr << " " << cloud_b.points[i].x << " " << cloud_b.points[i].y << " " << cloud_b.points[i].z << std::endl;

else

for (size_t i = 0; i < n_cloud_b.points.size (); ++i)

std::cerr << " " << n_cloud_b.points[i].normal[0] << " " << n_cloud_b.points[i].normal[1] << " " << n_cloud_b.points[i].normal[2] << std::endl;

// 複製點雲

if (strcmp(argv[1], "-p") == 0)

else

return (0);

}

連線點雲結果:

cloud a:

0.352222 -0.151883 -0.106395

-0.397406 -0.473106 0.292602

-0.731898 0.667105 0.441304

-0.734766 0.854581 -0.0361733

-0.4607 -0.277468 -0.916762

cloud b:

0.183749 0.968809 0.512055

-0.998983 -0.463871 0.691785

0.716053 0.525135 -0.523004

cloud c:

0.352222 -0.151883 -0.106395

-0.397406 -0.473106 0.292602

-0.731898 0.667105 0.441304

-0.734766 0.854581 -0.0361733

-0.4607 -0.277468 -0.916762

0.183749 0.968809 0.512055

-0.998983 -0.463871 0.691785

0.716053 0.525135 -0.523004

連線字段結果:

cloud a:

0.352222 -0.151883 -0.106395

-0.397406 -0.473106 0.292602

-0.731898 0.667105 0.441304

-0.734766 0.854581 -0.0361733

-0.4607 -0.277468 -0.916762

cloud b:

0.183749 0.968809 0.512055

-0.998983 -0.463871 0.691785

0.716053 0.525135 -0.523004

0.439387 0.56706 0.905417

-0.579787 0.898706 -0.504929

cloud c:

0.352222 -0.151883 -0.106395 0.183749 0.968809 0.512055

-0.397406 -0.473106 0.292602 -0.998983 -0.463871 0.691785

-0.731898 0.667105 0.441304 0.716053 0.525135 -0.523004

-0.734766 0.854581 -0.0361733 0.439387 0.56706 0.905417

-0.4607 -0.277468 -0.916762 -0.579787 0.898706 -0.504929

兩種方式體現的在不同方向連線點雲,每一種有自己的約束條件。

點雲學習3 兩個點雲連線

include include include intmain int argc,char ar for size t i 0 i cloud b.points.size i std cerr cloud a std endl for size t i 0 i cloud a.points.size...

PCL 學習筆記 使用 PCL 來顯示點雲

pcl 裡面使用的一些小技巧,可惜我現在才知道。記下來 方便以後檢視吧。當你得到了一些點雲之後怎麼去快速直觀的看到 點雲的效果呢?有一些比較好的小的技巧。1.顯示乙個點雲的方法 pcl viewer cloud cluster 0.pcd 2.多個點雲在一起顯示的方法 pcl viewer mult...

連線兩個點雲的字段或資料形成新點雲

學習如何連線兩個不同點雲為乙個點雲,進行操作前要確保兩個資料集中欄位的型別相同和維度相等,同時了解如何連線兩個不同點雲的字段 例如顏色 法線 這種操作的強制約束條件是兩個資料集中點的數目必須一樣,例如 點雲a是n個點xyz點,點雲b是n個點的rgb點,則連線兩個字段形成點雲c是n個點xyzrgb型別...