def sceneEval(inputObjectSet,params = ClusterParams(2,0.9,3,0.05,0.1,1,0,10)):
    
    '''
    find the clusters
    evaulate the inside of the clusters as lines to see if they'd be better as lines than clusters
    evaluate the outside of clusters for lines
    concatenate the lists of clusters and lines
    evaluate the whole thing with bundle search
    '''
    
    clusterCandidates = clustercost(dbscan(np.array(map(lambda x: (x.position,x.id),inputObjectSet))))
    lineCandidates = findChains(inputObjectSet,params)
    print'***'
    allCandidates = clusterCandidates + lineCandidates
    evali = bundleSearch(cluster_util.totuple(inputObjectSet), allCandidates, params.allow_intersection, 10)
    print evali
    return evali
Example #2
0
def sceneEval(inputObjectSet,params = ClusterParams(2,0.9,3,0.05,0.1,1,0,11,False)):
    
    '''
    find the clusters
    evaulate the inside of the clusters as lines to see if they'd be better as lines than clusters
    evaluate the outside of clusters for lines
    concatenate the lists of clusters and lines
    evaluate the whole thing with bundle search
    '''
    reducedObjectSet = copy(inputObjectSet)
    
    clusterCandidates = clustercost(dbscan(np.array(map(lambda x: (x.position,x.id),inputObjectSet))))
    
    innerLines = []
    #search for lines inside large clusters
    if params.attempt_dnc==True:
        for cluster in clusterCandidates[1]:

            innerObjects = []
            for id in cluster:
                for x in inputObjectSet:
                    if x.id == id:
                        innerObjects.append(x)
            innerChains = findChains(innerObjects,params)
            for thing in innerChains:
                innerLines.append(thing)
            
        #remove core clusters
        for cluster in clusterCandidates[0]:
            for id in cluster:
                for x in reducedObjectSet:
                    if x.id == id:
                        reducedObjectSet.remove(x)

    lineCandidates = findChains(reducedObjectSet,params)
    
    allCandidates = clusterCandidates[0]+clusterCandidates[1] + lineCandidates + innerLines
    groupDictionary = dict()
    for i in allCandidates:
        groupDictionary[i.uuid]=i
    evali = bundleSearch(cluster_util.totuple(inputObjectSet), allCandidates, params.allow_intersection, params.beam_width)   
    #find the things in evali that aren't in the dictionary ,and make a singleton group out of them, and add it to the output
    output = map(lambda x: groupDictionary.get(x),evali)
    return output
