예제 #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...");
        }
예제 #2
0
        private async Task GetBlackWhiteAndMask(Scene scene)
        {
            Util.Dispose(ref Black);
            Util.Dispose(ref White);
            Util.Dispose(ref Colored);
            Util.Dispose(ref Mask);

            var clearBlack = new Clear(Color.Black);
            var clearWhite = new Clear(Color.White);
            var clearLightish = new Clear(Color.WhiteSmoke);

            scene.Clear();
            scene.Add(clearBlack);
            Black = await RenderThenCapture("Black");

            scene.Clear();
            scene.Add(clearWhite);
            White = await RenderThenCapture("White");

            scene.Clear();
            scene.Add(clearLightish);
            Colored = await RenderThenCaptureColored("Colored");

            var maskThreshold = new Gray(75);
            var maskOn = new Gray(255);
            Mask = new Picture<Gray, byte>(White.Width, White.Height);
            (White.Emgu - Black.Emgu).ThresholdBinary(maskThreshold, maskOn).CopyTo(Mask.Emgu);

            Black.Emgu.Save(Global.TmpFileName("black", "png"));
            White.Emgu.Save(Global.TmpFileName("white", "png"));
            Mask.Emgu.Save(Global.TmpFileName("mask", "png"));
            Colored.Emgu.Convert<Bgr, byte>().Save(Global.TmpFileName("colored", "png"));
        }