// --- int64
+template<>
+bool pyopencv_to(PyObject* obj, int64& value, const ArgInfo& info)
+{
+ if (!obj || obj == Py_None)
+ {
+ return true;
+ }
+ if (isBool(obj))
+ {
+ failmsg("Argument '%s' must be integer, not bool", info.name);
+ return false;
+ }
+ if (PyArray_IsIntegerScalar(obj))
+ {
+ value = PyLong_AsLongLong(obj);
+ }
+ else
+ {
+ failmsg("Argument '%s' is required to be an integer", info.name);
+ return false;
+ }
+ return !CV_HAS_CONVERSION_ERROR(value);
+}
+
template<>
PyObject* pyopencv_from(const int64& value)
{
msg=get_no_exception_msg(not_convertible)):
_ = cv.utils.dumpInt(not_convertible)
+ def test_parse_to_int64_convertible(self):
+ try_to_convert = partial(self._try_to_convert, cv.utils.dumpInt64)
+ min_int64, max_int64 = get_limits(ctypes.c_longlong)
+ for convertible in (-10, -1, 2, int(43.2), np.uint8(15), np.int8(33), np.int16(-13),
+ np.int32(4), np.int64(345), (23), min_int64, max_int64, np.int_(33)):
+ expected = 'int64: {0:d}'.format(convertible)
+ actual = try_to_convert(convertible)
+ self.assertEqual(expected, actual,
+ msg=get_conversion_error_msg(convertible, expected, actual))
+
+ def test_parse_to_int64_not_convertible(self):
+ min_int64, max_int64 = get_limits(ctypes.c_longlong)
+ for not_convertible in (1.2, np.float(4), float(3), np.double(45), 's', 'str',
+ np.array([1, 2]), (1,), [1, 2], min_int64 - 1, max_int64 + 1,
+ complex(1, 1), complex(imag=2), complex(1.1), np.bool_(True),
+ True, False, np.float32(2.3), np.array([3, ], dtype=int),
+ np.array([-2, ], dtype=np.int32), np.array([1, ], dtype=np.int),
+ np.array([11, ], dtype=np.uint8)):
+ with self.assertRaises((TypeError, OverflowError, ValueError),
+ msg=get_no_exception_msg(not_convertible)):
+ _ = cv.utils.dumpInt64(not_convertible)
+
def test_parse_to_size_t_convertible(self):
try_to_convert = partial(self._try_to_convert, cv.utils.dumpSizeT)
_, max_uint = get_limits(ctypes.c_uint)
#ifdef HAVE_OPENCV_VIDEOIO
typedef std::vector<VideoCaptureAPIs> vector_VideoCaptureAPIs;
+typedef std::vector<VideoCapture> vector_VideoCapture;
template<> struct pyopencvVecConverter<cv::VideoCaptureAPIs>
{
return pyopencvVecConverter<cv::VideoCaptureAPIs>::to(o, apis, info);
}
+template<> bool pyopencv_to(PyObject* obj, cv::VideoCapture& stream, const ArgInfo& info)
+{
+ Ptr<VideoCapture> * obj_getp = nullptr;
+ if (!pyopencv_VideoCapture_getp(obj, obj_getp))
+ return (failmsgp("Incorrect type of self (must be 'VideoCapture' or its derivative)") != nullptr);
+
+ stream = **obj_getp;
+ return true;
+}
+
#endif // HAVE_OPENCV_VIDEOIO