public void Init(KinectFrame frame, KinectCameraInfo cameraInfo) { _initialized = true; // store variables _xRes = cameraInfo.XRes; _yRes = cameraInfo.YRes; _focalLengthImage = (float)cameraInfo.FocalLengthImage; _focalLengthDepth = (float)cameraInfo.FocalLengthDetph; _depthToRgb = cameraInfo.DepthToRgb; CreateVertexBuffer(); CreateIndexBuffer(); CreateTextures(); _light = new DxLight { Type = DxLightType.None, Position = new Vector3(0, 0, 0f), Direction = new Vector3(0, 0, 1), Ambient = new Vector4(0.4f, 0.4f, 0.4f, 1.0f), Diffuse = new Vector4(1.0f, 1.0f, 1.0f, 1.0f), Specular = new Vector4(1.0f, 1.0f, 1.0f, 1.0f), Attenuation = new Vector3(0.0f, 0.005f, 0.0f), SpotPower = 0.001f, Range = 1000f }; }
public void Update(KinectFrame frame, KinectCameraInfo cameraInfo) { if (!_initialized) { Init(frame, cameraInfo); } var imageRect = _imageTexture.Map(0, MapMode.WriteDiscard, MapFlags.None); var imageMap = frame.ImageMap; var imagePtr = 0; // update texture // need to convert from RGB24 to RGBA32 for (int v = 0; v < _yRes; v++) { for (int u = 0; u < _xRes; u++) { byte r = imageMap[imagePtr++]; byte g = imageMap[imagePtr++]; byte b = imageMap[imagePtr++]; byte a = 255; int argb = (a << 24) + (b << 16) + (g << 8) + r; imageRect.Data.Write(argb); } } _imageTexture.Unmap(0); // update depth map DataStream depthStream = _depthMapBuffer.Map(MapMode.WriteDiscard, MapFlags.None); depthStream.WriteRange(frame.DepthMap); _depthMapBuffer.Unmap(); }
public void Init(KinectFrame frame, KinectCameraInfo cameraInfo) { _initialized = true; // store variables _xRes = cameraInfo.XRes; _yRes = cameraInfo.YRes; _focalLengthImage = (float)cameraInfo.FocalLengthImage; _focalLengthDepth = (float)cameraInfo.FocalLengthDetph; _depthToRgb = cameraInfo.DepthToRgb; CreateVertexBuffer(); CreateTextures(); }
private void UpdateCameraInfo() { if (_cameraInfo == null) { _cameraInfo = new KinectCameraInfo(); } _cameraInfo.XRes = (int)_imageMeta.XRes; _cameraInfo.YRes = (int)_imageMeta.YRes; _cameraInfo.ZRes = (int)_depthMeta.ZRes; // get the focal length in mm (ZPS = zero plane distance)/ focal length // _imageCameraInfo.ZeroPlaneDistance = _imageNode.GetIntProperty("ZPD"); _cameraInfo.ZeroPlaneDistance = _depthNode.GetIntProperty("ZPD"); // get the pixel size in mm ("ZPPS" = pixel size at zero plane) // _imageCameraInfo.ZeroPlanePixelSize = _imageNode.GetRealProperty("ZPPS") * 2.0; _cameraInfo.ZeroPlanePixelSize = _depthNode.GetRealProperty("ZPPS") * 2.0; _cameraInfo.FocalLengthImage = 525f; _cameraInfo.FocalLengthDetph = _cameraInfo.ZeroPlaneDistance / _cameraInfo.ZeroPlanePixelSize; // get base line (distance from IR camera to laser projector in cm) _cameraInfo.Baseline = _depthNode.GetRealProperty("LDDIS") * 10; _cameraInfo.ShadowValue = _depthNode.GetIntProperty("ShadowValue"); _cameraInfo.NoSampleValue = _depthNode.GetIntProperty("NoSampleValue"); // best guess _cameraInfo.DepthToRgb = Matrix.Translation(35f, 15f, 0f); /* * //from ROS calibraition * _cameraInfo.DepthToRgb = new Matrix * { * M11 = 1f, M21 = 0.006497f, M31 = -0.000801f, M41 = -25.165f, * M12 = -0.006498f, M22 = 1f, M32 = -0.001054f, M42 = 0.047f, * M13 = 0.000794f, M23 = 0.001059f, M33 = 1f, M43 = -4.077f, * M14 = 0f, M24 = 0f, M34 = 0f, M44 = 1f * }; */ }
private void UpdateCameraInfo() { if (_cameraInfo == null) _cameraInfo = new KinectCameraInfo(); _cameraInfo.XRes = (int) _imageMeta.XRes; _cameraInfo.YRes = (int) _imageMeta.YRes; _cameraInfo.ZRes = (int) _depthMeta.ZRes; // get the focal length in mm (ZPS = zero plane distance)/ focal length // _imageCameraInfo.ZeroPlaneDistance = _imageNode.GetIntProperty("ZPD"); _cameraInfo.ZeroPlaneDistance = _depthNode.GetIntProperty("ZPD"); // get the pixel size in mm ("ZPPS" = pixel size at zero plane) // _imageCameraInfo.ZeroPlanePixelSize = _imageNode.GetRealProperty("ZPPS") * 2.0; _cameraInfo.ZeroPlanePixelSize = _depthNode.GetRealProperty("ZPPS")*2.0; _cameraInfo.FocalLengthImage = 525f; _cameraInfo.FocalLengthDetph = _cameraInfo.ZeroPlaneDistance/_cameraInfo.ZeroPlanePixelSize; // get base line (distance from IR camera to laser projector in cm) _cameraInfo.Baseline = _depthNode.GetRealProperty("LDDIS")*10; _cameraInfo.ShadowValue = _depthNode.GetIntProperty("ShadowValue"); _cameraInfo.NoSampleValue = _depthNode.GetIntProperty("NoSampleValue"); // best guess _cameraInfo.DepthToRgb = Matrix.Translation(35f, 15f, 0f); /* //from ROS calibraition _cameraInfo.DepthToRgb = new Matrix { M11 = 1f, M21 = 0.006497f, M31 = -0.000801f, M41 = -25.165f, M12 = -0.006498f, M22 = 1f, M32 = -0.001054f, M42 = 0.047f, M13 = 0.000794f, M23 = 0.001059f, M33 = 1f, M43 = -4.077f, M14 = 0f, M24 = 0f, M34 = 0f, M44 = 1f }; */ }
public void Update(KinectFrame frame, KinectCameraInfo cameraInfo) { if (!_initialized) Init(frame, cameraInfo); // update texture if (_imageTexture != null) { var imageRect = _imageTexture.Map(0, MapMode.WriteDiscard, MapFlags.None); var imageMap = frame.ImageMap; var imagePtr = 0; // need to convert from RGB24 to RGBA32 for (int v = 0; v < _yRes; v++) { for (int u = 0; u < _xRes; u++) { byte r = imageMap[imagePtr++]; byte g = imageMap[imagePtr++]; byte b = imageMap[imagePtr++]; byte a = 255; int argb = (a << 24) + (b << 16) + (g << 8) + r; imageRect.Data.Write(argb); } } _imageTexture.Unmap(0); } // update depth map if (_depthMapBuffer != null) { DataStream depthStream = _depthMapBuffer.Map(MapMode.WriteDiscard, MapFlags.None); depthStream.WriteRange(frame.DepthMap); _depthMapBuffer.Unmap(); } }
public void Init(KinectFrame frame, KinectCameraInfo cameraInfo) { _initialized = true; // store variables _xRes = cameraInfo.XRes; _yRes = cameraInfo.YRes; _focalLengthImage = (float)cameraInfo.FocalLengthImage; _focalLengthDepth = (float)cameraInfo.FocalLengthDetph; _depthToRgb = cameraInfo.DepthToRgb; CreateVertexBuffer(); CreateIndexBuffer(); CreateTextures(); _light = new DxLight { Type = DxLightType.None, Position = new Vector3(0, 0, 0f), Direction = new Vector3(0, 0, 1), Ambient = new Vector4(0.4f, 0.4f, 0.4f, 1.0f), Diffuse = new Vector4(1.0f, 1.0f, 1.0f, 1.0f), Specular = new Vector4(1.0f, 1.0f, 1.0f, 1.0f), Attenuation = new Vector3(0.0f, 0.005f, 0.0f), SpotPower = 0.001f, Range = 1000f }; }
public void Init(KinectFrame frame, KinectCameraInfo cameraInfo) { _initialized = true; // store variables _xRes = cameraInfo.XRes; _yRes = cameraInfo.YRes; _focalLengthImage = (float)cameraInfo.FocalLengthImage; _focalLengthDepth = (float)cameraInfo.FocalLengthDetph; _depthToRgb = cameraInfo.DepthToRgb; CreateVertexBuffer(); CreateTextures(); }