Parcourir la source

Fixed DepthImage and handImage creation.

Daniel Kauth il y a 11 ans
Parent
commit
3e8c7e0f25
2 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 2 2
      bbiwarg/Detectors/Palm/PalmDetector.cs
  2. 2 2
      bbiwarg/Images/DepthImage.cs

+ 2 - 2
bbiwarg/Detectors/Palm/PalmDetector.cs

@@ -49,8 +49,8 @@ namespace bbiwarg.Detectors.Palm
             this.edgeImage = edgeImage;
             this.palmImage = palmImage;
 
-            // dst = (src > 254) ? 0 : 1
-            handImage = depthImage.Image.ThresholdBinaryInv(new Gray(254), new Gray(1)).Convert<Gray, Byte>();
+            // dst = (src > (MaxDepth - MinDepth)) ? 0 : 1
+            handImage = depthImage.Image.ThresholdBinaryInv(new Gray(depthImage.MaxDepth - depthImage.MinDepth - 1), new Gray(1)).Convert<Gray, Byte>();
 
             fingers = getFingersWithoutThumb(detectedFingers);
             buildPointingHandMask();

+ 2 - 2
bbiwarg/Images/DepthImage.cs

@@ -26,8 +26,8 @@ namespace bbiwarg.Images
             MinDepth = findMinDepth(image);
             MaxDepth = (Int16)(MinDepth + 200); // max = minDepth+255 (else it can't fit whole range in byte image)
 
-            //smooth+threshold
-            Image = image.SmoothMedian(3).ThresholdTrunc(new Gray(MaxDepth)).Convert<Gray, byte>();
+            //smooth+threshold (dst = (src > (MaxDepth - MinDepth)) ? MaxDepth - MinDepth : src)
+            Image = image.SmoothMedian(3).Sub(new Gray(MinDepth)).ThresholdTrunc(new Gray(MaxDepth - MinDepth)).Convert<Gray, byte>();
         }
 
         public Int16 getDepthAt(Point point)