示例#1
0
def pre_analyze(db):
    result = dict()

    mobile.DB = db
    readings = mobile.stream_readings()

    start = time.time()
    H = cluster.Hierarchy(next(readings))
    for i, r in enumerate(readings):
        H.append(r)

    movements = cluster.segment(H, threshold=0.01)
    locs = cluster.locations(movements, threshold=0.5)

    return (H, movements, locs)
示例#2
0
def make_single_images(image):
    for startX, endX in cluster.segment(image, max_threshold=10000):
        startY, endY = segment_vertical(image[:, startX:endX])
        yield image[startY:endY, startX:endX]
示例#3
0
readings = mobile.stream_readings()

# Clustering
start = time.time()
H = cluster.Hierarchy(next(readings))
for i, r in enumerate(readings):
    H.append(r)
    # if i % 1000 == 0:
    #     print(i)

print("Clustering duration = %.2f seconds" % (time.time() - start))

# Segmentation
start = time.time()
tops = cluster.segment(H, threshold=0.01)
print("Segmentation duration = %.2f seconds" % (time.time() - start))

# Locations
start = time.time()
locs = cluster.locations(tops, threshold=0.1)
print("Locations duration = %.2f seconds" % (time.time() - start))

def humanize(sec):
    if sec < 60:
        return "%2.2f s" % sec
    min = sec / 60.0
    if min < 60:
        return "%2.2f m" % min
    hr = min / 60.0
    return "%2.2f h" % hr