Quantcast
Channel: Kinect - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 530

Kinect PointCloudDepthOGL display delay

$
0
0

Hi everyone, I have been trying to achieve a 3-6 sec delay on the live display from my kinect 2's point cloud feed, I am new to all this, so I have been basing my work on the KinectPV2 library by Langeling, I also came across a post here (https://forum.processing.org/two/discussion/15800/how-to-delay-the-feed-of-the-kinect-2-point-cloud) where it is solved but i am having a hard time applying it to the solution I have in hands. this is the code i have in hands

import java.nio.*; import KinectPV2.*;

KinectPV2 kinect;

int Vloc, z = -200, VBOID; float scale = 260, pointScale = 100.0, a = 0.1;

int distanceMax = 4500, distanceMin = 0;

PGL pgl; PShader psh; ArrayList clouds; int limit = 120;

public void setup () { size(1280, 720, P3D); kinect = new KinectPV2(this); kinect.enableDepthImg(true); kinect.enablePointCloud(true); kinect.setLowThresholdPC(distanceMin); kinect.setHighThresholdPC(distanceMax);

kinect.init();

psh = loadShader("frag.glsl", "vert.glsl"); PGL pgl = beginPGL(); IntBuffer buffer = IntBuffer.allocate(1); pgl.genBuffers(1, buffer); VBOID = buffer.get(0); endPGL();

clouds = new ArrayList(); }

public void draw () { background(0); translate(width/2, height/2, z); scale(scale, -1*scale, scale); rotate(a, 0.0f, 1.0f, 0.0f); kinect.setLowThresholdPC(distanceMin); kinect.setHighThresholdPC(distanceMax);

FloatBuffer cloudBuf=kinect.getPointCloudPos();

pgl=beginPGL();
psh.bind();

Vloc=pgl.getAttribLocation(psh.glProgram, "vertex");
pgl.enableVertexAttribArray(Vloc);
int vData=kinect.WIDTHDepth * kinect.HEIGHTDepth *3;

{
 pgl.bindBuffer(PGL.ARRAY_BUFFER, VBOID);
 pgl.bufferData(PGL.ARRAY_BUFFER, Float.BYTES*vData,cloudBuf, PGL.DYNAMIC_DRAW);
 pgl.vertexAttribPointer(Vloc, 3, PGL.FLOAT, false, Float.BYTES*3,0);
}

pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);

//draw point buffer as set of points //this is where the delay-draw mechanis should be? //or what it should encapsulate? pgl.drawArrays(PGL.POINTS, 0, vData);

pgl.disableVertexAttribArray(Vloc);

psh.unbind(); endPGL();

stroke(255,0,0);

}


Viewing all articles
Browse latest Browse all 530

Trending Articles