void Start() { _KinectSensor = _AzureKinectManager.Sensor; if (_KinectSensor != null) { int depthImageSize = _KinectSensor.DepthImageWidth * _KinectSensor.DepthImageHeight; _DepthRawData = new byte[depthImageSize * sizeof(ushort)]; _EncodedDepthData = new byte[depthImageSize]; _DecodedDepthData = new short[depthImageSize]; _Diff = new short[depthImageSize]; _DepthImageTexture = new Texture2D(_KinectSensor.DepthImageWidth, _KinectSensor.DepthImageHeight, TextureFormat.R16, false); _DecodedDepthImageTexture = new Texture2D(_KinectSensor.DepthImageWidth, _KinectSensor.DepthImageHeight, TextureFormat.R16, false); _DiffImageTexture = new Texture2D(_KinectSensor.DepthImageWidth, _KinectSensor.DepthImageHeight, TextureFormat.R16, false); _ColorImageTexture = new Texture2D(_KinectSensor.ColorImageWidth, _KinectSensor.ColorImageHeight, TextureFormat.BGRA32, false); MeshRenderer depthMeshRenderer = _DepthImageObject.GetComponent <MeshRenderer>(); depthMeshRenderer.sharedMaterial = new Material(_DepthVisualizer); depthMeshRenderer.sharedMaterial.SetTexture("_DepthTex", _DepthImageTexture); MeshRenderer decodedDepthMeshRenderer = _DecodedDepthImageObject.GetComponent <MeshRenderer>(); decodedDepthMeshRenderer.sharedMaterial = new Material(_DepthVisualizer); decodedDepthMeshRenderer.sharedMaterial.SetTexture("_DepthTex", _DecodedDepthImageTexture); MeshRenderer diffMeshRenderer = _DiffImageObject.GetComponent <MeshRenderer>(); diffMeshRenderer.sharedMaterial = new Material(_DiffVisualizer); diffMeshRenderer.sharedMaterial.SetTexture("_DepthTex", _DiffImageTexture); MeshRenderer colorMeshRenderer = _ColorImageObject.GetComponent <MeshRenderer>(); colorMeshRenderer.sharedMaterial = new Material(_UnlitTextureMaterial); colorMeshRenderer.sharedMaterial.SetTexture("_MainTex", _ColorImageTexture); Debug.Log("ColorResolution: " + _KinectSensor.ColorImageWidth + "x" + _KinectSensor.ColorImageHeight); Debug.Log("DepthResolution: " + _KinectSensor.DepthImageWidth + "x" + _KinectSensor.DepthImageHeight); _TrvlEncoder = new TemporalRVLEncoder(depthImageSize, 10, 2); _TrvlDecoder = new TemporalRVLDecoder(depthImageSize); } }
public void Initialize() { _KinectSensor = _AzureKinectManager.Sensor; if (_KinectSensor != null) { Debug.Log("ColorResolution: " + _KinectSensor.ColorImageWidth + "x" + _KinectSensor.ColorImageHeight); Debug.Log("DepthResolution: " + _KinectSensor.DepthImageWidth + "x" + _KinectSensor.DepthImageHeight); _DepthImageSize = _KinectSensor.DepthImageWidth * _KinectSensor.DepthImageHeight; _DepthRawData = new byte[_DepthImageSize * sizeof(short)]; _Diff = new short[_DepthImageSize]; _EncodedColorImageData = new byte[_DepthImageSize]; _DepthImageTexture = new Texture2D(_KinectSensor.DepthImageWidth, _KinectSensor.DepthImageHeight, TextureFormat.R16, false); _DecodedDepthImageTexture = new Texture2D(_KinectSensor.DepthImageWidth, _KinectSensor.DepthImageHeight, TextureFormat.R16, false); _DiffImageTexture = new Texture2D(_KinectSensor.DepthImageWidth, _KinectSensor.DepthImageHeight, TextureFormat.R16, false); _ColorImageTexture = new Texture2D(_KinectSensor.DepthImageWidth, _KinectSensor.DepthImageHeight, TextureFormat.BGRA32, false); _TrvlEncoder = new TemporalRVLEncoder(_DepthImageSize, 10, 2); _TrvlDecoder = new TemporalRVLDecoder(_DepthImageSize); CameraCalibration deviceDepthCameraCalibration = _KinectSensor.DeviceCalibration.DepthCameraCalibration; CameraCalibration deviceColorCameraCalibration = _KinectSensor.DeviceCalibration.ColorCameraCalibration; _Calibration = new K4A.Calibration(); _Calibration.DepthCameraCalibration = CreateCalibrationCamera(deviceDepthCameraCalibration, _KinectSensor.DepthImageWidth, _KinectSensor.DepthImageHeight); _Calibration.ColorCameraCalibration = CreateCalibrationCamera(deviceColorCameraCalibration, _KinectSensor.ColorImageWidth, _KinectSensor.ColorImageHeight); _CalibrationType = K4A.CalibrationType.Depth; // Color to depth _Initialized = true; } else { Debug.LogError("KinectSensor is null!"); } }