def preprocess_points(points):
    global FANCY_OUTPUT
    
    ## divide points ##
    wallpoints = array([p for p in points if floorseparator.is_wall(p)])
    floorpoints = array([p for p in points if floorseparator.is_floor(p)])
    
    ## check if enough points
    if len(wallpoints) < MIN_NUM_POINTS: return None
    if len(floorpoints) < MIN_NUM_POINTS: return None
    
    ## convert 3D points to 2D ##
    if wallpoints.shape[1] == 3:
        wallpoints = wallpoints[:, :2]
        floorpoints = floorpoints[:, :2]
    
    ## plot points
    if FANCY_OUTPUT:
        plot_points([p for p in wallpoints if norm(p) < 10e3])
        pl.legend(['raw wall points'], 'best')
        pl.draw()
    
    ## filter outliers by clustering ##
    wallpoints = outlierfilterlib.filter_outliers(wallpoints, threshold=300, min_cluster_size=20)
    clusters = outlierfilterlib.filter_outliers(wallpoints, threshold=150, min_cluster_size=1, return_clusters=True)
    
    ## plot filtered points
    if FANCY_OUTPUT:
        pts = []
        for c in clusters: pts += c.tolist()
        pl.clf()
        plot_points(pts, '.y')
        pl.legend(['after cluster filter'], 'best')
        pl.draw()
    
    ## filter outliers by floor points ##
    definite_points = prefilterlib.get_definite_points(floorpoints)
    envelope_points = prefilterlib.envelope_from_points(definite_points)
    wallpoints = prefilterlib.filter_clusters_with_envelope(envelope_points, clusters)
    
    ## plot filtered points
    if FANCY_OUTPUT:
        plot_points(wallpoints, '.b')
        pl.legend(['after cluster filter', 'after floor filter'], 'best')
        pl.draw()
    
    ## enlighten dense areas ##
    wallpoints = prefilterlib.enlighten_dense_areas(wallpoints)
    
    ## plot filtered points
    if FANCY_OUTPUT:
        pl.clf()
        plot_points(wallpoints)
        pl.legend(['final'], 'best')
        pl.draw()
    
    ## check if enough points
    if len(wallpoints) < MIN_NUM_POINTS:
        return None
    return wallpoints
def preprocess_points(points):
    global FANCY_OUTPUT

    ## divide points ##
    wallpoints = array([p for p in points if floorseparator.is_wall(p)])
    floorpoints = array([p for p in points if floorseparator.is_floor(p)])

    ## check if enough points
    if len(wallpoints) < MIN_NUM_POINTS: return None
    if len(floorpoints) < MIN_NUM_POINTS: return None

    ## convert 3D points to 2D ##
    if wallpoints.shape[1] == 3:
        wallpoints = wallpoints[:, :2]
        floorpoints = floorpoints[:, :2]

    ## plot points
    if FANCY_OUTPUT:
        plot_points([p for p in wallpoints if norm(p) < 10e3])
        pl.legend(['raw wall points'], 'best')
        pl.draw()

    ## filter outliers by clustering ##
    wallpoints = outlierfilterlib.filter_outliers(wallpoints,
                                                  threshold=300,
                                                  min_cluster_size=20)
    clusters = outlierfilterlib.filter_outliers(wallpoints,
                                                threshold=150,
                                                min_cluster_size=1,
                                                return_clusters=True)

    ## plot filtered points
    if FANCY_OUTPUT:
        pts = []
        for c in clusters:
            pts += c.tolist()
        pl.clf()
        plot_points(pts, '.y')
        pl.legend(['after cluster filter'], 'best')
        pl.draw()

    ## filter outliers by floor points ##
    definite_points = prefilterlib.get_definite_points(floorpoints)
    envelope_points = prefilterlib.envelope_from_points(definite_points)
    wallpoints = prefilterlib.filter_clusters_with_envelope(
        envelope_points, clusters)

    ## plot filtered points
    if FANCY_OUTPUT:
        plot_points(wallpoints, '.b')
        pl.legend(['after cluster filter', 'after floor filter'], 'best')
        pl.draw()

    ## enlighten dense areas ##
    wallpoints = prefilterlib.enlighten_dense_areas(wallpoints)

    ## plot filtered points
    if FANCY_OUTPUT:
        pl.clf()
        plot_points(wallpoints)
        pl.legend(['final'], 'best')
        pl.draw()

    ## check if enough points
    if len(wallpoints) < MIN_NUM_POINTS:
        return None
    return wallpoints
