Skip to content

8-bit SIFT descriptors#18001

Merged
alalek merged 6 commits intoopencv:3.4from
Yosshi999:sift-8bit-descr
Aug 17, 2020
Merged

8-bit SIFT descriptors#18001
alalek merged 6 commits intoopencv:3.4from
Yosshi999:sift-8bit-descr

Conversation

@Yosshi999
Copy link
Copy Markdown
Contributor

I added an option so that SIFT can return 8-bit descriptors instead of 32-bit floating-point descriptors.
(David Lowe in his paper uses 8-bit descriptors)

These 8-bit descriptors must be equal to 32-bit floating-point ones because the current implementation applies saturate_cast<uchar> to the descriptors. (The test Features2d_SIFT.descriptor_type ensures this.)

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • [+] I agree to contribute to the project under OpenCV (BSD) License.
  • [+] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • [+] The PR is proposed to proper branch
  • [+] There is reference to original bug report and related work
  • [+] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • [+] The feature is well documented and sample code can be built with the project CMake

@asmorkalov
Copy link
Copy Markdown
Contributor

@vpisarev Could you look at it?

@asmorkalov asmorkalov requested a review from vpisarev July 31, 2020 12:21
@vpisarev
Copy link
Copy Markdown
Contributor

vpisarev commented Aug 1, 2020

@Yosshi999, thank you for the patch!

@param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image
is captured with a weak camera with soft lenses, you might want to reduce the number.

@param useUcharDescriptors If true, the type of descriptors will be CV_8U. If false (default), it
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please update the parameter description as well

return makePtr<SIFT_Impl>(_nfeatures, _nOctaveLayers, _contrastThreshold, _edgeThreshold, _sigma);

CV_Assert(_descriptorType == CV_32F || _descriptorType == CV_8U);
bool useUcharDescriptors = (_descriptorType == CV_8U);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it make sense to propagate the type info deeper to SIFT_Impl itself to simplify descriptorType() and allocation of _descriptors. I also suggest providing a comment why _descriptorType is restricted to 8U and 32F since it's not obvious here.

@terfendail
Copy link
Copy Markdown
Contributor

@vpisarev The build is failed due to ABI change introduced to SIFT::create() however I don't see the simple and clean way to extend the functionality without changing the ABI. Could you please share your thoughts on this?

CV_WRAP static Ptr<SIFT> create(int nfeatures = 0, int nOctaveLayers = 3,
double contrastThreshold = 0.04, double edgeThreshold = 10,
double sigma = 1.6);
double sigma = 1.6, int descriptorType = CV_32F);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add one more create function instead. If there are two create functions: one with the previous set of parameters and one with extended set of parameters(without default values so all of them are mandatory) it should solve ABI compatibility check issue.

By the way there is no ABI compatibility requirement on master branch, so such a change should pass CI tests there.

@vpisarev vpisarev added the GSoC label Aug 6, 2020
@alalek
Copy link
Copy Markdown
Member

alalek commented Aug 9, 2020

Is 8-bit implementation bit-exact? (with BE resize?)

@Yosshi999
Copy link
Copy Markdown
Contributor Author

@alalek No. Its calculation part is same as 32-bit implementation's one.

@alalek
Copy link
Copy Markdown
Member

alalek commented Aug 14, 2020

@terfendail Please confirm that bit-exact results are not expected by this patch.

@terfendail
Copy link
Copy Markdown
Contributor

Internal SIFT descriptor implementation was actually developed in accordance with Lowe paper so the result is always integer values in range 0-255. However evaluation is implemented using floating point arithmetic. The purpose of the patch is to allow return of descriptor data in a more reasonable format. Bit-exact implementation of descriptor require essentially more efforts and will be prepared as a separate patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants