- std::vector<float> feature_hog;
- cv::Mat img;
- cv::resize(image, img, PREFERRED_SIZE);
- this->descriptor.compute(img, feature_hog);
-
- cv::Mat hist;
- //cv::calcHist()
- patch->image_crop = image;
+
+ // 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);