Ejemplo n.º 1
0
        private static ProcessingParameters?ParseCommandLineArguments(string[] args)
        {
            var parameters = new ProcessingParameters();

            for (var i = 0; i < args.Length; i++)
            {
                var arg = args[i].Trim();
                switch (arg.ToLowerInvariant())
                {
                case "-m":
                case "--mode":
                    if (!ParseArgument(args, ref i, parameters.TrySetCpuOnlyMode))
                    {
                        return(null);
                    }
                    break;

                case "-i":
                case "--implementation":
                    if (!ParseArgument(args, ref i, parameters.TrySetImplementation))
                    {
                        return(null);
                    }
                    break;

                case "-s":
                case "--startTime":
                    if (!ParseArgument(args, ref i, parameters.TrySetStartTime))
                    {
                        return(null);
                    }
                    break;

                case "-e":
                case "--endTime":
                    if (!ParseArgument(args, ref i, parameters.TrySetEndTime))
                    {
                        return(null);
                    }
                    break;

                default:
                    if (!parameters.TrySetMkvPath(arg, out var message))
                    {
                        Console.WriteLine($"Invalid command-line argument \"{arg}\":");
                        if (arg.StartsWith("-") && !ProcessingParameters.IsValueLikeToMkvFilePath(arg))
                        {
                            message = "Unknown option " + arg;
                        }
                        Console.WriteLine(message);
                        return(null);
                    }
                    break;
                }
            }

            return(parameters);
        }
Ejemplo n.º 2
0
 public EnqueueInBackgroundProcessor(ProcessingParameters processingParameters)
     : base(processingParameters)
 {
     processing       = true;
     backgroundThread = new Thread(EnqueueLoop)
     {
         IsBackground = true
     };
     backgroundThread.Start();
 }
Ejemplo n.º 3
0
        public static Processor Create(ProcessingParameters processingParameters)
        {
            switch (processingParameters.Implementation)
            {
            case ProcessingImplementation.SingleThread: return(new SingleThreadProcessor(processingParameters));

            case ProcessingImplementation.PopInBackground: return(new PopInBackgroundProcessor(processingParameters));

            case ProcessingImplementation.EnqueueInBackground: return(new EnqueueInBackgroundProcessor(processingParameters));

            default: throw new NotSupportedException();
            }
        }
Ejemplo n.º 4
0
 protected Processor(ProcessingParameters processingParameters)
 {
     this.processingParameters = processingParameters;
     playback = new Record.Playback(processingParameters.MkvPath);
     playback.GetRecordConfiguration(out recordConfig);
     RecordLength = playback.RecordLength;
     playback.GetCalibration(out calibration);
     if (processingParameters.StartTime.HasValue)
     {
         Seek(processingParameters.StartTime.Value);
     }
     tracker = new BodyTracking.Tracker(ref calibration);
 }
Ejemplo n.º 5
0
        protected Processor(ProcessingParameters processingParameters)
        {
            this.processingParameters = processingParameters;
            playback = new Record.Playback(processingParameters.MkvPath);
            playback.GetRecordConfiguration(out recordConfig);
            RecordLength = playback.RecordLength;
            playback.GetCalibration(out calibration);
            if (processingParameters.StartTime.HasValue)
            {
                Seek(processingParameters.StartTime.Value);
            }
            var config = BodyTracking.TrackerConfiguration.Default;

            config.ProcessingMode = processingParameters.CpuOnlyMode
                ? BodyTracking.TrackerProcessingMode.Cpu
                : BodyTracking.TrackerProcessingMode.Gpu;
            tracker = new BodyTracking.Tracker(ref calibration, config);
        }
Ejemplo n.º 6
0
 private static void Process(ProcessingParameters processingParameters)
 {
     try
     {
         Console.WriteLine();
         Console.WriteLine("opening recording and creating body tracking pipeline...");
         using (var processor = Processor.Create(processingParameters))
         {
             Console.WriteLine("opened:");
             Console.WriteLine("  depth mode = " + processor.RecordConfig.DepthMode);
             Console.WriteLine("  camera frame rate = " + processor.RecordConfig.CameraFps.ToNumberHz());
             Console.WriteLine("  record length = " + processor.RecordLength);
             Console.WriteLine("processing frames:");
             var sw = Stopwatch.StartNew();
             while (processor.NextFrame())
             {
                 PrintProcessingStatus(processor);
             }
             sw.Stop();
             PrintProcessingStatus(processor);
             Console.WriteLine();
             Console.WriteLine("done!");
             if (sw.Elapsed.TotalSeconds > 0)
             {
                 var trackingSpeed = processor.TotalFrameCount / sw.Elapsed.TotalSeconds;
                 Console.WriteLine($"tracking speed = {trackingSpeed} FPS");
             }
         }
     }
     catch (Exception exc)
     {
         Console.WriteLine();
         Console.WriteLine("ERROR!");
         Console.WriteLine(exc.ToString());
     }
 }
Ejemplo n.º 7
0
        private static ProcessingParameters AskProcessingParameters()
        {
            Console.WriteLine("No command line arguments specified.");
            Console.WriteLine("Please enter execution parameters:");
            var parameters = new ProcessingParameters();

            if (!AskParameter(ProcessingParameters.MkvPathDescription, parameters.TrySetMkvPath))
            {
                return(null);
            }
            if (!AskParameter(ProcessingParameters.ImplementationDescription, parameters.TrySetImplementation))
            {
                return(null);
            }
            if (!AskParameter(ProcessingParameters.StartTimeDescription, parameters.TrySetStartTime))
            {
                return(null);
            }
            if (!AskParameter(ProcessingParameters.EndTimeDescription, parameters.TrySetEndTime))
            {
                return(null);
            }
            return(parameters);
        }
Ejemplo n.º 8
0
 public static Processor Create(ProcessingParameters processingParameters) => processingParameters.Implementation switch
 {