Exemplo n.º 1
0
        /**
         * Initialise View and start updater Thread
         */
        public CameraView(Model model)
        {
            this.model = model;

            session = PXCMSession.CreateInstance();

            if (session == null) // Something went wrong, session could not be initialised
            {
                Console.WriteLine("F**k!");
                Application.Exit();
                return;
            }

            iv = session.QueryVersion();
            String versionString = "v" + iv.major + "." + iv.minor;

            Console.WriteLine(versionString);
            Text = versionString;


            pb = new PictureBox();
            // Set size
            pb.Bounds = new Rectangle(0, 0, model.Width, model.Height);
            // init UI
            this.Bounds = new Rectangle(0, 0, model.Width, model.Height);
            this.Controls.Add(pb);
            FormClosed += new FormClosedEventHandler(Quit);
            this.Show();
            // Start Updater Thread
            updaterThread = new Thread(this.update);
            updaterThread.Start();
        }
Exemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Get instance of SenseManager
            PXCMSession session = PXCMSession.CreateInstance();

            // Get RS version
            PXCMSession.ImplVersion version = session.QueryVersion();
            textBox1.Text = version.major.ToString() + "." + version.minor.ToString();

            // setup Pipeline
            PXCMSenseManager sm = session.CreateSenseManager();

            // Get streams ready
            sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480);
            sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 640, 480);

            // Init Pipeline
            sm.Init();

            // Get samples
            pxcmStatus status = sm.AcquireFrame(true); // Synchronous capturing

            PXCMCapture.Sample sample = sm.QuerySample();

            // Convert samples to image
            PXCMImage image  = sample.color;
            PXCMImage dimage = sample.depth;

            PXCMImage.ImageData data;
            image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32, out data);
            WriteableBitmap wbm = data.ToWritableBitmap(0,
                                                        image.info.width,
                                                        image.info.height,
                                                        96.0, 96.0);

            PXCMImage.ImageData data2;
            dimage.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_DEPTH_RAW, out data2);
            WriteableBitmap wbm2 = data2.ToWritableBitmap(
                0,
                dimage.info.width,
                dimage.info.height,
                96.0, 96.0);

            // Display image
            imageRGB.Source   = wbm;
            imageDepth.Source = wbm2;


            // Clean up
            image.ReleaseAccess(data);
            image.ReleaseAccess(data2);
            sm.ReleaseFrame();


            sm.Close();
            session.Dispose();
        }
Exemplo n.º 3
0
        /**
         * Initialise View and start updater Thread
         */
        public CameraView(int width, int height, int framterate, List <RSModule> mods)
        {
            // Initialise Stuff, turn Camera on
            senseManager = PXCMSenseManager.CreateInstance();
            senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, width, height, framterate);
            // Enable Face detection
            senseManager.EnableFace();
            modules = mods;
            modules.ForEach(delegate(RSModule rsm)
            {
                rsm.Init(senseManager);
            });
            senseManager.Init();

            session = PXCMSession.CreateInstance();

            if (session == null) // Something went wrong, session could not be initialised
            {
                Console.WriteLine("F**k!");
                Application.Exit();
                return;
            }

            iv = session.QueryVersion();
            String versionString = "v" + iv.major + "." + iv.minor;

            Console.WriteLine(versionString);
            Text = versionString;


            pb = new PictureBox();
            // Set size
            pb.Bounds = new Rectangle(0, 0, width, height);
            // init UI
            this.Bounds = new Rectangle(0, 0, width, height);
            this.Controls.Add(pb);
            FormClosed += new FormClosedEventHandler(Quit);
            this.Show();
            // Start Updater Thread
            updaterThread = new Thread(this.update);
            updaterThread.Start();
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            PXCMSession session = PXCMSession.CreateInstance();

            PXCMSession.ImplVersion version = session.QueryVersion();
            textBox1.Text = version.major.ToString() + "." + version.minor.ToString();
            PXCMSenseManager sm = session.CreateSenseManager();

            sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 0, 0);
            sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 0, 0);
            sm.Init();

            pxcmStatus status = sm.AcquireFrame(true);

            PXCMCapture.Sample sample = sm.QuerySample();

            PXCMImage image  = sample.color;
            PXCMImage dimage = sample.depth;

            PXCMImage.ImageData data;
            PXCMImage.ImageData data2;

            image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32, out data);
            dimage.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_DEPTH_RAW, out data2);

            WriteableBitmap wbm  = data.ToWritableBitmap(0, image.info.width, image.info.height, 96.0, 96.0);
            WriteableBitmap wbm2 = data2.ToWritableBitmap(0, dimage.info.width, dimage.info.height, 96.0, 96.0);

            image1.Source = wbm;
            image2.Source = wbm2;

            image.ReleaseAccess(data);
            dimage.ReleaseAccess(data2);
            sm.ReleaseFrame();
            sm.Close();
            session.Dispose();
        }
Exemplo n.º 5
0
        /**
         * Initialises View and starts updater Thread
         * @param model - reference to data model
         * @param Mode.Mode m - mode the UI should run
         */
        public CameraView(Model model, Model.MODE m)
        {
            KeyPreview = true;

            this.model = model;
            model.View = this;
            testMode   = m == Model.MODE.TEST;
            session    = PXCMSession.CreateInstance();

            if (session == null) // Something went wrong, session could not be initialised
            {
                Application.Exit();
                return;
            }

            iv = session.QueryVersion();
            String versionString = "v" + iv.major + "." + iv.minor;

            Text = versionString;


            pb          = new PictureBox();
            FormClosed += new FormClosedEventHandler(Quit);

            if ((m == Model.MODE.TEST))
            {
                // Set size
                pb.Bounds = new Rectangle(0, 0, model.Width, model.Height);
                // init UI
                this.Bounds = new Rectangle(0, 0, model.Width, model.Height + 180);
                this.Controls.Add(pb);

                enableOutput.Bounds = new Rectangle(20, 1080, 500, 30);
                enableOutput.Text   = "Output";
                enableOutput.Click +=
                    new System.EventHandler(delegate
                {
                    outputEnabled = !outputEnabled;
                });
                AddComponent(enableOutput);

                enableImage.Bounds = new Rectangle(20, 1110, 500, 30);
                enableImage.Text   = "NoImg";
                enableImage.Click +=
                    new System.EventHandler(delegate
                {
                    imageEnabled = !imageEnabled;
                });
                AddComponent(enableImage);
            }
            else
            {
                windowBitmap      = new Bitmap(Bitmap.FromFile(Directory.GetCurrentDirectory() + "\\Images\\window.png"));
                smallWindowBitmap = new Bitmap(Bitmap.FromFile(Directory.GetCurrentDirectory() + "\\Images\\small_window.png"));
                warningBitmap     = new Bitmap(Bitmap.FromFile(Directory.GetCurrentDirectory() + "\\Images\\warning.png"));
                this.Bounds       = Screen.PrimaryScreen.Bounds;
                FormBorderStyle   = FormBorderStyle.None;
                WindowState       = FormWindowState.Maximized;
                pb.Bounds         = new Rectangle(this.Bounds.Width / 2 - model.Width / 2, this.Bounds.Height / 2 - model.Height / 2, 1920, 1080);
                this.Controls.Add(pb);
                this.BackColor = Color.Black;
            }
            KeyDown += OnKeyDown;
            this.Show();
            // Start Updater Thread
            updaterThread = new Thread(this.update);
            updaterThread.Start();
        }