예제 #1
0
        public InterpSettings(string serializedData)
        {
            inPath           = "";
            outPath          = "";
            ai               = Networks.networks[0];
            inFps            = 0;
            interpFactor     = 0;
            outFps           = 0;
            outMode          = Interpolate.OutMode.VidMp4;
            model            = "";
            alpha            = false;
            stepByStep       = false;
            inputResolution  = new Size(0, 0);
            scaledResolution = new Size(0, 0);

            Dictionary <string, string> entries = new Dictionary <string, string>();

            foreach (string line in serializedData.SplitIntoLines())
            {
                if (line.Length < 3)
                {
                    continue;
                }
                string[] keyValuePair = line.Split('|');
                entries.Add(keyValuePair[0], keyValuePair[1]);
            }

            foreach (KeyValuePair <string, string> entry in entries)
            {
                switch (entry.Key)
                {
                case "INPATH": inPath = entry.Value; break;

                case "OUTPATH": outPath = entry.Value; break;

                case "AI": ai = Networks.GetAi(entry.Value); break;

                case "INFPS": inFps = float.Parse(entry.Value); break;

                case "OUTFPS": outFps = float.Parse(entry.Value); break;

                case "INTERPFACTOR": interpFactor = float.Parse(entry.Value); break;

                case "OUTMODE": outMode = (Interpolate.OutMode)Enum.Parse(typeof(Interpolate.OutMode), entry.Value); break;

                case "MODEL": model = entry.Value; break;

                case "INPUTRES": inputResolution = FormatUtils.ParseSize(entry.Value); break;

                case "OUTPUTRES": scaledResolution = FormatUtils.ParseSize(entry.Value); break;

                case "ALPHA": alpha = bool.Parse(entry.Value); break;

                case "STEPBYSTEP": stepByStep = bool.Parse(entry.Value); break;
                }
            }

            try
            {
                tempFolder    = InterpolateUtils.GetTempFolderLoc(inPath, outPath);
                framesFolder  = Path.Combine(tempFolder, Paths.framesDir);
                interpFolder  = Path.Combine(tempFolder, Paths.interpDir);
                inputIsFrames = IOUtils.IsPathDirectory(inPath);
            }
            catch
            {
                Logger.Log("Tried to create InterpSettings struct without an inpath. Can't set tempFolder, framesFolder and interpFolder.", true);
                tempFolder    = "";
                framesFolder  = "";
                interpFolder  = "";
                inputIsFrames = false;
            }
        }