三维重建10:点云配准和点云匹配
?? ? ??? 點(diǎn)云的配準(zhǔn)一般分為等價(jià)集合和律屬集合兩種配準(zhǔn),其中等價(jià)集合配準(zhǔn)叫做匹配過程,律屬集合配準(zhǔn)被稱為Alignment。
??????? 點(diǎn)云的匹配一般使用ICP方法(? ICP:Iterative Closest Point迭代最近點(diǎn)),即兩個(gè)點(diǎn)云純粹通過剛體位姿變換即可大致重合,參考三維點(diǎn)集擬合:平面擬合、RANSAC、ICP算法。
??????? 若找稠密/稀疏點(diǎn)的匹配關(guān)系,ICP算法即簡(jiǎn)化成一個(gè)最小二乘問題,可以通過解方程的方法得到解析解,使用優(yōu)化方式迭代求解則一定可以得到全局最優(yōu)解。若沒有匹配關(guān)系,純粹的迭代最近點(diǎn)方法也能得到一個(gè)極值結(jié)果,但不一定是最優(yōu)的。
ICP的求解方法:
? ? ? ?? 把ICP方法看做一個(gè)點(diǎn)云位姿變換的過程,可以使用代數(shù)方法和非線性優(yōu)化方法。
????????? 假設(shè)有兩堆點(diǎn)云,分別記為兩個(gè)集合X=x1,x2,...,xm和Y=y1,y2,...,ym(m并不總是等于n)。
?????????? ICP公式為:
?????????
1.SVD等代數(shù)方法
???????? 先構(gòu)建誤差矩陣,構(gòu)建最小二乘問題,求使得誤差平方和最小的點(diǎn)云旋轉(zhuǎn)和位移R,T。
???????? 初始化估計(jì):ICP發(fā)展了多年之后,當(dāng)然有很多的方法來估計(jì)初始的R和t,PCL自己的函數(shù) SampleConsensusInitalAlignment 函數(shù)以及TransformationEstimationSVD函數(shù) 都可以得到較好的初始估計(jì)。
???????? 優(yōu)化:得到初始化估計(jì)之后仍然存在誤差問題,RANSAC之后,若已存在完全正確匹配,則可以再次求取旋轉(zhuǎn)的essential矩陣,通過SVD分解得到最終旋轉(zhuǎn)R和平移t。
2.非線性優(yōu)化方法
???????? RANSAC算法之后,去除掉 外點(diǎn)之后。
???????? 使用位姿的代數(shù)變化轉(zhuǎn)換構(gòu)建一個(gè)誤差項(xiàng),在非線性優(yōu)化過程中不停地迭代,一般能找到極小值。
3.PCL的ICP方法
code:
Alignment方法:
PCL鏈接:http://pointclouds.org/documentation/tutorials/template_alignment.php#template-alignment
??????? Alignment分特殊情況即目標(biāo)單側(cè)面匹配,即是確定可見面對(duì)應(yīng)目標(biāo)物體的位姿。此種方案有多種解決方法,可以劃分到物體位姿識(shí)別的范疇,使用位姿識(shí)別的通用方法來完成Alignment。
??????? Alignment的通常情況是可見面是目標(biāo)物體的一部分,并非單側(cè)面全覆蓋,同時(shí)對(duì)應(yīng)了單側(cè)面被遮擋的狀況,此種平凡狀態(tài)使用不同于位姿識(shí)別的簡(jiǎn)單方法。一般使用體素化降采樣,先找到大致可能的位姿變換;再通過特征匹配的方法,使用RANSAC方法,找到可視子集的目標(biāo)附屬位置;而后使用ICP方法,進(jìn)行再次精準(zhǔn)配準(zhǔn)。
PCL代碼:
// ... and downsampling the point cloudconst float voxel_grid_size = 0.005f;pcl::VoxelGrid<pcl::PointXYZ> vox_grid;vox_grid.setInputCloud (cloud);vox_grid.setLeafSize (voxel_grid_size, voxel_grid_size, voxel_grid_size);//vox_grid.filter (*cloud); // Please see this http://www.pcl-developers.org/Possible-problem-in-new-VoxelGrid-implementation-from-PCL-1-5-0-td5490361.htmlpcl::PointCloud<pcl::PointXYZ>::Ptr tempCloud (new pcl::PointCloud<pcl::PointXYZ>); vox_grid.filter (*tempCloud);cloud = tempCloud; // Assign to the target FeatureCloudFeatureCloud target_cloud;target_cloud.setInputCloud (cloud);// Set the TemplateAlignment inputsTemplateAlignment template_align;for (size_t i = 0; i < object_templates.size (); ++i){template_align.addTemplateCloud (object_templates[i]);}template_align.setTargetCloud (target_cloud);// Find the best template alignmentTemplateAlignment::Result best_alignment;int best_index = template_align.findBestAlignment (best_alignment);const FeatureCloud &best_template = object_templates[best_index];// Print the alignment fitness score (values less than 0.00002 are good)printf ("Best fitness score: %f\n", best_alignment.fitness_score);// Print the rotation matrix and translation vectorEigen::Matrix3f rotation = best_alignment.final_transformation.block<3,3>(0, 0);Eigen::Vector3f translation = best_alignment.final_transformation.block<3,1>(0, 3);后記:
??????? 在去除外點(diǎn),匹配已知的情況下,ICP的最小二乘問題總會(huì)得到一個(gè)最優(yōu)解,即ICP的SVD方法總會(huì)有一個(gè)解析解。
總結(jié)
以上是生活随笔為你收集整理的三维重建10:点云配准和点云匹配的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 烟雨江湖南岭怎么去
- 下一篇: gta5导弹车怎么发射 Rockstar