From dd3ccad0e24c626b8e2d468a84d7d8c0452b7870 Mon Sep 17 00:00:00 2001 From: kallaballa Date: Sat, 24 Jun 2023 04:24:46 +0200 Subject: [PATCH] optimized pedestrian-demo performance --- modules/v4d/samples/pedestrian-demo.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/v4d/samples/pedestrian-demo.cpp b/modules/v4d/samples/pedestrian-demo.cpp index 0b055c0e7..e3a331004 100644 --- a/modules/v4d/samples/pedestrian-demo.cpp +++ b/modules/v4d/samples/pedestrian-demo.cpp @@ -125,9 +125,13 @@ static bool iteration() { static vector> boxes; //probability of detected object being a pedestrian - currently always set to 1.0 static vector probs; - + //Faster tracking parameters + static cv::TrackerKCF::Params params; + params.desc_pca = cv::TrackerKCF::GRAY; + params.compress_feature = false; + params.compressed_size = 1; //KCF tracker used instead of continous detection - static cv::Ptr tracker = cv::TrackerKCF::create(); + static cv::Ptr tracker = cv::TrackerKCF::create(params); //The bounding rectangle of the currently tracked pedestrian static cv::Rect tracked(0,0,1,1); static bool trackerInit = false; @@ -150,11 +154,11 @@ static bool iteration() { tracked = cv::Rect(0,0,1,1); //Try to track the pedestrian (if we currently are tracking one), else re-detect using HOG descriptor - if (redetect || !tracker->update(videoFrameDown, tracked)) { + if (!trackerInit || redetect || !tracker->update(videoFrameDownGrey, tracked)) { redetect = false; tracked = cv::Rect(0,0,1,1); //Detect pedestrians - hog.detectMultiScale(videoFrameDownGrey, locations, 0, cv::Size(), cv::Size(), 1.025, 2.0, false); + hog.detectMultiScale(videoFrameDownGrey, locations, 0, cv::Size(), cv::Size(), 1.15, 2.0, false); if (!locations.empty()) { boxes.clear(); @@ -177,7 +181,7 @@ static bool iteration() { if(!trackerInit) { //initialize the tracker once - tracker->init(videoFrameDown, tracked); + tracker->init(videoFrameDownGrey, tracked); trackerInit = true; }