def fitGroundObject(polyData=None, expectedDimensionsMin=[0.2, 0.02], expectedDimensionsMax=[1.3, 0.1]):

    removeGroundFunc = removeGroundSimple

    polyData = polyData or getCurrentRevolutionData()
    groundPoints, scenePoints =  removeGroundFunc(polyData, groundThickness=0.02, sceneHeightFromGround=0.035)

    searchRegion = thresholdPoints(scenePoints, 'dist_to_plane', [0.05, 0.2])

    clusters = extractClusters(searchRegion, clusterTolerance=0.07, minClusterSize=4)

    candidates = []
    for clusterId, cluster in enumerate(clusters):


        origin, edges, _ = getOrientedBoundingBox(cluster)
        edgeLengths = [np.linalg.norm(edge) for edge in edges[:2]]

        found = (expectedDimensionsMin[0] <= edgeLengths[0] < expectedDimensionsMax[0]
             and expectedDimensionsMin[1] <= edgeLengths[1] < expectedDimensionsMax[1])

        if not found:
            updatePolyData(cluster, 'candidate cluster %d' % clusterId, color=[1,1,0], parent=getDebugFolder(), visible=False)
            continue

        updatePolyData(cluster, 'cluster %d' % clusterId, color=[0,1,0], parent=getDebugFolder(), visible=False)
        candidates.append(cluster)

    if not candidates:
        return None


    viewFrame = SegmentationContext.getGlobalInstance().getViewFrame()
    viewOrigin = np.array(viewFrame.GetPosition())

    dists = [np.linalg.norm(viewOrigin - computeCentroid(cluster)) for cluster in candidates]
    candidates = [candidates[i] for i in np.argsort(dists)]

    cluster = candidates[0]
    obj = makePolyDataFields(cluster)

    return vis.showClusterObjects([obj], parent='segmentation')[0]
dataset/ETHPy150Open RobotLocomotion/director/src/python/director/segmentation.py/fitGroundObject/original