public ProjectorCameraEnsemble(int numProjectors, int numCameras)
        {
            projectors = new List<ProjectorCameraEnsemble.Projector>();
            for (int i = 0; i < numProjectors; i++)
            {
                var projector = new ProjectorCameraEnsemble.Projector();
                projector.name = i.ToString();
                projector.hostNameOrAddress = "localhost";
                projectors.Add(projector);
            }
            cameras = new List<ProjectorCameraEnsemble.Camera>();
            for (int i = 0; i < numCameras; i++)
            {
                var camera = new ProjectorCameraEnsemble.Camera();
                camera.name = i.ToString();
                camera.hostNameOrAddress = "localhost";
                cameras.Add(camera);

                if (i == 0)
                    camera.pose = RoomAliveToolkit.Matrix.Identity(4, 4);
            }
            name = "Untitled";

            imagingFactory = new SharpDX.WIC.ImagingFactory();
            stopWatch = new System.Diagnostics.Stopwatch();
        }
Example #2
0
        // could be method on Projector:
        void SetViewProjectionFromProjector(ProjectorCameraEnsemble.Projector projector)
        {
            // pick up view and projection for a given projector
            view = new SharpDX.Matrix();
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    view[i, j] = (float)projector.pose[i, j];
                }
            }
            view.Invert();
            view.Transpose();

            var   cameraMatrix = projector.cameraMatrix;
            float fx           = (float)cameraMatrix[0, 0];
            float fy           = (float)cameraMatrix[1, 1];
            float cx           = (float)cameraMatrix[0, 2];
            float cy           = (float)cameraMatrix[1, 2];

            float near = 0.1f;
            float far  = 100.0f;

            float w = projector.width;
            float h = projector.height;

            projection = ProjectionMatrixFromCameraMatrix(fx, fy, cx, cy, w, h, near, far);
            projection.Transpose();
        }
Example #3
0
        internal void LoadCalibrationData()
        {
            cam        = this.GetComponent <Camera>();
            projConfig = null;
            if (hasCalibration)
            {
                ProjectorCameraEnsemble ensembleConfig = calibrationData.GetEnsemble();
                foreach (ProjectorCameraEnsemble.Projector pc in ensembleConfig.projectors)
                {
                    if (pc.name == nameInConfiguration)
                    {
                        projConfig = pc;
                    }
                }
            }
            else
            {
                projConfig = null;
            }


            if (projConfig != null)
            {
                if (displayIndex < 0)
                {
                    displayIndex = projConfig.displayIndex;
                }
                //Debug.Log("Projective Rendering - Loading projector calibration information.");
                imageWidth  = projConfig.width;
                imageHeight = projConfig.height;

                //// used by shadow etc...
                //// this is the vertical field of view - fy
                cam.aspect = (float)imageWidth / imageHeight;
                float fieldOfViewRad = 2.0f * (float)Math.Atan((((double)(imageHeight)) / 2.0) / projConfig.cameraMatrix[1, 1]);
                float fieldOfViewDeg = fieldOfViewRad / 3.14159265359f * 180.0f;
                cam.fieldOfView = fieldOfViewDeg;
                Matrix4x4 opencvProjMat = GetProjectionMatrix(projConfig.cameraMatrix, cam.nearClipPlane, cam.farClipPlane);
                cam.projectionMatrix = UnityUtilities.ConvertRHtoLH(opencvProjMat);

                //var irCoef = projConfig.lensDistortion.AsFloatArray();
                //! jolaur -- looks like this is not being used and is now 2 elements instead of four in the new xml format
                //! lensDist = new Vector4(irCoef[0], irCoef[1], irCoef[2], irCoef[3]);
                lensDist = new Vector4();

                Matrix4x4 worldToLocal = RAT2Unity.Convert(projConfig.pose);
                worldToLocal = UnityUtilities.ConvertRHtoLH(worldToLocal);
                this.transform.localPosition = worldToLocal.ExtractTranslation();
                this.transform.localRotation = worldToLocal.ExtractRotation();
            }
            else
            {
                Debug.Log("Projective Rendering - Using default camera calibration information.");
                lensDist = new Vector4();
            }
        }
        public ProjectorCameraEnsemble(int numProjectors, int numCameras)
        {
            projectors = new List<ProjectorCameraEnsemble.Projector>();
            for (int i = 0; i < numProjectors; i++)
            {
                var projector = new ProjectorCameraEnsemble.Projector();
                projector.name = i.ToString();
                projector.hostNameOrAddress = "localhost";
                projectors.Add(projector);
            }
            cameras = new List<ProjectorCameraEnsemble.Camera>();
            for (int i = 0; i < numCameras; i++)
            {
                var camera = new ProjectorCameraEnsemble.Camera();
                camera.name = i.ToString();
                camera.hostNameOrAddress = "localhost";
                cameras.Add(camera);

                if (i == 0)
                    camera.pose = RoomAliveToolkit.Matrix.Identity(4, 4);
            }
            name = "Untitled";
        }
Example #5
0
 public ProjectorForm(Factory factory, SharpDX.Direct3D11.Device device, Object renderLock, ProjectorCameraEnsemble.Projector projector) : base(factory, device, renderLock)
 {
     this.projector = projector;
     Text           = "Projector " + projector.name;
 }
Example #6
0
 public ProjectorForm(Factory factory, SharpDX.Direct3D11.Device device, Object renderLock, ProjectorCameraEnsemble.Projector projector)
     : base(factory, device, renderLock)
 {
     this.projector = projector;
     Text = "Projector " + projector.name;
 }