java - Map Depth to RGB Space -
i'm using kinectpv2 library great poorly documented.
with reference example "mapdepthtocolor" copied below i'm trying retrieve depth each rgb pixel.
having managed tweak original example map depth rgb space i'm left strange duplicated edge (see bottom left image).
can point out what's going on?
/* thomas sanchez lengeling. <a href="http://codigogenerativo.com/" target="_blank" rel="nofollow">http://codigogenerativo.com/</a> kinectpv2, kinect windows v2 library processing color fepth example, color frame aligned depth frame */ import kinectpv2.*; kinectpv2 kinect; int [] depthzero; //buffer array 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 array 0s (int = 0; < kinectpv2.widthdepth; i++) { (int j = 0; j < 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(); // size: 434,176 (512*424) //get raw data depth , color int [] colorraw = kinect.getrawcolor(); // size: 2,073,600 (1920*1080) int [] depthraw = kinect.getrawdepthdata(); // 434176 //clean de pixels papplet.arraycopy(depthzero, depthtocolorimg.pixels); int count = 0; depthtocolorimg.loadpixels(); (int = 0; < kinectpv2.widthdepth; i++) { (int j = 0; j < kinectpv2.heightdepth; j++) { //incoming pixels 512 x 424 position in 1920 x 1080 float valx = mapdct[count * 2 + 0]; float valy = mapdct[count * 2 + 1]; //maps pixels 512 x 424, not necessary 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 >= 0 && valxdepth < 512 && valydepth >= 0 && valydepth < 424 && valxcolor >= 0 && valxcolor < 1920 && valycolor >= 0 && valycolor < 1080) { float col = map(depthraw[valydepth * 512 + valxdepth], 0, 4500, 0, 255); //color colorpixel = colorraw[valycolor * 1920 + valxcolor]; // works intended color colorpixel = color(col); // doesn't 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); }
i posted solution issues here: https://forum.processing.org/two/discussion/comment/95494#comment_95494
Comments
Post a Comment