Kinect Z depth Range selector problem
I am having one heck of a time tackling this problem. I am using the Kinect to do some basic hand tracking on people standing in front of an installation. The problem is that the threshold I need to isolate their hands is on an odd angle because I have to put the Kinect almost on ground level, so when i try to find the appropriate range it finds their hands and legs in the same plane. I made a simple patch using the wonderful jit.freenect.grab object and some of the demo patches that allows me to select a range within the Kinect data, but I need to be able to control the angle as well. Another way to explain what I am trying to do is be able to select a different threshold range on each horizontal line in the matrix in order to shift the threshold to a line that is perpendicular to ground level, NOT perpendicular to the kinect.
Any help is appeciated, I have attached an image that may help explain my problem.
Is it not possible to tilt the camera so that the feet (and possibly lower body) are out of the cameras range?
If that is not possible then to continue with your illustrated method you probably need to be scaling/multiplying the depth data suitably from top to bottom of the image (effectively a grayscale). Maybe with another equal sized matrix via jit. op for example that so the upper part of the scene is interpreted at a closer depth ( assuming something closer is indicated by a higher value x>1.) and the lower range is gradually de-emphasized ( x<1.).
I cant tilt it higher, or the plane becomes completely un-useable.
but as far as the second thought: Thank you, that is a really great solution! I am having problems with it however (I’m kind of an idiot when it comes to this stuff). What operator do I run it through? I have attached what I have so far, which seems to work right at boot up, but it stops working when I try to adjust the gradient. I have attached the new patch.
your drawing is kind of odd
because the cone is symetrical from the camera
this is important for the following
if you drawing is in the plane x y
and find the formula to go from the cone to realspace
then translate your coordonnates ( x = x – x_offset ) to have the center
where you want your plane (green)
then do a rotation ( of the angle between your to plane )
xr = x * cos (angle ) – y * sin( angle )
yr = x * sin( angle ) + y * cos( angle )
the sign of xr give you which side of the plane you are
hope it help
Sorry but I don’t really have too much time to get very deeply into this right now…
I think Maa’s suggestions will probably result in a more technically correct /useable transformation if you can implement it compared to the method I suggested (which may stil work anyway).
As far as your posted example goes – It appears there are two issues: jit.gradient works from left to right (rather than top to bottom as you require) so the resulting greyscale matrix needs to be rotated somehow, and 2: swapping inputs to the jit.op doing the scaling enables adjustments to the gradient without interrupting the process (also maybe try using @ op *)
my patch here gives you a perspective corrected 3d mesh of the kinect’s depth map. you can rotate it to make up for the camera angle and then do your tracking stuff.