[英]Loading a point cloud in CImg
我正在嘗試從點雲創建 3D CImg object 以使用 CImg 的編輯功能。
我有一個點雲,我以 ascii 格式保存
pcl::io::savePCDFileASCII("/path/data.txt", *cloud);
然后我初始化一個 3d CImg object 並嘗試加載 asci 文件
CImg<float> image(cloud->width, cloud->height, 5);
image.load_ascii("/path/data.txt");
這是錯誤
[CImg] *** CImgIOException *** [instance(512,432,5,1,0x55555668f800,non-shared)] CImg<float>::load_ascii(): Invalid ascii header in file '/path/data.txt', image dimensions are set to (0,1,1,1).
terminate called after throwing an instance of 'cimg_library::CImgIOException'
what(): [instance(512,432,5,1,0x55555668f800,non-shared)] CImg<float>::load_ascii(): Invalid ascii header in file '/path/data.txt', image dimensions are set to (0,1,1,1).
這是我生成的 ascii 文件
# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z rgb
SIZE 4 4 4 4
TYPE F F F U
COUNT 1 1 1 1
WIDTH 512
HEIGHT 432
VIEWPOINT 0 0 0 1 0 0 0
POINTS 221184
DATA ascii
-0.2196694 -0.1688118 0.55800003 4285428082
-0.21879199 -0.1688118 0.55800003 4285559668
...
我是 c++ 和 CImg 的新手,所以我不確定將點雲加載到 CImg 中的正確或最佳方法是什么。 我在互聯網上也找不到任何有用的東西,而 CImg github 造成的混亂多於它的幫助。
我正在使用 Ubuntu 20、c++ 11 並加載任何類型的 2D 圖像都可以正常工作。
您的 PCL 文件與CImg
的預期不符。 它正在尋找一個以以下開頭的文件:
WIDTH HEIGHT DEPTH NUMCHANNELS
float1
float2
float3
...
所以,我做了這個例子:
#include "CImg.h"
#include <iostream>
using namespace cimg_library;
using namespace std;
int main()
{
// Load image
CImg<float> image;
image.load_ascii("image.asc");
cout << image.width() << endl;
cout << image.height() << endl;
}
然后我制作了一個像這樣尺寸為 4x8x3 的虛擬image.asc
文件,它工作正常:
4 8 3 1
float1
float2
float3
...
float96
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.