I am trying to create a 3D CImg object from a point cloud to use the editing capabilities of CImg.
I have a point cloud that I save in ascii format
pcl::io::savePCDFileASCII("/path/data.txt", *cloud);
Then i initialize a 3d CImg object and try to load the asci file
CImg<float> image(cloud->width, cloud->height, 5);
image.load_ascii("/path/data.txt");
This is the error
[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).
here is my generated ascii file
# .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
...
I'm new to c++ and CImg so I'm not sure what is the correct or optimal way to load a point cloud into CImg. I also couldn't find anything helpful on the internet and the CImg github causes more confusion than it helps.
I'm using Ubuntu 20, c++ 11 and loading any kind of 2D image works fine.