Skip to content

[evolution] Stitching for OpenCV 4.0 - #12827

Merged
alalek merged 11 commits into
opencv:masterfrom
hrnr:stitching_4
Nov 10, 2018
Merged

alalek merged 11 commits into
opencv:masterfrom
hrnr:stitching_4

Conversation

@hrnr

@hrnr hrnr commented Oct 14, 2018 •

Copy link
Copy Markdown
Contributor

I have received a very little feedback on evolution proposal #11039. I have decided to come with some code, to start the discussion. Here are some minimal changes in the stitching module, that I think should go to OpenCV 4.0. Large parts of the evolution proposal are not implemented and I'm awaiting further feedback.

  • remove detail::FeaturesFinder and detail::FeaturesMatcher wrapper classes. Use cv::Feature2D and cv::DescriptorMatcher from features2d module. This will allow to use all features and descriptors with stitching modules. Move all estimation code from detail::FeaturesMatcher to detail::Estimator. This also solves problems with dependencies on xfeatures2d.
  • allow user to explicitly set detail::Estimator
  • consolidate creation methods for stitcher. Keep only Stitcher::create, wrap this method for Python. Drop try_use_gpu flag, rely on T-API or user explicitly setting CUDA classes to use.
  • allow users to set FeaturesFinder, DescriptorMatcher, BundleAdjuster etc. from Python
  • drop legacy usage of legacy Levenberg–Marquardt API from bundle adjusters. Replace with new LevMarq API.
  • remove direct usage of CUDA from stitching module (OpenCL alternatives are already available). Move to CUDA modules where it makes sense.
force_builders=linux,Linux OpenCL,windows,macosx,docs,Custom,Win64 OpenCL
docker_image:Custom=ubuntu-cuda:16.04
**WIP**

@alalek

alalek commented Oct 14, 2018

Copy link
Copy Markdown
Member

drop try_use_gpu

Agreed. CUDA code doesn't work here > 3 years: #8792

@hrnr

hrnr commented Oct 15, 2018

Copy link
Copy Markdown
Contributor Author

I have dropped try_use_gpu flag. OCL will be utilised automatically in enabled paths. To use CUDA paths user needs to explicitly set CUDA classes in stitching.

What do you think about dropping detail::FeaturesFinder, detail::FeaturesMatcher and the wrapper code in favour of cv::Feature2D, cv::DescriptorMatcher and classes from features2d? Should I go forward with that? That will be a big change and quite a lot of work, so I want some approval before I continue.

@alalek

alalek commented Oct 15, 2018

Copy link
Copy Markdown
Member

favour of cv::Feature2D, cv::DescriptorMatcher and classes from features2d

Sounds good.

@LaurentBerger

Copy link
Copy Markdown
Contributor

May be too late but in this example I can save all results of stitching process except ExposureCompensator. Is it possible to add a method to get ExposureCompensator result?

@hrnr

hrnr commented Oct 16, 2018

Copy link
Copy Markdown
Contributor Author

I don't get what you want to achieve. There is ExposureCompensator::apply to get the results of exposure compensation. What are you missing? Is there any other info that is not exposed?

@LaurentBerger

LaurentBerger commented Oct 16, 2018 •

Copy link
Copy Markdown
Contributor

I need to investigate more but I think it is gain_maps
You can save everything in yml file except results of those lines :

       pp.algoCorrectExpo = ExposureCompensator::createDefault(pp.correctionExposition);
        pp.algoCorrectExpo->feed(pp.posCoin, imagesProjetees, pp.masqueCompo);

Example I have two webcam and I stitch images. I save everything . Then I can run my program without any initialize stitching (except ExposureCompensator)

hrnr added 5 commits October 16, 2018 15:48
* provide method for consistent stitcher usage across languages
* port cpp stitching sample to python
* remove Stitcher::createDefault, it returns Stitcher, not Ptr<Stitcher> -> inconsistent API
* deprecate cv::createStitcher and cv::createStitcherScans in favor of Stitcher::create
* ORIG_RESOL should be double
* add documentatiton
@hrnr

hrnr commented Oct 16, 2018

Copy link
Copy Markdown
Contributor Author

I have rebased the brach due to merge conflict.

@alalek

alalek commented Nov 9, 2018

Copy link
Copy Markdown
Member

@hrnr Well done!

Looks like there is bug in SURF detector which doesn't handle masks correctly (fix will be merged soon into opencv_contrib: opencv/opencv_contrib#1887).

Other possible issue is about resizing of "mask":

resize(masks_[i], feature_find_masks[i], Size(), work_scale_, work_scale_, INTER_LINEAR_EXACT);

