pyk4a icon indicating copy to clipboard operation
pyk4a copied to clipboard

Feature/body tracking

Open nathantsoi opened this issue 4 years ago • 8 comments

2 changes in this branch / pr:

  • enable body tracking by default, so no extra build-time params are required
  • add the body track id, so each body can be uniquely identified

nathantsoi avatar Jan 15 '21 03:01 nathantsoi

Hi and thanks for the PR!

I always assumed body_id was simply an index. After seeing your PR, I assume body_id is unique and matches a specific person only.

It is sad the Capsule.body_index_map uses indexes instead of body_ids. Otherwise, we could have used a dict to store the body_skeleton without having Capsule.body_ids

Do you think we should save the capsule usage by replacing the body_id numpy array with a tuple? This tuple would be created without having to malloc and free in the c extension (see here: https://stackoverflow.com/a/55987196).

It's just an idea, let me know if you think it would be faster this way.

lpasselin avatar Jan 15 '21 16:01 lpasselin

Any ideas when this will make it to master?

romilpunetha avatar Mar 24 '21 09:03 romilpunetha

It's not my top priority right now. If you absolutely need this branch and the newer features in dev/master, I'll try to find some time to work on it.

lpasselin avatar Mar 25 '21 02:03 lpasselin

It's not my top priority right now. If you absolutely need this branch and the newer features in dev/master, I'll try to find some time to work on it.

Yup. I needed the body tracking sdk for python. I'm trying to build something on top of it which will run on linux, hence needed this capability.

romilpunetha avatar Mar 25 '21 04:03 romilpunetha

@lpasselin please find some time to work on it, I also need this capability, currently using @nathantsoi 's branch

0xc1c4da avatar Apr 04 '21 07:04 0xc1c4da

@lpasselin please find some time to work on it, I also need this capability, currently using @nathantsoi 's branch

Yep, I also need this haha.

ZhengyangSun1020 avatar Apr 10 '21 13:04 ZhengyangSun1020

It would be great to have body tracking in the master!

ZdenekM avatar Mar 23 '22 08:03 ZdenekM

In my testing, I've found that cleanup functions capsule_cleanup_body_ids and capsule_cleanup_body_data are never called. What I found:

  • no circular reference on body_skeleton
  • len(gc.get_referrers(capture._body_skeleton)) == 1, as it should be
  • when adding fprints to other cleanup functions, I can see that capsule_cleanup_capture is properly called every time capture goes out of scope

How to reproduce: Simply run python3 examples/pose_display_2d.py and watch process memory go up.

I don't really know why is that happening but it causes huge memory leaks (~14 MB/s if capture.body_skeleton is called on each capture and FPS is 30). @lpasselin Can you find some time to investigate this issue please?

Edit: I've managed to get body_ids and body_skeleton working (I've removed body_index_map as it was not working with the same 'fix'). See https://github.com/Jakub-Dv/pyk4a/tree/feature/body-tracking. I don't really know if this is the correct fix, but it works.

Jakub-Dv avatar Mar 30 '22 09:03 Jakub-Dv