//loads settings public static void loadCalibration(out Matrix4x4 result, out float colorBlend) { string destination = Application.persistentDataPath + "/calibration.dat"; FileStream file; result = new Matrix4x4(); if (File.Exists(destination)) { file = File.OpenRead(destination); } else { result = Matrix4x4.identity; result.m22 = -1; result.m23 = -5; colorBlend = 0.16f; return; } BinaryFormatter bf = new BinaryFormatter(); CalibrationData data = (CalibrationData)bf.Deserialize(file); file.Close(); for (int i = 0; i < 16; i++) { result[i] = data.matrix[i]; } colorBlend = data.colorBlend; }
public bool TrySaveCalibration(string name, CalibrationData calibration, out CalibrationInfo info) { var calibrations = GetStoredCalibrations(); info = calibrations.FirstOrDefault(c => c.Name.Equals(name) && c.DeviceFamilyName.Equals(calibration.DeviceFamilyName)); if (info == null) { info = CalibrationInfo.Create(name, calibration.DeviceFamilyName, calibration.DeviceName, DateTime.Now); calibrations = new List <CalibrationInfo>(calibrations.Prepend(info)); } else { info.CreatedAt = DateTime.Now; } string path = GetCalibrationFilePath(info); EnsureRootDirectoryExists(); File.WriteAllBytes(GetCalibrationFilePath(info), calibration.Data); SaveCalibrationsIndex(calibrations); return(true); }
private void ReadCalibrationData() { const byte READ_PROM = 0xA6; byte[] commands = new byte[] { 0xA0, 0xA2, 0xA4, 0xA6, 0xA8, 0xAA, 0xAC, 0xAE }; byte[] results = new byte[16]; for (int i = 0; i < commands.Length; i++) { //_i2cBus.Write(_i2cConfig, new byte[] { commands[i] }, I2C_TIMEOUT); byte[] temp = new byte[2]; //_i2cBus.Read(_i2cConfig, temp, I2C_TIMEOUT); _i2cBus.ReadRegister(_i2cConfig, commands[i], temp, I2C_TIMEOUT); Array.Copy(temp, 0, results, 2 * i, 2); } _calibrationData = new CalibrationData(results); }
internal AutomaticFbtCalibrationHost(PlayerAvatarManager avatarManager, VRPlayerInputInternal playerInput, Settings settings, CalibrationData calibrationData) { _avatarManager = avatarManager; _playerInput = playerInput; _settings = settings; _calibrationData = calibrationData; }
public TrackData() { eyesROI = new Rectangle(); leftROI = new Rectangle(); rightROI = new Rectangle(); pupilDataLeft = new PupilData(); pupilDataRight = new PupilData(); glintDataLeft = new GlintData(); glintDataRight = new GlintData(); calibrationDataLeft = new CalibrationData(); calibrationDataRight = new CalibrationData(); gazeDataRaw = new GTGazeData(); gazeDataSmoothed = new GTGazeData(); //eyeMovement = new GazeTrackingLibrary.EyeMovement.Classifier(); eyesDetected = false; eyeDetected = false; pupilLeftDetected = false; pupilRightDetected = false; glintsLeftDetected = false; glintsRightDetected = false; }
private void OnWiimoteChanged(object sender, WiimoteChangedEventArgs args) { mx.WaitOne(); try { if (isCalibrated) { controller.StartHandling(args.WiimoteState); } else if (calibrating) { isCalibrated = calibrator.Calibrate(args.WiimoteState); calibrating = !isCalibrated; if (isCalibrated) { lastCalibrationData = calibrator.GetCalibrationData(); } if (calibrator.HasChanged()) { Notify(); } } } catch (UserTerminatedException) { wiimote.Disconnect(); } mx.ReleaseMutex(); }
internal AvatarSpecificSettingsHost(PlayerAvatarManager avatarManager, VRPlayerInputInternal playerInput, Settings settings, CalibrationData calibrationData, ManualCalibrationHelper manualCalibrationHelper) { _avatarManager = avatarManager; _playerInput = playerInput; _settings = settings; _calibrationData = calibrationData; _manualCalibrationHelper = manualCalibrationHelper; }
public static CalibrationData Instance() { if (instance == null) { instance = new CalibrationData(); } return(instance); }
public void PrepareSave(CalibrationData data) { _resultData = data; IsSaved = false; saveCommand?.RaiseCanExecuteChanged(); OnPropertyChanged(nameof(CanSave)); }
public Task SetCalibrationAsync(CalibrationData calibration) { calibration.ThrowIf(c => c.DeviceFamilyName != FamilyName, nameof(calibration), "Calibration data is for a different family of devices."); _tracker.ApplyCalibrationData(new Tobii.Research.CalibrationData(calibration.Data)); return(Task.FromResult(true)); }
private void OnCalibrationFinished(CalibrationData data) { finishedCalibration = true; //calibratedText.color = Color.green; //projectionErrorText.color = Color.green; calibratedString = "Calibrated: True"; projectionErrorString = "ProjectionError: " + data.projectionError; }
public void StoreCalibrationData() { _participantCalibrationData = CalibrationManager.Instance.GetCalibrationData(); _participantCalibrationData.AverageExperimentFPS = _frameRates.Average(); _participantCalibrationData.ApplicationDuration = TimeManager.Instance.GetApplicationDuration(); _participantCalibrationData.ExperimentDuration = TimeManager.Instance.GetExperimentDuration(); _participantCalibrationData.TrainingSuccessState = CalibrationManager.Instance.GetTestDriveState(); _participantCalibrationData.NumberOfTrainingTrials = CalibrationManager.Instance.GetTestDriveNumberOfTrials(); }
private void Convert_A_page(CalibrationData calib) { cal_ax = (ax - calib.zero_ax) * calib.lsb_acc - calib.drift_ax; cal_ay = (ay - calib.zero_ay) * calib.lsb_acc - calib.drift_ay; cal_az = (az - calib.zero_az) * calib.lsb_acc - calib.drift_az; cal_gx = (gx - calib.zero_gx) * calib.lsb_gyro - calib.drift_gx; cal_gy = (gy - calib.zero_gy) * calib.lsb_gyro - calib.drift_gy; cal_gz = (gz - calib.zero_gz) * calib.lsb_gyro - calib.drift_gz; }
private AvatarTailor(ILoggerProvider loggerProvider, MainSettingsModelSO mainSettingsModel, PlayerDataModel playerDataModel, Settings settings, CalibrationData calibrationData, TrackedDeviceManager trackedDeviceManager) { _logger = loggerProvider.CreateLogger <AvatarTailor>(); _mainSettingsModel = mainSettingsModel; _playerDataModel = playerDataModel; _settings = settings; _calibrationData = calibrationData; _trackedDeviceManager = trackedDeviceManager; }
private void Inject(ILoggerProvider loggerProvider, PlayerAvatarManager avatarManager, Settings settings, CalibrationData calibrationData, ShaderLoader shaderLoader, VRPlayerInput playerInput) { _logger = loggerProvider.CreateLogger <SettingsViewController>(); _avatarManager = avatarManager; _settings = settings; _calibrationData = calibrationData; _shaderLoader = shaderLoader; _playerInput = playerInput; }
public static void Save(string avatarId, CalibrationPoint point, CalibrationData data) { if (!SavedAvatars.ContainsKey(avatarId)) { SavedAvatars[avatarId] = new Dictionary <CalibrationPoint, CalibrationData>(); } SavedAvatars[avatarId][point] = data; }
private void Inject(TrackedDeviceManager trackedDeviceManager, PlayerAvatarManager avatarManager, AvatarTailor avatarTailor, Settings settings, CalibrationData calibrationData, ShaderLoader shaderLoader, ILoggerProvider loggerProvider) { _trackedDeviceManager = trackedDeviceManager; _avatarManager = avatarManager; _avatarTailor = avatarTailor; _settings = settings; _calibrationData = calibrationData; _shaderLoader = shaderLoader; _logger = loggerProvider.CreateLogger <SettingsViewController>(); }
internal VRPlayerInput(ILoggerProvider loggerProvider, DeviceManager trackedDeviceManager, PlayerAvatarManager avatarManager, Settings settings, CalibrationData calibrationData, BeatSaberUtilities beatSaberUtilities, TrackingHelper trackingHelper) { _logger = loggerProvider.CreateLogger <VRPlayerInput>(); _deviceManager = trackedDeviceManager; _avatarManager = avatarManager; _settings = settings; _calibrationData = calibrationData; _beatSaberUtilities = beatSaberUtilities; _trackingHelper = trackingHelper; }
private void Awake() { //singleton pattern a la Unity if (Instance == null) { Instance = this; // DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } _desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); _desktopFolderPath = Path.GetFullPath(Path.Combine(_desktopPath, "WestdriveLoopARData")); _calibrationFilePath = GetPathForSaveFile("CalibrationData"); if (!File.Exists(_desktopPath)) { Directory.CreateDirectory(Path.GetFullPath(Path.Combine(_desktopPath, "WestdriveLoopARData"))); } if (File.Exists(_calibrationFilePath)) { _calibrationData = LoadCalibrationFile(_calibrationFilePath); } else { _calibrationData = new CalibrationData(); } if (!File.Exists(GetPathForSaveFolder("Input"))) { Directory.CreateDirectory(Path.GetFullPath(Path.Combine(_desktopFolderPath, "Input"))); } if (!File.Exists(GetPathForSaveFolder("EyeTracking"))) { Directory.CreateDirectory(Path.GetFullPath(Path.Combine(_desktopFolderPath, "EyeTracking"))); } if (!File.Exists(GetPathForSaveFolder("ParticipantCalibrationData"))) { Directory.CreateDirectory(Path.GetFullPath(Path.Combine(_desktopFolderPath, "ParticipantCalibrationData"))); } if (!File.Exists(GetPathForSaveFolder("SceneData"))) { Directory.CreateDirectory(Path.GetFullPath(Path.Combine(_desktopFolderPath, "SceneData"))); } _random = new Random(); }
private async void StoredCalibrations_CalibrationLoaded(object sender, CalibrationData data) { if (data != null && _calibrator.CanRestore(data)) { await _calibrator.RestoreAsync(data); } else { // TODO show error } }
static M_Page() { defaultCalibrationData = new CalibrationData(); defaultCalibrationData.zero_mx = 0; defaultCalibrationData.zero_my = 0; defaultCalibrationData.zero_mz = 0; defaultCalibrationData.fullScale_mag = 1000; // Full Scale ±1000uT defaultCalibrationData.lsb_mag = 0.1; // sensitivity 0.1uT/LSB }
public async Task <Exception> ProcessCalibrationData(bool isAccepted, CalibrationData calibrationData) { var result = await this.Provider.ProcessCalibrationData(isAccepted, calibrationData).ConfigureAwait(false); if (isAccepted) { AcquisitionConfigurationFactory.Instance.Update(this.ConfigurationFilePath, string.Format("Module.Providers.{0}.PPKMLeft", this.Configuration.Module.ActiveProviderName), ((DistanceCalibrationData)calibrationData).PpkmLeft); AcquisitionConfigurationFactory.Instance.Update(this.ConfigurationFilePath, string.Format("Module.Providers.{0}.PPKMRight", this.Configuration.Module.ActiveProviderName), ((DistanceCalibrationData)calibrationData).PpkmRight); } return(result); }
void SaveCalibratedData() { BinaryFormatter bf = new BinaryFormatter(); CalibrationData data = new CalibrationData(yUpSplit, xRightSplit, yDownSplit, xLeftSplit, Caps, CapsColors); using (FileStream stream = new FileStream(Application.persistentDataPath + FileName, FileMode.OpenOrCreate)) { bf.Serialize(stream, data); } Debug.Log("Caibration data saved!"); }
////*Raycasting*//// public void CreateRaycast() { float raycastTilt = new CalibrationData().Tilt(); raycastRot.eulerAngles = new Vector3(raycastTilt, 0.0f, 0.0f); GameObject newRaycastPos = new GameObject(); newRaycastPos.name = "RaycastPos"; raycastPos = newRaycastPos.transform; raycastPos.SetParent(this.headRot.transform); raycastPos.localPosition = new Vector3(0.0f, 0.15f, 0.1f); raycastPos.localRotation = raycastRot; }
public Task SetCalibrationAsync(CalibrationData calibrationData) { calibrationData.ThrowIf(c => c.DeviceFamilyName != FamilyName, nameof(calibrationData), "Calibration data is for the different family of devices."); IEnumerable <CalibrationPointResult> points = CalibrationSerializer.Deserialize(calibrationData.Data); var calibration = _calibration.Value; calibration.Clear(); calibration.AddRange(points); return(Task.FromResult(true)); }
//save the calibration in a serial binary file public void Save() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/calibration.dat", FileMode.OpenOrCreate); CalibrationData data = new CalibrationData(); data.keyboardOffsetLocalPositionX = keyboardOffset.localPosition.x; data.keyboardOffsetLocalPositionY = keyboardOffset.localPosition.y; data.keyboardOffsetLocalPositionZ = keyboardOffset.localPosition.z; data.keyboardOffsetLocalEulerAnglesX = keyboardOffset.localEulerAngles.x; data.keyboardOffsetLocalEulerAnglesY = keyboardOffset.localEulerAngles.y; data.keyboardOffsetLocalEulerAnglesZ = keyboardOffset.localEulerAngles.z; data.kinectOffsetPositionX = kinectOffset.position.x; data.kinectOffsetPositionZ = kinectOffset.position.z; data.kinectOffsetEulerAnglesY = kinectOffset.eulerAngles.y; data.kinectOffsetEulerAnglesZ = kinectOffset.eulerAngles.z; data.kinectFloorOffset = bodyTracker.floorOffset; data.viveMirrorPositionX = viveMirror.position.x; data.viveMirrorPositionY = viveMirror.position.y; data.viveMirrorPositionZ = viveMirror.position.z; data.viveMirrorEulerAnglesX = viveMirror.eulerAngles.x; data.viveMirrorEulerAnglesY = viveMirror.eulerAngles.y; data.viveMirrorEulerAnglesZ = viveMirror.eulerAngles.z; data.viveMirrorLocalScaleX = viveMirror.localScale.x; data.viveMirrorLocalScaleY = viveMirror.localScale.y; data.viveMirrorLocalScaleZ = viveMirror.localScale.z; data.projectionReflectionPositionX = projectionReflection.position.x; data.projectionReflectionPositionY = projectionReflection.position.y; data.projectionReflectionPositionZ = projectionReflection.position.z; data.projectionReflectionEulerAnglesX = projectionReflection.eulerAngles.x; data.projectionReflectionEulerAnglesY = projectionReflection.eulerAngles.y; data.projectionReflectionEulerAnglesZ = projectionReflection.eulerAngles.z; data.projectionReflectionHeight = projectionReflection.GetComponent <ReflectionTracker>().projectionHeight; data.projectionReflectionWidth = projectionReflection.GetComponent <ReflectionTracker>().projectionWidth; data.projectionReflectionZoom = projectionReflection.GetComponent <ReflectionTracker>().cameraZoom; data.audioRotationLocalEulerAnglesX = audioRotation.xRotation; data.audioRotationLocalEulerAnglesY = audioRotation.yRotation; data.audioRotationLocalEulerAnglesZ = audioRotation.zRotation; bf.Serialize(file, data); file.Close(); }
public void BuildMesh(bool left, int plat, Material mat) { curPlatform = plat; if (left) { leftEye = true; } if (curPlatform != 0) { androidCalib = new AndroidCalibration(); androidCalib.UpdateCalibration(); this.xSize = androidCalib.GetGridSizeX(); this.ySize = androidCalib.GetGridSizeY(); android = true; } else if (curPlatform == 0) { pcPlugin = new CalibrationData(); this.xSize = pcPlugin.GridX(); this.ySize = pcPlugin.GridY(); } meshMat = mat; if (android == false) { this.rotation = new Vector3(0.0f, 0.0f, -90.0f); } else if (android == true) { if (leftEye) { this.rotation = new Vector3(0.0f, 0.0f, -90.0f); } else { this.rotation = new Vector3(0.0f, 0.0f, 90.0f); } } GenerateMesh(); WarpMesh(); FindCenters(); CreateScreenCamera(); Destroy(GetComponent <Distortion>()); }
private void Start() { // GvrTrackerインスタンス取得 vrTacker = MobileVRTracker.Instance; calibData = new CalibrationData(); // PointCloudパーティクル初期化 particleBase = Instantiate(pointCloudParticlePrefab); frameUpdated = false; UnityARSessionNativeInterface.ARFrameUpdatedEvent += ARFrameUpdated; // Plane生成用Anchor anchorManager = new UnityARAnchorManager(); UnityARUtility.InitializePlanePrefab(planePrefab); }
internal VRPlayerInput(TrackedDeviceManager trackedDeviceManager, LoadedAvatar avatar, Settings settings, CalibrationData calibrationData) { _deviceManager = trackedDeviceManager; _settings = settings; _avatarSettings = settings.GetAvatarSettings(avatar.fileName); _calibrationData = calibrationData; _manualCalibration = calibrationData.GetAvatarManualCalibration(avatar.fileName); _deviceManager.deviceAdded += OnDevicesUpdated; _deviceManager.deviceRemoved += OnDevicesUpdated; _deviceManager.deviceTrackingAcquired += OnDevicesUpdated; _deviceManager.deviceTrackingLost += OnDevicesUpdated; _leftHandAnimAction = new SkeletalInput("/actions/customavatars/in/lefthandanim"); _rightHandAnimAction = new SkeletalInput("/actions/customavatars/in/righthandanim"); }
/// <summary> /// Simple calibration to head and hands using predefined anchor position and rotation offsets. /// </summary> /// <param name="ik">The VRIK component.</param> /// <param name="centerEyeAnchor">HMD.</param> /// <param name="leftHandAnchor">Left hand controller.</param> /// <param name="rightHandAnchor">Right hand controller.</param> /// <param name="centerEyePositionOffset">Position offset of the camera from the head bone (root space).</param> /// <param name="centerEyeRotationOffset">Rotation offset of the camera from the head bone (root space).</param> /// <param name="handPositionOffset">Position offset of the hand controller from the hand bone (controller space).</param> /// <param name="handRotationOffset">Rotation offset of the hand controller from the hand bone (controller space).</param> /// <param name="scaleMlp">Multiplies the scale of the root.</param> /// <returns></returns> public static CalibrationData Calibrate(VRIK ik, Transform centerEyeAnchor, Transform leftHandAnchor, Transform rightHandAnchor, Vector3 centerEyePositionOffset, Vector3 centerEyeRotationOffset, Vector3 handPositionOffset, Vector3 handRotationOffset, float scaleMlp = 1f) { CalibrateHead(ik, centerEyeAnchor, centerEyePositionOffset, centerEyeRotationOffset); CalibrateHands(ik, leftHandAnchor, rightHandAnchor, handPositionOffset, handRotationOffset); CalibrateScale(ik, scaleMlp); // Fill in Calibration Data CalibrationData data = new CalibrationData(); data.scale = ik.references.root.localScale.y; data.head = new CalibrationData.Target(ik.solver.spine.headTarget); data.leftHand = new CalibrationData.Target(ik.solver.leftArm.target); data.rightHand = new CalibrationData.Target(ik.solver.rightArm.target); return(data); }
/// <summary> /// Create SetCalibrationData tagop /// </summary> /// <param name="cal">Calibration data acquired from Get Calibration Data. /// Must read data from tag first to avoid changing "DO NOT MODIFY" fields.</param> /// <param name="passwordLevel">Password level</param> /// <param name="password">Password</param> public SetCalibrationData(CalibrationData cal, Level passwordLevel, UInt32 password) : base(0xA5, passwordLevel, password) { Cal = cal; }
/// <summary> /// Create SetCalibrationData tagop /// </summary> /// <param name="cal">Calibration data acquired from Get Calibration Data. /// Must read data from tag first to avoid changing "DO NOT MODIFY" fields.</param> public SetCalibrationData(CalibrationData cal) : base(0xA5) { Cal = cal; }
/// <summary> /// Create Calibration Data / SFE Parameter object from raw 72-bit reply /// </summary> /// <param name="reply"></param> /// <param name="offset"></param> public CalSfe(byte[] reply, int offset) { Cal = new CalibrationData(reply, offset + 0); Sfe = new SfeParameters(reply, offset + 7); }