OpenCV3.4.1を使用しデプスデータ作成後、PCL(PointCloudLibrary)を使用して
点群データを表示しましたが、表示する点群データが四角錐のようになります。
原因を確認しましたがわかりませんでした。
どなたかこのような現象となる原因についてご存知でしたらご教授いただきたく思います。
C++
1//視差画像2D->深度マップ 2int ImageProc::DisparityCreation3D(cv::Mat capImg, cv::Mat Q, char *depthImgSaveFilePath, cv::Mat disparity_data, std::vector<float> &depthdata, int loopCount) { 3 int chk = 0; 4 int devNo = 1; 5 6 float baseline = 1.0f; 7 8 //--- 深度マップ作成 ---// 9 printf("深度マップを作成します。"); 10 11 cv::Mat image3DData; 12 //cv::reprojectImageTo3D(disparity_data, _3dImage, Q); //視差画像を3次元空間に再投影する 13 cv::reprojectImageTo3D(disparity_data, image3DData, Q);// , false, CV_32F); //視差画像を3次元空間に再投影する 14 15 cv::FileStorage fs3DData("3dImage_data.xml", cv::FileStorage::WRITE); 16 if (!fs3DData.isOpened()) { 17 std::cout << "File can not be opened." << std::endl; 18 std::wcout << "3Dデータファイルが開けません。" << std::endl; 19 } 20 fs3DData << "data" << image3DData; 21 fs3DData.release(); 22 23 pcl::PointXYZRGB point; 24 25 //--- 表示 ---// 26 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_ptr(new pcl::PointCloud<pcl::PointXYZRGB>()); 27 cloud_ptr->width = static_cast<uint32_t>(disparity_data.cols); 28 cloud_ptr->height = static_cast<uint32_t>(disparity_data.rows); 29 cloud_ptr->is_dense = false; 30 31 for (int i = 0; i < disparity_data.rows; ++i) { 32 // 33 uchar *rgb_ptr = capImg.ptr<uchar>(i); 34 uchar *disp_ptr = disparity_data.ptr<uchar>(i); 35 double *xyz_ptr = image3DData.ptr<double>(i); 36 37 for (int j = 0; j < disparity_data.cols; ++j) { 38 uchar d = disp_ptr[j]; 39 if (d == 0) continue; 40 Point3f p = image3DData.at<Point3f>(i, j); 41 42 //**** 190105 add p.z操作 ****// 43 if (std::isinf(p.z)) { 44 p.z = 0; 45 } 46 //else { 47 // p.z /= 100; 48 //} 49 50 point.z = p.z; 51 point.x = p.x; 52 point.y = p.y; 53 54 point.b = rgb_ptr[3 * j]; 55 point.g = rgb_ptr[3 * j + 1]; 56 point.r = rgb_ptr[3 * j + 2]; 57 cloud_ptr->points.push_back(point); 58 } 59 } 60 pcl::visualization::CloudViewer viewer("Simple Cloud Viewer"); 61 viewer.showCloud(cloud_ptr); 62 63 while (!viewer.wasStopped()) 64 { 65 } 66 67}
回答1件
あなたの回答
tips
プレビュー