示例#1
0
def gen_img(mac):
    global IMGCOUNT
    img = Image.open('map_img/2x_' + image_filename)
    img = img.convert('RGB')
    draw = ImageDraw.Draw(img)
    CSIZE = 1

    for (i,t) in enumerate(mac2ts[mac]):
        for dt in range(-30,30):
            pos = gps.get(t + dt)

            x = 2*c2s_x(pos['long'])
            y = 2*c2s_y(pos['lat'])
            x, y = shuffle(x, y)

            draw.ellipse((x - CSIZE, y - CSIZE, x + CSIZE, y + CSIZE), fill='red')

    #draw.text((10, i * 20), t2str(t), (0,0,0))


    istr = '%s' % (mac[:9] + 'XX:XX:XX',)
    draw.text((10, 1200), istr, (0,0,0))

    img.save('/tmp/img/%03d.png' % IMGCOUNT)
    IMGCOUNT += 1
示例#2
0
import json
import time
import sys
from PIL import Image, ImageDraw
from map_plot import image_filename, c2s_x, c2s_y
from gps import GPS
gps = GPS()

CSIZE = 2
SEC = 60

img = Image.open('map_img/' + image_filename)
draw = ImageDraw.Draw(img)

t0 = 1435421469
t1 = 1435441950

for t in range(t0, t1, SEC):
    pos = gps.get(t)

    x = c2s_x(pos['long'])
    y = c2s_y(pos['lat'])

    draw.ellipse((x - CSIZE, y - CSIZE, x + CSIZE, y + CSIZE), outline=0)

img.show()



示例#3
0
from PIL import Image, ImageDraw
from map_plot import image_filename, c2s_x, c2s_y


img = Image.open('map_img/2x_dim_' + image_filename)
draw = ImageDraw.Draw(img)

last_line = None
f = open('data/gps.log', 'r')
for crt_line_json in f:
    crt_line = json.loads(crt_line_json)
    if float(crt_line['accuracy']) > 30:
        continue
    if last_line is None:
        last_line = crt_line
        continue
    x0 = 2*c2s_x(last_line['long'])
    y0 = 2*c2s_y(last_line['lat'])
    x1 = 2*c2s_x(crt_line['long'])
    y1 = 2*c2s_y(crt_line['lat'])

    draw.line((x0, y0, x1, y1), fill=0, width=1)

    last_line = crt_line

img.save('blog_walk.png')
img.show()



示例#4
0
    1435440908,
]

print len(TS)
exit(1)

import json
import time
import sys
from PIL import Image, ImageDraw
from map_plot import image_filename, c2s_x, c2s_y
from gps import GPS

gps = GPS()

CSIZE = 2
SEC = 60

img = Image.open("map_img/" + image_filename)
draw = ImageDraw.Draw(img)

for t in TS:
    pos = gps.get(t)

    x = c2s_x(pos["long"])
    y = c2s_y(pos["lat"])

    draw.ellipse((x - CSIZE, y - CSIZE, x + CSIZE, y + CSIZE), outline=0)

img.show()
示例#5
0
    mac2ts[mac].append(ts)
f.close()

ts_list = [min(mac2ts[mac]) for mac in mac2ts.keys()]
ts_list = sorted(ts_list)

print len(ts_list)

CSIZE = 1

img = Image.open('map_img/2x_dim_' + image_filename)
draw = ImageDraw.Draw(img)

RADIUS = 5

def shuffle(x, y):
    return (x + random.randint(-RADIUS, RADIUS), y + random.randint(-RADIUS, RADIUS))

for t in ts_list:
    pos = gps.get(t)

    x = 2 * c2s_x(pos['long'])
    y = 2 * c2s_y(pos['lat'])
    x, y = shuffle(x, y)

    draw.point((x, y), 'red')

img.save('blog_unique_macs.png')
img.show()