Classifying blobs by color and keypoints
Our classifier operates on the assumption that a blob contains distinctive colors, distinctive keypoints, or both. To conserve memory and precompute as much relevant information as possible, we do not store images of the reference blobs, but instead we store histograms and keypoint descriptors.
Create a new file, BlobClassifier.cpp
, for the implementation of our BlobClassifier
class. (To review the header, refer back to the Defining blob descriptors and a blob classifier section.) At the top of BlobDetector.cpp
, we will define several constants that pertain to the number of histogram bins, the histogram comparison method, and the relative importance of the histogram comparison versus the keypoint comparison. Here is the relevant code:
#include <opencv2/imgproc.hpp> #include "BlobClassifier.h" #ifdef WITH_OPENCV_CONTRIB #include <opencv2/xfeatures2d.hpp> #endif const int HISTOGRAM_NUM_BINS_PER_CHANNEL = 32; const int HISTOGRAM_COMPARISON_METHOD...