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;
"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
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):