Ejemplo n.º 1
0
        public static void Run(string[] args)
        {
            var main = OpenTK.DisplayDevice.AvailableDisplays.First(row => row.IsPrimary);
            var display = new BitmapWindow(main.Bounds.Left + 50, 50, 640, 480);
            display.Load();
            display.ResizeGraphics();
            var display2 = new BitmapWindow(main.Bounds.Left + 690, 50, 640, 480);
            display2.Load();
            display2.ResizeGraphics();

            var displays = new BitmapWindow[] { display, display2 };
            var kinects = KinectSensor.KinectSensors.Where(r => r.Status == KinectStatus.Connected).ToArray();
            foreach (var k in kinects)
            {
                k.Start();
                k.ElevationAngle = 19;
            }
            var cameras = kinects.Select(k => new Camera(k, ColorImageFormat.RgbResolution640x480Fps30)).ToArray();
            while (true)
            {
                cameras.Zip(displays, (c, d) =>
                {
                    d.DrawBitmap(c.TakePicture(0));
                    d.ProcessEvents();
                    return 0;
                }).ToArray();
            }
        }
Ejemplo n.º 2
0
        public static void Run(string[] args)
        {
            int[] ra = Range.OfInts(52).ToArray();
            string test = "decode.exe options.ini " + string.Join(" ", ra.Select(i => string.Format("picture-{0:000}.bmp", i)).ToArray());
            test.ToArray();
            string dir = @"C:\Users\ASUS\git\procamtools-v1\Debug";

            Thread.Sleep(100);
            ExCamera xcam = new ExCamera();
            Projector proj = new Projector();
            var main = OpenTK.DisplayDevice.AvailableDisplays.First(row => row.IsPrimary);
            var display = new BitmapWindow(main.Bounds.Left + 50, 50, 1280, 960);
            display.Load();
            display.ResizeGraphics();
            proj.DrawBackground(Color.White);
            int c = 0;

            foreach (var file in Directory.GetFiles(dir, "pattern-*.bmp"))
            {
                var map = new Bitmap(Path.Combine(dir, file));
                proj.DrawBitmap(map);
                var pic = xcam.TakePicture();
                display.DrawBitmap(pic);
                var bits = (Bitmap)pic.Clone(new Rectangle(0, 0, pic.Width, pic.Height), PixelFormat.Format32bppRgb);
                bits.Save(Path.Combine(dir, string.Format("picture-{0:000}.bmp", c++)), ImageFormat.Bmp);
            }
            display.Close();
            proj.Close();
            xcam.Dispose();
        }
Ejemplo n.º 3
0
        public static void Calibrate(string[] args)
        {
            var camfile = args.FirstOrDefault() ?? KinectDefaultFileName;
            var projfile = args.Skip(1).FirstOrDefault() ?? ProjectorDefaultFileName;
            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();
            StereoCalibration.DebugWindow = window;
            KinectSensor sensor = KinectSensor.KinectSensors.First();
            sensor.Start();

            Camera camera = new Camera(sensor, ColorImageFormat.RgbResolution1280x960Fps12);
            Projector projector = new Projector();
            PointF[][] data;
            bool proceed = false;
            CalibrationResult cc, pc;
            do
            {
                cc = CalibrateCamera(camera, projector, out data, false, true, true);

                pc = CalibrateProjector(sensor, camera, projector, cc, data, true, false);

                var peas = new float[][] {
                    new float[] { 0f, 0f, 0.0f },
                    new float[] { 0.5f, 0f, 0.0f },
                    new float[] { 0f, -0.5f, 0.0f },
                    new float[] { 0.5f, -0.5f, 0.0f },
                };
                var tpe = pc.Transform(peas);
                var tpp = cc.Transform(peas);
                projector.DrawPoints(tpe, 25);
                var pic2 = camera.TakePicture(5);
                QuickDraw.Start(pic2).Color(Color.Green).DrawPoint(tpp, 15).Finish();
                window.DrawBitmap(pic2);
                Console.WriteLine("Save result? (y/n)");
                proceed = Console.ReadLine() == "y";
            } while (!proceed);

            Utils.SerializeObject(cc, camfile);
            Utils.SerializeObject(pc, projfile);
            window.Close();
            window.Dispose();
            projector.Close();
            camera.Dispose();
            sensor.Stop();
        }
Ejemplo n.º 4
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();
 }
Ejemplo n.º 5
0
        public Form1()
        {
            InitializeComponent();

            var main = DisplayDevice.AvailableDisplays.First(row => row.IsPrimary);
            var window = new BitmapWindow(main.Bounds.Left + main.Width / 2 + 50, 50, 640, 480);
            window.Load();
            window.ResizeGraphics();
            StereoCalibration.DebugWindow = window;
            Projector proj = new Projector();
            Camera camera = new Camera(KinectSensor.KinectSensors.First(row => row.Status == KinectStatus.Connected), ColorImageFormat.RgbResolution1280x960Fps12);

            StereoCalibration.Test(proj, camera);
            //proj.Renderer.RenderBitmap(bitm);
            //BitmapWindow window = BitmapWindow.Make();

            //window.RenderFrame();
            //Projector proj = new Projector();
            //var main = DisplayDevice.AvailableDisplays.First(row => row.IsPrimary);
            //var window = new BitmapWindow(main.Bounds.Left + main.Width / 2 + 50, 50, 640, 480);
            //window.Load();
            //window.ResizeGraphics();
            //DualCalibrator.DebugWindow = window;
            ////proj.DrawPoints((new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }).Select(row => new PointF(row * 10, row * 10)).ToArray(), 10);
            ////proj.DrawPoints(new PointF[] { new PointF(50f, 50f) }, 10);
            //Camera camera = new Camera(KinectSensor.KinectSensors.First(row => row.Status == KinectStatus.Connected), ColorImageFormat.RgbResolution640x480Fps30);
            //bool res = false;
            //Application.Idle += (o, e) =>
            //{
            //    if (res)
            //        return;
            //    Bitmap map;
            //    res = DualCalibrator.DrawCorners(proj, camera, out map);
            //    //DualCalibrator.DrawNoFull(proj, camera, out map);
            //    //res = true;
            //    pictureBox1.Image = map;
            //};
        }