Exemplo n.º 3
0
from numpy import array

""" second example """
# points = array([[664.07019043, 210.639526367], [626.296936035, 38.1672210693], [586.798278809, 76.9563446045], [623.219055176, 413.724578857], [638.314819336, 484.286895752], [632.081176758, 288.60836792], [768.622619629, -4.1607260704], [733.464660645, -206.878967285], [752.626953125, -298.737091064], [759.517211914, -390.695648193], [722.851318359, -409.393310547], [727.429077148, -219.19644165], [744.580749512, -65.7007980347], [731.705322266, 7.80438327789], [741.099914551, -413.06338501], [747.718261719, -462.602905273], [749.251831055, 43.1038894653], [781.252563477, 720.810180664], [833.977294922, 607.826599121], [828.570068359, 208.867965698], [757.896240234, -464.180908203], [518.985168457, 15.784113884], [678.558959961, -26.5554256439], [726.412902832, -486.613800049], [780.028869629, -586.819396973], [734.517883301, 584.196044922], [683.728942871, 403.664672852], [697.023498535, -39.524471283], [687.598388672, -195.250305176], [689.946166992, -717.972229004], [717.619445801, -344.233306885], [697.478759766, -161.875473022], [697.129699707, 541.71282959], [739.830932617, 783.126525879], [726.540466309, 638.765136719], [760.535949707, 416.061187744], [730.859130859, 219.196487427], [690.38079834, -150.639358521], [698.422363281, -252.360229492], [728.690307617, -484.093200684], [713.232910156, -624.550842285], [682.327331543, -548.108459473], [711.921447754, -23.5835514069], [784.360961914, 517.129211426], [799.114562988, 804.177307129], [695.726013184, 444.213439941], [573.605895996, 464.885894775], [554.516906738, 376.735015869], [760.285522461, 306.142944336], [919.53527832, 184.564041138], [647.55657959, 51.5436706543], [673.891418457, -231.631713867], [981.851135254, -293.580871582], [527.969055176, -372.878112793], [693.541870117, -62.4232330322], [1093.65661621, 208.691589355], [618.150817871, 554.956848145], [643.592346191, 465.890350342], [727.43939209, -127.242111206], [510.059814453, -148.579544067], [628.015869141, 543.349853516], [1029.80090332, 588.589050293], [745.608398438, 644.616821289], [649.906799316, 598.653625488], [475.525878906, 279.245391846], [542.645935059, -207.969848633], [1040.47705078, -252.874938965], [627.154724121, 64.3083572388], [1007.82751465, 90.8511962891], [962.23260498, -796.517578125], [801.03515625, -731.305358887], [488.324676514, -656.108459473], [352.721862793, -675.696899414], [52.2229652405, -751.423156738], [-423.257263184, -692.109069824], [-554.257873535, -693.947753906], [-787.505554199, -719.666259766], [-459.97833252, -766.674926758], [-260.546722412, -783.947875977], [278.614624023, -847.830566406], [555.579650879, -811.470031738], [-47.7308273315, -721.452880859], [-659.140930176, -747.194824219], [-747.237915039, -749.064208984], [-313.430480957, -766.664489746], [155.65145874, -854.737243652], [391.414428711, -884.507873535], [572.605407715, -899.32598877], [674.093383789, -879.409423828], [592.672119141, -844.697692871], [161.828994751, -789.989257812], [-209.356750488, -849.451721191], [-414.262939453, -852.186401367], [-713.942565918, -858.156066895], [-109.27671051, -817.213867188], [394.566070557, -765.697143555], [286.297485352, -688.246032715], [-113.074028015, -748.098815918], [-337.824890137, -746.489868164], [-556.101135254, -788.04083252], [-437.356323242, -726.403503418], [92.2749252319, -668.081604004], [452.40222168, -708.762451172], [131.37890625, -734.736938477], [-51.3323516846, -772.46270752], [-535.459899902, -703.895751953], [-583.680480957, -715.920288086], [-404.346435547, -675.508422852], [46.8680076599, -721.758117676], [257.178405762, -741.097351074], [145.07585144, -719.938171387], [-361.484588623, -649.348266602], [-819.395629883, -744.053833008], [-784.080627441, -761.653015137], [-845.080627441, -783.681762695], [-1121.47924805, -783.510803223], [-1304.61169434, -757.437927246], [-1443.46057129, -774.672424316], [-1291.69580078, -780.559936523], [-1433.68151855, -653.281799316], [-1540.68493652, -760.54864502], [-1758.86218262, -807.360534668], [-1907.50024414, -894.860534668], [-1878.37060547, -833.447937012], [-1506.77172852, -902.751098633], [-1200.00097656, -930.741516113], [-1442.90490723, -845.014038086], [-2158.51367188, -793.212585449], [-1313.44372559, -766.96295166], [-1023.53167725, -796.566589355], [-852.428222656, -815.046630859], [-774.249938965, -800.482910156], [-1011.10137939, -790.464050293], [-1679.63818359, -909.824584961], [-1336.20837402, -816.058654785], [-712.192138672, -675.678710938]])

