Ejemplo n.º 1
0
        /// <summary>
        /// Updates both skin mask and player mask.
        /// </summary>
        /// <param name="depthFrame"></param>
        /// <param name="colorPixelData"></param>
        /// <param name="mapper"></param>
        /// <param name="roi">ROI in depth image.</param>
        public void UpdateMasks(short[] depthFrame, byte[] colorPixelData,
                                Rectangle roi, bool filterPlayer = false, bool filterSkin = false)
        {
            if (skinDetector == null)
            {
                skinDetector = new SkinDetector(width, height);
            }

            if (DepthSkinMask == null)
            {
                DepthSkinMask = new Image <Gray, Byte>(width, height);
            }

            UpdatePlayerMask(depthFrame);

            var colorSkinMask = skinDetector.DetectSkin(colorPixelData, roi);

            ImageUtil.AlignImageColorToDepth(colorSkinMask, DepthSkinMask, depthFrame, mapper);
            dataBuffer.EnqueueAndCopy(skinDetector.SkinImage);

            byte[, ,] playerMask = null;
            byte[, ,] skinMask   = null;
            if (filterPlayer)
            {
                playerMask = DepthPlayerMask.Data;
            }
            if (filterSkin)
            {
                skinMask = DepthSkinMask.Data;
            }
            UpdatePlayerDepthImage(depthFrame, playerMask, skinMask, roi);
        }
Ejemplo n.º 2
0
        public void FilterPlayerContourSkin(short[] depthFrame, byte[] colorFrame)
        {
            if (skinDetector == null)
            {
                skinDetector = new SkinDetector(width, height);
            }

            if (DepthSkinMask == null)
            {
                DepthSkinMask = new Image <Gray, Byte>(width, height);
            }

            UpdatePlayerMask(depthFrame);
            var contour = FindPlayerContour(DepthPlayerMask);

            var skinMask = skinDetector.DetectSkin(colorFrame);

            ImageUtil.AlignImageColorToDepth(skinMask, DepthSkinMask, depthFrame, mapper);
            CvInvoke.cvAnd(skinDetector.SkinImage.Ptr, ColorPlayerMask.Ptr, skinDetector.SkinImage.Ptr,
                           IntPtr.Zero);
            dataBuffer.EnqueueAndCopy(skinDetector.SkinImage);

            UpdatePlayerDepthImage(depthFrame, contour, DepthSkinMask.Data);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates both skin mask and player mask.
        /// </summary>
        /// <param name="depthFrame"></param>
        /// <param name="colorPixelData"></param>
        /// <param name="mapper"></param>
        /// <param name="roi">ROI in depth image.</param>
        public void UpdateMasks(short[] depthFrame, byte[] colorPixelData,
        Rectangle roi, bool filterPlayer = false, bool filterSkin = false)
        {
            if (skinDetector == null)
            skinDetector = new SkinDetector(width, height);

              if (DepthSkinMask == null)
            DepthSkinMask = new Image<Gray, Byte>(width, height);

              UpdatePlayerMask(depthFrame);

              var colorSkinMask = skinDetector.DetectSkin(colorPixelData, roi);
              ImageUtil.AlignImageColorToDepth(colorSkinMask, DepthSkinMask, depthFrame, mapper);
              dataBuffer.EnqueueAndCopy(skinDetector.SkinImage);

              byte[, ,] playerMask = null;
              byte[, ,] skinMask = null;
              if (filterPlayer)
            playerMask = DepthPlayerMask.Data;
              if (filterSkin)
            skinMask = DepthSkinMask.Data;
              UpdatePlayerDepthImage(depthFrame, playerMask, skinMask, roi);
        }
Ejemplo n.º 4
0
        public void FilterPlayerContourSkin(short[] depthFrame, byte[] colorFrame)
        {
            if (skinDetector == null)
            skinDetector = new SkinDetector(width, height);

              if (DepthSkinMask == null)
            DepthSkinMask = new Image<Gray, Byte>(width, height);

              UpdatePlayerMask(depthFrame);
              var contour = FindPlayerContour(DepthPlayerMask);

              var skinMask = skinDetector.DetectSkin(colorFrame);
              ImageUtil.AlignImageColorToDepth(skinMask, DepthSkinMask, depthFrame, mapper);
              CvInvoke.cvAnd(skinDetector.SkinImage.Ptr, ColorPlayerMask.Ptr, skinDetector.SkinImage.Ptr,
                     IntPtr.Zero);
              dataBuffer.EnqueueAndCopy(skinDetector.SkinImage);

              UpdatePlayerDepthImage(depthFrame, contour, DepthSkinMask.Data);
        }