日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

三维重建10:点云配准和点云匹配

發(fā)布時間:2023/12/31 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 三维重建10:点云配准和点云匹配 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?? ? ??? 點云的配準(zhǔn)一般分為等價集合和律屬集合兩種配準(zhǔn),其中等價集合配準(zhǔn)叫做匹配過程,律屬集合配準(zhǔn)被稱為Alignment。

??????? 點云的匹配一般使用ICP方法(? ICP:Iterative Closest Point迭代最近點),即兩個點云純粹通過剛體位姿變換即可大致重合,參考三維點集擬合:平面擬合、RANSAC、ICP算法。

??????? 若找稠密/稀疏點的匹配關(guān)系,ICP算法即簡化成一個最小二乘問題,可以通過解方程的方法得到解析解,使用優(yōu)化方式迭代求解則一定可以得到全局最優(yōu)解。若沒有匹配關(guān)系,純粹的迭代最近點方法也能得到一個極值結(jié)果,但不一定是最優(yōu)的。

ICP的求解方法

? ? ? ?? 把ICP方法看做一個點云位姿變換的過程,可以使用代數(shù)方法和非線性優(yōu)化方法。

????????? 假設(shè)有兩堆點云,分別記為兩個集合X=x1,x2,...,xmY=y1,y2,...,ym(m并不總是等于n)。

?????????? ICP公式為:

?????????

1.SVD等代數(shù)方法

???????? 先構(gòu)建誤差矩陣,構(gòu)建最小二乘問題,求使得誤差平方和最小的點云旋轉(zhuǎn)和位移R,T。

???????? 初始化估計:ICP發(fā)展了多年之后,當(dāng)然有很多的方法來估計初始的R和t,PCL自己的函數(shù) SampleConsensusInitalAlignment 函數(shù)以及TransformationEstimationSVD函數(shù) 都可以得到較好的初始估計。

???????? 優(yōu)化:得到初始化估計之后仍然存在誤差問題,RANSAC之后,若已存在完全正確匹配,則可以再次求取旋轉(zhuǎn)的essential矩陣,通過SVD分解得到最終旋轉(zhuǎn)R和平移t。


2.非線性優(yōu)化方法

???????? RANSAC算法之后,去除掉 外點之后。

???????? 使用位姿的代數(shù)變化轉(zhuǎn)換構(gòu)建一個誤差項,在非線性優(yōu)化過程中不停地迭代,一般能找到極小值。


3.PCL的ICP方法

code:

// A translation on Z axis (0.4 meters)transformation_matrix (2, 3) = 0.4;// Executing the transformationpcl::transformPointCloud (*cloud_in, *cloud_icp, transformation_matrix);*cloud_tr = *cloud_icp; // We backup cloud_icp into cloud_tr for later use// The Iterative Closest Point algorithmtime.tic ();pcl::IterativeClosestPoint<PointT, PointT> icp;icp.setMaximumIterations (iterations);icp.setInputSource (cloud_icp);icp.setInputTarget (cloud_in);icp.align (*cloud_icp);icp.setMaximumIterations (1); // We set this variable to 1 for the next time we will call .align () functionstd::cout << "Applied " << iterations << " ICP iteration(s) in " << time.toc () << " ms" << std::endl;transformation_matrix = icp.getFinalTransformation ().cast<double>();


Alignment方法:

PCL鏈接:http://pointclouds.org/documentation/tutorials/template_alignment.php#template-alignment

??????? Alignment分特殊情況即目標(biāo)單側(cè)面匹配,即是確定可見面對應(yīng)目標(biāo)物體的位姿。此種方案有多種解決方法,可以劃分到物體位姿識別的范疇,使用位姿識別的通用方法來完成Alignment。

??????? Alignment的通常情況是可見面是目標(biāo)物體的一部分,并非單側(cè)面全覆蓋,同時對應(yīng)了單側(cè)面被遮擋的狀況,此種平凡狀態(tài)使用不同于位姿識別的簡單方法。一般使用體素化降采樣,先找到大致可能的位姿變換;再通過特征匹配的方法,使用RANSAC方法,找到可視子集的目標(biāo)附屬位置;而后使用ICP方法,進行再次精準(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);

后記:

??????? 在去除外點,匹配已知的情況下,ICP的最小二乘問題總會得到一個最優(yōu)解,即ICP的SVD方法總會有一個解析解。


總結(jié)

以上是生活随笔為你收集整理的三维重建10:点云配准和点云匹配的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。