pedestrian-demo: smoothed tracking a bit

pull/3471/head
kallaballa 2 years ago
parent 4bc36e1750
commit d15063072a
  1. 6
      modules/v4d/samples/pedestrian-demo.cpp

@ -210,12 +210,16 @@ public:
{ {
window->parallel([](cv::UMat& videoFrameDownGrey, Detection& detection, const uint64_t& frameCnt, cv::Rect& tracked, Cache& cache){ window->parallel([](cv::UMat& videoFrameDownGrey, Detection& detection, const uint64_t& frameCnt, cv::Rect& tracked, Cache& cache){
// cerr << "track: " << frameCnt << " " << cache.fps_ << endl; // cerr << "track: " << frameCnt << " " << cache.fps_ << endl;
cv::Rect oldTracked = tracked;
if((cache.fps_ == 0 || frameCnt % cache.fps_ == 0) || !detection.tracker_->update(videoFrameDownGrey, tracked)) { if((cache.fps_ == 0 || frameCnt % cache.fps_ == 0) || !detection.tracker_->update(videoFrameDownGrey, tracked)) {
cache.fps_ = uint64_t(std::ceil(Global::fps())); cache.fps_ = uint64_t(std::ceil(Global::fps()));
//detection failed - re-detect //detection failed - re-detect
detection.redetect_ = true; detection.redetect_ = true;
} }
tracked.x = (oldTracked.x + tracked.x) / 2.0;
tracked.y = (oldTracked.y + tracked.y) / 2.0;
tracked.width = (oldTracked.width + tracked.width) / 2.0;
tracked.height = (oldTracked.height+ tracked.height) / 2.0;
}, videoFrameDownGrey_, detection_, window->frameCount(), tracked_, cache_); }, videoFrameDownGrey_, detection_, window->frameCount(), tracked_, cache_);
} }
window->endbranch(dontRedect_, detection_.trackerInitialized_, detection_.redetect_); window->endbranch(dontRedect_, detection_.trackerInitialized_, detection_.redetect_);

Loading…
Cancel
Save