PCL視覺化概述(PCL Visualization overview)
這篇是學習過程,對PCL官網,以及《點雲庫PCL學習教程》的學習與研究。
PCL視覺化庫,其建立目的是對通過演算法來計算三維點雲資料後得到的結果進行快速地復原與視覺化。類似於OpenCV的highgui程式,用來在螢幕上展示二維影象或者二維形狀。
PCL視覺化庫提供一下功能:
◆通過改變pcl::PointCloud<T> 的格式,對任何n維點雲資料集,都能夠描述和設定視覺化屬性(顏色、點大小、透明性等等);
◆無論是點的集合,還是有引數的方程,都可在螢幕上繪出基本三維形狀(例如圓筒、球體、線、多邊形物體等等);
◆運用PCLHistogramVisualizer將一個視覺化柱狀圖模型構建為二維座標系;
◆通過pcl::PointCloud<T>處理資料集,可實現多種幾何與色彩表示方法;
◆一個pcl::RangeImage視覺化模型;
檔案包為描繪三維模型,利用VTK庫來實現一系列影象以及二維操作。為加深你對視覺化的理解,運用庫來學習與實踐以下的例子。
簡單的雲圖視覺化
如果你只想運用幾行程式碼就能在你程式中對某物實現視覺化,可以嘗試如下幾個簡短的程式碼:
#include <pcl_visualization/cloud_viewer.h> //... void foo () { pcl::PointCloud<pcl::PointXYZRGB> cloud; //... populate cloud pcl_visualization::CloudViewer viewer("Simple Cloud Viewer"); viewer.showCloud(cloud); while (!viewer.wasStopped()) { } }
PCD Viewer
使用pcd_viewer可以快速的視覺化PCD檔案。對於pcd_viewer 0.2.7,幫助文件如下文:
Syntax is: pcd_viewer <file_name 1..N>.pcd <options>where options are: -bc r,g,b = background color -fc r,g,b = foreground color -ps X = point size (1..64) -opaque X = rendered point cloud opacity (0..1) -ax n = enable on-screen display of XYZ axes and scale them to n -ax_pos X,Y,Z = if axes are enabled, set their X,Y,Z position in space (default 0,0,0) -cam (*) = use given camera settings as initial view (*) [Clipping Range / Focal Point / Position / ViewUp / Distance / Window Size / Window Pos] or use a <filename.cam> that contains the same information. -multiview 0/1 = enable/disable auto-multi viewport rendering (default disabled) -normals 0/X = disable/enable the display of every Xth point's surface normal as lines (default disabled) -normals_scale X = resize the normal unit vector size to X (default 0.02) -pc 0/X = disable/enable the display of every Xth point's principal curvatures as lines (default disabled) -pc_scale X = resize the principal curvatures vectors size to X (default 0.02)(Note: for multiple .pcd files, provide multiple -{fc,ps} parameters; they will be automatically assigned to the right file)
Usage examples
<span style="font-size:18px;">$pcd_viewer-multiview 1 data/partial_cup_model.pcd data/partial_cup_model.pcd data/partial_cup_model.pcd</span>
上面的程式碼將會載入partial_up_model.pcd三次,並將引數多檢視角度(multiview 1)
在點雲開啟過程中,按下h,可以獲得幫助條令:
| Help:------- p, P : switch to a point-based representation w, W : switch to a wireframe-based representation (where available) s, S : switch to a surface-based representation (where available) j, J : take a .PNG snapshot of the current window view c, C : display current camera/window parameters + / - : increment/decrement overall point size g, G : display scale grid (on/off) u, U : display lookup table (on/off) r, R [+ ALT] : reset camera [to viewpoint = {0, 0, 0} -> center_{x, y, z}] ALT + s, S : turn stereo mode on/off ALT + f, F : switch between maximized window mode and original size l, L : list all available geometric and color handlers for the current actor map ALT + 0..9 [+ CTRL] : switch between different geometric handlers (where available) 0..9 [+ CTRL] : switch between different color handlers (where available)
按1將會現實當前可用幾何/顏色設定,例如以下:
<span style="font-size:18px;">List of available geometry handlers for actor partial_cup_model.pcd-0: xyz(1) normal_xyz(2)List of available color handlers for actor partial_cup_model.pcd-0: [random](1) x(2) y(3) z(4) normal_x(5) normal_y(6) normal_z(7) curvature(8) boundary(9) k(10) principal_curvature_x(11) principal_curvature_y(12) principal_curvature_z(13) pc1(14) pc2(15)</span>
轉到normal_xyz幾何操作可用ALT+1,然後按8可開啟曲面顏色控制,其結果如下:
<span style="font-size:18px;">$ pcd_viewer -normals 100 data/partial_cup_model.pcd</span>
使用下面命令,可載入partial_cup_model.pcd,然後展示100個曲面法線在螢幕上。
<span style="font-size:18px;">$ pcd_viewer -pc 100 data/partial_cup_model.pcd</span>
上面將會載入partial_up_model.pcd,然後將會在螢幕上找色每100個主曲率(+surface normal)。
<span style="font-size:18px;"><span style="font-family: Arial, Helvetica, sans-serif;">$ pcd_viewer data/bun000.pcd data/bun045.pcd -ax 0.5 -ps 3 -ps 1</span></span>
對於已下載的bun000.pcd和bun045.pcd的利用,下面圖片中,用u和g能分別展示the lookup table和on-grid display。
Range Image Visualizer
快速視覺化序列影象,可以用range_image_visualization的二進位制程式碼:
<span style="font-size:18px;">$ tutorial_range_image_visualization data/office_scene.pcd</span>
以上會載入office_scene.pcd點雲檔案,從中建立一個序列影象並且將其視覺化,無論是點雲還是序列圖片。