From: 赵楚洋 Date: Sun, 2 Oct 2022 09:06:07 +0000 (+0800) Subject: add test X-Git-Tag: accepted/tizen/unified/20230127.161057~1^2~67^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1055a7e91372448a53fb2ecd4f56f5cd75fbc11;p=platform%2Fupstream%2Fopencv.git add test --- diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index afc2742ab6..073833e8f2 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -4973,6 +4973,7 @@ public: }; //! @cond IGNORED +CV_EXPORTS_W void testMatxPythonConverter(InputArray src, OutputArray dst, const Vec2d& defaultParam = Vec2d(-5, 5)); // === LineIterator implementation === diff --git a/modules/imgproc/misc/python/test/test_matx_converter.py b/modules/imgproc/misc/python/test/test_matx_converter.py new file mode 100644 index 0000000000..8a39031ca7 --- /dev/null +++ b/modules/imgproc/misc/python/test/test_matx_converter.py @@ -0,0 +1,19 @@ +from __future__ import print_function +import cv2 as cv +from cv2 import testMatxPythonConverter +from tests_common import NewOpenCVTests + + +class MatxConverterTest(NewOpenCVTests): + def test_matxconverter(self): + samples = ['samples/data/lena.jpg', 'cv/cascadeandhog/images/mona-lisa.png'] + + for sample in samples: + img = self.get_sample(sample) + out = testMatxPythonConverter(img) + + +if __name__ == '__main__': + NewOpenCVTests.bootstrap() + + diff --git a/modules/imgproc/src/test_matx_converter.cpp b/modules/imgproc/src/test_matx_converter.cpp new file mode 100644 index 0000000000..96e0ecacaf --- /dev/null +++ b/modules/imgproc/src/test_matx_converter.cpp @@ -0,0 +1,9 @@ +#include "precomp.hpp" + +namespace cv{ + void testMatxPythonConverter(InputArray _src, OutputArray _dst, const Vec2d& defaultParam){ + printf("%f %f\n", defaultParam[0], defaultParam[1]); + Mat src = _src.getMat(); + src.copyTo(_dst); + } +} diff --git a/modules/python/src2/cv2_convert.hpp b/modules/python/src2/cv2_convert.hpp index 563f5386b7..7dc0ffb788 100644 --- a/modules/python/src2/cv2_convert.hpp +++ b/modules/python/src2/cv2_convert.hpp @@ -62,6 +62,9 @@ PyObject* pyopencv_from(const T& src) { return PyOpenCV_Converter::from(src); template bool pyopencv_to(PyObject* o, cv::Matx<_Tp, m, n>& mx, const ArgInfo& info) { + if (!o || o == Py_None) + return true; + cv::Mat tmp; if (!pyopencv_to(o, tmp, info)) { return false;