mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 07:13:02 +04:00
Merge pull request #26026 from Abdurrahheem:ash/python_bool_binding
Add support for boolan input/outputs in python bindings #26026 This PR add support boolean input/output binding in python. The issue what mention in ticket https://github.com/opencv/opencv/issues/26024 and the PR soleves it. Data and models are located in [here](https://github.com/opencv/opencv_extra/pull/1201) ### 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. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
7e8f2a1bc4
commit
45fd4d8217
@@ -234,6 +234,7 @@ class Bindings(NewOpenCVTests):
|
||||
cv.CV_16UC2: [cv.CV_16U, 2, cv.CV_16UC],
|
||||
cv.CV_32SC1: [cv.CV_32S, 1, cv.CV_32SC],
|
||||
cv.CV_16FC3: [cv.CV_16F, 3, cv.CV_16FC],
|
||||
cv.CV_BoolC1: [cv.CV_Bool, 1, cv.CV_BoolC],
|
||||
}
|
||||
for ref, (depth, channels, func) in data.items():
|
||||
self.assertEqual(ref, cv.CV_MAKETYPE(depth, channels))
|
||||
@@ -277,6 +278,9 @@ class Arguments(NewOpenCVTests):
|
||||
a = np.zeros((2,3,4,5), dtype='f')
|
||||
res7 = cv.utils.dumpInputArray(a)
|
||||
self.assertEqual(res7, "InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=120 dims(-1)=4 size(-1)=[2 3 4 5] type(-1)=CV_32FC1")
|
||||
a = np.array([0, 1, 0, 1], dtype=bool)
|
||||
res8 = cv.utils.dumpInputArray(a)
|
||||
self.assertEqual(res8, "InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=4 dims(-1)=1 size(-1)=4x1 type(-1)=CV_BoolC1")
|
||||
|
||||
def test_InputArrayOfArrays(self):
|
||||
res1 = cv.utils.dumpInputArrayOfArrays(None)
|
||||
@@ -339,7 +343,7 @@ class Arguments(NewOpenCVTests):
|
||||
|
||||
def test_parse_to_bool_not_convertible(self):
|
||||
for not_convertible in (1.2, np.float32(2.3), 's', 'str', (1, 2), [1, 2], complex(1, 1),
|
||||
complex(imag=2), complex(1.1), np.array([1, 0], dtype=bool)):
|
||||
complex(imag=2), complex(1.1)):
|
||||
with self.assertRaises((TypeError, OverflowError),
|
||||
msg=get_no_exception_msg(not_convertible)):
|
||||
_ = cv.utils.dumpBool(not_convertible)
|
||||
|
||||
Reference in New Issue
Block a user