Merged
Conversation
alalek
reviewed
Dec 18, 2020
Comment on lines
+1563
to
+1568
| if (ddepth < 0) | ||
| ddepth = src.depth(); | ||
| if (params.scale != 1) { | ||
| int kdepth = K.depth(); | ||
| K.convertTo(tempK, | ||
| kdepth == CV_32F || kdepth == CV_64F ? kdepth : CV_32F, | ||
| params.scale, 0); | ||
| K = tempK; | ||
| } |
Member
There was a problem hiding this comment.
Why do we need such logic here? Is it already handled by filter2D()?
We should avoid duplication of such code (especially in incomplete form with missing checks).
Contributor
Author
There was a problem hiding this comment.
ddepthcheck was removed, thanks!scalecheck is retained, because it's extension to the existing API
Comment on lines
+1511
to
+1524
| class CV_EXPORTS_W_PARAMS Filter2DParams | ||
| { | ||
| public: | ||
| CV_PROP_RW int anchorX = -1; | ||
| CV_PROP_RW int anchorY = -1; | ||
| CV_PROP_RW int borderType = BORDER_DEFAULT; | ||
| CV_PROP_RW Scalar borderValue = Scalar(); | ||
| CV_PROP_RW int ddepth = -1; | ||
| CV_PROP_RW double scale = 1.; | ||
| CV_PROP_RW double shift = 0.; | ||
| }; | ||
|
|
||
| CV_EXPORTS_AS(filter2Dp) void filter2D( InputArray src, OutputArray dst, InputArray kernel, | ||
| const Filter2DParams& params=Filter2DParams()); |
Member
There was a problem hiding this comment.
As previously noted this is just a syntax sugar.
- These entries should be generated by automatic script (like binding generator, but for these named parameters)
- This stuff should not be EXPORTed in terms of C++ (its ABI is unstable)
- Implementation should be straightforward and "inline". No extra logic inside!
- Dedicated header should be used (to be generated by script)
Contributor
Author
There was a problem hiding this comment.
- previously noted where and by whom?
- we don't care about ABI starting from OpenCV 4.0.
- this will be the main API for complex functions in OpenCV 5 (optical flow, camera calibration, video writer initialization, etc.). The previous API will become backward-compatibility wrappers. The current solution for filter2D when the new API is implemented via the old API is temporary.
- in this particular case the new API is extension of the previous API. No automatic script can handle that
…ed parameters * added sample filter2D[p]() function and a little python test for it to demonstrate the concept
08e20c2 to
ed86965
Compare
Contributor
Author
|
👍 |
2 tasks
6 tasks
asmorkalov
added a commit
to asmorkalov/opencv
that referenced
this pull request
May 29, 2023
6 tasks
asmorkalov
added a commit
that referenced
this pull request
May 30, 2023
Re-implement named parameters bindings for Python #23705 Reverted named argument handling from #19156. Ported new solution from #23224 The port is required to harmonize 4.x -> 5.x merges. ### 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 - [x] 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is initial implementation of OE34 (https://github.com/opencv/opencv/wiki/OE-34.-Named-Parameters; discussion: #17997).
It's incomplete in a sense that while it's planned to refactor some of OpenCV 5 functionality to follow this style, this patch just adds a single C++ function with the new-style API. But it's a proof-of-concept and it also provides a method for Python, Java, JS etc. generators to handle such API.
For Python there is a special modification that maps named parameters in Python directly to named parameters in C++ API, e.g.
will map to
and if you use C++ 20, you can replace the code above with
Pull Request Readiness Checklist
Patch to opencv_extra has the same branch name.