Пример #1
0
 public EnqueueInBackgroundProcessor(ProcessingParameters processingParameters)
     : base(processingParameters)
 {
     processing = true;
     new Thread(EnqueueLoop)
     {
         IsBackground = true
     }.Start();
 }
Пример #2
0
 public PopInBackgroundProcessor(ProcessingParameters processingParameters)
     : base(processingParameters)
 {
     processing       = true;
     backgroundThread = new Thread(ProcessingLoop)
     {
         IsBackground = true
     };
     backgroundThread.Start();
 }
Пример #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();
            }
        }
Пример #4
0
 protected Processor(ProcessingParameters processingParameters)
 {
     this.processingParameters = processingParameters;
     playback = new Record.Playback(processingParameters.MkvPath);
     playback.GetRecordConfiguration(out recordConfig);
     RecordLength = playback.LastTimestamp;
     playback.GetCalibration(out calibration);
     if (processingParameters.StartTime.HasValue)
     {
         Seek(processingParameters.StartTime.Value);
     }
     tracker = new BodyTracking.Tracker(ref calibration);
 }
Пример #5
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 "-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);
        }
Пример #6
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);
        }
Пример #7
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());
     }
 }