private IEnumerator InitializeSelf() { int camWidth = 0, camHeight = 0; int result = HandTrackerInterop.Init(ref camWidth, ref camHeight); if (result < 0) { if (result == 1) { Debug.LogWarningFormat("[{0}] Failed to open camera stream.", GetType()); } yield break; } _currentGameConfig.CameraWidth = camWidth; _currentGameConfig.CameraHeight = camHeight; _services = new Dictionary <Type, object> { { typeof(MainService), new MainService(this) }, }; MainService mainService = _services[typeof(MainService)] as MainService; ServicesInitialized = true; yield return(GameController.CorountinePerformerInstance.StartCoroutine(mainService.IntiializeMainService())); }
public void StartColorSamplingAndTracking() { HandTrackerInterop.StartColorSampling(); if (_colorSampleAwait != null) { GameController.CorountinePerformerInstance.StopCoroutine(_colorSampleAwait); } _colorSampleAwait = GameController.CorountinePerformerInstance.StartCoroutine(ColorSampleAwaitRoutine()); }
private void Release() { if (_colorSampleAwait != null) { GameController.CorountinePerformerInstance.StopCoroutine(_colorSampleAwait); } foreach (ComponentLinkedController controller in _controllers.Values) { controller.Release(); } HandTrackerInterop.Close(); }
private void Update() { float x = 0f, y = 0f; HandTrackerInterop.GetHandCoordinates(ref x, ref y); Vector2 relativeCoordinates = new Vector2(x, y) - _videoFeedCenterCoordinates; //Some filtering or coordinate adjusting, as well as check for borderline //cases could be done here. //The idea is to move the object relative to the plane on which //the video feed is projected _componentHolder.MovableObjectTransform.position = new Vector3(relativeCoordinates.x / 100f, -relativeCoordinates.y / 100f, GameConfig.CameraDistance); }
private IEnumerator ColorSampleAwaitRoutine() { float timer = 0.0f; while (true) { if (timer > GameConfig.ColorSampleAwaitTime) { break; } timer += Time.unscaledDeltaTime; yield return(null); } HandTrackerInterop.StartTracking(); MovableObjectController cubeController = _controllers[typeof(MovableObjectController)] as MovableObjectController; cubeController.StartTracking(); }
private void Update() { //This isn't the most performant way of going about this, but I just //wanted to test out the concept quickly. Of course it's better to //avoid using Texture2D unsafe { fixed(PixelData *pixels = _framePixels) { HandTrackerInterop.GetFrame(pixels); } } Color32[] colors = new Color32[_framePixels.Length]; for (int i = 0; i < _framePixels.Length; i++) { colors[i] = _framePixels[i].ToColor32(); } _videoTexture.SetPixels32(colors); _videoTexture.Apply(); }
public void StartSetup() { HandTrackerInterop.SetupForGettingColorSample(); }