From 18550b4601bdbbeb467870bc736efdee47e817df Mon Sep 17 00:00:00 2001 From: Vadim Levin Date: Wed, 15 Apr 2020 14:12:31 +0300 Subject: [PATCH 1/2] test: Added tests for VideoCapture constructors in java --- .../misc/java/test/VideoCaptureTest.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/videoio/misc/java/test/VideoCaptureTest.java b/modules/videoio/misc/java/test/VideoCaptureTest.java index e61277492f..9609a55620 100644 --- a/modules/videoio/misc/java/test/VideoCaptureTest.java +++ b/modules/videoio/misc/java/test/VideoCaptureTest.java @@ -35,10 +35,30 @@ public class VideoCaptureTest extends OpenCVTestCase { assertFalse(capture.isOpened()); } - public void testVideoCapture() { + public void testDefaultConstructor() { capture = new VideoCapture(); assertNotNull(capture); assertFalse(capture.isOpened()); } + public void testConstructorWithFilename() { + capture = new VideoCapture("some_file.avi"); + assertNotNull(capture); + } + + public void testConstructorWithFilenameAndExplicitlySpecifiedAPI() { + capture = new VideoCapture("some_file.avi", Videoio.CAP_ANY); + assertNotNull(capture); + } + + public void testConstructorWithIndex() { + capture = new VideoCapture(0); + assertNotNull(capture); + } + + public void testConstructorWithIndexAndExplicitlySpecifiedAPI() { + capture = new VideoCapture(0, Videoio.CAP_ANY); + assertNotNull(capture); + } + } From 1d8c73cf6c9d0ef1022d3a302aef0e13bc255602 Mon Sep 17 00:00:00 2001 From: Vadim Levin Date: Wed, 15 Apr 2020 14:25:39 +0300 Subject: [PATCH 2/2] feature: Added `explicit` support to header parser - It is safe to remove `explicit` keyword for constructors with 1 argument, because it is C++ specific keyword and does not affect any of the generated binding. --- modules/python/src2/hdr_parser.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/python/src2/hdr_parser.py b/modules/python/src2/hdr_parser.py index 780a263ced..eba7000d47 100755 --- a/modules/python/src2/hdr_parser.py +++ b/modules/python/src2/hdr_parser.py @@ -430,9 +430,10 @@ class CppHeaderParser(object): # filter off some common prefixes, which are meaningless for Python wrappers. # note that we do not strip "static" prefix, which does matter; # it means class methods, not instance methods - decl_str = self.batch_replace(decl_str, [("static inline", ""), ("inline", ""),\ - ("CV_EXPORTS_W", ""), ("CV_EXPORTS", ""), ("CV_CDECL", ""), ("CV_WRAP ", " "), ("CV_INLINE", ""), - ("CV_DEPRECATED", ""), ("CV_DEPRECATED_EXTERNAL", "")]).strip() + decl_str = self.batch_replace(decl_str, [("static inline", ""), ("inline", ""), ("explicit ", ""), + ("CV_EXPORTS_W", ""), ("CV_EXPORTS", ""), ("CV_CDECL", ""), + ("CV_WRAP ", " "), ("CV_INLINE", ""), + ("CV_DEPRECATED", ""), ("CV_DEPRECATED_EXTERNAL", "")]).strip() if decl_str.strip().startswith('virtual'):