""" wall-generated example """
import sys, os
sys.path.append(os.path.dirname(__file__) + '/../1_other_techniques/simulator')
sys.path.append('./../1_other_techniques/simulator')
sys.path.append(os.path.dirname(__file__) + '/..')
#import points_generator
#points = points_generator.generate_points(300)
from outlierfilter import outlierfilterlib
from points_dataset_real2 import points
points = outlierfilterlib.filter_outliers(points)

""" calc N """
N = len(points)

Exemplo n.º 4
0
from numpy import array
""" second example """
# points = array([[664.07019043, 210.639526367], [626.296936035, 38.1672210693], [586.798278809, 76.9563446045], [623.219055176, 413.724578857], [638.314819336, 484.286895752], [632.081176758, 288.60836792], [768.622619629, -4.1607260704], [733.464660645, -206.878967285], [752.626953125, -298.737091064], [759.517211914, -390.695648193], [722.851318359, -409.393310547], [727.429077148, -219.19644165], [744.580749512, -65.7007980347], [731.705322266, 7.80438327789], [741.099914551, -413.06338501], [747.718261719, -462.602905273], [749.251831055, 43.1038894653], [781.252563477, 720.810180664], [833.977294922, 607.826599121], [828.570068359, 208.867965698], [757.896240234, -464.180908203], [518.985168457, 15.784113884], [678.558959961, -26.5554256439], [726.412902832, -486.613800049], [780.028869629, -586.819396973], [734.517883301, 584.196044922], [683.728942871, 403.664672852], [697.023498535, -39.524471283], [687.598388672, -195.250305176], [689.946166992, -717.972229004], [717.619445801, -344.233306885], [697.478759766, -161.875473022], [697.129699707, 541.71282959], [739.830932617, 783.126525879], [726.540466309, 638.765136719], [760.535949707, 416.061187744], [730.859130859, 219.196487427], [690.38079834, -150.639358521], [698.422363281, -252.360229492], [728.690307617, -484.093200684], [713.232910156, -624.550842285], [682.327331543, -548.108459473], [711.921447754, -23.5835514069], [784.360961914, 517.129211426], [799.114562988, 804.177307129], [695.726013184, 444.213439941], [573.605895996, 464.885894775], [554.516906738, 376.735015869], [760.285522461, 306.142944336], [919.53527832, 184.564041138], [647.55657959, 51.5436706543], [673.891418457, -231.631713867], [981.851135254, -293.580871582], [527.969055176, -372.878112793], [693.541870117, -62.4232330322], [1093.65661621, 208.691589355], [618.150817871, 554.956848145], [643.592346191, 465.890350342], [727.43939209, -127.242111206], [510.059814453, -148.579544067], [628.015869141, 543.349853516], [1029.80090332, 588.589050293], [745.608398438, 644.616821289], [649.906799316, 598.653625488], [475.525878906, 279.245391846], [542.645935059, -207.969848633], [1040.47705078, -252.874938965], [627.154724121, 64.3083572388], [1007.82751465, 90.8511962891], [962.23260498, -796.517578125], [801.03515625, -731.305358887], [488.324676514, -656.108459473], [352.721862793, -675.696899414], [52.2229652405, -751.423156738], [-423.257263184, -692.109069824], [-554.257873535, -693.947753906], [-787.505554199, -719.666259766], [-459.97833252, -766.674926758], [-260.546722412, -783.947875977], [278.614624023, -847.830566406], [555.579650879, -811.470031738], [-47.7308273315, -721.452880859], [-659.140930176, -747.194824219], [-747.237915039, -749.064208984], [-313.430480957, -766.664489746], [155.65145874, -854.737243652], [391.414428711, -884.507873535], [572.605407715, -899.32598877], [674.093383789, -879.409423828], [592.672119141, -844.697692871], [161.828994751, -789.989257812], [-209.356750488, -849.451721191], [-414.262939453, -852.186401367], [-713.942565918, -858.156066895], [-109.27671051, -817.213867188], [394.566070557, -765.697143555], [286.297485352, -688.246032715], [-113.074028015, -748.098815918], [-337.824890137, -746.489868164], [-556.101135254, -788.04083252], [-437.356323242, -726.403503418], [92.2749252319, -668.081604004], [452.40222168, -708.762451172], [131.37890625, -734.736938477], [-51.3323516846, -772.46270752], [-535.459899902, -703.895751953], [-583.680480957, -715.920288086], [-404.346435547, -675.508422852], [46.8680076599, -721.758117676], [257.178405762, -741.097351074], [145.07585144, -719.938171387], [-361.484588623, -649.348266602], [-819.395629883, -744.053833008], [-784.080627441, -761.653015137], [-845.080627441, -783.681762695], [-1121.47924805, -783.510803223], [-1304.61169434, -757.437927246], [-1443.46057129, -774.672424316], [-1291.69580078, -780.559936523], [-1433.68151855, -653.281799316], [-1540.68493652, -760.54864502], [-1758.86218262, -807.360534668], [-1907.50024414, -894.860534668], [-1878.37060547, -833.447937012], [-1506.77172852, -902.751098633], [-1200.00097656, -930.741516113], [-1442.90490723, -845.014038086], [-2158.51367188, -793.212585449], [-1313.44372559, -766.96295166], [-1023.53167725, -796.566589355], [-852.428222656, -815.046630859], [-774.249938965, -800.482910156], [-1011.10137939, -790.464050293], [-1679.63818359, -909.824584961], [-1336.20837402, -816.058654785], [-712.192138672, -675.678710938]])
""" wall-generated example """
import sys, os
sys.path.append(os.path.dirname(__file__) + '/../1_other_techniques/simulator')
sys.path.append('./../1_other_techniques/simulator')
sys.path.append(os.path.dirname(__file__) + '/..')
#import points_generator
#points = points_generator.generate_points(300)
from outlierfilter import outlierfilterlib
from points_dataset_real2 import points
points = outlierfilterlib.filter_outliers(points)
""" calc N """
N = len(points)