Beispiel #1
0
        public async Task Run(Scene worldScene)
        {
            WriteLine("Scanning...");

            var scene = Projector.Scene;
            var size = Projector.Intrinsics.ImageSize;

            WriteLine("Black, White, Color, and Mask...");

            var clearBlack = new Clear(Color.Black);
            await GetBlackWhiteAndMask(scene);

            WriteLine("Horizontal...");

            var horSgc = new SafeGrayCode(size.Width);
            var horGcs = new GrayCodeSweep(horSgc, size.Height, GrayCodeSweep.Direction.Horizontal);            
            scene.Clear();
            scene.Add(horGcs);
            var horAssembly = await SweepGrayCode(horGcs);

            int[] verAssembly = null;
            
            WriteLine("Vertical...");

            var verSgc = new SafeGrayCode(size.Height);
            var verGcs = new GrayCodeSweep(verSgc, size.Width, GrayCodeSweep.Direction.Vertical);
            scene.Clear();
            scene.Add(verGcs);
            verAssembly = await SweepGrayCode(verGcs);

            scene.Clear();
            scene.Add(new Clear(Color.White));

            WriteLine("Making...");

            await Make(horAssembly, verAssembly, worldScene);

            WriteLine("Done...");
        }
Beispiel #2
0
        private async Task<int[]> SweepGrayCode(GrayCodeSweep gcs)
        {
            var sweeps = new List<Picture<Gray, byte>>(gcs.Sgc.NumBits);
            using (Disposable.Create(() => sweeps.Run(s => Util.Dispose(ref s))))
            {
                for (int b = 0; b < gcs.Sgc.NumBits; ++b)
                {
                    gcs.Bit = b;
                    using (var positive = await RenderThenCapture("Positive {0} [{1}/{2}]".FormatWith(gcs.Dir, gcs.Bit, gcs.Sgc.NumBits)))
                    {
                        gcs.Invert();
                        using (var negative = await RenderThenCapture("Negative {0} [{1}/{2}]".FormatWith(gcs.Dir, gcs.Bit, gcs.Sgc.NumBits)))
                        {
                            gcs.Invert();

                            var gray = Binarize(positive, negative);
                            sweeps.Add(gray);
                        }
                    }
                }

                return await Assemble(sweeps, gcs.Sgc);
            }
        }