public ChessboardShapeTask(Window window, Projector projector, Chessboard chessboard) : base(window) { Projector = projector; Chessboard = chessboard; ColoredChessboard = new ColoredChessboard(Chessboard, Color.Black, Color.White); LoadOrDefault(projector.Window.ClientSize); }
public CalibrateIndirectlyTask(Window window, IEnumerable<CaptureCamera> captureCameras, Projector projector, Chessboard chessboard) : base(window) { CaptureCameras = captureCameras; Chessboard = chessboard; Projector = projector; ProjectorQuadCorners = Chessboard.GetDefaultImageQuadCorners(projector.Window.ClientSize); WorldToProjectorHom = Chessboard.GetHomographyTo(ProjectorQuadCorners); ColoredChessboard = new ColoredChessboard(Chessboard, Color.Black, Color.White, WorldToProjectorHom.ToMatrixFromHomogeneous3x3()); Circles = Chessboard.Saddles.Select(s => new Circle2D(s.ToVector3(z: 0.01f), 10, 4, Color.Crimson) { AlreadyInScreenSpace = false } ).ToList(); }
public ProgramTask() { Monitor.ClientSize = new Size(640, 480); ColoredChessboard = new ColoredChessboard(Chessboard, Color.CornflowerBlue.Alpha(0.9f), Color.Orange.Alpha(0.3f)); var maybeSecondaryScreen = Screen.AllScreens.Where(s => s != Screen.PrimaryScreen).FirstOrDefault() ?? Screen.PrimaryScreen; // Projector = new RealProjector("Optoma EW1610", "1018", maybeSecondaryScreen.Bounds.Size, maybeSecondaryScreen); var virtualProjectorOrbit = new OrbitCamera("Virtual Projector Orbit", "N/A", new Size(1280, 800), new PointF(640, 850), 100, 2, 134); Projector = new VirtualProjector(Monitor, virtualProjectorOrbit); WorldCamera = new OrbitCamera("World Orbit", "1018", Monitor.Size, Monitor.Size.CenterF(), Monitor.Size.Width, 0.1f, 100) { Center = Chessboard.VertexCenter, Distance = 56, YawPitch = new Vector2(0.2f, -0.2f), }; WorldScene = new Scene(WorldCamera) { // MakeColoredAxisOfLength(Vector3.UnitX, Color.Red, length: 20.0f), // MakeColoredAxisOfLength(Vector3.UnitY, Color.Green, length: 20.0f), // MakeColoredAxisOfLength(Vector3.UnitZ, Color.Blue, length: 20.0f), // ColoredChessboard, // new Grid(Matrix.CreateRotationX(MathHelper.PiOver2), Color.Red.Lerp(Color.White, 0.9f).Alpha(0.3f), Color.Red.Alpha(0.5f)), // new Grid(Matrix.CreateRotationY(-MathHelper.PiOver2), Color.Green.Lerp(Color.White, 0.9f).Alpha(0.1f), Color.Green.Alpha(0.3f)), // new Grid(Matrix.Identity, Color.Blue.Lerp(Color.White, 0.9f).Alpha(0.1f), Color.Blue.Alpha(0.4f)), new MeshModel("ManStanding", Matrix.CreateScale(0.1f) * Matrix.CreateRotationY(-MathHelper.PiOver2) * Matrix.CreateTranslation(4, 0, 2)) { ProjectorViewProject = Projector }, new MeshModel("MutantStanding", Matrix.CreateScale(0.4f) * Matrix.CreateRotationY(0) * Matrix.CreateTranslation(8, 0, 1)) { ProjectorViewProject = Projector }, new MeshModel("HeadFemale", Matrix.CreateScale(0.2f) * Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateTranslation(-3, 6, 0)) { ProjectorViewProject = Projector }, }; CaptureCameras = CreateCaptureCameras().ToList(); if (CaptureCameras.IsEmpty()) AddVirtualCaptureCamera("VirCam 1", "1018", Color.Red); CaptureCameraSelectionPictureGray = new Picture2D(CaptureCameraSelected.Intrinsics.ImageSize.LimitProportional(290, 290).AnchorWithin(Monitor.ClientRectangle, AnchorPoints.BottomLeft), CaptureCameraSelected.Capture.GrayTexture2D); CaptureCameraSelectionPictureRgba = new Picture2D(CaptureCameraSelected.Intrinsics.ImageSize.LimitProportional(290, 290).ToRect(CaptureCameraSelectionPictureGray.Rectangle.Left, CaptureCameraSelectionPictureGray.Rectangle.Top, AnchorPoints.BottomLeft), CaptureCameraSelected.Capture.RgbaTexture2D); CaptureCameraSelected.Highlight = true; WorldScene.Add(CaptureCameras); WorldScene.Add(Projector); Monitor.Scene = new Scene(new ScreenCamera(Monitor)) { new Clear(Color.LightGray), WorldScene, CaptureCameraSelectionPictureGray, CaptureCameraSelectionPictureRgba, }; LocateTrigger = new Trigger(() => new LocateTask(Monitor, CaptureCameraSelected, Chessboard).Run(), Keys.L); CalibrateTrigger = new Trigger(() => new CalibrateTask(Monitor, CaptureCameraSelected, Chessboard).Run(CaptureCameraSelected), Keys.C); ChessboardShapeTrigger = new Trigger(() => new ChessboardShapeTask(Monitor, Projector, Chessboard).Run(), Keys.S); CalibrateIndirectlyTrigger = new Trigger(() => { WorldScene.Remove(ColoredChessboard); return new CalibrateIndirectlyTask(Monitor, CaptureCameras, Projector, Chessboard).Run(WorldScene); }, Keys.I); GrayScanTrigger = new Trigger(() => new GrayScanTask(Monitor, CaptureCameras.First(), Projector).Run(WorldScene), Keys.G); AttachInputToCamera(Program.WhenInput.Where(input => !input.KeyPressed(Keys.LeftAlt)), Monitor, WorldCamera); AttachInputToCamera(Program.WhenInput.Where(input => input.KeyPressed(Keys.LeftAlt)), Monitor, virtualProjectorOrbit); AttachPerformanceBar(); Program.WhenInput.Where(input => input.KeyDown(Keys.Tab)).Subscribe(input => { CaptureCameraSelected.Highlight = false; CaptureCameraSelectionIdx = (CaptureCameraSelectionIdx + 1) % CaptureCameras.Count; CaptureCameraSelected.Highlight = true; CaptureCameraSelectionPictureGray.Texture2D = CaptureCameraSelected.Capture.GrayTexture2D; CaptureCameraSelectionPictureRgba.Texture2D = CaptureCameraSelected.Capture.RgbaTexture2D; }); }