コード例 #1
0
ファイル: LayoutTool.py プロジェクト: AI-Force/PanoAnnotator
def genLayoutDepthMap(scene, size):

    depthMap = np.zeros(size)

    for y in range(0, size[0]):
        for x in range(0, size[1]):
            coords = utils.pos2coords((y,x), size)
            coordsT = utils.posTranspose(coords)
            vec =  utils.coords2xyz(coordsT, 1)
            if y <= int(size[0]/2):
                plane = scene.label.getLayoutCeiling().planeEquation
            else:
                plane = scene.label.getLayoutFloor().planeEquation
            point = utils.vectorPlaneHit(vec, plane)
            depth = 0 if point is None else utils.pointsDistance((0,0,0), point)
            depthMap[y,x] = depth

    for wall in scene.label.getLayoutWalls():
        if wall.planeEquation[3] > 0:
            continue
        isCross, polygon = genWallPolygon2d(size, wall)
        if not isCross:
            utils.imageDrawWallDepth(depthMap, polygon, wall)
        else:
            utils.imageDrawWallDepth(depthMap, polygon[0], wall)
            utils.imageDrawWallDepth(depthMap, polygon[1], wall)

    return depthMap
コード例 #2
0
def depth2map(depth, size, ratio):

    num = depth.shape[0]
    plist = [
        utils.coords2xyz((float(i) / num, 0.5), depth[i])
        for i in np.arange(0, num)
    ]

    pointMap = np.zeros(size)
    polygon = []
    for p in plist:
        xz = np.asarray(p)[[0, 2]] / ratio + size[0] / 2
        xz[xz > size[0]] = size[0]
        xz[xz < 0] = 0
        polygon.append(tuple(xz))

    utils.imageDrawPolygon(pointMap, polygon)
    '''
    xy = [[p[0] for p in plist], [p[2] for p in plist]]
    xy = np.asarray(xy)

    pointMap = np.zeros(size)
    xy /= ratio 
    xy += size[0]/2
    xy = xy.astype(int)
    pointMap[xy[1,:],xy[0,:]] = 1
    '''

    return pointMap
コード例 #3
0
    def selectByCoords(self, coords):

        vec = utils.coords2xyz(coords, 1)

        #select object2d first
        for obj2d in self.__scene.label.getLayoutObject2d():
            isHit, point = obj2d.checkRayHit(vec)
            if isHit:
                self.selectObject(obj2d, point)
                return

        #select walls and save all hit wall into hitinfo
        self.__hitWalls = []
        for wall in self.__scene.label.getLayoutWalls():
            isHit, point = wall.checkRayHit(vec)
            if isHit:
                self.__hitWalls.append((wall, point))
        if self.__hitWalls:
            wall, point = self.__hitWalls[0]
            self.selectObject(wall, point)
            return

        #select floor and ceiling
        if vec[1] <= 0:
            self.selectObject(self.__scene.label.getLayoutFloor(), None)
        else:
            self.selectObject(self.__scene.label.getLayoutCeiling(), None)
コード例 #4
0
    def mouseMoveEvent(self, event):

        if not self.__isAvailable:
            return
        coords = (event.x() / self.width(), event.y() / self.height())
        vec = utils.coords2xyz(coords, 1)
        if self.__keyPress == pm.keyDict['object'] and self.__hitWalls:
            wall, point1 = self.__hitWalls[0]
            isHit, point2 = wall.checkRayHit(vec)
            if isHit:
                self.__dragPoints = [point1, point2]
コード例 #5
0
ファイル: GeoPoint.py プロジェクト: zokin/DuLa-Net
    def __init__(self, data):

        if (len(data) == 2):
            self.coords = data
            self.xyz = utils.coords2xyz(self.coords, 1)
        else:
            self.xyz = data
            self.coords = utils.xyz2coords(self.xyz)

        global gpInstanceCount
        gpInstanceCount += 1
        self.id = gpInstanceCount
コード例 #6
0
ファイル: ImageTool.py プロジェクト: AI-Force/PanoAnnotator
def imageDrawWallDepth(data, polygon, wall):

    size = (data.shape[1], data.shape[0])
    polyx = np.array([p[0] for p in polygon])
    polyy = np.array([p[1] for p in polygon])

    posy, posx = draw.polygon(polyy, polyx)

    for i in range(len(posy)):
        coords = utils.pos2coords((posx[i], posy[i]), size)
        vec = utils.coords2xyz(coords, 1)

        point = utils.vectorPlaneHit(vec, wall.planeEquation)
        depth = 0 if point is None else utils.pointsDistance((0, 0, 0), point)
        color = (depth, depth, depth)
        draw.set_color(data, [posy[i], posx[i]], list(color))
コード例 #7
0
ファイル: GeoPoint.py プロジェクト: zokin/PanoAnnotator
    def initByScene(self):

        if self.coords == None:
            self.coords = utils.xyz2coords(self.xyz)

        coordsT = (self.coords[1], self.coords[0])

        colorData = self.__scene.getPanoColorData()

        colorPos = utils.coords2pos(coordsT, colorData.shape)
        rgb = colorData[colorPos[0]][colorPos[1]]
        self.color = (rgb[0], rgb[1], rgb[2])

        depthData = self.__scene.getPanoDepthData()

        depthPos = utils.coords2pos(coordsT, depthData.shape)
        depthMean = utils.imageRegionMean(depthData, depthPos, (5, 5))
        self.depth = depthMean
        #self.depth = depthData[depthPos[0]][depthPos[1]]

        if self.xyz == None:
            self.xyz = utils.coords2xyz(self.coords, self.depth)
コード例 #8
0
    def __init__(self, scene, coords=None, xyz=None):

        self.coords = coords
        self.color = (0, 0, 0)
        self.depth = 0
        self.xyz = xyz

        self.type = 0  # [concave, convex, occul]
        self.id = 0

        if self.coords == None:
            self.coords = utils.xyz2coords(self.xyz)

        coordsT = (self.coords[1], self.coords[0])

        cpos = utils.coords2pos(coordsT, scene.color.shape)
        self.color = tuple(scene.color[cpos[0]][cpos[1]])

        dpos = utils.coords2pos(coordsT, scene.depth.shape)
        self.depth = scene.depth[dpos[0]][dpos[1]]

        if self.xyz == None:
            self.xyz = utils.coords2xyz(self.coords, self.depth)