+ //////
+ if ((cc % 50) == 0){
+ if (EnginePtr e = engine.lock()){
+ e->onStatusChanged();
+ }
+ }
+ cc++;
+
+ //////
+ int row = trackers.size();
+ int col = total;
+ Eigen::MatrixXi cost_matrix = Eigen::MatrixXi::Zero(row, col);
+ for (int i = 0; i < row; i++){
+ for (int j = 0; j < col; j++){
+ //if (calc_iou_ratio(trackers[i], detections[j]) < -0.1)
+ // cost_matrix(i, j) = MaxCost;
+ //else
+ cost_matrix(i, j) = distance(trackers[i], image, detections[j]);
+ }
+ }
+
+ Eigen::VectorXi tracker_inds, bb_inds;
+ linear_sum_assignment(cost_matrix, tracker_inds, bb_inds);
+
+ // handle unmatched trackers
+ //vector<TrackerPtr> unmatched_trackers;
+ for (int i = 0; i < row; i++){
+ if (!(tracker_inds.array() == i).any()){
+ trackers[i]->updateState(image);
+ }
+ }
+
+ // handle unmatched detections
+ vector<int> unmatched_detection;
+ for(int j = 0; j < col; j++){
+ if (!(bb_inds.array() == j).any()){
+ unmatched_detection.push_back(j);
+ }
+ }
+ // create new trackers for new detections
+ for (auto i : unmatched_detection){
+ TrackerPtr t (new Tracker(image));
+ this->trackers.push_back(t);
+ }
+
+ Detection dd;
+
+ PatchPtr pp = createPatch(image, dd);
+}
+
+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);