Dense SURF Descriptor OpenCV 3 with multiple scales
I want to implement SURF Dense Descriptor for object recognition in OpenCV 3 for object recogntion. A simple solution (taken from here):
int step = 10; // 10 pixels spacing between kp's
vector<KeyPoint> kps;
for (int i=step; i<img.rows-step; i+=step)
{
for (int j=step; j<img.cols-step; j+=step)
{
// x,y,radius
kps.push_back(KeyPoint(float(j), float(i), float(step)));
}
}
Ptr<xfeatures2d::SURF> surf = xfeatures2d::SURF::create();
surf->compute(img,kps,features);
However, this approach isn't scale invariant. An "almost scale invariant approach" is used in VLFeat with vl_phow (which use Dense SIFT, not Dense SURF), where they compute the descriptors with the same grid (step) but at multiple scales. In addition, for each scale they apply a Gaussian filter for smoothing (which seems to be important). Finally, they give the possibility to add color descriptor (however color descriptors doesn't always guarantee best performances).
So what miss from my "SURF phow" is:
- Multiple scales: given a keypoint, how can I compute SURF descriptor using different scales? This parameter is
Sizes
in VLFeat and it represents the number of pixels per SIFT bin (each SIFT descriptor uses 4x4 bins). Reading SURF documentation:neighbourhood of size 20sX20s is taken around the keypoint where s is the size. It is divided into 4x4 subregions
So it ssems that there is an analogous parameter in SURF too. - Image smoothing: before describing the given grid using a certain scale/bin size, a Gaussian filter is applied. Reading documentation:
The image is smoothed by a Gaussian kernel of standard deviation SIZE / MAGNIF.
How can I apply such a filter to the image for this purpose? - Color descriptor: this should be easy, I implemented a straightforward solution here. Give a look at it and let me know what you think about it.
How can I implement the first 2 points (eventually 3 too)? Of course some aspects of vl_phow
cannot be reproduced (for example the Fast
parameter which is an approximation for computing Dense SIFT descriptors), but I want to do it as similar as possible using OpenCV and SURF.
How about trying to translate it 1on1 and get back once issues arise?
@StevenPuttemans I don't understand what you mean :)
I am basicall y saying, start programming it yourself then ask forum help of issues arise