Skip to content

goodFeaturesToTrack returns also corner value#17836

Closed
WisdomPill wants to merge 6 commits intoopencv:masterfrom
WisdomPill:master
Closed

goodFeaturesToTrack returns also corner value#17836
WisdomPill wants to merge 6 commits intoopencv:masterfrom
WisdomPill:master

Conversation

@WisdomPill
Copy link
Copy Markdown
Contributor

@WisdomPill WisdomPill commented Jul 14, 2020

Closes #16462

This is still a work in progress, for the moment I have been working only on the function goodFeaturesToTrack and not the GFTT Detector. This is also my first time with c++ since university, please bear with me if you see naive errors.

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

I have some issue with perf tests, I can't understand why I get this error.

/Users/wisdompill/Projects/opencv/modules/ts/src/ts_perf.cpp:470: Failure
Expected equality of these values:
  expected_type
    Which is: 13
  array.type()
    Which is: 21
  Argument "corners" has unexpected type

I changed the types accordingly but I cannot understand why is this happening.

I removed the test_cornerEigenValsVecs function because it was incomplete resulting in bad accuracy and I think not needed for testing goodFeaturesToTrack

force_builders=linux,docs

@WisdomPill WisdomPill changed the title WIP goodFeaturesToTrack returns also corner value goodFeaturesToTrack returns also corner value Jul 14, 2020
@WisdomPill WisdomPill marked this pull request as ready for review July 14, 2020 07:24
@WisdomPill
Copy link
Copy Markdown
Contributor Author

@asmorkalov @alalek can I close this and reopen differently? I forgot to create a branch for this PR.

@vpisarev vpisarev self-assigned this Jul 17, 2020
@vpisarev
Copy link
Copy Markdown
Contributor

@WisdomPill, thank you for the contribution!

I suggest to make the patch more compatible with the existing API.

  1. cvGoodFeaturesToTrack is C API. It's frozen and will be completely removed in OpenCV 5.0 (due to be out in the end of 2020). So, please, do not change it.
  2. Please, add another output parameter, OutputArray cornerValues=noArray() to cv::goodFeaturesToTrack. It will take CV_32F matrix or std::vector. There you can store corner values without touching keypoints themselves.
  3. The newly added KeyPoint(Point3f, ...) should also be eliminated. Use the existing KeyPoint constructor, where you can pass 2D point and the computed corner value from a separate vector.

@WisdomPill
Copy link
Copy Markdown
Contributor Author

Okay, got it, I will do it in the beginning of next week, do you think I should create another branch?

I already did here, and probably will do the same in opencv/opencv_extra

@asmorkalov
Copy link
Copy Markdown
Contributor

@WisdomPill no need to create another branch and PR. I propose to continue work here.

@WisdomPill
Copy link
Copy Markdown
Contributor Author

Should be okay by now, I also update opencv_extra for the perftests.

I will tackle the cuda version of the GFTTDetector I might need more time for this, I saw that the cuda version does not implement feature2d methods and also does not provie getters and setters.

I pushed opencv_extra on the branch gftt_response_value, I mentioned this pull request on the pull request of opencv_extra

@mshabunin
Copy link
Copy Markdown
Contributor

mshabunin commented Jul 22, 2020

@WisdomPill , we try to avoid increasing sanity checks in performance tests. It would be better to make good accuracy test.

Your PR to opencv_extra have different branch name and will not be tested on our CI together with this one.

@WisdomPill
Copy link
Copy Markdown
Contributor Author

Okay, I see, so your saying that corners response values should not be sanity checked in perf_tests but only the values in the accuracy in the unittests, for example here modules/imgproc/test/test_goodfeaturetotrack.cpp?

Also, I think that GFTTDetector needs testing, should I add it?

In this case the pull request for opencv_extra is not needed at all and the tests should pass in the next commit that fixes perf_tests.

@Ibrarkhan55
Copy link
Copy Markdown

16642

@mshabunin
Copy link
Copy Markdown
Contributor

corners response values should not be sanity checked in perf_tests

@WisdomPill , yes, exactly.

Also, I think that GFTTDetector needs testing, should I add it?

There are two tests in features2d module, perhaps they could be extended:

TEST(Features2d_Detector_Keypoints_GFTT, validation)
{
Ptr<GFTTDetector> gftt = GFTTDetector::create();
gftt->setHarrisDetector(true);
CV_FeatureDetectorKeypointsTest test(gftt);
test.safe_run();
}

