<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with getrawdepthdata() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=getrawdepthdata%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:51:27 +0000</pubDate>
         <description>Tagged with getrawdepthdata() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedgetrawdepthdata%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>kin</title>
      <link>https://forum.processing.org/two/discussion/26335/kin</link>
      <pubDate>Tue, 13 Feb 2018 11:51:36 +0000</pubDate>
      <dc:creator>meru_lp</dc:creator>
      <guid isPermaLink="false">26335@/two/discussions</guid>
      <description><![CDATA[<p>thanks for your response</p>
]]></description>
   </item>
   <item>
      <title>Get Depth Value for Each Pixel</title>
      <link>https://forum.processing.org/two/discussion/21990/get-depth-value-for-each-pixel</link>
      <pubDate>Fri, 14 Apr 2017 10:08:18 +0000</pubDate>
      <dc:creator>CharlesDesign</dc:creator>
      <guid isPermaLink="false">21990@/two/discussions</guid>
      <description><![CDATA[<p>Hi All,</p>

<p>I'd really appreciate some help on this, I'm using the KinectPV2 library which is great but very poorly documented.</p>

<p>With reference to the example "MapDepthToColor" copied below I'm trying to retrieve the depth for each RGB pixel. I'm having a hard time decrypting what's going on, can someone help me out?</p>

<p>Thanks in advance,
Charles</p>

<pre><code>/*
Thomas Sanchez Lengeling.
<a href="http://codigogenerativo.com/" target="_blank" rel="nofollow">http://codigogenerativo.com/</a>

KinectPV2, Kinect for Windows v2 library for processing

Color to fepth Example,
Color Frame is aligned to the depth frame
*/

import KinectPV2.*;

KinectPV2 kinect;

int [] depthZero;

//BUFFER ARRAY TO CLEAN DE PIXLES
PImage depthToColorImg;

void setup() {
  size(1024, 848, P3D);

  depthToColorImg = createImage(512, 424, PImage.RGB);
  depthZero    = new int[ KinectPV2.WIDTHDepth * KinectPV2.HEIGHTDepth];

  //SET THE ARRAY TO 0s
  for (int i = 0; i &lt; KinectPV2.WIDTHDepth; i++) {
    for (int j = 0; j &lt; KinectPV2.HEIGHTDepth; j++) {
      depthZero[424*i + j] = 0;
    }
  }

  kinect = new KinectPV2(this);
  kinect.enableDepthImg(true);
  kinect.enableColorImg(true);
  kinect.enablePointCloud(true);

  kinect.init();
}

void draw() {
  background(0);

  float [] mapDCT = kinect.getMapDepthToColor(); // Length: 434,176

  //get the raw data from depth and color
  int [] colorRaw = kinect.getRawColor(); // Length: 2,073,600

  //clean de pixels
  PApplet.arrayCopy(depthZero, depthToColorImg.pixels);

  int count = 0;
  depthToColorImg.loadPixels();
  for (int i = 0; i &lt; KinectPV2.WIDTHDepth; i++) {
    for (int j = 0; j &lt; KinectPV2.HEIGHTDepth; j++) {

      //incoming pixels 512 x 424 with position in 1920 x 1080
      float valX = mapDCT[count * 2 + 0];
      float valY = mapDCT[count * 2 + 1];

      //maps the pixels to 512 x 424, not necessary but looks better
      int valXDepth = (int)((valX/1920.0) * 512.0);
      int valYDepth = (int)((valY/1080.0) * 424.0);

      int  valXColor = (int)(valX);
      int  valYColor = (int)(valY);

      if ( valXDepth &gt;= 0 &amp;&amp; valXDepth &lt; 512 &amp;&amp; valYDepth &gt;= 0 &amp;&amp; valYDepth &lt; 424 &amp;&amp;
        valXColor &gt;= 0 &amp;&amp; valXColor &lt; 1920 &amp;&amp; valYColor &gt;= 0 &amp;&amp; valYColor &lt; 1080) {
        color colorPixel = colorRaw[valYColor * 1920 + valXColor];
        //color colorPixel = depthRaw[valYDepth*512 + valXDepth];
        depthToColorImg.pixels[valYDepth * 512 + valXDepth] = colorPixel;
      } 
      count++;
    }
  }
  depthToColorImg.updatePixels();

  image(depthToColorImg, 0, 424);
  image(kinect.getColorImage(), 0, 0, 512, 424);
  image(kinect.getDepthImage(), 512, 0);

  text("fps: "+frameRate, 50, 50);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>KinectPV2 library Color image to depth issue</title>
      <link>https://forum.processing.org/two/discussion/15974/kinectpv2-library-color-image-to-depth-issue</link>
      <pubDate>Tue, 12 Apr 2016 00:04:25 +0000</pubDate>
      <dc:creator>jackthegoodboy</dc:creator>
      <guid isPermaLink="false">15974@/two/discussions</guid>
      <description><![CDATA[<p>Hey!</p>

<p>I'm trying to map color pixels to the depth map using the KinectPV2 library, in order to do some checkerboard detection for calibration.</p>

<p>I've been using the function getMapDepthToColor() which gives you a mapping between the 2 spaces (or so I think).</p>

<p>The following is a modification of the MapDepthToColor example to suit my needs.</p>

<pre><code>import KinectPV2.*;

KinectPV2 kinect;

int [] depthZero;

//BUFFER ARRAY TO CLEAN DE PIXLES
PImage depthToColorImg;

void setup() {
  size(1024, 848, P3D);

  depthToColorImg = createImage(512, 424, PImage.RGB);
  depthZero    = new int[ KinectPV2.WIDTHDepth * KinectPV2.HEIGHTDepth];

  //SET THE ARRAY TO 0s
  for (int i = 0; i &lt; KinectPV2.WIDTHDepth; i++) {
    for (int j = 0; j &lt; KinectPV2.HEIGHTDepth; j++) {
      depthZero[424*i + j] = 0;
    }
  }

  kinect = new KinectPV2(this);
  kinect.enableDepthImg(true);
  kinect.enableColorImg(true);
  kinect.enablePointCloud(true);

  kinect.init();
}

void draw() {
  background(0);

  float [] mapDCT = kinect.getMapDepthToColor();

  //get the raw data from depth and color
  int [] colorRaw = kinect.getRawColor();
  int [] depthRaw = kinect.getRawDepthData();

  //clean de pixels
  PApplet.arrayCopy(depthZero, depthToColorImg.pixels);

  int count = 0;
  depthToColorImg.loadPixels();
  count = 0;

  for (int i = 0; i &lt; KinectPV2.HEIGHTDepth; i++) {
    for (int j = 0; j &lt; KinectPV2.WIDTHDepth; j++) {

      //incoming pixels 512 x 424 with position in 1920 x 1080
      int valX = (int)mapDCT[(count) * 2 + 0];
      int valY = (int)mapDCT[(count) * 2 + 1];

      if (valX &gt;= 0 &amp;&amp; valX &lt; 1920 &amp;&amp; valY &gt;= 0 &amp;&amp; valY &lt; 1080) {
        color colorPixel = colorRaw[valY * 1920 + valX];
        depthToColorImg.pixels[count] = colorPixel;
      }
      count++;
    }
  }

  depthToColorImg.updatePixels();

  image(depthToColorImg, 0, 424);
  image(kinect.getColorImage(), 0, 0, 512, 424);
  image(kinect.getDepthImage(), 512, 0);
}
</code></pre>

<p>Giving the output:</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/160/HYPV7TUI2DSD.PNG" alt="Capture" title="Capture" /></p>

<p>Is there something I'm misunderstanding here? Any help would be much appreciated.</p>
]]></description>
   </item>
   </channel>
</rss>