mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -58,6 +58,12 @@ String dumpCString(const char* argument)
|
||||
return cv::format("String: %s", argument);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpString(const String& argument)
|
||||
{
|
||||
return cv::format("String: %s", argument.c_str());
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
AsyncArray testAsyncArray(InputArray argument)
|
||||
{
|
||||
|
||||
@@ -104,6 +104,7 @@ inline int dstChannels(int code)
|
||||
return 4;
|
||||
|
||||
case COLOR_BGRA2BGR: case COLOR_RGBA2BGR: case COLOR_RGB2BGR:
|
||||
case COLOR_YUV2RGB: case COLOR_YUV2BGR: case COLOR_RGB2YUV: case COLOR_BGR2YUV:
|
||||
case COLOR_BGR5652BGR: case COLOR_BGR5552BGR: case COLOR_BGR5652RGB: case COLOR_BGR5552RGB:
|
||||
case COLOR_GRAY2BGR:
|
||||
case COLOR_YUV2BGR_NV21: case COLOR_YUV2RGB_NV21: case COLOR_YUV2BGR_NV12: case COLOR_YUV2RGB_NV12:
|
||||
|
||||
@@ -778,15 +778,13 @@ class JSWrapperGenerator(object):
|
||||
self.bindings+=binding
|
||||
|
||||
# generate code for the classes and their methods
|
||||
class_list = list(self.classes.items())
|
||||
|
||||
for name, class_info in class_list:
|
||||
for name, class_info in sorted(self.classes.items()):
|
||||
class_bindings = []
|
||||
if not name in white_list:
|
||||
continue
|
||||
|
||||
# Generate bindings for methods
|
||||
for method_name, method in class_info.methods.items():
|
||||
for method_name, method in sorted(class_info.methods.items()):
|
||||
if method.cname in ignore_list:
|
||||
continue
|
||||
if not method.name in white_list[method.class_name]:
|
||||
@@ -824,7 +822,7 @@ class JSWrapperGenerator(object):
|
||||
|
||||
|
||||
# Generate bindings for properties
|
||||
for property in class_info.props:
|
||||
for property in sorted(class_info.props):
|
||||
_class_property = class_property_enum_template if property.tp in type_dict else class_property_template
|
||||
class_bindings.append(_class_property.substitute(js_name=property.name, cpp_name='::'.join(
|
||||
[class_info.cname, property.name])))
|
||||
|
||||
@@ -227,7 +227,11 @@ TEST(Photo_CalibrateDebevec, regression)
|
||||
diff = diff.mul(1.0f / response);
|
||||
double max;
|
||||
minMaxLoc(diff, NULL, &max);
|
||||
ASSERT_FALSE(max > 0.1);
|
||||
#if defined(__arm__) || defined(__aarch64__)
|
||||
ASSERT_LT(max, 0.131);
|
||||
#else
|
||||
ASSERT_LT(max, 0.1);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Photo_CalibrateRobertson, regression)
|
||||
|
||||
@@ -993,15 +993,31 @@ PyObject* pyopencv_from(const std::string& value)
|
||||
template<>
|
||||
bool pyopencv_to(PyObject* obj, String &value, const ArgInfo& info)
|
||||
{
|
||||
CV_UNUSED(info);
|
||||
if(!obj || obj == Py_None)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
std::string str;
|
||||
if (getUnicodeString(obj, str))
|
||||
{
|
||||
value = str;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If error hasn't been already set by Python conversion functions
|
||||
if (!PyErr_Occurred())
|
||||
{
|
||||
// Direct access to underlying slots of PyObjectType is not allowed
|
||||
// when limited API is enabled
|
||||
#ifdef Py_LIMITED_API
|
||||
failmsg("Can't convert object to 'str' for '%s'", info.name);
|
||||
#else
|
||||
failmsg("Can't convert object of type '%s' to 'str' for '%s'",
|
||||
obj->ob_type->tp_name, info.name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ class Arguments(NewOpenCVTests):
|
||||
|
||||
def test_parse_to_cstring_convertible(self):
|
||||
try_to_convert = partial(self._try_to_convert, cv.utils.dumpCString)
|
||||
for convertible in ('s', 'str', str(123), ('char'), np.str('test1'), np.str_('test2')):
|
||||
for convertible in ('', 's', 'str', str(123), ('char'), np.str('test1'), np.str_('test2')):
|
||||
expected = 'string: ' + convertible
|
||||
actual = try_to_convert(convertible)
|
||||
self.assertEqual(expected, actual,
|
||||
@@ -326,6 +326,20 @@ class Arguments(NewOpenCVTests):
|
||||
with self.assertRaises((TypeError), msg=get_no_exception_msg(not_convertible)):
|
||||
_ = cv.utils.dumpCString(not_convertible)
|
||||
|
||||
def test_parse_to_string_convertible(self):
|
||||
try_to_convert = partial(self._try_to_convert, cv.utils.dumpString)
|
||||
for convertible in (None, '', 's', 'str', str(123), np.str('test1'), np.str_('test2')):
|
||||
expected = 'string: ' + (convertible if convertible else '')
|
||||
actual = try_to_convert(convertible)
|
||||
self.assertEqual(expected, actual,
|
||||
msg=get_conversion_error_msg(convertible, expected, actual))
|
||||
|
||||
def test_parse_to_string_not_convertible(self):
|
||||
for not_convertible in ((12,), ('t', 'e', 's', 't'), np.array(['123', ]),
|
||||
np.array(['t', 'e', 's', 't']), 1, True, False):
|
||||
with self.assertRaises((TypeError), msg=get_no_exception_msg(not_convertible)):
|
||||
_ = cv.utils.dumpString(not_convertible)
|
||||
|
||||
|
||||
class SamplesFindFile(NewOpenCVTests):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user