Example #1
0
def read_data(file):
    data = np.genfromtxt(file, unpack=True, delimiter='\t')

    prev_vid = 1
    fovs = []
    idx = 0
    videos = []
    for vid in data[1]:
        if vid == prev_vid:
            #lat, long, compass, R, alpha
            fov = FOV(data[2][idx], data[3][idx], data[4][idx], data[5][idx],
                      data[6][idx])
            fovs.append(fov)
        else:
            # new video
            v = Video(fovs)
            v.id = vid
            videos.append(v)
            # print v.to_str()

            # new fovs
            fovs = []
            fov = FOV(data[2][idx], data[3][idx], data[4][idx], data[5][idx],
                      data[6][idx])
            fovs.append(fov)

        idx += 1
        prev_vid = vid

    return videos
Example #2
0
def read_fovs(file):
    data = np.genfromtxt(file, dtype=None, unpack=True, delimiter='\t')

    prev_vid = data[0][0]
    fovs = []
    idx = 0
    videos = []
    for d in data:
        vid = d[0]
        # print str(vid), str(prev_vid)
        if vid == prev_vid:
            # lat, lon, compass, R, alpha
            fov = FOV(data[idx][2], data[idx][3], data[idx][4], data[idx][5],
                      data[idx][6])
            fovs.append(fov)
        else:
            # new video
            v = Video(fovs)
            v.id = prev_vid
            videos.append(v)
            # print v.to_str()

            # new fovs
            fovs = []
            fov = FOV(data[idx][2], data[idx][3], data[idx][4], data[idx][5],
                      data[idx][6])
            fovs.append(fov)

        idx = idx + 1
        prev_vid = vid

    print "number of videos", len(videos)
    return videos
Example #3
0
def read_image_data(file):
    data = np.genfromtxt(file, unpack=True)

    idx = 0
    fovs = []
    for i in range(0,data.shape[1]):
        fov = FOV(data[0][idx],data[1][idx],data[2][idx], 60, 250)
        fov.id = idx
        idx = idx + 1
        fovs.append(fov)

    return fovs
Example #4
0
def compute_coverage_map(grid_size = 100):
    swlat=34.018212
    swlng=-118.291716
    nelat=34.025296
    nelng=-118.279826
    videos = get_videos(swlat, swlng, nelat, nelng)

    map = np.ndarray(shape=(grid_size, grid_size), dtype=int)
    for video in videos:
        if IS_FROM_MEDIAQ:
            if video.properties['vid']:
                vid = str(video.properties['vid'])
                fovs = getFOVs(vid)

                if fovs and len(fovs) > 0:
                    for fov in fovs.features:
                        f = FOV(fov)
                        param = Params(200, swlat, swlng, nelat, nelng)
                        param.GRID_SIZE = grid_size
                        for cid in f.cellids(param):
                            cell_lat, cell_lng = cell_coord(cid, param)
                            if f.cover(cell_lat, cell_lng):
                                y_idx = cid/param.GRID_SIZE
                                x_idx = cid - y_idx*param.GRID_SIZE
                                # print x_idx, y_idx, map[x_idx][y_idx]
                                map[x_idx][y_idx] = map[x_idx][y_idx] + 1
        else:
            for f in video.fovs:
                param = Params(200, swlat, swlng, nelat, nelng)
                param.GRID_SIZE = grid_size
                for cid in f.cellids(param):
                    cell_lat, cell_lng = cell_coord(cid, param)
                    if f.cover(cell_lat, cell_lng):
                        y_idx = cid/param.GRID_SIZE
                        x_idx = cid - y_idx*param.GRID_SIZE
                        # print x_idx, y_idx, map[x_idx][y_idx]
                        map[x_idx][y_idx] = map[x_idx][y_idx] + 1

    fig, ax = plt.subplots()
    heatmap = ax.pcolor(map, cmap=plt.cm.Reds)
    plt.show()
    plt.close()
    np.savetxt("mediaq_coverage_heatmap.txt" , map, fmt='%i\t')
Example #5
0
def compute_coverage_map(grid_size=100):
    swlat = 34.018212
    swlng = -118.291716
    nelat = 34.025296
    nelng = -118.279826
    videos = get_videos(swlat, swlng, nelat, nelng)

    map = np.ndarray(shape=(grid_size, grid_size), dtype=int)
    for video in videos:
        if IS_FROM_MEDIAQ:
            if video.properties['vid']:
                vid = str(video.properties['vid'])
                fovs = getFOVs(vid)

                if fovs and len(fovs) > 0:
                    for fov in fovs.features:
                        f = FOV(fov)
                        param = Params(200, swlat, swlng, nelat, nelng)
                        param.GRID_SIZE = grid_size
                        for cid in f.cellids(param):
                            cell_lat, cell_lng = cell_coord(cid, param)
                            if f.cover(cell_lat, cell_lng):
                                y_idx = cid / param.GRID_SIZE
                                x_idx = cid - y_idx * param.GRID_SIZE
                                # print x_idx, y_idx, map[x_idx][y_idx]
                                map[x_idx][y_idx] = map[x_idx][y_idx] + 1
        else:
            for f in video.fovs:
                param = Params(200, swlat, swlng, nelat, nelng)
                param.GRID_SIZE = grid_size
                for cid in f.cellids(param):
                    cell_lat, cell_lng = cell_coord(cid, param)
                    if f.cover(cell_lat, cell_lng):
                        y_idx = cid / param.GRID_SIZE
                        x_idx = cid - y_idx * param.GRID_SIZE
                        # print x_idx, y_idx, map[x_idx][y_idx]
                        map[x_idx][y_idx] = map[x_idx][y_idx] + 1

    fig, ax = plt.subplots()
    heatmap = ax.pcolor(map, cmap=plt.cm.Reds)
    plt.show()
    plt.close()
    np.savetxt("mediaq_coverage_heatmap.txt", map, fmt='%i\t')
Example #6
0
    def location(self):
        return [self.fovs[0].lat, self.fovs[0].lon]

    def sum_fov_area(self):
        return sum([fov.area() for fov in self.fovs])

    def to_str(self):
        return str(self.id) + "\n" + "\n".join(fov.to_str() for fov in self.fovs)


from figures import SIZE, GRAY, BLUE

COLOR = {True: "#6699cc", False: "#ff3333"}

if False:
    fov1 = FOV(34.03331, -118.26935, 270, 60, 0.250)
    fov2 = FOV(34.03215, -118.26937, 255, 60, 0.250)
    fov_list = [fov2, fov1]
    video = Video(fov_list, 10)

    print fov1.mbr()
    print rect_area(fov2.mbr()), fov2.area(), video.area()

    fig = pyplot.figure(1, figsize=SIZE, dpi=90)

    ax = fig.add_subplot(122)
    patch2b = PolygonPatch(video.c_union(), fc=BLUE, ec=BLUE, alpha=0.5, zorder=2)
    ax.add_patch(patch2b)

    ax.set_title("union")
    xrange = [34.03, 34.04]