Example #3
0
def sceneEval(inputObjectSet,
              params=ClusterParams(2, 0.9, 3, 0.05, 0.1, 1, 0, 11, False)):
    '''
    find the clusters
    evaulate the inside of the clusters as lines to see if they'd be better as lines than clusters
    evaluate the outside of clusters for lines
    concatenate the lists of clusters and lines
    evaluate the whole thing with bundle search
    '''
    reducedObjectSet = copy(inputObjectSet)
    objectDict = dict()
    for i in inputObjectSet:
        objectDict[i.id] = i
    distanceMatrix = cluster_util.create_distance_matrix(inputObjectSet)
    dbtimestart = time()
    clusterCandidates = clustercost(
        dbscan(inputObjectSet, distanceMatrix, objectDict), objectDict)
    dbtimestop = time()
    print "dbscan time: \t\t\t", dbtimestop - dbtimestart
    #    print 'clustercandidates',clusterCandidates

    innerLines = []
    #search for lines inside large clusters
    if params.attempt_dnc == True:
        insideLineStart = time()
        for cluster in clusterCandidates[1]:

            innerObjects = []
            for id in cluster:
                for x in inputObjectSet:
                    if x.id == id:
                        innerObjects.append(x)
            innerChains = findChains(innerObjects, params)
            for thing in innerChains:
                innerLines.append(thing)

        #remove core clusters
        for cluster in clusterCandidates[0]:
            for id in cluster:
                for x in reducedObjectSet:
                    if x.id == id:
                        reducedObjectSet.remove(x)
        ReducedDistanceMatrix = cluster_util.create_distance_matrix(
            reducedObjectSet)
        insideLineStop = time()
        print "inside linesearch time:\t\t", insideLineStop - insideLineStart

    outsideLineStart = time()
    lineCandidates = findChains(reducedObjectSet, params)
    outsideLineStop = time()

    #    for i in scene:
    #        groups.append(cluster_util.SingletonBundle([i[0]],1))

    #need to implement singletons intelligently.

    print "general linesearch time:\t", outsideLineStop - outsideLineStart
    allCandidates = clusterCandidates[0] + clusterCandidates[
        1] + lineCandidates + innerLines
    groupDictionary = dict()
    for i in allCandidates:
        groupDictionary[i.uuid] = i
    for i in inputObjectSet:
        groupDictionary[i.uuid] = cluster_util.SingletonBundle([i.id], 1,
                                                               i.uuid)
    bundleStart = time()
    evali = bundleSearch(inputObjectSet, allCandidates,
                         params.allow_intersection, params.beam_width)
    bundleStop = time()
    print "bundlesearch time: \t\t", bundleStop - bundleStart
    #find the things in evali that aren't in the dictionary ,and make a singleton group out of them, and add it to the output

    #what the heck am i doing here?
    physicalobjects = []

    for i in evali:
        try:
            physicalobjects.append(groupDictionary.get(i))
        except:
            print "not in dictionary"
    output = map(lambda x: groupDictionary.get(x), evali)

    #    print 'costs', map(lambda x: x.cost,output)
    return output
Example #4
0
def sceneEval(inputObjectSet,params = ClusterParams(2,0.9,3,0.05,0.1,1,1,11,False)):
    
    '''
    find the clusters
    evaulate the inside of the clusters as lines to see if they'd be better as lines than clusters
    evaluate the outside of clusters for lines
    concatenate the lists of clusters and lines
    evaluate the whole thing with bundle search
    '''
    print "*",inputObjectSet
    reducedObjectSet = copy(inputObjectSet)
    objectDict = dict()
    for i in inputObjectSet:
        objectDict[i.uuid]=i
    distanceMatrix = cluster_util.create_distance_matrix(inputObjectSet)
    dbtimestart = time()
    clusterCandidates = clustercost(dbscan(inputObjectSet,distanceMatrix,objectDict),objectDict)
    dbtimestop = time()
    print "dbscan time: \t\t\t", dbtimestop-dbtimestart
    
    innerLines = []
    #search for lines inside large clusters
    if params.attempt_dnc==True:
        insideLineStart= time()
        for cluster in clusterCandidates[1]:

            innerObjects = []
            for id in cluster:
                for x in inputObjectSet:
                    if x.id == id:
                        innerObjects.append(x)
            innerChains = findChains(innerObjects,params)
            for thing in innerChains:
                innerLines.append(thing)
            
        #remove core clusters
        for cluster in clusterCandidates[0]:
            for id in cluster:
                for x in reducedObjectSet:
                    if x.id == id:
                        reducedObjectSet.remove(x)
        ReducedDistanceMatrix = cluster_util.create_distance_matrix(reducedObjectSet)
        insideLineStop = time()
        print "inside linesearch time:\t\t",insideLineStop-insideLineStart
        
    outsideLineStart = time()
    lineCandidates = findChains(reducedObjectSet,params,objectDict)
    outsideLineStop = time()
    
    print "general linesearch time:\t",outsideLineStop-outsideLineStart
    allCandidates = clusterCandidates[0]+clusterCandidates[1] + lineCandidates + innerLines
    allClusters = clusterCandidates[0]+clusterCandidates[1]
    allLines = lineCandidates + innerLines
    groupDictionary = dict()
    for i in allCandidates:
        groupDictionary[i.uuid]=i
    for i in inputObjectSet:
        groupDictionary[i.uuid]=i
    lineBundleStart = time()
    bestLines = bundleSearch(inputObjectSet, allLines, params.allow_intersection, params.beam_width)   
    lineBundleStop = time()
    print "linebundle time: \t\t", lineBundleStop-lineBundleStart
    
    clusterBundleStart = time()
    bestClusters = bundleSearch(inputObjectSet, allClusters, params.allow_intersection, params.beam_width) 
    print params.allow_intersection
    clusterBundleStop = time()
    print "clusterbundle time: \t\t", clusterBundleStop-clusterBundleStart
    bundleStart = time()
    evali = [] 

    try:
         evali = evali + bestLines
    except: print "there aren't any lines."
    try:
         evali = evali + bestClusters
    except: print "there aren't any clusterss."
    print "evali",evali
    
    
    output = map(lambda x: groupDictionary.get(x),evali)
    bundleStop = time()
    print "bundlesearch cleanup time: \t",bundleStop-bundleStart
    print "output",output
    return output
