+ // Delete lost trackers
+ vector<Person> outPersons;
+ for (auto it = trackers.begin(); it < trackers.end(); it++){
+ if ((*it)->status == TrackerStatus::Delete){
+ Person test; // TODO
+ outPersons.push_back(test);
+ trackers.erase(it);
+ }
+ }
+
+ // callback and notify engine - persons out
+ if (outPersons.size() > 0){
+ if (auto e = engine.lock()){
+ e->onPersonsOut(outPersons);
+ }
+ }
+}
+
+static cv::Mat image_crop(const cv::Mat& image, const Detection& bb)
+{
+ return image(getRectInDetection(bb));
+}
+
+PatchPtr MultiTracker::createPatch(const Mat& image, const Detection& detect)
+{
+ PatchPtr patch(new Patch());
+
+ // calculate hog descriptors, size is 3780
+ Mat im, im2;
+ im = image_crop(image, detect);
+ resize(im, im2, PREFERRED_SIZE);
+ vector<float> feature_hog;
+ this->descriptor.compute(im2, feature_hog);
+
+ // calculate histogram, size is (64 x 45)
+ Mat hsv, hist;
+ cvtColor(im, hsv, COLOR_BGR2HSV);
+ int channels[] = {0, 1};
+ int histSize[] = {45, 64};
+ float hranges[] = {0, 180};
+ float sranges[] = {0, 256};
+ const float* ranges[] = {hranges, sranges};
+ calcHist(&hsv, 1, channels, Mat(), hist, 2, histSize, ranges, true, false);
+
+ patch->image_crop = im.clone();
+ patch->detection = detect;
+ std::vector<double> feature_hog_double (feature_hog.begin(), feature_hog.end()); // convert to double
+ patch->features = std::make_pair(feature_hog_double, hist);
+ return patch;