Exemplo n.º 1
0
    def raw_eslf_out(self,
                     lfp_in,
                     calibration_in=None,
                     dir_out=None,
                     imagerep=None,
                     threads=None,
                     i=0):
        """TNT process: raw LFR to lightfield image out

        :param lfp_in: `str`, source LFP file
        :param calibration_in: `str`, calibration directory
        :param dir_out: `str`, directory out
        :param imagerep: `str`, image representation for processed LFP
        :param threads: `int`, number of processing threads to use
        :param i: `int`, iteration during multi file-out process
        """

        calibration_in = self._set_calibration_in(lfp_in, calibration_in)
        imagerep = imagerep or self._db['imagerep_raw_eslf_out']

        basedir, name, ext = self._split_path(lfp_in)
        dir_out = self._check_dir(dir_out) if dir_out else basedir
        eslf_out = self.eslf_out(dir_out, name, imagerep)
        eslf_out = utils.sanitize_path(eslf_out)

        slf = "standardized lightfield image"
        self._status(slf, "raw", src=lfp_in, dest=eslf_out, i=i)

        tnt = Tnt(verbose=self.verbose)
        tnt.threads(threads)
        tnt.lfp_in(lfp_in)
        tnt.eslf_out(eslf_out)
        tnt.calibration_in(calibration_in)
        self._execute(tnt)
Exemplo n.º 2
0
    def warp_transcode(self, lfp_in, lfp_out=None, threads=None, i=0):
        """TNT process: warp LFP to warp LFP

        :param lfp_in: `str`, source LFP file
        :param lfp_out: `str`, destination LFP file
        :param threads: `int`, number of processing threads to use
        :param i: `int`, iteration during multi file-out process
        """

        lfp_out = lfp_out or lfp_in

        self._status("warp LFP", "warp", src=lfp_in, dest=lfp_out, i=i)

        tnt = Tnt(verbose=self.verbose)
        tnt.threads(threads)
        tnt.lfp_in(lfp_in)
        tnt.lfp_out(lfp_out)
        tnt.transcode()
        self._execute(tnt)
Exemplo n.º 3
0
    def get_lfp_recipe(self, lfp_in):
        """generates a recipe class from a given LFP

        :param lfp_in: `str`, path to LFP to generate recipe from
        :return: instantiated recipe class
        """

        recipe_out = tempfile.NamedTemporaryFile().name
        Tnt().lfp_in(lfp_in).recipe_out(recipe_out).execute()
        recipe = Recipe(recipe_out, self.print_help)
        return recipe
Exemplo n.º 4
0
    def raw_raw2lfp(self, raw_in, dir_out=None, threads=None, i=0):
        """TNT process: package RAW and corresponding TXT

        :param raw_in: `str`, source RAW file
        :param dir_out: `str`, directory out
        :param threads: `int`, number of processing threads to use
        :param i: `int`, iteration during multi file-out process
        """

        basedir, name, ext = self._split_path(raw_in)
        dir_out = self._check_dir(dir_out) if dir_out else basedir
        lfp_out = self.lfr_out(dir_out, name)
        lfp_out = utils.sanitize_path(lfp_out)

        self._status("raw", "unpackaged RAW", src=raw_in, dest=lfp_out, i=i)

        tnt = Tnt(verbose=self.verbose)
        tnt.threads(threads)
        tnt.raw_in(raw_in)
        tnt.lfp_out(lfp_out)
        tnt.raw2lfp()
        self._execute(tnt)
Exemplo n.º 5
0
    def new(self, args):
        """new command -- creates new recipes

        :param args: `argparse.Namespace`, input arguments from recipe
        """

        self._set_print_help(args)

        for i, file_path in enumerate(args.paths, start=1):
            recipe_out = utils.sanitize_path(file_path)
            msgutils.status("generating new recipe file",
                            count=i, dest=recipe_out)
            Tnt(recipe_out=recipe_out).execute()
            recipe = Recipe(recipe_out, self.print_help)
            recipe.flush()
