Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

How to get/output the distance a person is away from the Kinect once their body is detected? #1042

Closed
MaaaChu opened this issue Jan 20, 2020 · 5 comments

Comments

@MaaaChu
Copy link

MaaaChu commented Jan 20, 2020

I'm pretty new to developing with the Kinect and I'm using the Kinect to extract data a person's movements in a room.

Firstly, I want to get the distance a person is away from the Kinect after their body has been detected using the body tracking SDK.
I'm looking to achieve something similar to the Cognitive Services example where a distance in mm is output when a person is detected.

Any suggestions are appreciated! Thanks.

@RoseFlunder
Copy link

My guess would be choosing a position from the body (i.e. head) and just calculate the euclidean distance to 0|0|0 because thats the position of the depth camera.

Example:
Head Position is at 2|1|1:
Distance = sqrt((2-0)²+(1-0)²+(1-0)²)

@Sagid28
Copy link

Sagid28 commented Feb 12, 2020

My guess would be choosing a position from the body (i.e. head) and just calculate the euclidean distance to 0|0|0 because thats the position of the depth camera.

Example:
Head Position is at 2|1|1:
Distance = sqrt((2-0)²+(1-0)²+(1-0)²)

can you give me the source code please if you have.

@RoseFlunder
Copy link

Sorry I don't have an working example at hand, but you could check out this example on how to get all the joint positions:
https://github.com/microsoft/Azure-Kinect-Samples/blob/master/body-tracking-samples/simple_cpp_sample/main.cpp#L15

So after line 15 you would calculate the joints distance to the camera like this:
sqrt(position.v[0]*position.v[0] + position.v[1] * position.v[1] + position.v[2] + position.v[2])

For the "sqrt" function you would need to include "math.h"

@Sagid28
Copy link

Sagid28 commented Feb 12, 2020 via email

@angelicaCruz
Copy link

Piggy backing on this comment, is there a way to get the distance of a segmented body that does not have body tracker active on it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants