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;
        }
Example #2
0
        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);
        }