opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

New rectification and reconstruction functions for omnidir model

Open stefan-spiss opened this issue 3 years ago • 7 comments

To make the 3D reconstruction workflow with the omnidir camera model similar to the one for the pinhole and fisheye model, new functions were implemented:

  • estimateNewCameraMatrixForUndistortRectify -> estimates new projection matrices for the rectified output image (same as for the fisheye model)
  • extended stereoRectify -> overloaded function that not only estimates the rotations between the cameras, but also new projection matrices after rectification
  • reprojectImageTo3D -> function that depending on the rectification type (perspective or longilati) either calls the default reprojectImateTo3D function or calculates the 3D information itself (for the longilati rectification).

In addition, the documentation was updated and the naming style for function parameters was unified (new_size -> newSize).

Addresses parts of https://github.com/opencv/opencv/issues/16601#issue-566288527

Pull Request Readiness Checklist

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

  • [x] I agree to contribute to the project under Apache 2 License.
  • [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • [x] The PR is proposed to the proper branch
  • [x] There is a reference to the 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

Since there was no example code available for 3D reconstruction with the omnidir model, I did not add anything new yet. But if that is required, I of course can add an example and new data for it. For the same reason, no tests were added yet.

stefan-spiss avatar Nov 10 '22 11:11 stefan-spiss

Thank you for the contribution!

Could you add tests for the added functionality?


BTW, currently this module have zero tests. Please refer on test from other modules, e.g. from here: https://github.com/opencv/opencv_contrib/tree/4.6.0/modules/mcc/test

alalek avatar Nov 11 '22 07:11 alalek

@alalek I can add some tests, but similar to the issue https://github.com/opencv/opencv/issues/22537 it is not very easy to test all of it properly.

stefan-spiss avatar Nov 14 '22 10:11 stefan-spiss

I mean to add tests for the added functionality here (similar to your use case). No need to cover by tests already existed functionality - it is out of scope.

Also no need to parameterize inputs, one input is enough for good start.

alalek avatar Nov 14 '22 11:11 alalek

@alalek sounds good, I will do that!

stefan-spiss avatar Nov 14 '22 13:11 stefan-spiss

@stefan-spiss friendly reminder about the test.

asmorkalov avatar Dec 14 '22 11:12 asmorkalov

@asmorkalov thanks and sorry. I was very busy the last couple of weeks, but I am on it and hope I will have the tests ready soon.

stefan-spiss avatar Dec 14 '22 13:12 stefan-spiss

@asmorkalov and @alalek: I implemented a test for the new function omnidir::reprojectImageTo3D

Regarding the two other functions I am unsure how to properly test them.

  • estimateNewCameraMatrixForUndistortRectify
    As already mentioned before, testing the function is not that easy. In the fisheye model, the test of this function currently compares to some reference values, but to get these reference values, I would need to run the function itself. So it only would help to make sure, that future code changes do not alter the result of the function.
    I also had a look at the corresponding function of the pinhole model, getOptimalNewCameraMatrix() and I could not find any test for it.
    Therefore, I am not sure how to test the function. Does someone has an idea? Or should I just do a similar test as in the fisheye model, using reference values?

  • stereoRectify
    In the fisheye model, this function is tested using reference values, which were generated with the function itself (mentioned in a comment). So again, with that I would make sure that future changes produce the same result, but I would not check that the current results are correct.
    In the pinhole model, this function is tested in an integration test that covers the whole stereo calibration pipeline. Parts of it I could also use to test the stereoRectify function of the omnidir model, but with that I would only cover parts of the functionality. Do you have any suggestions regarding the test of this function?

stefan-spiss avatar Dec 20 '22 17:12 stefan-spiss