Beispiel #1
0
inline void
convertDepthToInverseDepthRgba (
    const uint16* depthValues,
    int numPixels,
    float scaleToMeters,
    uint8* rgbaBuffer,
    uint8 noDepthAlpha = 0,
    uint8 depthAlpha = 255
)
{
    for (int i = 0; i < numPixels; ++i)
    {
        int r = 0, g = 0, b = 0;

        uint8 alpha = noDepthAlpha;

        uint16 depth = depthValues[i];

        if (0 < depth && depth < shift2depth(0xffff))
        {
            const float idepth = 1.f / (float(depth) * scaleToMeters);

            // rainbow between 0 and 4
            r = int((0.f - idepth) * 255.f / 1.f);
            g = int((1.f - idepth) * 255.f / 1.f);
            b = int((2.f - idepth) * 255.f / 1.f);

            if (r < 0)
                r = -r;
            
            if (g < 0)
                g = -g;
            
            if (b < 0)
                b = -b;

            alpha = depthAlpha;
        }

        uint8_t rc = keepInRange (r, 0, 255);
        uint8_t gc = keepInRange (g, 0, 255);
        uint8_t bc = keepInRange (b, 0, 255);

        rgbaBuffer[4 * i    ] = 255 - rc;
        rgbaBuffer[4 * i + 1] = 255 - gc;
        rgbaBuffer[4 * i + 2] = 255 - bc;
        rgbaBuffer[4 * i + 3] = alpha;
    }
}
Beispiel #2
0
void testObj::test<4>(void)
{
  try
  {
    keepInRange(42, 60, 10);
    fail("no exception on invalid range");
  }
  catch(const Util::Exception&)
  { }
}
Beispiel #3
0
void testObj::test<3>(void)
{
  ensure_equals("in range failed", keepInRange(666, 10, 50), 50);
}
Beispiel #4
0
void testObj::test<2>(void)
{
  ensure_equals("in range failed", keepInRange(3, 10, 50), 10);
}
Beispiel #5
0
void testObj::test<1>(void)
{
  ensure_equals("in range failed", keepInRange(42, 10, 50), 42);
}