From: Alexander Alekhin Date: Sun, 18 Dec 2022 02:16:17 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/3.4' into merge-3.4 X-Git-Tag: accepted/tizen/unified/20230127.161057~1^2~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=420db56ffd736e6660e5fc5d03ebc1fa635dc2ea;p=platform%2Fupstream%2Fopencv.git Merge remote-tracking branch 'upstream/3.4' into merge-3.4 --- 420db56ffd736e6660e5fc5d03ebc1fa635dc2ea diff --cc modules/core/include/opencv2/core/bindings_utils.hpp index a0710134a9,5de2f7022e..001d91c381 --- a/modules/core/include/opencv2/core/bindings_utils.hpp +++ b/modules/core/include/opencv2/core/bindings_utils.hpp @@@ -227,11 -213,17 +227,22 @@@ AsyncArray testAsyncException( return p.getArrayResult(); } +CV_WRAP static inline +String dumpVec2i(const cv::Vec2i value = cv::Vec2i(42, 24)) { + return format("Vec2i(%d, %d)", value[0], value[1]); +} + + struct CV_EXPORTS_W_SIMPLE ClassWithKeywordProperties { + CV_PROP_RW int lambda; + CV_PROP int except; + + CV_WRAP explicit ClassWithKeywordProperties(int lambda_arg = 24, int except_arg = 42) + { + lambda = lambda_arg; + except = except_arg; + } + }; + namespace nested { CV_WRAP static inline bool testEchoBooleanFunction(bool flag) { return flag; diff --cc modules/python/src2/gen2.py index 14ef904251,59ddc2d6fa..d7a54910ba --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@@ -210,8 -210,7 +210,9 @@@ simple_argtype_mapping = "float": ArgTypeInfo("float", FormatStrings.float, "0.f", True), "double": ArgTypeInfo("double", FormatStrings.double, "0", True), "c_string": ArgTypeInfo("char*", FormatStrings.string, '(char*)""'), + "string": ArgTypeInfo("std::string", FormatStrings.object, None, True), + "Stream": ArgTypeInfo("Stream", FormatStrings.object, 'Stream::Null()', True), + "UMat": ArgTypeInfo("UMat", FormatStrings.object, 'UMat()', True), # FIXIT: switch to CV_EXPORTS_W_SIMPLE as UMat is already a some kind of smart pointer } # Set of reserved keywords for Python. Can be acquired via the following call diff --cc modules/python/test/test_misc.py index 9b5ab0cf49,3199147dbd..f0c184e390 --- a/modules/python/test/test_misc.py +++ b/modules/python/test/test_misc.py @@@ -728,44 -698,11 +735,44 @@@ class Arguments(NewOpenCVTests) self.assertEqual( params.float_value, instance.getFloatParam(), msg="Class initialized with wrong integer parameter. Expected: {}. Actual: {}".format( - params.float_value, instance.getFloatParam() - )) - + params.float_value, instance.getFloatParam() + ) + ) + +class CanUsePurePythonModuleFunction(NewOpenCVTests): + def test_can_get_ocv_version(self): + import sys + if sys.version_info[0] < 3: + raise unittest.SkipTest('Python 2.x is not supported') + + self.assertEqual(cv.misc.get_ocv_version(), cv.__version__, + "Can't get package version using Python misc module") + + def test_native_method_can_be_patched(self): + import sys + + if sys.version_info[0] < 3: + raise unittest.SkipTest('Python 2.x is not supported') + + res = cv.utils.testOverwriteNativeMethod(10) + self.assertTrue(isinstance(res, Sequence), + msg="Overwritten method should return sequence. " + "Got: {} of type {}".format(res, type(res))) + self.assertSequenceEqual(res, (11, 10), + msg="Failed to overwrite native method") + res = cv.utils._native.testOverwriteNativeMethod(123) + self.assertEqual(res, 123, msg="Failed to call native method implementation") + + def test_default_matx_argument(self): + res = cv.utils.dumpVec2i() + self.assertEqual(res, "Vec2i(42, 24)", + msg="Default argument is not properly handled") + res = cv.utils.dumpVec2i((12, 21)) + self.assertEqual(res, "Vec2i(12, 21)") + + class SamplesFindFile(NewOpenCVTests): def test_ExistedFile(self):