-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix boundary condition when calculating Haar features #4076
fix boundary condition when calculating Haar features #4076
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! This looks good to me. Is there any chance we can add a small unit test that tests for the correct number of features or similar?
Also, the current tests are failing badly. It would be good to start from them. |
@glemaitre would you have the time to take a look at this PR? |
perhaps @warmspringwinds could also weigh in here... |
@jni Sure, no problem! -- let's see if @glemaitre is available first. @glemaitre -- Sorry for bugging, If I recall correctly you worked on this feature? |
The tests will fail just because of the shape since the filter contains one pixel more. So they can easily be adapted:
Regarding the fix itself, I think that it makes sense. Basically, you would expect that |
Do you want me to take over and modify the tests? |
@glemaitre Thanks for helping out! Just review the pull request so that it looks good to you @WeiChungChang Thank you for your pull request! |
additional features are found after the range was fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @WeiChungChang. The change to the range proposed looks correct to me. I double-checked that the numbers of features of each type now match those listed in Fig. 2 of the following IPOL paper:
https://www.ipol.im/pub/art/2014/104/
I updated the docstring and test output to reflect this change.
also closes #4818 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @WeiChungChang for the fix and @grlee77 for updating the UT 😉
Description
Closes #4077. Closes #4818.
Fix boundary condition when calculating Haar features
Current # of Haar features is wrong. It can be verified by 2 ways
https://en.wikipedia.org/wiki/Haar-like_feature
Notice that we should have # = 1 for this case but get 0 now.
Please refer to:
https://stackoverflow.com/questions/1707620/viola-jones-face-detection-claims-180k-features
The correct result should be 162,336.
However, current results is 161864,
The problem is we miss the largest height(or width) since for python,
for for dy in range(1, height) does NOT include height.
Result
Apply this fix, both test cases are correct.