Problem with empty ccPointCloud

Any question about the database & algorithms library 'CCLib'
Post Reply
alvarofergar
Posts: 10
Joined: Wed Mar 13, 2019 12:07 pm

Problem with empty ccPointCloud

Post by alvarofergar »

Hello everyone!

I'm trying to implement the "Compute cloud/cloud distance" in a Qt project. I have been able to run the ccViewer in Qt. and, also, I'm capable of visualize clouds dropped on the viewer window or from a file read in the code.

My main problem is that, when I compute the distances, I get a mean distance and deviaton of zero. I also have to resize the clouds in order to avoid errors. It's like the ccPointCloud doesn't have any points even though the reading function returns CC_FERR_NO_ERROR and the cloud it's correctly displayed.

I leave here the function I have made to read the .asc files and get the information in a ccHObject.

Code: Select all

CC_FILE_ERROR readASCPointCloud(QString path, ccHObject &container, ccViewer* widget)
{
    AsciiFilter *mFilter= new AsciiFilter;
    CCVector3d loadCoordinatesShift(0,0,0);
    bool loadCoordinatesTransEnabled = true;
    FileIOFilter::LoadParameters mParam;
    {
            mParam.alwaysDisplayLoadDialog = false;//true to see the window
            mParam.shiftHandlingMode = ccGlobalShiftManager::DIALOG_IF_NECESSARY;
            mParam.coordinatesShift = &loadCoordinatesShift;
            mParam.coordinatesShiftEnabled = &loadCoordinatesTransEnabled;
            mParam.parentWidget = widget;
    }

    return mFilter->loadFile(path,container, mParam);
}
Also, here is the chunk of code where I read the files, convert the clouds to ccPointCloud and compute the distances.

Code: Select all

...
ccViewer w;
...
 //Reading the Ascii files
ccHObject* comp_example=ccHObject::New(CC_TYPES::POINT_CLOUD);
CC_FILE_ERROR read_comp;
read_comp=readASCPointCloud(path1, *comp_example, &w);

ccHObject* src_example=ccHObject::New(CC_TYPES::POINT_CLOUD);
CC_FILE_ERROR read_ref;
read_ref=readASCPointCloud(path2, *src_example, &w);

//Casting
ccPointCloud* compCloud = ccHObjectCaster::ToPointCloud(comp_example);
ccPointCloud* srcCloud = ccHObjectCaster::ToPointCloud(src_example);
                 
//Display in viewer
w.addToDB(srcCloud);
w.addToDB(compCloud);

//Avoiding error -1
compCloud->resize(80589); 
srcCloud->resize(80589);

//Computing distances
w.ComputePointCloudDistances(compCloud, srcCloud);
w.addToDB(compCloud);
When I debug I get that, after the casting, the cloud is apparently empty even though is displayed in the viewer without problem.
error.png
error.png (132.73 KiB) Viewed 21043 times


Does anyone know what I'm doing wrong? Any kind of help will be useful.

Thanks in advance!
Álvaro
daniel
Site Admin
Posts: 7374
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Problem with empty ccPointCloud

Post by daniel »

comp_example is a ccHObject instance (a 'group' object). You cannot convert it to a point cloud directly.

You have to look for its children (normally there should only be one if you load an ASCII file) and this child should be a point cloud. Pay attention that ccHObjectCaster::ToPointCloud may return a null pointer (if the input entity cannot be converted to a point cloud).
Daniel, CloudCompare admin
daniel
Site Admin
Posts: 7374
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Problem with empty ccPointCloud

Post by daniel »

And if the cloud is empty, it's for a reason. No need to 'resize' it to make the function 'work'. As there will be no valid point in such a cloud.
Daniel, CloudCompare admin
alvarofergar
Posts: 10
Joined: Wed Mar 13, 2019 12:07 pm

Re: Problem with empty ccPointCloud

Post by alvarofergar »

daniel wrote: Wed Mar 13, 2019 8:10 pm comp_example is a ccHObject instance (a 'group' object). You cannot convert it to a point cloud directly.

You have to look for its children (normally there should only be one if you load an ASCII file) and this child should be a point cloud. Pay attention that ccHObjectCaster::ToPointCloud may return a null pointer (if the input entity cannot be converted to a point cloud).
Thanks! I was sure that i have tested with getting childs from the ccHObject but there must have been other mistakes when I tried. Now I'm dealing with some errors in the cloud2cloud distance calculation but, at least, my clouds have some points!

daniel wrote: Wed Mar 13, 2019 8:13 pm And if the cloud is empty, it's for a reason. No need to 'resize' it to make the function 'work'. As there will be no valid point in such a cloud.
Yeah, I know it doesn't have much sense but after a couple of hours trying to solve it I started to think that there was a kind of bug. It was more like something I did to debug. Sorry for including it in the posted code.

Thank you again!
Post Reply