Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/body tracking #96

Open
wants to merge 5 commits into
base: feature/body-tracking
Choose a base branch
from

Conversation

nathantsoi
Copy link

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

@@ -29,7 +29,7 @@ class pyk4a_build_ext(build_ext):
boolean_options = build_ext.boolean_options + ['enable-body-tracking', ]

def initialize_options(self):
self.enable_body_tracking = False
self.enable_body_tracking = True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan was to merge the body tracking branch into the master branch someday.
I worry we will forget to reset this to False before the merge.

pyk4a/pyk4a.cpp Outdated
@@ -1254,6 +1255,12 @@ extern "C" {
free(buffer);
}

static void capsule_cleanup_body_ids(PyObject *capsule) {
fprintf(stdout, "free called on body ids");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fprintf should be removed after you confirm it is called properly

@lpasselin
Copy link
Collaborator

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.

@romilpunetha
Copy link

Any ideas when this will make it to master?

@lpasselin
Copy link
Collaborator

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.

@romilpunetha
Copy link

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.

@0xc1c4da
Copy link

0xc1c4da commented Apr 4, 2021

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

@ZhengyangSun1020
Copy link

@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.

@ZdenekM
Copy link

ZdenekM commented Mar 23, 2022

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

@Jakub-Dv
Copy link

Jakub-Dv commented Mar 30, 2022

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.

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

Successfully merging this pull request may close these issues.

7 participants