public override double Calculate() { Vector2d result = projector.GetCoordinatesForScreenPoint(point.X, point.Y); switch (point.AxisType) { case AxisTypes.Alt: { double dist = (result.Y - point.Alt) * 100 * point.Weight; return(dist); } case AxisTypes.Az: { double dist = (result.X - (-point.Az + 270)) * 100 * point.Weight; return(dist); } case AxisTypes.Both: { Vector2d test = new Vector2d(-point.Az + 270, point.Alt); double dist = result.Distance3d(test) * 100 * point.Weight; return(dist); } case AxisTypes.Edge: default: return(0); } }
public override double Calculate() { Vector2d resultLeft = left.GetCoordinatesForScreenPoint(point.Left.X, point.Left.Y); Vector2d resultRight = right.GetCoordinatesForScreenPoint(point.Right.X, point.Right.Y); double dist = resultLeft.Distance3d(resultRight) * 100 * point.Left.Weight; return(dist); }
private void ProjectorList_SelectedIndexChanged(object sender, EventArgs e) { var pe = (ProjectorEntry)ProjectorList.SelectedItem; var sp = new SolveProjector(pe, CalibrationInfo.DomeSize, CalibrationInfo.ScreenType == ScreenTypes.FishEye ? ProjectionType.FishEye : ProjectionType.Projector, ScreenTypes.Spherical, SolveParameters.Default); var pnt = sp.GetCoordinatesForScreenPoint(pe.Width / 2.0, pe.Height / 2.0); sp.GetCoordinatesForScreenPoint(pe.Width/2 + 1, pe.Height/2.0); var pntCamera = sp.GetCoordinatesForProjector(); var pntRayDirection = GetPointFromAltAz(new PointF((float)pnt.X+90, (float)pnt.Y)); var pntProj = GetPointFromAltAz(new PointF((float)pntCamera.X+90, (float)pntCamera.Y)); Refresh(); MousePad.Refresh(); var g = MousePad.CreateGraphics(); g.DrawLine(Pens.Yellow, pntRayDirection, pntProj); g.DrawRectangle(Pens.Red, pntProj.X - 5, pntProj.Y - 5, 10, 10); g.Dispose(); }
public static Bitmap MakeWarpMap(ProjectorEntry pe, double domeSize, bool radialDistortion, List<GroundTruthPoint> gtPointList, ScreenTypes screenType) { List<Vector2d> PointTo = new List<Vector2d>(); List<Vector2d> PointFrom = new List<Vector2d>(); double xFactor = pe.Width / 512.0; double yFactor = pe.Height / 512.0; Bitmap bmp = new Bitmap(512, 512); FastBitmap fastBmp = new FastBitmap(bmp); SolveProjector spProjector = new SolveProjector(pe, domeSize, ProjectionType.Projector, screenType, SolveParameters.Default); spProjector.RadialDistorion = radialDistortion; SolveProjector spView = new SolveProjector(pe, domeSize, ProjectionType.View, ScreenTypes.Spherical, SolveParameters.Default); spView.RadialDistorion = false; foreach (GroundTruthPoint gt in gtPointList) { PointFrom.Add(new Vector2d((double)gt.X / (double)pe.Width * 512, (double)gt.Y / (double)pe.Height * 512)); Vector2d pntOutTarget = spView.ProjectPoint(new Vector2d(gt.Az, gt.Alt)); Vector2d AltAzMapped = spProjector.GetCoordinatesForScreenPoint(gt.X,gt.Y); Vector2d pntOutMapped = spView.ProjectPoint(new Vector2d(AltAzMapped.X, AltAzMapped.Y)); pntOutTarget.X = pntOutTarget.X *(512 / 2.0) + (512 / 2.0); pntOutTarget.Y = pntOutTarget.Y *(-512 / 2.0) + (512 / 2.0); pntOutMapped.X = pntOutMapped.X *(512 / 2.0) + (512 / 2.0); pntOutMapped.Y = pntOutMapped.Y *(-512 / 2.0) + (512 / 2.0); PointTo.Add(new Vector2d(pntOutTarget.X - pntOutMapped.X, pntOutTarget.Y - pntOutMapped.Y)); } //Matrix3d projMat = spView.GetCameraMatrix(); unsafe { fastBmp.LockBitmap(); for (int y = 0; y < 512; y++) { for (int x = 0; x < 512; x++) { Vector2d pnt = spProjector.GetCoordinatesForScreenPoint(x * xFactor, y * yFactor); Vector2d pntOut = spView.ProjectPoint(pnt); // Map pntOut.X = pntOut.X * (512 / 2.0) + (512 / 2.0); pntOut.Y = pntOut.Y * (-512 / 2.0) + (512 / 2.0); pntOut = MapPoint(new Vector2d(x,y), pntOut, PointTo, PointFrom); pntOut.X = (pntOut.X - (512 / 2.0)) / (512 / 2.0); pntOut.Y = (pntOut.Y - (512 / 2.0)) / (-512 / 2.0); // End Map double xo = pntOut.X * (4096 / 2.0) + (4096 / 2.0); double yo = pntOut.Y * (-4096 / 2.0) + (4096 / 2.0); int blue = (int)xo & 255; int green = (int)yo & 255; int red = (((int)yo) >> 4 & 240) + (((int)xo) >> 8 & 15); *fastBmp[x, y] = new PixelData(red, green, blue, 255); } } fastBmp.UnlockBitmap(); } return bmp; }
public static Bitmap MakeWarpMap(ProjectorEntry pe, double domeSize, bool radialDistortion, List <GroundTruthPoint> gtPointList, ScreenTypes screenType) { List <Vector2d> PointTo = new List <Vector2d>(); List <Vector2d> PointFrom = new List <Vector2d>(); double xFactor = pe.Width / 512.0; double yFactor = pe.Height / 512.0; Bitmap bmp = new Bitmap(512, 512); FastBitmap fastBmp = new FastBitmap(bmp); SolveProjector spProjector = new SolveProjector(pe, domeSize, ProjectionType.Projector, screenType, SolveParameters.Default); spProjector.RadialDistorion = radialDistortion; SolveProjector spView = new SolveProjector(pe, domeSize, ProjectionType.View, ScreenTypes.Spherical, SolveParameters.Default); spView.RadialDistorion = false; foreach (GroundTruthPoint gt in gtPointList) { PointFrom.Add(new Vector2d((double)gt.X / (double)pe.Width * 512, (double)gt.Y / (double)pe.Height * 512)); Vector2d pntOutTarget = spView.ProjectPoint(new Vector2d(gt.Az, gt.Alt)); Vector2d AltAzMapped = spProjector.GetCoordinatesForScreenPoint(gt.X, gt.Y); Vector2d pntOutMapped = spView.ProjectPoint(new Vector2d(AltAzMapped.X, AltAzMapped.Y)); pntOutTarget.X = pntOutTarget.X * (512 / 2.0) + (512 / 2.0); pntOutTarget.Y = pntOutTarget.Y * (-512 / 2.0) + (512 / 2.0); pntOutMapped.X = pntOutMapped.X * (512 / 2.0) + (512 / 2.0); pntOutMapped.Y = pntOutMapped.Y * (-512 / 2.0) + (512 / 2.0); PointTo.Add(new Vector2d(pntOutTarget.X - pntOutMapped.X, pntOutTarget.Y - pntOutMapped.Y)); } //Matrix3d projMat = spView.GetCameraMatrix(); unsafe { fastBmp.LockBitmap(); for (int y = 0; y < 512; y++) { for (int x = 0; x < 512; x++) { Vector2d pnt = spProjector.GetCoordinatesForScreenPoint(x * xFactor, y * yFactor); Vector2d pntOut = spView.ProjectPoint(pnt); // Map pntOut.X = pntOut.X * (512 / 2.0) + (512 / 2.0); pntOut.Y = pntOut.Y * (-512 / 2.0) + (512 / 2.0); pntOut = MapPoint(new Vector2d(x, y), pntOut, PointTo, PointFrom); pntOut.X = (pntOut.X - (512 / 2.0)) / (512 / 2.0); pntOut.Y = (pntOut.Y - (512 / 2.0)) / (-512 / 2.0); // End Map double xo = pntOut.X * (4096 / 2.0) + (4096 / 2.0); double yo = pntOut.Y * (-4096 / 2.0) + (4096 / 2.0); int blue = (int)xo & 255; int green = (int)yo & 255; int red = (((int)yo) >> 4 & 240) + (((int)xo) >> 8 & 15); * fastBmp[x, y] = new PixelData(red, green, blue, 255); } } fastBmp.UnlockBitmap(); } return(bmp); }