当前位置: 首页>>代码示例>>Python>>正文


Python Tile.from_string方法代码示例

本文整理汇总了Python中tile.Tile.from_string方法的典型用法代码示例。如果您正苦于以下问题:Python Tile.from_string方法的具体用法?Python Tile.from_string怎么用?Python Tile.from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tile.Tile的用法示例。


在下文中一共展示了Tile.from_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_bounding_box

# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import from_string [as 别名]
  def update_bounding_box(self):
    '''
    '''

    # first, grab the meta data, then calculate the bounding box
    directory = self._directory
    metadata_file = os.path.join(directory, Constants.METADATA_FILE)
    image_coordinates_file = os.path.join(directory, Constants.IMAGE_COORDINATES_FILE)


    #
    # read meta data
    #
    metadata = {}

    with open(metadata_file) as f:
      for l in f.readlines():
        l = l.strip()
        values = l.split()
        metadata[values[0].strip(':')] = values[-1]

    #
    # we do want to parse some of the meta data
    #
    width = int(metadata['Width'].strip('px'))
    height = int(metadata['Height'].strip('px'))
    
    #
    # index tiles
    #
    tiles = {}

    with open(image_coordinates_file) as f:
      
      # we need to remove duplicate entries here and only grab the last 61
      lines = FoV.filter_duplicate_lines(f.readlines())[-61:]
      
      for i,l in enumerate(lines):

        # if i>60:
        #   # only look at the first 61 entries since we do not use other thumbnails
        #   break
        tile = Tile.from_string(l)
        # update width and height
        tile.width = width
        tile.height = height
        tiles[tile.id] = tile


    self._tiles = tiles
    self._metadata = metadata

    # now the bounding box
    width = -sys.maxint
    height = -sys.maxint

    minX = sys.maxint
    minY = sys.maxint
    maxX = -sys.maxint
    maxY = -sys.maxint

    for i in self._tiles:
      image = self._tiles[i]
      minX = min(minX, image._tx)
      minY = min(minY, image._ty)
      maxX = max(maxX, image._tx)
      maxY = max(maxY, image._ty)

    width = maxX - minX + image.width
    height = maxY - minY + image.height

    self._tx = minX
    self._ty = minY

    self._width = width
    self._height = height

    print width, height
开发者ID:fasrc,项目名称:mbeam,代码行数:80,代码来源:fov.py


注:本文中的tile.Tile.from_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。