예제 #1
0
        public static void Run(string[] args)
        {
            var camfile = args.FirstOrDefault() ?? Calibration.KinectDefaultFileName;
            if (!File.Exists(camfile))
            {
                Console.WriteLine("Calib file could not be found.");
                return;
            }
            var cc = Utils.DeSerializeObject<CalibrationResult>(camfile);
            var overview = new ProgramWindow(750, 50, 640, 480);
            overview.Load();
            overview.ResizeGraphics();
            OverviewProgram program = new OverviewProgram();
            overview.SetProgram(program);
            RemoteKinect kinect = new RemoteKinect("localhost", 10500);
            IDepthCamera depth = new RemoteDepthCamera(kinect);
            ISkeletonCamera skeleton = new RemoteSkeletonCamera(kinect);
            kinect.Start(Commands.Depth80 | Commands.Skeleton);
            TriplexCamera triplex = new TriplexCamera(depth, skeleton);
            KinectCalibrator kc = new KinectCalibrator(cc);
            var coordinateMapper = KinectSensor.KinectSensors.First().CoordinateMapper;

            //KinectSensor sensor = KinectSensor.KinectSensors.First();
            //var format = DepthImageFormat.Resolution80x60Fps30;
            //DepthCamera depthCam = new DepthCamera(sensor, format);
            //SkeletonCamera skeletonCam = new SkeletonCamera(sensor);
            //TriplexCamera triplex = new TriplexCamera(depthCam, skeletonCam);
            //KinectCalibrator kc = new KinectCalibrator(sensor, cc);
            //sensor.Start();

            while (true)
            {
                var players = triplex.Trigger(1000);
                if (players.Length > 0)
                {
                    for (int i = 0; i < players.Length; i++)
                    {
                        program.SetPointCloud(i, players[i].DepthPoints.Select(dp =>
                        {
                            var sp = coordinateMapper.MapDepthPointToSkeletonPoint(DepthImageFormat.Resolution80x60Fps30, dp);
                            var gp = kc.ToGlobal(sp);
                            return new DynamicVertex(new Vector3(gp[0], gp[1], gp[2]));
                        }).ToArray());
                    }
                }
                overview.ProcessEvents();
                overview.RenderFrame();
            }
        }
예제 #2
0
 public static void Run(string[] args)
 {
     var main = OpenTK.DisplayDevice.AvailableDisplays.First(row => row.IsPrimary);
     var window = new BitmapWindow(main.Bounds.Left + main.Width / 2 + 50, 50, 640, 480);
     window.Load();
     window.ResizeGraphics();
     RemoteKinect kinect = new RemoteKinect("localhost", 10500);
     Bitmap map = new Bitmap(100, 100);
     object sync = new object();
     Stopwatch sw = new Stopwatch();
     sw.Start();
     int frames = 0;
     kinect.ReceivedSkeletons += (o, e) =>
     {
         frames++;
         e.Skeletons.ToString();
     };
     kinect.ReceivedColorImage += (o, e) =>
     {
         frames++;
         map = e.Bitmap;
         lock (sync)
             Monitor.Pulse(sync);
     };
     kinect.ReceivedDepthImage += (o, e) =>
     {
         frames++;
         e.Pixels.ToString();
     };
     kinect.Start(Commands.Color640);
     while (true)
     {
         lock (sync)
             Monitor.Wait(sync);
         window.DrawBitmap(map);
     }
     while (true)
     {
         Thread.Sleep(1000);
         Console.WriteLine("{0} frames in {1} ms", frames, sw.ElapsedMilliseconds);
         frames = 0;
         sw.Reset();
         sw.Start();
     }
     Console.ReadLine();
 }