/// <summary>
        /// Updates the camera setup to have the given number of cameras.
        /// </summary>
        /// <param name="cameraCount"></param> The number of cameras for the setup.
        public void ChangeCameraCount(int cameraCount)
        {
            CameraModel cameraParams = CameraModel.CreateCameraModel();

            // If there are already cameras in the setup, use one of them as the model.
            if (cameraModels != null && cameraModels.Length > 0)
            {
                cameraParams.ParametersFromCameraModel(cameraModels[0]);
            }
            else
            {
                cameraParams.SetCameraReferenceIndexAndImageName(cameraParams.cameraReferenceIndex, "Image");
            }
            // Update the camera setup, using this camera as a model.
            ResetCameraModels();
            cameraModels = new CameraModel[cameraCount];
            for (int iter = 0; iter < cameraModels.Length; iter++)
            {
                CameraModel cameraModel = AddCameraModel(iter);
                cameraModel.ParametersFromCameraModel(cameraParams);
                cameraModel.SetCameraReferenceIndexAndImageName(cameraModel.cameraReferenceIndex, cameraModel.imageName + GeneralToolkit.ToString(iter));
            }
            // Destroy the temporary camera model.
            DestroyImmediate(cameraParams.gameObject);
        }
        /// <summary>
        /// Saves additional information related to acquisition, with the given values.
        /// </summary>
        /// <param name="cameraSetup"></param> The camera setup containing the acquisition information.
        public void SaveCOLIBRIVRAdditionalInformation(CameraSetup cameraSetup)
        {
            // Determine the camera model, or initialize a new one if there is none.
            CameraModel cameraParams;

            if (cameraSetup.cameraModels != null)
            {
                cameraParams = cameraSetup.cameraModels[0];
            }
            else
            {
                cameraParams = CameraModel.CreateCameraModel();
            }
            // Get the initial viewing position.
            Vector3 initialViewingPos = cameraSetup.initialViewingPosition;

            // Store this information in the additional information file.
            GeneralToolkit.CreateOrClear(PathType.File, additionalInfoFile);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("# COLIBRI VR additional information:");
            stringBuilder.AppendLine("#   INITIAL_VIEWING_POSITION");
            string line = initialViewingPos.x + " " + initialViewingPos.y + " " + initialViewingPos.z;

            stringBuilder.AppendLine(line);
            File.WriteAllText(additionalInfoFile, stringBuilder.ToString());
            // Delete any temporary camera model.
            if (cameraSetup.cameraModels == null)
            {
                DestroyImmediate(cameraParams.gameObject);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Adds a camera model to the setup.
        /// </summary>
        /// <param name="setupIndex"></param> Index of the newly-created camera in the setup.
        /// <returns></returns> The created camera model.
        public CameraModel AddCameraModel(int setupIndex)
        {
            CameraModel cameraModel = CameraModel.CreateCameraModel(transform);

            cameraModels[setupIndex] = cameraModel;
#if UNITY_EDITOR
            UpdateGizmoColor(setupIndex);
#endif //UNITY_EDITOR
            return(cameraModel);
        }
        /// <summary>
        /// Saves additional information related to acquisition, with the given values.
        /// </summary>
        /// <param name="cameraSetup"></param> The camera setup containing the acquisition information.
        public void SaveAdditionalSetupInformation(CameraSetup cameraSetup)
        {
            // Determine the camera model, or initialize a new one if there is none.
            CameraModel cameraParams;

            if (cameraSetup.cameraModels != null && cameraSetup.cameraModels.Length > 0)
            {
                cameraParams = cameraSetup.cameraModels[0];
            }
            else
            {
                cameraParams = CameraModel.CreateCameraModel();
            }
            // Store the initial viewing position.
            Vector3 initialViewingPos = cameraSetup.initialViewingPosition;

            GeneralToolkit.CreateOrClear(PathType.File, additionalInfoFile);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("# Additional setup information:");
            stringBuilder.AppendLine("#   INITIAL_VIEWING_POSITION");
            string line = GeneralToolkit.ToString(initialViewingPos.x) + " " + GeneralToolkit.ToString(initialViewingPos.y) + " " + GeneralToolkit.ToString(initialViewingPos.z);

            stringBuilder.AppendLine(line);
            // Store the minimum/maximum distance range
            stringBuilder.AppendLine("#   Distance ranges with one line of data per camera:");
            stringBuilder.AppendLine("#   CAMERA_ID DISTANCE_RANGE_MIN DISTANCE_RANGE_MAX");
            foreach (CameraModel camera in cameraSetup.cameraModels)
            {
                Vector2 distanceRange = camera.distanceRange;
                stringBuilder.AppendLine(GeneralToolkit.ToString(camera.cameraReferenceIndex) + " " + GeneralToolkit.ToString(distanceRange.x) + " " + GeneralToolkit.ToString(distanceRange.y));
            }
            // Save the file.
            File.WriteAllText(additionalInfoFile, stringBuilder.ToString());
            // Delete any temporary camera model.
            if (cameraSetup.cameraModels == null)
            {
                DestroyImmediate(cameraParams.gameObject);
            }
        }