Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d24ffe9

Browse files
authored
Merge pull request #23705 from asmorkalov:as/cxx-named-arguments
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
1 parent 67a3d35 commit d24ffe9

File tree

4 files changed

+257
-125
lines changed

4 files changed

+257
-125
lines changed

modules/core/include/opencv2/core/bindings_utils.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,33 @@ struct CV_EXPORTS_W_SIMPLE ClassWithKeywordProperties {
243243
}
244244
};
245245

246+
struct CV_EXPORTS_W_PARAMS FunctionParams
247+
{
248+
CV_PROP_RW int lambda = -1;
249+
CV_PROP_RW float sigma = 0.0f;
250+
251+
FunctionParams& setLambda(int value) CV_NOEXCEPT
252+
{
253+
lambda = value;
254+
return *this;
255+
}
256+
257+
FunctionParams& setSigma(float value) CV_NOEXCEPT
258+
{
259+
sigma = value;
260+
return *this;
261+
}
262+
};
263+
264+
CV_WRAP static inline String
265+
copyMatAndDumpNamedArguments(InputArray src, OutputArray dst,
266+
const FunctionParams& params = FunctionParams())
267+
{
268+
src.copyTo(dst);
269+
return format("lambda=%d, sigma=%.1f", params.lambda,
270+
params.sigma);
271+
}
272+
246273
namespace nested {
247274
CV_WRAP static inline bool testEchoBooleanFunction(bool flag) {
248275
return flag;

0 commit comments

Comments
 (0)