Example #5
0
def sceneEval(inputObjectSet,params = ClusterParams(2,0.9,3,0.05,0.1,1,0,11,False)):
    
    '''
    find the clusters
    evaulate the inside of the clusters as lines to see if they'd be better as lines than clusters
    evaluate the outside of clusters for lines
    concatenate the lists of clusters and lines
    evaluate the whole thing with bundle search
    '''
    reducedObjectSet = copy(inputObjectSet)
    objectDict = dict()
    for i in inputObjectSet:
        objectDict[i.id]=i
    distanceMatrix = cluster_util.create_distance_matrix(inputObjectSet)
    dbtimestart = time()
    clusterCandidates = clustercost(dbscan(inputObjectSet,distanceMatrix,objectDict),objectDict)
    dbtimestop = time()
    print "dbscan time: \t\t\t", dbtimestop-dbtimestart
#    print 'clustercandidates',clusterCandidates
    
    innerLines = []
    #search for lines inside large clusters
    if params.attempt_dnc==True:
        insideLineStart= time()
        for cluster in clusterCandidates[1]:

            innerObjects = []
            for id in cluster:
                for x in inputObjectSet:
                    if x.id == id:
                        innerObjects.append(x)
            innerChains = findChains(innerObjects,params)
            for thing in innerChains:
                innerLines.append(thing)
            
        #remove core clusters
        for cluster in clusterCandidates[0]:
            for id in cluster:
                for x in reducedObjectSet:
                    if x.id == id:
                        reducedObjectSet.remove(x)
        ReducedDistanceMatrix = cluster_util.create_distance_matrix(reducedObjectSet)
        insideLineStop = time()
        print "inside linesearch time:\t\t",insideLineStop-insideLineStart
        
    outsideLineStart = time()
    lineCandidates = findChains(reducedObjectSet,params)
    outsideLineStop = time()
    
    

#    for i in scene:
#        groups.append(cluster_util.SingletonBundle([i[0]],1))

#need to implement singletons intelligently. 



    print "general linesearch time:\t",outsideLineStop-outsideLineStart
    allCandidates = clusterCandidates[0]+clusterCandidates[1] + lineCandidates + innerLines
    groupDictionary = dict()
    for i in allCandidates:
        groupDictionary[i.uuid]=i
    for i in inputObjectSet:
        groupDictionary[i.uuid]=cluster_util.SingletonBundle([i.id],1,i.uuid)
    bundleStart = time()
    evali = bundleSearch(inputObjectSet, allCandidates, params.allow_intersection, params.beam_width)   
    bundleStop = time()
    print "bundlesearch time: \t\t",bundleStop-bundleStart
    #find the things in evali that aren't in the dictionary ,and make a singleton group out of them, and add it to the output

    #what the heck am i doing here?
    physicalobjects = []

    for i in evali:
        try:
            physicalobjects.append(groupDictionary.get(i))
        except:
            print "not in dictionary"
    output = map(lambda x: groupDictionary.get(x),evali)

#    print 'costs', map(lambda x: x.cost,output)
    return output