I believe INTER_NEAREST should be here (because we don't want to "smooth" masks).
But it is not a show stopper with current set of tests.

Please squash "fixup" commits and we are ready to merge this for OpenCV 4.0 release.

@vpisarev vpisarev self-assigned this Nov 9, 2018
@vpisarev

vpisarev commented Nov 9, 2018

Copy link
Copy Markdown
Contributor

👍 can be merged as soon as buildbot becomes green

hrnr added 5 commits November 10, 2018 12:18
* OCL will be used automatically through T-API in OCL-enable paths
* CUDA won't be used unless user sets CUDA-enabled classes manually
* use Feature2D instead of FeaturesFinder
* interoperability with features2d module
* detach from dependency on xfeatures2d
* correctly pass UMats as UMats to allow OCL paths
* support vector of UMats as output arg
@hrnr

hrnr commented Nov 10, 2018

Copy link
Copy Markdown
Contributor Author

Thanks for the review. You are right, @alalek, INTER_NEAREST is the correct interpolation there. Fixed. Many thanks for fixing the issue in SURF.

Squashed fixup commits, rebased.

As you know I wanted a bigger scope for this, but I don't have much of a free time nowadays to put into this as I'm starting in a new job. At least, I'd love to see something similar done for detail::FeaturesMatcher, but I'm not sure if I find a free day for coding to take on that. Anyone from the community please feel free to take this further, I can help if you run into any issues, just mention me so I receive an email.

For the time being, I'm glad that at least this part goes in.

@LaurentBerger

Copy link
Copy Markdown
Contributor

@hrnr I can work on stitching module. I already wrote an example in C++. I need to translate this example in python. I need your PR. If something is missing I can make a new PR.

@hrnr

hrnr commented Nov 10, 2018

Copy link
Copy Markdown
Contributor Author

Sure go for it. My plan for detail::FeaturesMatcher was to replace it with cv::DescriptorMatcher everywhere, then delete almost all the code in the stitching module related to matches. One caveat there is that the transform estimation code (now sitting in the high-level Matchers) needs to moved to detail::Estimator, which will be solely responsible for the geometry model used. Apart from that it should be fairly straightforward job, requiring only small amount of the glue code to do the parallel matching - the code is already there, probably only needs to be moved around.

@hrnr

hrnr commented Nov 10, 2018

Copy link
Copy Markdown
Contributor Author

Thanks for fixing those, you were faster than me.

a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
[evolution] Stitching for OpenCV 4.0

* stitching: wrap Stitcher::create for bindings

* provide method for consistent stitcher usage across languages

* samples: add python stitching sample

* port cpp stitching sample to python

* stitching: consolidate Stitcher create methods

* remove Stitcher::createDefault, it returns Stitcher, not Ptr<Stitcher> -> inconsistent API
* deprecate cv::createStitcher and cv::createStitcherScans in favor of Stitcher::create

* stitching: avoid anonymous enum in Stitcher

* ORIG_RESOL should be double
* add documentatiton

* stitching: improve documentation in Stitcher

* stitching: expose estimator in Stitcher

* remove ABI hack

* stitching: drop try_use_gpu flag

* OCL will be used automatically through T-API in OCL-enable paths
* CUDA won't be used unless user sets CUDA-enabled classes manually

* stitching: drop FeaturesFinder

* use Feature2D instead of FeaturesFinder
* interoperability with features2d module
* detach from dependency on xfeatures2d

* features2d: fix compute and detect to work with UMat vectors

* correctly pass UMats as UMats to allow OCL paths
* support vector of UMats as output arg

* stitching: use nearest interpolation for resizing masks

* fix warnings
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
[evolution] Stitching for OpenCV 4.0

* stitching: wrap Stitcher::create for bindings

* provide method for consistent stitcher usage across languages

* samples: add python stitching sample

* port cpp stitching sample to python

* stitching: consolidate Stitcher create methods

* remove Stitcher::createDefault, it returns Stitcher, not Ptr<Stitcher> -> inconsistent API
* deprecate cv::createStitcher and cv::createStitcherScans in favor of Stitcher::create

* stitching: avoid anonymous enum in Stitcher

* ORIG_RESOL should be double
* add documentatiton

* stitching: improve documentation in Stitcher

* stitching: expose estimator in Stitcher

* remove ABI hack

* stitching: drop try_use_gpu flag

* OCL will be used automatically through T-API in OCL-enable paths
* CUDA won't be used unless user sets CUDA-enabled classes manually

* stitching: drop FeaturesFinder

* use Feature2D instead of FeaturesFinder
* interoperability with features2d module
* detach from dependency on xfeatures2d

* features2d: fix compute and detect to work with UMat vectors

* correctly pass UMats as UMats to allow OCL paths
* support vector of UMats as output arg

* stitching: use nearest interpolation for resizing masks

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

Labels

category: stitching future This issue can't be fixed during restrictions of the compatibility requirements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants