How to clean up vertices of an ofxKinectV2 generated pointcloud?

Hi, I’m new to OF and my first project uses a Kinect V2 to generate a three dimensional model of a performer which will be textured with a generative shader. Before that, I have to figure out how to get a clean triangulation of the given vertices.

Right now it looks like this:

Vertices which aren’t really adjacent to each other are connected by ofMesh resulting in weird, rain like distortions. I tried to compute a sane order of indices, based on Dan Buzzos tutorials on YT but to no avail.
Another try was given to ofxDelaunay, but it didn’t draw anything in my setup and the triangulate method stalls my update loop. It might be to slow for the amount of vertex data I provide it with.

Here’s my code.

Thanks in advance!

Check out Elliot woods Kinect for windows addon GitHub - elliotwoods/ofxKinectForWindows2: Implementation of Kinect For Windows v2 API (not using KinectCommonBridge) there is a good example of making the triangulation. It basically follows the pixel pattern, but you can check the distance between ant two points and only create the indicies of the points are less than a distance apart. This is not a perfect approach but will give a good enough result. To do proper surface reconstruction from points is difficult and very slow last time I checked. The update method in this file should show you how to do it

This addon uses the actual windows drivers. If you are using libfreenect drivers I had added this to a fork of ofxkinectv2 a long time ago. There should be an example that does what you want in this repo. GitHub - fred-dev/ofxKinectV2: An addon for the new Kinect For Windows V2 sensor.

walking thru the code I cant follow exactly how you are building the indices. As @fresla says - you can crop out garbage meshing by checking the distance between vertices and meshing or not meshing. However on a quick read of the code it appears that you are cropping out vertices before building your point cloud at line 240?
if (vertex.z > nearClip && vertex.z < farClip)
but this will give you a non-square grid to triangulate from ?

happy to help if I can

Hey @danb and @fresla , thank you both for the suggestions! back from vacation I adapted the code from eliot woods depth implementation and it’s still broken. I understand what the basic principle is, but I can’t figure out why vertices from all over the place are passing the conditions to create triangles in my case…

I updated my gist from above with my code.

looking at the images there is a consistent recurring mis-alignment - possibly the code is mis-counting the width or height that it is triangulating - as you make left and right triangles going across it should stop one vertex before the end of the row and also one vertex before the bottom of the column… it looks like the (either) lower or left most last triangle is actually linking to the next vertex in the next column/row