Ejemplo n.º 1
0
def findProcess(imageName, filterString):
    pid = Popen([
        'wmic', 'path', 'win32_process', 'where',
        "Name='%s'" % imageName, 'get', 'CommandLine,ProcessId', '/VALUE'
    ],
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE)
    out = pid.communicate()
    out = out[0].split('\r\r\n\r\r\n')
    out = filter(lambda x: 'CommandLine' in x, out)
    out = map(lambda x: x.strip().split('\r\r\n'), out)

    if out:
        if out[0][0].startswith('CommandLine'):
            commandLineIndex = 0
            processIndex = 1
        else:
            commandLineIndex = 1
            processIndex = 0
        out = map(
            lambda x: [int(x[processIndex][10:]), x[commandLineIndex][12:]],
            out)

        out = filter(lambda x: filterString in x[1], out)
        return map(lambda x: x[0], out)
    return []
Ejemplo n.º 2
0
    def zoomify_add_image(self, filename, width, height, bands, pixel_format):
        from hashlib import sha256
        import urllib

        import voxel_globe.meta.models

        #Create database entry
        img = voxel_globe.meta.models.Image(
            name="%s Upload %s (%s) Frame %s" %
            (self.meta_name, self.upload_session.name, self.upload_session.id,
             os.path.basename(filename)),
            image_width=width,
            image_height=height,
            number_bands=bands,
            pixel_format=pixel_format,
            file_format='zoom',
            service_id=self.task.request.id)
        img.filename_path = filename
        img.save()

        self.image_set.images.add(img)

        zoomify_path = img.zoomify_path
        pid = Popen(
            ['vips', 'dzsave', filename, zoomify_path, '--layout', 'zoomify'])
        pid.wait()
Ejemplo n.º 3
0
def convert_ply_to_potree(ply_filename, potree_dirname):
  from voxel_globe.tools.subprocessbg import Popen

  potree_ply = os.path.join(potree_dirname, 'potree.ply')

  with open(ply_filename, 'r') as fid_in, open(potree_ply, 'w') as fid_out:
    line = 'None'
    while not line.startswith('end_header') and line != '':
      line = fid_in.readline()
      if line == 'property float prob\n':
        line = 'property float nx\n'
      if line == 'property float le\n':
        line = 'property float ny\n'
      if line == 'property float ce\n':
        line = 'property float nz\n'
      fid_out.write(line)
    chunk = None
    while not chunk == '':
      chunk = fid_in.read(64*1024*1024)
      fid_out.write(chunk)

  pid = Popen(['PotreeConverter', '--source', potree_ply, 
               '-a', 'RGB', 'INTENSITY', 'CLASSIFICATION', 'REAL_NORMAL', 
               '-o', potree_dirname, 'potree'])
  pid.wait()
Ejemplo n.º 4
0
    def zoomify_add_image(self, filename, width, height, bands, pixel_format):
        from hashlib import sha256
        import urllib

        import voxel_globe.meta.models

        hasher = sha256()
        chunk = 1024 * 1024 * 16

        with open(filename, 'rb') as fid:
            data = fid.read(chunk)
            while data:
                hasher.update(data)
                data = fid.read(chunk)
        zoomify_name = os.path.join(
            os.path.split(filename)[0],
            hasher.hexdigest() + '_zoomify')
        #zoomify_name = os.path.splitext(filename)[0] + '_zoomify'
        pid = Popen(
            ['vips', 'dzsave', filename, zoomify_name, '--layout', 'zoomify'])
        pid.wait()

        #convert the slashes to URL slashes
        relative_file_path = urllib.pathname2url(
            os.path.relpath(filename, env['VIP_IMAGE_SERVER_ROOT']))
        basename = os.path.split(filename)[-1]
        relative_zoom_path = urllib.pathname2url(
            os.path.relpath(zoomify_name, env['VIP_IMAGE_SERVER_ROOT']))

        img = voxel_globe.meta.models.Image.create(
            name="%s Upload %s (%s) Frame %s" %
            (self.meta_name, self.upload_session.name, self.upload_session.id,
             basename),
            imageWidth=width,
            imageHeight=height,
            numberColorBands=bands,
            pixelFormat=pixel_format,
            fileFormat='zoom',
            imageUrl='%s://%s:%s/%s/%s/' %
            (env['VIP_IMAGE_SERVER_PROTOCOL'], env['VIP_IMAGE_SERVER_HOST'],
             env['VIP_IMAGE_SERVER_PORT'], env['VIP_IMAGE_SERVER_URL_PATH'],
             relative_zoom_path),
            originalImageUrl='%s://%s:%s/%s/%s' %
            (env['VIP_IMAGE_SERVER_PROTOCOL'], env['VIP_IMAGE_SERVER_HOST'],
             env['VIP_IMAGE_SERVER_PORT'], env['VIP_IMAGE_SERVER_URL_PATH'],
             relative_file_path),
            service_id=self.task.request.id,
            original_filename=basename)
        img.save()

        self.image_collection.images.add(img)
Ejemplo n.º 5
0
def zoomify_image(filename, zoomify_dir):
    pid = Popen(
        ['vips', 'dzsave', filename, zoomify_dir, '--layout', 'zoomify'])
    pid.wait()