#include "MultiTracker.h"
-#include "Metrics.h"
#include <algorithm>
#include "hungarian.h"
#include "Logger.h"
#include "Utils.h"
+#include <cstdlib>
+#include <stdexcept>
using namespace suanzi;
using namespace cv;
static const cv::Size PREFERRED_SIZE = Size(64, 128);
static const double MaxCost = 100000;
static const double ProbThreshold = 0.05;
+static const int MaxTrackers = 100;
MultiTracker::MultiTracker(EngineWPtr e)
: engine(e)
cv::Mat im2(PREFERRED_SIZE, p2->image_crop.type());
cv::resize(p1->image_crop, im1, im1.size());
cv::resize(p2->image_crop, im2, im2.size());
- cv::Mat result;
+
+ cv::Mat result = Mat::zeros(1,1, CV_64F);
+
cv::matchTemplate(im1, im2, result, CV_TM_CCOEFF_NORMED);
feature.push_back(result.at<double>(0, 0));
cv::matchTemplate(im1, im2, result, CV_TM_CCORR_NORMED);
feature.push_back(calc_iou_ratio(getRectInDetection(d1), getRectInDetection(d2)));
+// for (auto i : feature){
+// cout << i << "\t";
+// if (isnan(i)){
+// throw overflow_error("Nan in feature");
+// }
+// }
+// cout << endl;
+//
return feature;
}
ss = similarity(i, patch);
features.insert(features.end(), ss.begin(), ss.end());
}
- double prob = predictor->predict(Tracker::MaxPatch - 1, features); // TODO why is MaxPatch-1
+ double prob = predictor->predict(tracker->patches.size() - 1, features); // TODO why is MaxPatch-1
if (prob > ProbThreshold)
return -log(prob);
else
for (auto i : unmatch_bbs_indices){
TrackerPtr new_tracker (new Tracker(image, detections[i]));
new_tracker->addPatch(createPatch(image, detections[i]));
- this->trackers.push_back(new_tracker);
+ addTracker(new_tracker);
Person test; // TODO
inPersons.push_back(test);
}
patch->features = std::make_pair(feature_hog_double, hist);
return patch;
}
+
+void MultiTracker::addTracker(TrackerPtr t)
+{
+ trackers.insert(trackers.begin(), t);
+ if(trackers.size() > MaxTrackers){
+ LOG_ERROR(TAG, "trackers reaches the maximum " + to_string(MaxTrackers));
+ trackers.pop_back();
+ }
+}