Ejemplo n.º 1
0
    def __init__(self):
        self.grid_step = 1.0
        self.time_step = 0.2

        obst_mask, exit_mask = pathfield.load_raster_map('data/vo.png')
        dist, path = pathfield.calc_path_map(obst_mask, exit_mask)
        self.pathmap = path
        self.obst_mask = obst_mask
        h, w = path.shape[:2]
        pos = np.random.rand(10000, 2)*(w-200, h-200) + (100, 100)
        x, y = np.int32(pos + 0.5).T
        m = obst_mask[y, x]
        pos = pos[~m]
        self.pos = np.float32(pos)
Ejemplo n.º 2
0
import numpy as np
import pylab as pl
from matplotlib.collections import PolyCollection

from pathfield import load_raster_map

imgfn = 'data/vo.png'
cntfn = 'data/vo_contours.txt'
#imgfn = 'data/vo2.png'
#cntfn = 'data/vo2_contours.txt'

obst_mask, exit_mask = load_raster_map(imgfn)
contours = []
for s in open(cntfn):
    cnt = np.fromstring(s, sep=' ').reshape(-1, 2)
    contours.append(cnt)

pl.imshow(obst_mask, cmap='gray_r', vmax=3.0, interpolation='nearest')
polys = PolyCollection(contours, facecolors='none')
pl.gca().add_collection(polys)
pl.show()