Does FREAK eat keypoints when it can't find any descriptors?
I'm using OpenCV 2.4.2 with gcc 4.4.5 on a Debian testing box.
Basically I'm following FREAK sample in freak_demo.cpp
with the following snippet:
detector_.detect(img_, keypoints_);
ASSERT(keypoints_.size() > 0); // PASS
FREAK* freak = new FREAK();
freak->compute(img_, keypoints_, descriptors_);
ASSERT(keypoints_.size() > 0); // FAIL
ASSERT(descriptors_.rows > 0); // FAIL
detector_
is a FeatureDetector
and instantiated with a SurfFeatureDetector
here. ASSERT
s are BOOST_ASSERT
macros. I'm testing this with mainly binary images.
The first assertion passes, hence SURF detects some keypoints, but the second assertion fails and in between the only suspect is freak->compute
. If I remove the second assertion, the third one also fails. So FREAK does not produce any descriptors_
.
It may be related with the type of images I'm using, they are binary word or text line images. I changed the octave size to 2 (from the default 4) and will continue to test with different parameters.
Edit
The problem seems to be related with the parameters of SurfFeatureDescriptor
which I set identical with the values in freak_demo.cpp
. With default values (i.e. no explicit values in the constructor), FREAK retains some of the keypoints.
I also tested this with varying values for patternScale
parameter of FREAK. The initial value is the default.
patternScale: 22
keypoints.size() before: 118
keypoints.size() after: 5
...
patternScale: 18
keypoints.size() before: 118
keypoints.size() after: 15
...
patternScale: 14
keypoints.size() before: 118
keypoints.size() after: 33
...
patternScale: 8
keypoints.size() before: 118
keypoints.size() after: 82
...
So I think patternScale
size should be set according to the image size.
Anyhow I'd not expect keypoints to be zeroed. Is this an expected behavior?
I'm not sure the SURF detector is suited for the FREAK descriptor. When you read the publication, they used mutliscale AGAST (based on FAST). You do not need orientation-enabled detector, because FREAK will calculate the orientation itself.