|
|
|
|
|
|
|
|
|
|
void ProcessLabel(Labeling labeledEntity) |
|
|
|
{ |
|
|
|
// Cache out the data of a labeled game object the first time we see it, this will
|
|
|
|
// save performance each frame. Also checks to see if a labeled game object can be annotated.
|
|
|
|
if (!m_KnownStatus.ContainsKey(labeledEntity.instanceId)) |
|
|
|
if (idLabelConfig.TryGetLabelEntryFromInstanceId(labeledEntity.instanceId, out var labelEntry)) |
|
|
|
var cached = new CachedData() |
|
|
|
// Cache out the data of a labeled game object the first time we see it, this will
|
|
|
|
// save performance each frame. Also checks to see if a labeled game object can be annotated.
|
|
|
|
if (!m_KnownStatus.ContainsKey(labeledEntity.instanceId)) |
|
|
|
status = false, |
|
|
|
animator = null, |
|
|
|
keypoints = new KeypointEntry(), |
|
|
|
overrides = new List<(JointLabel, int)>() |
|
|
|
}; |
|
|
|
var cached = new CachedData() |
|
|
|
{ |
|
|
|
status = false, |
|
|
|
animator = null, |
|
|
|
keypoints = new KeypointEntry(), |
|
|
|
overrides = new List<(JointLabel, int)>() |
|
|
|
}; |
|
|
|
|
|
|
|
if (idLabelConfig.TryGetLabelEntryFromInstanceId(labeledEntity.instanceId, out var labelEntry)) |
|
|
|
{ |
|
|
|
var entityGameObject = labeledEntity.gameObject; |
|
|
|
|
|
|
|
cached.keypoints.instance_id = labeledEntity.instanceId; |
|
|
|
|
|
|
cached.status = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
m_KnownStatus[labeledEntity.instanceId] = cached; |
|
|
|
m_KnownStatus[labeledEntity.instanceId] = cached; |
|
|
|
} |
|
|
|
|
|
|
|
var cachedData = m_KnownStatus[labeledEntity.instanceId]; |
|
|
|
|
|
|
|
if (cachedData.status) |
|
|
|
{ |
|
|
|
var animator = cachedData.animator; |
|
|
|
var keypoints = cachedData.keypoints.keypoints; |
|
|
|
var cachedData = m_KnownStatus[labeledEntity.instanceId]; |
|
|
|
// Go through all of the rig keypoints and get their location
|
|
|
|
for (var i = 0; i < activeTemplate.keypoints.Length; i++) |
|
|
|
if (cachedData.status) |
|
|
|
var pt = activeTemplate.keypoints[i]; |
|
|
|
if (pt.associateToRig) |
|
|
|
var animator = cachedData.animator; |
|
|
|
var keypoints = cachedData.keypoints.keypoints; |
|
|
|
|
|
|
|
// Go through all of the rig keypoints and get their location
|
|
|
|
for (var i = 0; i < activeTemplate.keypoints.Length; i++) |
|
|
|
var bone = animator.GetBoneTransform(pt.rigLabel); |
|
|
|
if (bone != null) |
|
|
|
var pt = activeTemplate.keypoints[i]; |
|
|
|
if (pt.associateToRig) |
|
|
|
var loc = ConvertToScreenSpace(bone.position); |
|
|
|
keypoints[i].index = i; |
|
|
|
keypoints[i].x = loc.x; |
|
|
|
keypoints[i].y = loc.y; |
|
|
|
keypoints[i].state = 2; |
|
|
|
var bone = animator.GetBoneTransform(pt.rigLabel); |
|
|
|
if (bone != null) |
|
|
|
{ |
|
|
|
var loc = ConvertToScreenSpace(bone.position); |
|
|
|
keypoints[i].index = i; |
|
|
|
keypoints[i].x = loc.x; |
|
|
|
keypoints[i].y = loc.y; |
|
|
|
keypoints[i].state = 2; |
|
|
|
} |
|
|
|
} |
|
|
|
// Go through all of the additional or override points defined by joint labels and get
|
|
|
|
// their locations
|
|
|
|
foreach (var (joint, idx) in cachedData.overrides) |
|
|
|
{ |
|
|
|
var loc = ConvertToScreenSpace(joint.transform.position); |
|
|
|
keypoints[idx].index = idx; |
|
|
|
keypoints[idx].x = loc.x; |
|
|
|
keypoints[idx].y = loc.y; |
|
|
|
keypoints[idx].state = 2; |
|
|
|
} |
|
|
|
// Go through all of the additional or override points defined by joint labels and get
|
|
|
|
// their locations
|
|
|
|
foreach (var (joint, idx) in cachedData.overrides) |
|
|
|
{ |
|
|
|
var loc = ConvertToScreenSpace(joint.transform.position); |
|
|
|
keypoints[idx].index = idx; |
|
|
|
keypoints[idx].x = loc.x; |
|
|
|
keypoints[idx].y = loc.y; |
|
|
|
keypoints[idx].state = 2; |
|
|
|
} |
|
|
|
cachedData.keypoints.pose = "unset"; |
|
|
|
cachedData.keypoints.pose = "unset"; |
|
|
|
if (cachedData.animator != null) |
|
|
|
{ |
|
|
|
cachedData.keypoints.pose = GetPose(cachedData.animator); |
|
|
|
} |
|
|
|
if (cachedData.animator != null) |
|
|
|
{ |
|
|
|
cachedData.keypoints.pose = GetPose(cachedData.animator); |
|
|
|
} |
|
|
|
m_AsyncAnnotations[m_CurrentFrame].keypoints[labeledEntity.instanceId] = cachedData.keypoints; |
|
|
|
m_AsyncAnnotations[m_CurrentFrame].keypoints[labeledEntity.instanceId] = cachedData.keypoints; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|