public static void Serialize(ICalibrationData template, string fileName) { try { var serializer = new BinaryFormatter(); var stream = new FileStream(fileName, FileMode.Create); serializer.Serialize(stream, template); stream.Flush(); stream.Close(); } catch (Exception ex) { throw new Exception(String.Format("Unable to serialize to file: {0}", ex.Message), ex); } }
private void StartPlayback() { currentTime = 0; currentFrameIndex = 0; recordingForPlayback = JsonUtility.FromJson <CalibrationRecording>(File.ReadAllText(indexFilePath)); ApplyFrame(currentFrameIndex); CompositionManager compositionManager = GetCompositionManager(); HolographicCameraObserver networkManager = GetHolographicCameraObserver(); previousCalibrationData = compositionManager.CalibrationData; compositionManager.EnableHolographicCamera(networkManager.transform, calibrationDataForPlayback); testCube = GameObject.CreatePrimitive(PrimitiveType.Cube); testCube.transform.localScale = Vector3.one * DeviceInfoObserver.arUcoMarkerSizeInMeters; testCube.transform.localPosition = new Vector3(0.0f, 0.0f, 0.05f); }
/// <summary> /// Enables the holographic camera rig for compositing. The hologram camera will be adjusted to match /// calibration data (its position and rotation will track the external camera, and its projection matrix /// will match the calibration information for the video camera used for compositing). /// </summary> /// <param name="parent">The parent transform that the holographic camera rig should be attached to.</param> /// <param name="calibrationData">The calibration data used to set up the position, rotation, and /// projection matrix for the holographic camera.</param> public void EnableHolographicCamera(Transform parent, ICalibrationData calibrationData) { #if UNITY_EDITOR this.calibrationData = calibrationData; if (videoCameraPose == null) { videoCameraPose = new GameObject("Camera HMD Pose"); } videoCameraPose.transform.SetParent(parent); videoCameraPose.transform.localPosition = Vector3.zero; videoCameraPose.transform.localRotation = Quaternion.identity; gameObject.transform.parent = videoCameraPose.transform; calibrationData.SetUnityCameraExtrinstics(transform); calibrationData.SetUnityCameraIntrinsics(GetComponent <Camera>()); IsCalibrationDataLoaded = true; #endif }
private void UpdateCalibrationFileForPlayback() { isCalibrationDataParsed = false; try { if (File.Exists(calibrationFilePath)) { byte[] calibrationDataPayload = File.ReadAllBytes(calibrationFilePath); CalculatedCameraCalibration calibration; if (CalculatedCameraCalibration.TryDeserialize(calibrationDataPayload, out calibration)) { calibrationDataForPlayback = new CalibrationData(calibration.Intrinsics, calibration.Extrinsics); isCalibrationDataParsed = true; } } } catch (Exception ex) { Debug.LogWarning($"Unexpected exception parsing file {indexFilePath}: {ex.ToString()}"); } }
public void SetCalibrationData(ICalibrationData data) { var myCalData = data as SorterVisionCalibrationData; if (myCalData != null) { ChessboardPoints = myCalData.ChessboardPoints; } }
public void SetCalibrationData(ICalibrationData data) { var myCalData = data as CalibrationDataTestMock; if (myCalData != null) { this._stringData = myCalData.StringData; } }