# Floor Plane Detection

• ### Question

• Hello all,

I'm relatively new to C# and the Kinect for Windows SDK, so I've got a few relatively basic questions to ask after doing a bit of coding, bit of research and a bit of reading. For starters, I do not use my Kinect with an Xbox 360, but I've been told that when the Kinect is connected to an Xbox 360 it looks down and scans for the floor, is this correct?

If so, I'm wondering if there is an inbuilt function to call for the Kinect to scan for the floor (I'm assuming that this wouldn't require skeletal tracking or anything, and would be able to determine it simply from say, the depth data).

I used OpenNI for a very brief period of time before trying out the Windows Kinect SDK, and found something similar to what I was trying to achieve here; https://groups.google.com/forum/#!topic/openni-dev/a9WZDvZtjkk - It'd obviously be nice if such a function existed in this SDK (and awfully convenient for me!)

If such a function doesn't exist, I know how to manually position the kinect and could obviously use such code to move to the correct position, but I'm honestly not too cluey as to how I would figure out what part of my image is the floor, and what part is not the floor. So my question would be, how would I go about using my Kinect to determine where the floor is. Potentially this may involve a full sweep, up and down the room and then moving to the position which best represents the floor (or a decent viewspace relative to the floor) within its range.

Thanks!

- Nic

• Edited by Monday, January 9, 2012 6:15 PM
Monday, January 9, 2012 6:14 PM

• The FloorClipPlane property of a SkeletonFrame gives you what you want. It is a tupple of 4 floats, representing a,b,c, and d of the planes equation (ax+by+cz+d=0). I don't know what the values look like when the Kinect can't see the floor, but you could just listen to the first 50 SkeletonFrames and look if a FloorClipPlane comes up. If not you can set the Kinects angle to make it look down. Then with a bit of luck you get the FloorClipPlane^^

cheers^

Hi theCake, thanks for the reply, considering this is over a month old, I solved this myself (haven't had the time to post back on these forums.

Since the SDK has no quick and easy floorScan(); function, I made one myself ;)

For those of you playing at home and want to do a floor scan, the best way to do it is to use the FloorClipPlane as explained above by theCake, then use a bit of simple trigonometry to determine where the floor sits. Then place it into a simple if statement to ensure that the nearest angle found is in the -27 to 27 range of the kinect.

So in a nut shell, my function acts as follows; scan from position -27 to 27, get values of FloorClipPlane, use inverse tan (Math.Atan) (remembering inverse tan in the math function gives you an answer in radians... that screwed me up a few times!), turn the value into an integer, check if the value is between -27 and 27, if it is, notify the user of the angle/move to said angle.

I wasn't too sure of how fast the kinect would gather the values so I created a quick and slow scan function, both seem to work out just fine, also keep in mind that within triangle your opposite and adjacent sides will flip for 1-27 degrees! (I haven't yet compensated for that but it may be the case that I need 1-27 degrees if my kinect is starting from an odd position).

Also, please keep in mind the limit as to how often you are to send calls to the kinect, don't go breaking it/burning it out!

• Marked as answer by Sunday, February 19, 2012 6:38 PM
Sunday, February 19, 2012 6:38 PM

### All replies

• The FloorClipPlane property of a SkeletonFrame gives you what you want. It is a tupple of 4 floats, representing a,b,c, and d of the planes equation (ax+by+cz+d=0). I don't know what the values look like when the Kinect can't see the floor, but you could just listen to the first 50 SkeletonFrames and look if a FloorClipPlane comes up. If not you can set the Kinects angle to make it look down. Then with a bit of luck you get the FloorClipPlane^^

cheers^

Sunday, February 19, 2012 11:53 AM
• The FloorClipPlane property of a SkeletonFrame gives you what you want. It is a tupple of 4 floats, representing a,b,c, and d of the planes equation (ax+by+cz+d=0). I don't know what the values look like when the Kinect can't see the floor, but you could just listen to the first 50 SkeletonFrames and look if a FloorClipPlane comes up. If not you can set the Kinects angle to make it look down. Then with a bit of luck you get the FloorClipPlane^^

cheers^

Hi theCake, thanks for the reply, considering this is over a month old, I solved this myself (haven't had the time to post back on these forums.

Since the SDK has no quick and easy floorScan(); function, I made one myself ;)

For those of you playing at home and want to do a floor scan, the best way to do it is to use the FloorClipPlane as explained above by theCake, then use a bit of simple trigonometry to determine where the floor sits. Then place it into a simple if statement to ensure that the nearest angle found is in the -27 to 27 range of the kinect.

So in a nut shell, my function acts as follows; scan from position -27 to 27, get values of FloorClipPlane, use inverse tan (Math.Atan) (remembering inverse tan in the math function gives you an answer in radians... that screwed me up a few times!), turn the value into an integer, check if the value is between -27 and 27, if it is, notify the user of the angle/move to said angle.

I wasn't too sure of how fast the kinect would gather the values so I created a quick and slow scan function, both seem to work out just fine, also keep in mind that within triangle your opposite and adjacent sides will flip for 1-27 degrees! (I haven't yet compensated for that but it may be the case that I need 1-27 degrees if my kinect is starting from an odd position).

Also, please keep in mind the limit as to how often you are to send calls to the kinect, don't go breaking it/burning it out!

• Marked as answer by Sunday, February 19, 2012 6:38 PM
Sunday, February 19, 2012 6:38 PM
• Hi,

If you happened to come back here, would you mind sharing the code here or via email? My email is hoangthevinh.htv@gmail.com

Thanks

Tuesday, January 8, 2013 1:01 PM