Exemplo n.º 6
0
    def recipe_out(self, lfp_in, dir_out=None, threads=None, i=0):
        """TNT process: raw LFR/warp LFP to recipe file

        :param lfp_in: `str`, source LFP file
        :param dir_out: `str`, directory out
        :param threads: `int`, number of processing threads to use
        :param i: `int`, iteration during multi file-out process
        """

        basedir, name, ext = self._split_path(lfp_in)
        dir_out = self._check_dir(dir_out) if dir_out else basedir
        recipe_out = self.recipe_json(dir_out, name)
        recipe_out = utils.sanitize_path(recipe_out)

        self._status("recipe file", "warp", src=lfp_in, dest=recipe_out, i=i)

        tnt = Tnt(verbose=self.verbose)
        tnt.threads(threads)
        tnt.lfp_in(lfp_in)
        tnt.recipe_out(recipe_out)
        self._execute(tnt)
Exemplo n.º 7
0
    def warp_unpack(self,
                    lfp_in,
                    depthrep=None,
                    dir_out=None,
                    height=None,
                    imagerep=None,
                    threads=None,
                    width=None,
                    i=0):
        """TNT process: warp LFP to unpacked warp LFP

        :param lfp_in: `str`, source LFP file
        :param depthrep: `str`, depth map representation
        :param dir_out: `str`, directory out
        :param height: `int`, resolution height (in pixels)
        :param imagerep: `str`, image representation for processed LFP
        :param threads: `int`, number of processing threads to use
        :param width: `int`, resolution width (in pixels)
        :param i: `int`, iteration during multi file-out process
        """

        depthrep = depthrep or self._db['depthrep_warp_unpack']
        imagerep = imagerep or self._db['imagerep_warp_unpack']
        height, width = self._set_height_width(lfp_in, height, width)

        basedir, name, ext = self._split_path(lfp_in)
        dir_out = self._check_dir(dir_out) if dir_out else basedir
        lfp_out = self.lfp_out_unpacked(dir_out, name)

        self._status("unpacked LFP", "warp", src=lfp_in, dest=dir_out, i=i)

        tnt = Tnt(verbose=self.verbose)
        tnt.threads(threads)
        tnt.lfp_in(lfp_in)
        tnt.dir_out(dir_out)
        tnt.lfp_out(lfp_out)
        tnt.transcode()
        tnt.unpack()
        tnt.imagerep(imagerep)
        tnt.depthrep(depthrep)
        tnt.height(height)
        tnt.width(width)
        self._execute(tnt)

        if os.path.exists(lfp_out):
            self.recipe_out(lfp_out, threads=threads, i=i)
            self.warp_depth_map_json_out(lfp_out, i=i)
