tsukuba_l.png, tsukuba_r.png画像を使用して、PCL(PointCloudLibrary)へ渡す3D情報を作成したいです。
OpenCVを使用し、tsukuba画像から視差画像、デプス画像を作成し、
以下のコードを作成してデプス画像データを点情報 PointXYZ 形式へ渡しました。
表示をさせると画像のようになり、予想した表示になりません。
デプスデータから、PointXYZへの変換方法をご教授いただきたく思います。
C++
1//PCLライブラリに渡す点情報をPointXYZ形式に格納する 2int ImageProc::Make3DPoints(cv::Mat cam1Dist, std::vector<float> depthData, pcl::PointCloud<pcl::PointXYZ> &cloud) { 3 int chk = 0; 4 cv::Mat testImg(cam1Dist.size(), cam1Dist.type()); 5 cloud.width = cam1Dist.cols; 6 cloud.height = cam1Dist.rows; //cam1Dist.rows or 1; 7 cloud.is_dense = false; 8 cloud.resize(cloud.width * cloud.height); 9 10 //--- マットから、x,yの値を取得する ---// 11 for (int y = 0; y < cam1Dist.rows; y++) { 12 for (int x = 0; x < cam1Dist.cols; x++) { 13 float z; 14 for (int c = 0; c < cam1Dist.channels(); ++c) { 15 //--- x, yと対応したz値をPointXYZに格納 ---// 16 z = depthData[y * cam1Dist.rows + x]; 17 cloud.points[y * cam1Dist.rows + x] = pcl::PointXYZ(x, y, z); 18 } 19 } 20 } 21 22 //--- 表示 ---// 23 pcl::visualization::CloudViewer viewer("Simple Cloud Viewer"); 24 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr(new pcl::PointCloud<pcl::PointXYZ>(cloud)); 25 viewer.showCloud(cloud_ptr); 26 27 while (!viewer.wasStopped()) 28 { 29 } 30 31 return chk; 32} 33コード
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/14 00:49