1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2025-02-19 09:31:51 +03:00
130 changed files with 6998 additions and 3110 deletions
@@ -52,6 +52,20 @@ def apply_manual_api_refinement(root: NamespaceNode) -> None:
])
def make_optional_none_return(root_node: NamespaceNode,
function_symbol_name: SymbolName) -> None:
"""
Make return type Optional[MatLike],
for the functions that may return None.
"""
function = find_function_node(root_node, function_symbol_name)
for overload in function.overloads:
if overload.return_type is not None:
if not isinstance(overload.return_type.type_node, OptionalTypeNode):
overload.return_type.type_node = OptionalTypeNode(
overload.return_type.type_node
)
def export_matrix_type_constants(root: NamespaceNode) -> None:
MAX_PREDEFINED_CHANNELS = 4
@@ -326,6 +340,8 @@ NODES_TO_REFINE = {
SymbolName(("cv", ), (), "resize"): make_optional_arg("dsize"),
SymbolName(("cv", ), (), "calcHist"): make_optional_arg("mask"),
SymbolName(("cv", ), (), "floodFill"): make_optional_arg("mask"),
SymbolName(("cv", ), (), "imread"): make_optional_none_return,
SymbolName(("cv", ), (), "imdecode"): make_optional_none_return,
}
ERROR_CLASS_PROPERTIES = (
@@ -54,8 +54,12 @@ _PREDEFINED_TYPES = (
doc="Required length is 2"),
AliasTypeNode.sequence_("Size2f", PrimitiveTypeNode.float_(),
doc="Required length is 2"),
AliasTypeNode.sequence_("Scalar", PrimitiveTypeNode.float_(),
doc="Required length is at most 4"),
AliasTypeNode.union_(
"Scalar",
items=(SequenceTypeNode("Scalar", PrimitiveTypeNode.float_()),
PrimitiveTypeNode.float_()),
doc="Max sequence length is at most 4"
),
AliasTypeNode.sequence_("Point", PrimitiveTypeNode.int_(),
doc="Required length is 2"),
AliasTypeNode.ref_("Point2i", "Point"),
+10 -2
View File
@@ -24,11 +24,12 @@ class NewOpenCVTests(unittest.TestCase):
# path to local repository folder containing 'samples' folder
repoPath = None
extraTestDataPath = None
extraDnnTestDataPath = None
# github repository url
repoUrl = 'https://raw.github.com/opencv/opencv/5.x'
def find_file(self, filename, searchPaths=[], required=True):
searchPaths = searchPaths if searchPaths else [self.repoPath, self.extraTestDataPath]
searchPaths = searchPaths if searchPaths else [self.repoPath, self.extraTestDataPath, self.extraDnnTestDataPath]
for path in searchPaths:
if path is not None:
candidate = path + '/' + filename
@@ -57,7 +58,7 @@ class NewOpenCVTests(unittest.TestCase):
def hashimg(self, im):
""" Compute a hash for an image, useful for image comparisons """
return hashlib.md5(im.tostring()).hexdigest()
return hashlib.md5(im.tobytes()).hexdigest()
if sys.version_info[:2] == (2, 6):
def assertLess(self, a, b, msg=None):
@@ -83,10 +84,17 @@ class NewOpenCVTests(unittest.TestCase):
print("Testing OpenCV", cv.__version__)
print("Local repo path:", args.repo)
NewOpenCVTests.repoPath = args.repo
try:
NewOpenCVTests.extraTestDataPath = os.environ['OPENCV_TEST_DATA_PATH']
except KeyError:
print('Missing opencv extra repository. Some of tests may fail.')
try:
NewOpenCVTests.extraDnnTestDataPath = os.environ['OPENCV_DNN_TEST_DATA_PATH']
except KeyError:
pass
random.seed(0)
unit_argv = [sys.argv[0]] + other
unittest.main(argv=unit_argv)