Project import generated by Copybara.
GitOrigin-RevId: 5b23708185311ae39a8605b0c2eff721e7b4939f
This commit is contained in:
@@ -316,6 +316,7 @@ cc_library(
|
||||
"//mediapipe/util/tracking",
|
||||
"//mediapipe/util/tracking:box_tracker",
|
||||
"//mediapipe/util/tracking:tracking_visualization_utilities",
|
||||
"@com_google_absl//absl/container:flat_hash_set",
|
||||
"@com_google_absl//absl/container:node_hash_set",
|
||||
"@com_google_absl//absl/strings",
|
||||
],
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "absl/container/node_hash_set.h"
|
||||
#include "absl/strings/numbers.h"
|
||||
#include "mediapipe/calculators/video/box_tracker_calculator.pb.h"
|
||||
@@ -238,6 +239,11 @@ class BoxTrackerCalculator : public CalculatorBase {
|
||||
// Queued track time requests.
|
||||
std::vector<Timestamp> queued_track_requests_;
|
||||
|
||||
// Stores the tracked ids that have been discarded actively, from continuous
|
||||
// tracking data. It may accumulate across multiple frames. Once consumed, it
|
||||
// should be cleared immediately.
|
||||
absl::flat_hash_set<int> actively_discarded_tracked_ids_;
|
||||
|
||||
// Add smooth transition between re-acquisition and previous tracked boxes.
|
||||
// `result_box` is the tracking result of one specific timestamp. The smoothed
|
||||
// result will be updated in place.
|
||||
@@ -1144,9 +1150,16 @@ void BoxTrackerCalculator::StreamTrack(const TrackingData& data,
|
||||
CHECK(box_map);
|
||||
CHECK(failed_ids);
|
||||
|
||||
// Cache the actively discarded tracked ids from the new tracking data.
|
||||
for (const int discarded_id :
|
||||
data.motion_data().actively_discarded_tracked_ids()) {
|
||||
actively_discarded_tracked_ids_.insert(discarded_id);
|
||||
}
|
||||
|
||||
// Track all existing boxes by one frame.
|
||||
MotionVectorFrame mvf; // Holds motion from current to previous frame.
|
||||
MotionVectorFrameFromTrackingData(data, &mvf);
|
||||
mvf.actively_discarded_tracked_ids = &actively_discarded_tracked_ids_;
|
||||
|
||||
if (forward) {
|
||||
MotionVectorFrame mvf_inverted;
|
||||
|
||||
Reference in New Issue
Block a user