From 3b4a4daec37cc213a81cfa38c50434808e5b186c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 29 Jul 2013 18:26:51 -0700 Subject: [PATCH] Ignore maximum values when computing the depth. --- interface/src/Webcam.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index a28bf87d10..2efb12aed2 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -587,10 +587,12 @@ void FrameGrabber::grabFrame() { qint64 depthTotal = 0; qint64 depthSamples = 0; ushort* src = _faceDepth.ptr(); + const ushort ELEVEN_BIT_MINIMUM = 0; + const ushort ELEVEN_BIT_MAXIMUM = 2047; for (int i = 0; i < ENCODED_FACE_HEIGHT; i++) { for (int j = 0; j < ENCODED_FACE_WIDTH; j++) { ushort depth = *src++; - if (depth != 0) { + if (depth != ELEVEN_BIT_MINIMUM && depth != ELEVEN_BIT_MAXIMUM) { depthTotal += depth; depthSamples++; } @@ -610,14 +612,13 @@ void FrameGrabber::grabFrame() { // likewise for the encoded representation uchar* yline = (uchar*)_encodedFace.data() + vpxImage.stride[0] * ENCODED_FACE_HEIGHT; src = _faceDepth.ptr(); - const char UNKNOWN_DEPTH = 0; - const char MAXIMUM_DEPTH = 255; + const char EIGHT_BIT_MAXIMUM = 255; for (int i = 0; i < ENCODED_FACE_HEIGHT; i++) { uchar* ydest = yline; for (int j = 0; j < ENCODED_FACE_WIDTH; j++) { ushort depth = *src++; - if (depth == UNKNOWN_DEPTH) { - *ydest++ = MAXIMUM_DEPTH; + if (depth == ELEVEN_BIT_MINIMUM) { + *ydest++ = EIGHT_BIT_MAXIMUM; } else { *ydest++ = saturate_cast(depth + _depthOffset);