Can't Destory the model in HumanBodyTracking3D
If I track a human ,the model will instantiate and update correctly,but when I move the camera out of the people, the log Removing a skeleton [{humanBody.trackableId}]." has not been called. So that the instantiated model will not be destroyed.
foreach (var humanBody in eventArgs.removed)
{
Debug.Log($"Removing a skeleton [{humanBody.trackableId}].");
if (m_SkeletonTracker.TryGetValue(humanBody.trackableId, out boneController))
{
Destroy(boneController.gameObject);
m_SkeletonTracker.Remove(humanBody.trackableId);
}
}
The removed list comes from ARKit, and human bodies never get "removed". Use the tracking state to determine when a person has moved out of frame.
The
removedlist comes from ARKit, and human bodies never get "removed". Use the tracking state to determine when a person has moved out of frame.
Do you mean it has no purpose in ARFoundation and is unused? If that is the case, then this fragment of code should be removed because it brings a lot of confusion.
I mean it is up to the underlying AR framework to decide when to remove a trackable, and while ARKit could decide that a human body will never be tracked again and remove it, in general we have found that if it just goes out of frame for a bit it will change its tracking state but not remove it. So it is not impossible, but the exact situations in which this could happen is an implementation detail in ARKit.
All trackables work this way: the lifecycle is "added", then periodically "updated" with new positions, data, tracking state, etc, then potentially "removed".
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The
removedlist comes from ARKit, and human bodies never get "removed". Use the tracking state to determine when a person has moved out of frame.
What is a proper way in case of Human body tracking scene to receive "tracking state" information, doesn't seem to allow to access it.
The ARHumanBody component has a trackingState property.
In @FantasyTianyu 's snippet, it would be humanBody.trackingState.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The ARHumanBody component has a trackingState property.
In @FantasyTianyu 's snippet, it would be
humanBody.trackingState.
Something just doesn't make any sense. Could you please provide a specific place where to call: Debug.Log(humanBody.trackingState); ?
void Start()
{
GetComponent<ARHumanBodyManager>().humanBodiesChanged += OnHumanBodiesChanged;
}
void OnHumanBodiesChanged(ARHumanBodiesChangedEventArgs eventArgs)
{
foreach (var humanBody in eventArgs.updated)
{
Debug.Log($"human body {humanBody.trackableId} has tracking state {humanBody.trackingState}");
}
}
void Start() { GetComponent<ARHumanBodyManager>().humanBodiesChanged += OnHumanBodiesChanged; } void OnHumanBodiesChanged(ARHumanBodiesChangedEventArgs eventArgs) { foreach (var humanBody in eventArgs.updated) { Debug.Log($"human body {humanBody.trackableId} has tracking state {humanBody.trackingState}"); } }
So that's what I had in mind. This is not a correct approach. Once the body tracking is lost (tracking of the body doesn't happen) this update part is never reached, so Debug.Log() wouldn't be called. I've tried it before. Of course, it would be ok if the body tracking takes place, but we need to get the trackingState value once that body tracking is lost.
When I run this, if the human I am tracking moves out of frame, I get one "updated" event with trackingState None. After that, I get no further updates on that human until they are tracked again. This is the expected behavior. Are you seeing something different?
If you want to know the tracking state of a particular human body at any given time, you can iterate all of them with ARHumanBodyManager.trackables or get a specific one by id with ARHumanBodyManager.GetHumanBody.
Hello. You are right! We get 1 frame! Awesome! Problem solved! Thanks!