예제 #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
예제 #2
0
    def genEdgeMap(self, wall):

        edgeMap = np.zeros(self.size)
        utils.imageDrawWallEdge(edgeMap, wall)
        edgeMapDilation = utils.imageDilation(edgeMap, 1)
        edgeMapBlur = utils.imageGaussianBlur(edgeMapDilation, 2)

        return edgeMapBlur
예제 #3
0
    def __initLines(self):

        panoLinesPath = os.path.join(self.__mainDirPath,
                                     pm.linesFileDefaultName)
        isExist = self.__panoLines.initByImageFile(panoLinesPath)

        #dilation & BLur data
        if isExist:
            self.__panoLines.data /= 255
            dataDilate = utils.imageDilation(self.__panoLines.data, 8)
            dataBlur = utils.imageGaussianBlur(dataDilate, 10)
            self.__panoLines.pixmap = utils.data2Pixmap(dataBlur)
예제 #4
0
def genLayoutCornerMap(scene, size, dilat=4, blur=20):

    corMap = np.zeros(size)

    for point in scene.layoutFloor.corners + scene.layoutCeiling.corners:
        pos = utils.coords2pos(utils.posTranspose(point.coords), size)
        corMap[pos[0]][pos[1]] = 1

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

    return corMap
예제 #5
0
def genLayoutFloorCornerMap(scene, size, ratio=0.02, dilat=4, blur=20):

    corMap = np.zeros(size)
    for point in scene.layoutFloor.gPoints:
        xz = np.asarray(point.xyz)[[0,2]] / ratio + size[0]/2
        xz[xz>=size[0]] = size[0]-1
        xz[xz<0] = 0
        corMap[int(xz[1])][int(xz[0])] = 1

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

    return corMap
예제 #6
0
        def calcMapError(self):
            #self.__scene.getMainWindows().refleshProcessEvent() #1.5sec

            normalMap = utils.genLayoutNormalMap(self.__scene, self.__size)
            omapMSE = utils.imagesMSE(normalMap, self.__oMapR)

            edgeMap = utils.genLayoutEdgeMap(self.__scene, self.__size)
            edgeMap = utils.imageDilation(edgeMap, 1)
            edgeMap = utils.imageGaussianBlur(edgeMap, 2)
            lineMSE = utils.imagesMSE(edgeMap, self.__linesMapR)
            #print('MSE lines:{0:.3f}  normal:{1:.3f}'.format(lineMSE,omapMSE))

            mix = omapMSE + lineMSE * 20
            return mix
예제 #7
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
예제 #8
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