Merge pull request #20976 from alalek:issue_20968

pull/20983/head
Alexander Alekhin 3 years ago
commit 1ceba29f4b
  1. 2
      modules/core/src/matrix.cpp
  2. 2
      modules/python/src2/cv2.cpp
  3. 4
      modules/python/test/test_misc.py

@ -463,7 +463,7 @@ Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
} }
else else
{ {
CV_Assert(_step >= minstep); CV_CheckGE(_step, minstep, "");
if (_step % esz1 != 0) if (_step % esz1 != 0)
{ {

@ -788,6 +788,8 @@ static bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo& info)
if (ndims >= 1 && _strides[ndims - 1] != (npy_intp)elemsize*_sizes[ndims]) if (ndims >= 1 && _strides[ndims - 1] != (npy_intp)elemsize*_sizes[ndims])
needcopy = true; needcopy = true;
elemsize = CV_ELEM_SIZE(type);
} }
if (needcopy) if (needcopy)

@ -187,6 +187,10 @@ class Arguments(NewOpenCVTests):
#res6 = cv.utils.dumpInputArray([a, b]) #res6 = cv.utils.dumpInputArray([a, b])
#self.assertEqual(res6, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=2 dims(-1)=1 size(-1)=2x1 type(0)=CV_32FC1 dims(0)=4 size(0)=[2 3 4 5]") #self.assertEqual(res6, "InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=2 dims(-1)=1 size(-1)=2x1 type(0)=CV_32FC1 dims(0)=4 size(0)=[2 3 4 5]")
def test_20968(self):
pixel = np.uint8([[[40, 50, 200]]])
_ = cv.cvtColor(pixel, cv.COLOR_RGB2BGR) # should not raise exception
def test_parse_to_bool_convertible(self): def test_parse_to_bool_convertible(self):
try_to_convert = partial(self._try_to_convert, cv.utils.dumpBool) try_to_convert = partial(self._try_to_convert, cv.utils.dumpBool)
for convertible_true in (True, 1, 64, np.bool(1), np.int8(123), np.int16(11), np.int32(2), for convertible_true in (True, 1, 64, np.bool(1), np.int8(123), np.int16(11), np.int32(2),

Loading…
Cancel
Save