Kinect Z-plane RGB mapping
Posted: 25 December 2010 08:14 PM   [ Ignore ]
New Member
Rank
Total Posts:  6
Joined  2010-11-27

I’ld like to make a bow to the work of AlexP and the 1121 CL-Nui Driver Team at Code Labs.

As a kind of CAD/GIS guy I felt some need to enhance:
GetNUICameraDepthFrameRGB32
by
GetNUICameraDepthFrameRAW
into a more intuitive RGB24 Colorsequence.

Blue,Green,Yellow,Orange,Red

//———————————————————————————————
UINT _StreamCamDepth_Proc(void *lpParam)
//———————————————————————————————
{
if (!lpParam) return 0;
CCamWnd *lpPB;
lpPB=(CCamWnd *)lpParam;

while (1)
{
 
  GetNUICameraDepthFrameRAW(lpPB->Cam, (PUSHORT) lpPB->m_lpBuffer2,2000);

  lpU=lpPB->m_lpBuffer2;
  lpRGB24=(RGB *)lpPB->m_lpBuffer;

 

  for (i=0;  i

<640*480; i++)
{ if (*lpU>

100 && *lpU

< 1500)
{
s=kinectDepth2Zm(*lpU );
setRGB_Val( lpRGB24, s );
}
else
{
lpRGB24->

R= 0xFF;
      lpRGB24->G= 0xFF;
      lpRGB24->B= 0xFF;
      }

      lpU++;
      lpRGB24++;
  }

  if (!lpPB->m_isOnPaint) lpPB->Invalidate();
}


whereas:
.............
int COLSEQ[]={
  6,
  0xFF050B, // rot
  0xFFE505, // gelb
  0x05FF2E, // grün
  0x05F6FF, // cyan
  0x050BFF, // blau
  0x4005FF, // lila
};

double HGTSEQ[]={
  6.0,
  0.4, // rot
  1.5, // gelb
  2.5, // grün
  3.0, // Cyan
  5.0, // blau
  100 // lila
};


//———————————————————————————————   
  void setRGB_Val( RGB* out, double s )
//——————————————————————————————— 
  { // zc in m = 0.5 .. 6 m
  if (!out) return;

  int i,cola,cole;
  double a,b;
  cola=1;cole=2;

  for (i=1;i

{ if (s >

HGTSEQ && s <= HGTSEQ[i+1]){ a=HGTSEQ

;b=HGTSEQ[i+1]; cola=i;cole=i+1;break;}
  }

  double zc;
  zc=(s-a)/(b-a);

  out->B=(int)((1-zc)*((COLSEQ[cola] & 0xFF0000) >> 16) + zc *((COLSEQ[cole] & 0xFF0000) >> 16));
  out->G=(int)((1-zc)*((COLSEQ[cola] & 0x00FF00) >>  8) + zc *((COLSEQ[cole] & 0x00FF00) >>  8));
  out->R=(int)((1-zc)*((COLSEQ[cola] & 0x0000FF) >>  0) + zc *((COLSEQ[cole] & 0x0000FF) >>  0));
  }


//——————————————————————————————— 
  double kinectDepth2Zm(USHORT n )
//——————————————————————————————— 
  {
  // Z plane in m
        return (-348.08/((double)n-1090.4));
  }

Image Attachments
thecat24rgb.jpg
Profile
 
 
 
 


RSS 2.0     Atom Feed