Ejemplo n.º 1
0
def genLayoutFloorEdgeMap(scene, size, ratio=0.02, dilat=4, blur=20):

    edgeMap = np.zeros(size)

    fpp = scene.layoutFloor.gPoints
    for i in range(len(fpp)):
        xz1 = np.asarray(fpp[i].xyz)[[0,2]] / ratio + size[0]/2
        xz2 = np.asarray(fpp[(i+1)%len(fpp)].xyz)[[0,2]] / ratio + size[0]/2
        p1 = (int(xz1[0]), int(xz1[1]))
        p2 = (int(xz2[0]), int(xz2[1]))
        utils.imageDrawLine(edgeMap, p1, p2)

    edgeMap = utils.imageDilation(edgeMap, dilat)
    edgeMap = utils.imageGaussianBlur(edgeMap, blur)
    edgeMap *= (1.0/edgeMap.max())

    return edgeMap
Ejemplo n.º 2
0
def genLayoutEdgeMap(scene, size):

    edgeMap = np.zeros(size)

    sizeT = (size[1], size[0])
    for wall in scene.label.getLayoutWalls():
        if wall.planeEquation[3] > 0:
            continue
        for edge in wall.edges:
            color = utils.normal2ManhColor(edge.vector)
            #color = (1, 1, 1)
            for i in range(len(edge.coords) - 1):
                isCross, l, r = utils.pointsCrossPano(edge.sample[i],
                                                      edge.sample[i + 1])
                if not isCross:
                    pos1 = utils.coords2pos(edge.coords[i], sizeT)
                    pos2 = utils.coords2pos(edge.coords[i + 1], sizeT)
                    utils.imageDrawLine(edgeMap, pos1, pos2, color)
                else:
                    lpos = utils.coords2pos(utils.xyz2coords(l), sizeT)
                    rpos = utils.coords2pos(utils.xyz2coords(r), sizeT)
                    ch = int((lpos[1] + rpos[1]) / 2)
                    utils.imageDrawLine(edgeMap, lpos, (0, ch), color)
                    utils.imageDrawLine(edgeMap, rpos, (sizeT[0], ch), color)

    edgeMap = utils.imageDilation(edgeMap, 1)
    edgeMap = utils.imageGaussianBlur(edgeMap, 2)
    return edgeMap
Ejemplo n.º 3
0
def genLayoutEdgeMap(scene, size, dilat=4, blur=20):

    edgeMap = np.zeros(size)
    sizeT = (size[1], size[0])

    walls = sortWallsByDist(scene.layoutWalls)
    for wall in walls:
        #if wall.planeEquation[3] > 0:
        #    continue
        '''
        isCross, polygon = genWallPolygon2d(size, wall)
        if not isCross:
            utils.imageDrawPolygon(edgeMap, polygon, (0,0,0))
        else:
            utils.imageDrawPolygon(edgeMap, polygon[0], (0,0,0))
            utils.imageDrawPolygon(edgeMap, polygon[1], (0,0,0))
        '''

        for i, edge in enumerate(wall.edges):
            #color = utils.normal2ManhColor(edge.vector)
            #color = (1, 1, 1)
            #color = type2Color(edge.type)
            color = idx2Color(i)

            for i in range(len(edge.coords) - 1):
                isCross, l, r = utils.pointsCrossPano(edge.sample[i],
                                                      edge.sample[i + 1])
                if not isCross:
                    pos1 = utils.coords2pos(edge.coords[i], sizeT)
                    pos2 = utils.coords2pos(edge.coords[i + 1], sizeT)
                    utils.imageDrawLine(edgeMap, pos1, pos2, color)
                else:
                    lpos = utils.coords2pos(utils.xyz2coords(l), sizeT)
                    rpos = utils.coords2pos(utils.xyz2coords(r), sizeT)
                    ch = int((lpos[1] + rpos[1]) / 2)
                    utils.imageDrawLine(edgeMap, lpos, (0, ch), color)
                    utils.imageDrawLine(edgeMap, rpos, (sizeT[0], ch), color)

    edgeMap = utils.imageDilation(edgeMap, dilat)
    edgeMap = utils.imageGaussianBlur(edgeMap, blur)
    for i in range(size[2]):
        edgeMap[:, :, i] *= (1.0 / edgeMap[:, :, i].max())

    return edgeMap