Use kinect to count number of people in a room.

670 views
Skip to first unread message

DenKinect

unread,
Jun 24, 2011, 1:08:25 AM6/24/11
to OpenNI
Hi,

I am doing a possible use of the kinect to count the number of people
in a room intelligently. The kinect would be counting the number of
people entering a particular room and then records it down. Then if
one person leaves the rooms, it would then minus it from its data,
updating the current number of people in a room.

But now, I am stuck with how will the kinect recognize whether the
user is entering the room or leaving the room. i thought of putting a
point (let's say a point at left side for entering another at right
for leaving) to differentiate between entering and leaving. Is this
possible?

If not, can you suggest any other ways to achieve this?

Any help would be appreciated! Thanks.

DenKinect

unread,
Jun 24, 2011, 1:11:07 AM6/24/11
to OpenNI
I am using c# programming btw.

kinector

unread,
Jun 24, 2011, 10:43:24 AM6/24/11
to OpenNI
Hello DenKinect

Look at the samples. When you enter the screen it recognizes the user.
For the skeleton of course you have to pose the T-Position but I think
the other thing should be simple to implement.

kind regards

Kinector
> > Any help would be appreciated! Thanks.- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Prasanna

unread,
Jun 29, 2011, 7:01:39 PM6/29/11
to openn...@googlegroups.com
You can start the user generator to start recognizing people. It automatically does what you want to do. Keeps the count of the number of people in the scene. Check out this function -

inline XnUInt16 GetNumberOfUsers() const

DenKinect

unread,
Jul 1, 2011, 1:19:21 AM7/1/11
to OpenNI
Thanks a lot! It indeed works! :)

Just another question...in the NIUserTracker sample, there is a float
at "foreach (int user in users)" and inside there is com.X and com.Y
which tracks the User coordinates in the frame. I tried using it make
a if statement "if(com.X >= 500)" to make it count 1 for a person who
passed through that point.

But now it just keep counting endlessly as it is in a for loop. Is
there anyway that I can make it only count once? Maybe like a
statement which allows do once only in a for loop or able to declare
the com.X or com.Y as a global variable and use it out of the for-
loop?

Any idea? Any help would be appreciated.

Yifan Jiang

unread,
Jul 1, 2011, 1:54:09 AM7/1/11
to openn...@googlegroups.com
Hi,

I am not sure how C# wrapper works like :)

But from my understanding, the GetCom tracks a user's
mess center continuously until the camera loses the user.

The method you are using calculate all of the user's mess
center X >= 500, regardless they are passing by some where.
i.e A user, whose mess center coord more than 500, stays
somewhere in the camerathere without any movement, the condition
will be 'True'.

If you wanna calculate a person passing by some specific point,
maybe you need to connect all the CoM.X of one user's movement
to a line, then see if the line actually crossing X=500.

Just a rough idea, hope it is understandable :P

Best wishes,
Yifan


--
You received this message because you are subscribed to the Google Groups "OpenNI" group.
To post to this group, send email to openn...@googlegroups.com.
To unsubscribe from this group, send email to openni-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openni-dev?hl=en.


Prasanna

unread,
Jul 1, 2011, 12:41:08 PM7/1/11
to openn...@googlegroups.com
Yes, Yifang is right.

Here s what I think you are trying to do - Count how many times a person is passing a particular point in one direction. If this is right, then try this...

if person.X from current frame > 500 and person.X from previous frame <= 500 then count = count + 1.

At 30 fps, checking the previous frame will result in a narrow range and might not work all the time and if the user is making small zig zag motions at X = 500. So i suggest you check person.X from say 10 frames before the current frame.

DenKinect

unread,
Jul 6, 2011, 2:38:38 AM7/6/11
to OpenNI
Ok Thanks a lot!!

DenKinect

unread,
Jul 6, 2011, 3:16:06 AM7/6/11
to OpenNI
Is there anyway to declare the com.X outside of the foreach loop
because it just keep repeating the loop which results in a person
being counted more than once. I have thought of using array to this.
Is there any suggestion for this?



On Jul 2, 12:41 am, Prasanna <maxg...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages