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();
        }
Пример #3
0
        private void UpdateFrameData()
        {
            if (_currentFrame == null)
            {
                _currentFrame = new KinectFrame();
            }

            _currentFrame.FrameId = (int)_imageMeta.FrameID;

            int imageSize = (int)(_imageMeta.XRes * _imageMeta.YRes * 3);

            Debug.Assert(imageSize == _imageMeta.DataSize);

            if (_currentFrame.ImageMap == null || _currentFrame.ImageMap.Length != imageSize)
            {
                _currentFrame.ImageMap = new byte[imageSize];
            }

            // copy image data
            Marshal.Copy(_imageMeta.Data, _currentFrame.ImageMap, 0, imageSize);

            int depthSize = (int)(_depthMeta.XRes * _depthMeta.YRes);

            Debug.Assert(depthSize * sizeof(ushort) == _depthMeta.DataSize);

            if (_currentFrame.DepthMap == null || _currentFrame.DepthMap.Length != depthSize)
            {
                _currentFrame.DepthMap = new short[depthSize];
            }

            // copy depth data
            Marshal.Copy(_depthMeta.Data, _currentFrame.DepthMap, 0, depthSize);
        }
        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();
        }
Пример #5
0
        private void UpdateFrameData()
        {
            if (_currentFrame == null)
                _currentFrame = new KinectFrame();

            _currentFrame.FrameId = (int)_imageMeta.FrameID;

            int imageSize = (int)(_imageMeta.XRes * _imageMeta.YRes * 3);
            Debug.Assert(imageSize == _imageMeta.DataSize);

            if (_currentFrame.ImageMap == null || _currentFrame.ImageMap.Length != imageSize)
                _currentFrame.ImageMap = new byte[imageSize];

            // copy image data
            Marshal.Copy(_imageMeta.Data, _currentFrame.ImageMap, 0, imageSize);

            int depthSize = (int)(_depthMeta.XRes * _depthMeta.YRes);
            Debug.Assert(depthSize * sizeof(ushort) == _depthMeta.DataSize);

            if (_currentFrame.DepthMap == null || _currentFrame.DepthMap.Length != depthSize)
                _currentFrame.DepthMap = new short[depthSize];

            // copy depth data
            Marshal.Copy(_depthMeta.Data, _currentFrame.DepthMap, 0, depthSize);
        }
Пример #6
0
        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();
            }
        }
Пример #7
0
        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();
        }