CloudCompare / CloudComPy

Python wrapper for CloudCompare
Other
291 stars 41 forks source link

None values in RANSAC meshes result #83

Closed xiangtaoxu closed 1 year ago

xiangtaoxu commented 1 year ago

I am testing the newest release (November 2022) today on Ubuntu 22.04. I found that my codes using RANSAC to extract cylinders do not work any more because the mesh array in RANSAC outputs are all None. The point clouds seem to be fine. Though the codes passed test035.py. I would appreciate if you can help to look into this....

([None, None, ..., None], [<_cloudComPy.ccPointCloud object at 0x7fbb0ac0e070>, ..., <_cloudComPy.ccPointCloud object at 0x7fbb0ac42d30>, <_cloudComPy.ccPointCloud object at 0x7fbb0ac42d70>])

Below are part of my codes: `

Set parameters for RANSAC

params = cc.RANSAC_SD.RansacParams()

# Extract cylinders
if 'cylinder' in shapes:
    params.setPrimEnabled(cc.RANSAC_SD.RANSAC_PRIMITIVE_TYPES.RPT_CYLINDER,True)
else:
    params.setPrimEnabled(cc.RANSAC_SD.RANSAC_PRIMITIVE_TYPES.RPT_CYLINDER,False)

if 'cone' in shapes:
    params.setPrimEnabled(cc.RANSAC_SD.RANSAC_PRIMITIVE_TYPES.RPT_CONE,True)
else:
    params.setPrimEnabled(cc.RANSAC_SD.RANSAC_PRIMITIVE_TYPES.RPT_CONE,False)

if 'plane' in shapes:
    params.setPrimEnabled(cc.RANSAC_SD.RANSAC_PRIMITIVE_TYPES.RPT_PLANE,True)
else:
    params.setPrimEnabled(cc.RANSAC_SD.RANSAC_PRIMITIVE_TYPES.RPT_PLANE,False)

if 'sphere' in shapes:
    params.setPrimEnabled(cc.RANSAC_SD.RANSAC_PRIMITIVE_TYPES.RPT_SPHERE,True)
else:
    params.setPrimEnabled(cc.RANSAC_SD.RANSAC_PRIMITIVE_TYPES.RPT_SPHERE,False)

if 'torus' in shapes:
    params.setPrimEnabled(cc.RANSAC_SD.RANSAC_PRIMITIVE_TYPES.RPT_TORUS,True)
else:
    params.setPrimEnabled(cc.RANSAC_SD.RANSAC_PRIMITIVE_TYPES.RPT_TORUS,False)

# Other useful parameters
params.maxCylinderRadius = maxCylinderRadius
params.minCylinderRadius = minCylinderRadius
params.probability = probability
params.supportPoints = supportPoints
params.createCloudFromLeftOverPoints = include_leftover # default: do not output leftover
params.bitmapEpsilon = bitmapEpsilon # larger value of bitmapEpsilon takes better account of data gaps
params.maxNormalDev_deg = maxNormalDev_deg
params.epsilon = epsilon
params.randomColor = False

# Run RANSAC
results = cc.RANSAC_SD.computeRANSAC_SD(pc_in,params)
print(results)
meshes = results[0]
clouds = results[1]
# for now there are many print output, ignore for now

return (meshes, clouds)

`

prascle commented 1 year ago

Hello, I can't find a simple explanation for this behavior. I have tried to reproduce it without success with several datasets, including the dataset in issue #39. Did you try your dataset and script with the previous version? Does this behavior depend on the parameter values and/or the dataset? Can you provide the parameter values and a dataset to reproduce the problem ?

Paul

xiangtaoxu commented 1 year ago

I can't get back this until next week. Will try to find a small data set that can reproduce this problem.

Xiangtao

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: prascle @.> Sent: Monday, January 9, 2023 9:10:46 AM To: CloudCompare/CloudComPy @.> Cc: Xiangtao Xu @.>; Author @.> Subject: Re: [CloudCompare/CloudComPy] None values in RANSAC meshes result (Issue #83)

Hello, I can't find a simple explanation for this behavior. I have tried to reproduce it without success with several datasets, including the dataset in issue #39https://github.com/CloudCompare/CloudComPy/issues/39. Did you try your dataset and script with the previous version? Does this behavior depend on the parameter values and/or the dataset? Can you provide the parameter values and a dataset to reproduce the problem ?

Paul

— Reply to this email directly, view it on GitHubhttps://github.com/CloudCompare/CloudComPy/issues/83#issuecomment-1375603624, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAVG3L3PUATDGPW5SFOCNZ3WRQE5NANCNFSM6AAAAAATTPGMRA. You are receiving this because you authored the thread.Message ID: @.***>

xiangtaoxu commented 1 year ago

ransac_test.tar.gz Hi Paul, I have now created a minimal reproducible case for the problem. Please see the attachment.

ransac_test.pcd is the data file, test_ransac.py is the code, and test_ransac.out is the output when I run the codes on my machine (Ubuntu 22.04.1 in WSL2, glibc version 2.35, cloudcompy binary version 20221122 for linux). Hope you can help me to find what's happening....

xiangtaoxu commented 1 year ago

What really puzzled me is that the RANSAC function worked well for me using 20221009 and 20220918 versions before. After I upgrade my ubuntu to 22.04, the old binary files generated the same None error now.... Maybe something is strange for 22.04?

prascle commented 1 year ago

Hi, Thanks for this dataset. I reproduce the problem, it is probably related to the presence of TLS/GBL info (sensors) in the dataset. In my coding, I didn't take this case into account: when I find the sensor, I try to convert it to mesh without success and don't try to find other data... This will probably be easy to fix. I have several other small fixes and improvements to make before the next release, maybe next week. Paul

xiangtaoxu commented 1 year ago

Perfect, that makes sense. The error did happen for a new data source. Look forward to the updated version. Thanks!

Xiangtao

xiangtaoxu commented 1 year ago

Solved with the 20230209 version