Exemplo n.º 8
0
    def raw_unpack(self,
                   lfp_in,
                   calibration_in=None,
                   depth_in=None,
                   depthrep=None,
                   dir_out=None,
                   height=None,
                   imagerep=None,
                   orientation=None,
                   perspective_u=None,
                   perspective_v=None,
                   recipe_in=None,
                   threads=None,
                   width=None,
                   i=0):
        """TNT process: raw LFR to image out

        :param lfp_in: `str`, source LFP file
        :param calibration_in: `str`, calibration directory
        :param depth_in: `str`, depth map input file
        :param depthrep: `str`, depth map representation
        :param dir_out: `str`, directory out
        :param height: `int`, resolution height (in pixels)
        :param imagerep: `str`, image representation for processed LFP
        :param orientation: `int`, image orientation
        :param perspective_u: `float`, perspective u coordinate
        :param perspective_v: `float`, perspective v coordinate
        :param recipe_in: `str`, input recipe file
        :param threads: `int`, number of processing threads to use
        :param width: `int`, resolution width (in pixels)
        :param i: `int`, iteration during multi file-out process
        """

        calibration_in = self._set_calibration_in(lfp_in, calibration_in)
        depthrep = depthrep or self._db['depthrep_raw_unpack']
        imagerep = imagerep or self._db['imagerep_raw_unpack']
        height, width = self._set_height_width(lfp_in, height, width)

        basedir, name, ext = self._split_path(lfp_in)
        recipe_in = self.set_recipe_in(recipe_in, i)
        parent_dir = self._check_dir(dir_out) if dir_out else basedir
        dir_out = os.path.join(parent_dir, name)
        dir_out = self._check_dir(dir_out, sane=True)
        lfp_out = self.lfp_out_unpacked(dir_out, name)

        self._status("unpacked warp LFP", "raw", src=lfp_in, dest=dir_out, i=i)

        tnt = Tnt(verbose=self.verbose)
        tnt.threads(threads)
        tnt.lfp_in(lfp_in)
        tnt.dir_out(dir_out)
        tnt.lfp_out(lfp_out)
        tnt.unpack()
        tnt.imagerep(imagerep)
        tnt.depthrep(depthrep)
        tnt.height(height)
        tnt.width(width)
        tnt.orientation(orientation)
        tnt.depth_in(depth_in)
        tnt.recipe_in(recipe_in)
        tnt.calibration_in(calibration_in)
        tnt.perspective_u(perspective_u)
        tnt.perspective_v(perspective_v)
        self._execute(tnt)

        if os.path.exists(lfp_out):
            self.recipe_out(lfp_out, threads=threads, i=i)
            self.warp_depth_map_json_out(lfp_out, i=i)
Exemplo n.º 9
0
    def raw_lfr2xraw(self,
                     lfp_in,
                     calibration_in=None,
                     dir_out=None,
                     threads=None,
                     i=0):
        """TNT process: raw LFR to xraw LFR

        :param lfp_in: `str`, source LFP file
        :param calibration_in: `str`, calibration directory
        :param dir_out: `str`, directory out
        :param threads: `int`, number of processing threads to use
        :param i: `int`, iteration during multi file-out process
        """

        calibration_in = self._set_calibration_in(lfp_in, calibration_in)

        basedir, name, ext = self._split_path(lfp_in)
        dir_out = self._check_dir(dir_out) if dir_out else basedir
        xraw_out = self.xraw_out(dir_out, name)
        xraw_out = utils.sanitize_path(xraw_out)

        self._status("xraw LFR", "raw", src=lfp_in, dest=xraw_out, i=i)

        tnt = Tnt(verbose=self.verbose)
        tnt.threads(threads)
        tnt.lfp_in(lfp_in)
        tnt.lfp_out(xraw_out)
        tnt.lfr2xraw()
        tnt.calibration_in(calibration_in)
        self._execute(tnt)
Exemplo n.º 10
0
    def raw_image_out(self,
                      lfp_in,
                      image_out=None,
                      calibration_in=None,
                      depth_in=None,
                      dir_out=None,
                      focus=None,
                      height=None,
                      imagerep=None,
                      orientation=None,
                      perspective_u=None,
                      perspective_v=None,
                      recipe_in=None,
                      threads=None,
                      width=None,
                      i=0):
        """TNT process: raw LFR to image out

        :param lfp_in: `str`, source LFP file
        :param calibration_in: `str`, calibration directory
        :param depth_in: `str`, depth map input file
        :param dir_out: `str`, directory out
        :param focus: `float`, image focus point
        :param height: `int`, resolution height (in pixels)
        :param image_out: `str`, destination image file
        :param imagerep: `str`, image representation for processed LFP
        :param orientation: `int`, image orientation
        :param perspective_u: `float`, perspective u coordinate
        :param perspective_v: `float`, perspective v coordinate
        :param recipe_in: `str`, input recipe file
        :param threads: `int`, number of processing threads to use
        :param width: `int`, resolution width (in pixels)
        :param i: `int`, iteration during multi file-out process
        """

        calibration_in = self._set_calibration_in(lfp_in, calibration_in)
        imagerep = imagerep or self._db['imagerep_raw_image_out']
        height, width = self._set_height_width(lfp_in, height, width)
        u, v = perspective_u, perspective_v

        recipe_in = self.set_recipe_in(recipe_in, i)

        if not image_out:
            basedir, name, ext = self._split_path(lfp_in)
            dir_out = self._check_dir(dir_out) if dir_out else basedir
            image_out = self.image_out(dir_out, name, imagerep)
            image_out = self._image_id(image_out, focus, u, v)
            image_out = utils.sanitize_path(image_out)

        self._status("image", "raw", src=lfp_in, dest=image_out, i=i)

        tnt = Tnt(verbose=self.verbose)
        tnt.threads(threads)
        tnt.lfp_in(lfp_in)
        tnt.image_out(image_out)
        tnt.calibration_in(calibration_in)
        tnt.imagerep(imagerep)
        tnt.height(height)
        tnt.width(width)
        tnt.orientation(orientation)
        tnt.depth_in(depth_in)
        tnt.recipe_in(recipe_in)
        tnt.focus(focus)
        tnt.perspective_u(u)
        tnt.perspective_v(v)

        self._execute(tnt)
