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


Python Loader.shmem_as_ndarray方法代码示例

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


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

示例1: process

# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import shmem_as_ndarray [as 别名]
  def process(self):
    '''
    Starts loading the next section.
    '''
    # do nothing while workers are not available
    if self._active_workers.full():
      return

    #
    # here we have at least 1 worker available
    #

    #
    # viewing has higher priority, so check if we have anything
    # in the viewing queue
    #
    if len(self._viewing_queue) != 0:

      for view in self._viewing_queue:

        # check if we have the tiles required for this view
        allLoaded = True

        for tile in view._tiles:
          if tile._status.isVirgin():
            # we need to load this tile
            tile._status.loading()
            self._loading_queue.append(tile)
            allLoaded = False
            print 'We need tile', tile
          elif tile._status.isLoading():
            # the tile is still loading
            allLoaded = False
            

        if allLoaded:
          #
          # we have all the tiles and
          # now we can stitch the view
          #
          self._viewing_queue.remove(view)
          view._status.loading()
          print 'Stitching', view

          # now it is time to calculate the bounding box for this view
          bbox = View.calculateBB(view._tiles, view._zoomlevel)
          # print bbox
          view._bbox = bbox # re-attach the bounding box (since something could have changed)

          # allocate shared mem for view
          memory = mp.RawArray(ctypes.c_ubyte, bbox[1]*bbox[3])
          view._memory = memory # we need to keep a reference
          view._imagedata = Stitcher.shmem_as_ndarray(memory)

          # start worker
          args = (self, view)
          worker = mp.Process(target=Stitcher.run, args=args)
          self._active_workers.put(1) # increase worker counter
          worker.start()


    #
    # loading has lower priority
    # check if we have anything in the loading queue
    #
    if len(self._loading_queue) != 0:
      tile = self._loading_queue.pop(0)

      #zoomlevels = [0, 1, 2, 3, 4, 5] # TODO dynamically

      # allocate shared mem for tile and for each zoom level
      for z in self._zoomlevels:
        divisor = 2**z
        tile_width = tile._bbox[1] / divisor
        tile_height = tile._bbox[3] / divisor # TODO maybe int?
        memory = mp.RawArray(ctypes.c_ubyte, tile_width*tile_height)
        imagedata = Loader.shmem_as_ndarray(memory)
        tile._levels.append(Level(memory, imagedata))

      # start worker
      args = (self, tile)
      worker = mp.Process(target=Loader.run, args=args)
      self._active_workers.put(1) # increase worker counter
      worker.start()
      return # jump out
开发者ID:haehn,项目名称:sandbox,代码行数:87,代码来源:manager.py


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