refactor: rework test to be more specific

pull/22594/head
Vadim Levin 2 years ago
parent f1055a7e91
commit 3a15152be5
  1. 5
      modules/core/include/opencv2/core/bindings_utils.hpp
  2. 1
      modules/imgproc/include/opencv2/imgproc.hpp
  3. 19
      modules/imgproc/misc/python/test/test_matx_converter.py
  4. 9
      modules/imgproc/src/test_matx_converter.cpp
  5. 3
      modules/python/src2/cv2_convert.hpp
  6. 7
      modules/python/test/test_misc.py

@ -219,6 +219,11 @@ AsyncArray testAsyncException()
return p.getArrayResult();
}
CV_WRAP static inline
String dumpVec2i(const cv::Vec2i value = cv::Vec2i(42, 24)) {
return format("Vec2i(%d, %d)", value[0], value[1]);
}
namespace nested {
CV_WRAP static inline bool testEchoBooleanFunction(bool flag) {
return flag;

@ -4973,7 +4973,6 @@ public:
};
//! @cond IGNORED
CV_EXPORTS_W void testMatxPythonConverter(InputArray src, OutputArray dst, const Vec2d& defaultParam = Vec2d(-5, 5));
// === LineIterator implementation ===

@ -1,19 +0,0 @@
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()

@ -1,9 +0,0 @@
#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);
}
}

@ -62,8 +62,9 @@ PyObject* pyopencv_from(const T& src) { return PyOpenCV_Converter<T>::from(src);
template<typename _Tp, int m, int n>
bool pyopencv_to(PyObject* o, cv::Matx<_Tp, m, n>& mx, const ArgInfo& info)
{
if (!o || o == Py_None)
if (!o || o == Py_None) {
return true;
}
cv::Mat tmp;
if (!pyopencv_to(o, tmp, info)) {

@ -736,6 +736,13 @@ class CanUsePurePythonModuleFunction(NewOpenCVTests):
res = cv.utils._native.testOverwriteNativeMethod(123)
self.assertEqual(res, 123, msg="Failed to call native method implementation")
def test_default_matx_argument(self):
res = cv.utils.dumpVec2i()
self.assertEqual(res, "Vec2i(42, 24)",
msg="Default argument is not properly handled")
res = cv.utils.dumpVec2i((12, 21))
self.assertEqual(res, "Vec2i(12, 21)")
class SamplesFindFile(NewOpenCVTests):

Loading…
Cancel
Save