Updating STAR detector and FREAK descriptor to work with large and/or 16-bit images (Bugfix #3322)


Added by Seth Price over 11 years ago. Updated almost 11 years ago.


Status:Done Start date:2013-10-15
Priority:Normal Due date:
Assignee:Seth Price % Done:

0%

Category:features2d
Target version:-
Affected version:branch 'master' (3.0-dev) Operating System:Mac OSX
Difficulty: HW Platform:x86
Pull request:https://github.com/Itseez/opencv/pull/1932

Description

A project that I've been working with involves large, 16-bit, images. The current implementations of the STAR feature detector and the FREAK feature descriptor don't support either large or 16-bit images. I've written a set of changes to support both. Much of the work goes into adding more bits to the integral image when appropriate. I'll discuss what needed doing:

- In STAR, the method of detecting if the matrix was color didn't make sense. I'm using channels() instead of type() now.

- In STAR, he integral image data type needed to be changed for two reasons. If each cell can have the value of 256, the integer type could overflow when the image is greater than 8 megapixels. If you are working with 16-bit imagery imagery instead of 8-bit, this will happen at much smaller image sizes. So, I've used templates to use a 32-bit integer under the normal case, and 64-bit double for large images and/or higher bit depth.

- In STAR, SSE2 is only enabled if the data type is the original 32-bit integer. It was my aim to support the new data types (shorts & doubles) without removing the existing SSE usage.

- In integral(), in sumpixels.cpp, I added templated support for working with 'short' & 'ushort' precision input. As mentioned before, it's appropriate to use double precision when working with 16-bit images (so that's what I did).

- In FREAK, I broke most of computeImpl() into a new function, computeDescriptors(). I did this so I could use templates and thus keep all the data type permutations sane.

- In FREAK, SSE2 is only used if the average value is expected to be an 8-bit number. This is the original usage, and it should be just as fast as before. 16-bit data falls back to the scalar code.

- In FREAK, meanIntensity() now uses templates.

- In FREAK, the return value of meanIntensity() is 'int' instead of 'uchar' for compatibility between possible data types. It should make no speed difference.


features.diff (1 kB) Seth Price, 2013-10-16 07:46 am

freak.diff (16.1 kB) Seth Price, 2013-10-16 07:46 am

stardetector.diff (7.3 kB) Seth Price, 2013-10-16 07:46 am

sumpixels.diff (1 kB) Seth Price, 2013-10-16 07:46 am


Associated revisions

Revision e05a0bc6
Added by Vadim Pisarevsky over 10 years ago

Merge pull request #3322 from StevenPuttemans:fix_pvpapi_interface

History

Updated by Steven Puttemans over 11 years ago

Nice project! Might consider to add a pull request yourself with your changes and claim your credit?
More info at http://code.opencv.org/projects/opencv/wiki/How_to_contribute!

Updated by Maria Dimashova over 11 years ago

+1 Please create a pull request with your suggestion.
Anyway you also should add tests for 16-bit and update the doc.
Thanks!

Updated by Maria Dimashova over 11 years ago

  • Assignee changed from Maria Dimashova to Vadim Pisarevsky

Updated by Seth Price over 11 years ago

I've tried out this whole pull request thing. Hopefully it is what you're looking for in a pull request...

https://github.com/Itseez/opencv/pull/1638

Updated by Seth Price over 11 years ago

Also, what doc files should I update? How do I run the tests? (I've looked for info on OpenCV tests and can't find much via Google...)

Updated by Seth Price over 11 years ago

Ok, I think this one works better (merging against 2.4 & updated a header file):
https://github.com/Itseez/opencv/pull/1639

Updated by Seth Price over 11 years ago

Ok, I'd love to fix the windows error that was found, but it the error log is in russian (I think):
http://build.opencv.org/builders/precommit_windows/builds/6392

Updated by Steven Puttemans over 11 years ago

To solve your errors, go to translate.google.com.
Add one line of the errors, pick russian -> english and your error should come out quite understandable.

Always work from top to bottom, since a single error on top can generate tons beneath.

The first errors:

15> .. \ .. \ .. \ src \ opencv \ modules \ features2d \ src \ freak.cpp (257): error C2220: warning treated as error - file "object" is not created
15> .. \ .. \ .. \ src \ opencv \ modules \ features2d \ src \ stardetector.cpp (289): error C2220: warning treated as error - file "object" is not created
17> LINK: fatal error LNK1181: can not open input file ".. \ .. \ lib \ Release \ opencv_features2d246.lib"

Updated by Seth Price over 11 years ago

Created a new pull request for merging into 'master' due to required header change:
https://github.com/Itseez/opencv/pull/1654

Updated by Dmitry Retinskiy over 11 years ago

  • Status changed from New to Open
  • Assignee changed from Vadim Pisarevsky to Seth Price
  • Pull request set to https://github.com/Itseez/opencv/pull/1654
  • Affected version changed from branch '2.4' (2.4-dev) to branch 'master' (3.0-dev)

Updated by Seth Price over 11 years ago

Ok, I worked my way through all the code, and figured out what the 'bug' is:

    if( image.channels() > 1 )
        cvtColor( image, grayImage, COLOR_BGR2GRAY );

I'm automatically changing color images to grayscale. If I comment that out, the test passes. However, I would think that conversion to grayscale would be preferred. (That's how it's done in the STAR detector.) What is the preferred behavior?

Updated by Seth Price over 11 years ago

Clean pull request maintaining existing behavior:
https://github.com/Itseez/opencv/pull/1932

Updated by Seth Price over 11 years ago

PS: all tests pass on pullrequest.opencv.org!

Updated by Seth Price about 11 years ago

Hey all, just a reminder that I'm paciently waiting for this patch to be applied!

Updated by Steven Puttemans almost 11 years ago

The last request was merged. This can thus be closed down!

  • Pull request changed from https://github.com/Itseez/opencv/pull/1654 to https://github.com/Itseez/opencv/pull/1932

Updated by Steven Puttemans almost 11 years ago

  • Status changed from Open to Done

Also available in: Atom PDF