Exemplo n.º 11
0
    def raw_depth_out(self,
                      lfp_in,
                      calibration_in=None,
                      depth_in=None,
                      depthrep=None,
                      dir_out=None,
                      imagerep=None,
                      orientation=None,
                      threads=None,
                      i=0):
        """TNT process: raw LFR to warp depth out

        :param lfp_in: `str`, source LFP file
        :param calibration_in: `str`, calibration directory
        :param depth_in: `str`, depth map input file
        :param depthrep: `str`, depth map representation
        :param dir_out: `str`, directory out
        :param imagerep: `str`, image representation for processed LFP
        :param orientation: `int`, image orientation
        :param threads: `int`, number of processing threads to use
        :param i: `int`, iteration during multi file-out process
        """

        calibration_in = self._set_calibration_in(lfp_in, calibration_in)
        depthrep = depthrep or self._db['depthrep_raw_depth_out']
        imagerep = imagerep or self._db['imagerep_raw_depth_out']

        basedir, name, ext = self._split_path(lfp_in)
        dir_out = self._check_dir(dir_out) if dir_out else basedir
        depth_out = self.depth_out(dir_out, name, depthrep)
        image_out = self.image_out(dir_out, name, imagerep)
        depth_out = utils.sanitize_path(depth_out)
        image_out = utils.sanitize_path(image_out)
        jsn_out = self.jsn_out(image_out)
        dest = depth_out, image_out, jsn_out

        self._status("depth map", "raw", src=lfp_in, dest=dest, i=i)

        tnt = Tnt(verbose=self.verbose)
        tnt.threads(threads)
        tnt.lfp_in(lfp_in)
        tnt.depth_out(depth_out)
        tnt.image_out(image_out)
        tnt.orientation(orientation)
        tnt.calibration_in(calibration_in)
        tnt.depth_in(depth_in)
        self._execute(tnt)
Exemplo n.º 12
0
from copy import copy

from lpt.lfp.tnt import Tnt
from lpt.lfp.tntcommon import TntCommon
from lpt.lfp.tool import Tool
from lpt.recipe.make import Generator
from lpt.recipe.make import Make
from lpt.utils.argutils import ArgUtils
from lpt.utils.calcutils import CalcUtils
from lpt.utils.jsonutils import JsonUtils
from lpt.utils.msgutils import MsgUtils
from lpt.utils.msgutils import ToolError
from lpt.utils.msgutils import ToolWarn
from lpt.utils.utils import Utils

tnt = Tnt()
make = Make()
tool = Tool()
utils = Utils()
argutils = ArgUtils()
msgutils = MsgUtils()
calcutils = CalcUtils()
jsonutils = JsonUtils()

od = collections.OrderedDict
all_or_none = argutils.all_or_none
arg_format = argutils.arg_format
any_ = utils.any_
_verbose = False