Esempio n. 1
0
        public ProjectorForm(int screenIndex)
        {
            InitializeComponent();
            this.screenIndex = screenIndex;
            ShowInTaskbar    = false;

            FormBorderStyle = FormBorderStyle.None;


            // assumes that taskbar is not displayed on every display

            bounds        = Screen.AllScreens[screenIndex].Bounds;
            StartPosition = FormStartPosition.Manual;
            Location      = new System.Drawing.Point(bounds.X, bounds.Y);
            Size          = new Size(bounds.Width, bounds.Height);

            // Gray code
            grayCode       = new GrayCode(bounds.Width, bounds.Height);
            grayCodeImages = grayCode.Generate();
        }
Esempio n. 2
0
        public ProjectorForm(int screenIndex)
        {
            InitializeComponent();
            this.screenIndex = screenIndex;
            ShowInTaskbar = false;

            FormBorderStyle = FormBorderStyle.None;


            // assumes that taskbar is not displayed on every display

            bounds = Screen.AllScreens[screenIndex].Bounds;
            StartPosition = FormStartPosition.Manual;
            Location = new System.Drawing.Point(bounds.X, bounds.Y);
            Size = new Size(bounds.Width, bounds.Height);

            // Gray code 
            grayCode = new GrayCode(bounds.Width, bounds.Height);
            grayCodeImages = grayCode.Generate();


        }
        public void DecodeGrayCodeImages(string directory)
        {
            stopWatch.Start();

            // decode Gray code captures
            foreach (var projector in projectors)
            {
                string projectorDirectory = directory + "/projector" + projector.name;

                var grayCode = new GrayCode(projector.width, projector.height);

                // allocate space for captured images
                int nCapturedImages = 2 * (grayCode.numXBits + grayCode.numYBits); // varies by projector
                var capturedImages = new ByteImage[nCapturedImages];
                for (int i = 0; i < nCapturedImages; i++) // varies by projector
                    capturedImages[i] = new ByteImage(Kinect2Calibration.colorImageWidth, Kinect2Calibration.colorImageHeight);

                foreach (var camera in cameras)
                {
                    Console.WriteLine("decoding Gray code images for projector " + projector.name + ", camera " + camera.name);

                    string cameraDirectory = projectorDirectory + "/camera" + camera.name;

                    // load and decode Gray code images
                    for (int i = 0; i < nCapturedImages; i++)
                        LoadFromTiff(imagingFactory, capturedImages[i], cameraDirectory + "/grayCode" + i + ".tiff");

                    var decodedColumns = new ShortImage(Kinect2Calibration.colorImageWidth, Kinect2Calibration.colorImageHeight);
                    var decodedRows = new ShortImage(Kinect2Calibration.colorImageWidth, Kinect2Calibration.colorImageHeight);
                    var mask = new ByteImage(Kinect2Calibration.colorImageWidth, Kinect2Calibration.colorImageHeight);

                    // TODO: there are a couple of interesting thresholds in Decode; they should be surfaced here
                    grayCode.Decode(capturedImages, decodedColumns, decodedRows, mask);

                    //Console.WriteLine("saving camera " + camera.displayName);

                    SaveToTiff(imagingFactory, decodedColumns, cameraDirectory + "/decodedColumns.tiff");
                    SaveToTiff(imagingFactory, decodedRows, cameraDirectory + "/decodedRows.tiff");
                    SaveToTiff(imagingFactory, mask, cameraDirectory + "/mask.tiff");

                    var decodedColumnsMasked = new ShortImage(Kinect2Calibration.colorImageWidth, Kinect2Calibration.colorImageHeight);
                    var decodedRowsMasked = new ShortImage(Kinect2Calibration.colorImageWidth, Kinect2Calibration.colorImageHeight);

                    for (int y = 0; y < Kinect2Calibration.colorImageHeight; y++)
                        for (int x = 0; x < Kinect2Calibration.colorImageWidth; x++)
                        {
                            if (mask[x, y] > 0)
                            {
                                decodedColumnsMasked[x, y] = decodedColumns[x, y];
                                decodedRowsMasked[x, y] = decodedRows[x, y];
                            }
                            else
                            {
                                decodedColumnsMasked[x, y] = 0;
                                decodedRowsMasked[x, y] = 0;
                            }
                        }
                    SaveToTiff(imagingFactory, decodedColumnsMasked, cameraDirectory + "/decodedColumnsMasked.tiff");
                    SaveToTiff(imagingFactory, decodedRowsMasked, cameraDirectory + "/decodedRowsMasked.tiff");
                }
            }

            Console.WriteLine("elapsed time " + stopWatch.ElapsedMilliseconds);
        }