0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pcdファイルの可視化

Last updated at Posted at 2022-02-21

前回はbagファイルからpcdファイルへ変換した
今回は,pcdファイルの中身を見てみよう
任意の場所に新たにフォルダを作成し,pcd_write.cppとCMakeLists.txtを作成する

# include <iostream>
# include <pcl/io/pcd_io.h>
# include <pcl/point_types.h>

int main(int argc, char **argv)
{
    pcl::PointCloud<pcl::PointXYZ> cloud;

    // Fill in the cloud data
    cloud.width =10;
    //表示する数?
    cloud.height = 1;
    cloud.is_dense = false;
    cloud.points.resize(cloud.width * cloud.height);
    //point cloudの大きさを指定
    for (size_t i = 0; i < cloud.points.size(); ++i)
    {
        cloud.points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
        cloud.points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
        cloud.points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
    }

    pcl::io::savePCDFileASCII("1645410112.408859474.pcd", cloud);
    //pcdファイルは各自で変更
    std::cerr << "Saved " << cloud.points.size() << " data points to test_pcd.pcd." << std::endl;

    for (size_t i = 0; i < cloud.points.size(); ++i)
        std::cerr << "    " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;
    return (0);
}
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(pcd_write)

find_package(PCL 1.2 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_executable (pcd_write pcd_write.cpp)
target_link_libraries (pcd_write ${PCL_LIBRARIES})

保存したら,

mkdir build 
cd build 
sudo cmake ..
sudo make 
sudo ./pcd_write

上から順に実行するとx,y,zの情報が表示される

ここからが問題ってばよ!!
x,yだけが欲しいからzをうまく削除できるようにならないと
pcdファイルを点群で見る

pcl_viewer <pcdfile> <ps 数字> <-fc R,G,B>
//<ps 数字>で点の大きさを指定
//<-fc R,G,B>で点の色を指定  例)255,255,255は白

オプション

オプション 結果
-bc r,g,b 背景色
-fc r,g,b 点群色
-ps X 点のサイズ(1~64)
-opaque X 点群の不透明度(0~1)
-ax n 軸の有効にし,nにスケーリング
-ax_pos X,Y,Z 軸が有効になっている場合は,x,y,zの位置を空間にする
-cam (*) 指定されたカメラ設定を初期ビューとして使用する
-multiview 0/1 自動マルチビューポートレンダリングを有効/無効にする
-normals 0/X すべてのX点のサーフェス法線を線として表示することを無効/有効にする
-normals_scale X 通常の単位ベクトルサイズをXに変更する
-pc 0/X すべてのX点の主曲率の線としての表示を無効/有効にする
-pc_scale X 主曲率ベクトルのサイズをXに変更する

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?