TEST( Features2d_Detector_GFTT, regression )
{
CV_FeatureDetectorTest test( "detector-gftt", GFTTDetector::create() );
test.safe_run();
}

@WisdomPill
Copy link
Copy Markdown
Contributor Author

WisdomPill commented Jul 22, 2020

Okay, so as I understand the tool is always the same modules/ts/misc/run.py but there is an accuracy flag,
maybe the wiki has to be updated a little bit. I had a look at this https://github.com/opencv/opencv/wiki/How_to_contribute

Should I push the accuracy tests on master branch as well in opencv_extra?
So that the continuous integration bot can pick it up, otherwise a new branch is needed.

@mshabunin
Copy link
Copy Markdown
Contributor

@WisdomPill , yes, in order to test changes together branches should have the same name.

You can run tests directly without run.py, e.g. ./bin/opencv_test_imgproc --gtest_filter=*GFTT*. Some more information about tests can be found here: https://github.com/opencv/opencv/wiki/QA_in_OpenCV

@asmorkalov
Copy link
Copy Markdown
Contributor

@WisdomPill Do you have a chance to finish the PR in meantime?

@WisdomPill
Copy link
Copy Markdown
Contributor Author

Yes sorry, I am on holiday, and will come back this weekend. I had finished most of the work, I was just missing the accuracy tests. Is it okay if I finish when I will be back?

@WisdomPill
Copy link
Copy Markdown
Contributor Author

I do not understand how to update the xml file for accuracy tests.

Accuracy tests seem to pass without changes, maybe it is because the function isSimilarKeyPoints here

bool CV_FeatureDetectorTest::isSimilarKeypoints( const KeyPoint& p1, const KeyPoint& p2 )
has a high maxResponseDif value. If I change it and lower it to 0.001 the test fail like it should but also SIFT fails.

Is this the file to update (https://github.com/opencv/opencv_extra/blob/master/testdata/cv/features2d/feature_detectors/detector-gftt.xml.gz)?
Can you please show me how to do that?

Also one of the perf tests is failing, and I do not understand one kind of error regarding the size of corners variable here https://pullrequest.opencv.org/buildbot/builders/precommit_linux64/builds/27302/steps/perf_imgproc/logs/tests%20summary

the other errors are about degradation in performance?

{ return *a > *b; }
};

static void
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.

why is the reference implementation removed? please, restore and use it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed it because I was also testing the response value which was not accurate with that test method.
I am restoring it right now

@vpisarev
Copy link
Copy Markdown
Contributor

@WisdomPill, it looks like in this particular test it's enough to erase the existing detector-gftt.xml.gz and run the test, then it will re-create it.

Also, I as mentioned above, please, restore the reference implementation test_cornerEigenValsVecs. Otherwise, it will be a meaningless test – to compare the function output with itself.

@WisdomPill
Copy link
Copy Markdown
Contributor Author

@vpisarev thank you for the hint, I updated detector-gftt.xml.gz by deleting the file and the test recreated it.
Can you help me understand why the accuracy on test_cornerEigenValsVecs is bad?
Should I keep testing for the accuracy there or not?

@asmorkalov
Copy link
Copy Markdown
Contributor

@vpisarev @WisdomPill Friendly reminder.

@asmorkalov asmorkalov requested a review from vpisarev November 24, 2020 19:38
@vpisarev
Copy link
Copy Markdown
Contributor

vpisarev commented Dec 1, 2020

@asmorkalov, @WisdomPill, I just run our buildbot — there are many problems. I guess, the changes in C API should be undone, because in C there is no optional arguments. Then, the test failures need to be fixed. In general, the patch can be merged, as long as buildbot is "green"

@WisdomPill
Copy link
Copy Markdown
Contributor Author

@vpisarev I do not understand what changes are you referring to, I need more guidance because I am not used to c++. Can you help?

@asmorkalov
Copy link
Copy Markdown
Contributor

Replaced by #19392. The new PR includes commits from the original PR and adds test fixes and sanity data.

@asmorkalov asmorkalov closed this Feb 3, 2021
@WisdomPill
Copy link
Copy Markdown
Contributor Author

Thanks

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.

GFFTDetector and goodFeaturesToTrack do not return intensity of the corner

5 participants