Example #1
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
Example #2
0
 def checkCross(self):
     for i in range(len(self.coords) - 1):
         isCross, l, r = utils.pointsCrossPano(self.sample[i],
                                               self.sample[i + 1])
         if isCross:
             return True, l, r
     return False, None, None
Example #3
0
 def drawEdges(qp, obj):
     for edge in obj.edges:
         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], size)
                 pos2 = utils.coords2pos(edge.coords[i + 1], size)
                 qp.drawLine(pos1[0], pos1[1], pos2[0], pos2[1])
             else:
                 lpos = utils.coords2pos(utils.xyz2coords(l), size)
                 rpos = utils.coords2pos(utils.xyz2coords(r), size)
                 ch = int((lpos[1] + rpos[1]) / 2)
                 qp.drawLine(lpos[0], lpos[1], 0, ch)
                 qp.drawLine(rpos[0], rpos[1], size[0], ch)
Example #4
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