Skip to content
Snippets Groups Projects
Commit 05615bb8 authored by Corvin-N's avatar Corvin-N
Browse files

Extract preparation of trackedHumans for association in extra method

parent 26182499
No related branches found
No related tags found
2 merge requests!68Add human tracking,!28Draft: Dev -> Main
...@@ -12,24 +12,7 @@ namespace armarx::navigation::human ...@@ -12,24 +12,7 @@ namespace armarx::navigation::human
void void
HumanTracker::update(const CameraMeasurement& measurements) HumanTracker::update(const CameraMeasurement& measurements)
{ {
// iterate over all existing tracked humans prepareTrackedHumans(measurements.detectionTime);
for (auto it = trackedHumans.begin(); it != trackedHumans.end();)
{
auto& human = *it;
// when the tracked human recieved no new measurement for too long, remove it
if ((measurements.detectionTime - human.humanFilter.get().detectionTime) >=
parameters.maxTrackingAge)
{
it = trackedHumans.erase(it);
}
// otherwise the tracked human is prepared for association at the current point in time
else
{
human.associated = false;
human.humanFilter.propagation(measurements.detectionTime);
it++;
}
}
// calculate the poses according to the new received measurements // calculate the poses according to the new received measurements
std::vector<DetectedHuman> newPoses = std::vector<DetectedHuman> newPoses =
...@@ -166,27 +149,19 @@ namespace armarx::navigation::human ...@@ -166,27 +149,19 @@ namespace armarx::navigation::human
std::vector<HumanTracker::PosLaserDistance> std::vector<HumanTracker::PosLaserDistance>
HumanTracker::getSortedDistances(std::vector<TrackedHuman>& oldHumans, HumanTracker::getSortedDistances(std::vector<TrackedHuman>& oldHumans,
std::vector<Cluster>& newClusters) std::vector<AdvancedCluster>& newClusters)
{ {
std::vector<PosLaserDistance> posDistances; std::vector<PosLaserDistance> posDistances;
for (auto& newCluster : newClusters) for (auto& oldHuman : oldHumans)
{ {
//calculate center of cluster for (auto& newCluster : newClusters)
Eigen::Vector2f clusterCenter;
for (auto& point : newCluster.points)
{
clusterCenter += point;
}
clusterCenter /= newCluster.points.size();
for (auto& oldHuman : oldHumans)
{ {
// calculate distance between every possible combination of tracked human and cluster // calculate distance between every possible combination of tracked human and cluster
posDistances.push_back( posDistances.push_back(
{&oldHuman, {&oldHuman,
&newCluster, &newCluster,
(clusterCenter - oldHuman.humanFilter.get().pose.translation()).norm()}); (newCluster.center - oldHuman.humanFilter.get().pose.translation()).norm()});
} }
} }
...@@ -272,4 +247,27 @@ namespace armarx::navigation::human ...@@ -272,4 +247,27 @@ namespace armarx::navigation::human
return maxSize; return maxSize;
} }
void
HumanTracker::prepareTrackedHumans(DateTime time)
{
// iterate over all existing tracked humans
for (auto it = trackedHumans.begin(); it != trackedHumans.end();)
{
auto& human = *it;
// when the tracked human recieved no new measurement for too long, remove it
if ((time - human.humanFilter.get().detectionTime) >= parameters.maxTrackingAge)
{
it = trackedHumans.erase(it);
}
// otherwise the tracked human is prepared for association at the current point in time
else
{
human.associatedClusters = 0;
human.associated = false;
human.humanFilter.propagation(time);
it++;
}
}
}
} // namespace armarx::navigation::human } // namespace armarx::navigation::human
...@@ -76,6 +76,14 @@ namespace armarx::navigation::human ...@@ -76,6 +76,14 @@ namespace armarx::navigation::human
{ {
HumanFilter humanFilter; HumanFilter humanFilter;
std::optional<std::string> trackingId = std::nullopt; std::optional<std::string> trackingId = std::nullopt;
int associatedClusters;
bool associated;
};
struct AdvancedCluster
{
Eigen::Vector2f center;
Cluster cluster;
bool associated; bool associated;
}; };
...@@ -89,7 +97,7 @@ namespace armarx::navigation::human ...@@ -89,7 +97,7 @@ namespace armarx::navigation::human
struct PosLaserDistance struct PosLaserDistance
{ {
HumanTracker::TrackedHuman* oldHuman; HumanTracker::TrackedHuman* oldHuman;
Cluster* newCluster; AdvancedCluster* newCluster;
float distance; float distance;
}; };
...@@ -172,7 +180,7 @@ namespace armarx::navigation::human ...@@ -172,7 +180,7 @@ namespace armarx::navigation::human
*/ */
std::vector<PosLaserDistance> std::vector<PosLaserDistance>
getSortedDistances(std::vector<HumanTracker::TrackedHuman>& oldHumans, getSortedDistances(std::vector<HumanTracker::TrackedHuman>& oldHumans,
std::vector<Cluster>& newClusters); std::vector<AdvancedCluster>& newClusters);
/** /**
* @brief HumanTracker::associateHumans Associates those tracked and detected humans that * @brief HumanTracker::associateHumans Associates those tracked and detected humans that
* belong together. * belong together.
...@@ -194,6 +202,10 @@ namespace armarx::navigation::human ...@@ -194,6 +202,10 @@ namespace armarx::navigation::human
* @return the size * @return the size
*/ */
float getClusterSize(Cluster cluster); float getClusterSize(Cluster cluster);
/**
* @brief prepareTrackedHumans
*/
void prepareTrackedHumans(DateTime time);
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment