mirror of
https://github.com/opencv/opencv.git
synced 2026-11-09 18:04:29 -06:00
Merge pull request #30508 from mh-masum6875/docs-python-manual-signatures
python: add documentation signatures for manually wrapped highgui functions
This commit is contained in:
@@ -115,7 +115,7 @@ static PyMethodDef special_methods[] = {
|
||||
#ifdef HAVE_OPENCV_HIGHGUI
|
||||
{"createTrackbar", (PyCFunction)pycvCreateTrackbar, METH_VARARGS, "createTrackbar(trackbarName, windowName, value, count, onChange) -> None"},
|
||||
{"createButton", CV_PY_FN_WITH_KW(pycvCreateButton), "createButton(buttonName, onChange [, userData, buttonType, initialButtonState]) -> None"},
|
||||
{"setMouseCallback", CV_PY_FN_WITH_KW(pycvSetMouseCallback), "setMouseCallback(windowName, onMouse [, param]) -> None"},
|
||||
{"setMouseCallback", CV_PY_FN_WITH_KW(pycvSetMouseCallback), "setMouseCallback(window_name, on_mouse [, param]) -> None"},
|
||||
#endif
|
||||
#ifdef HAVE_OPENCV_DNN
|
||||
{"dnn_registerLayer", CV_PY_FN_WITH_KW(pyopencv_cv_dnn_registerLayer), "registerLayer(type, class) -> None"},
|
||||
|
||||
@@ -1505,6 +1505,16 @@ class PythonWrapperGenerator(object):
|
||||
for name, constinfo in constlist:
|
||||
self.gen_const_reg(constinfo)
|
||||
|
||||
# step 6: add documentation signatures for the functions wrapped by hand in cv2.cpp,
|
||||
# because they are not parsed from the headers
|
||||
manual_signatures = [
|
||||
("cv::createTrackbar", "cv.createTrackbar", "trackbarName, windowName, value, count, onChange", "None"),
|
||||
("cv::createButton", "cv.createButton", "buttonName, onChange[, userData[, buttonType[, initialButtonState]]]", "None"),
|
||||
("cv::setMouseCallback", "cv.setMouseCallback", "window_name, on_mouse[, param]", "None"),
|
||||
]
|
||||
for cname, py_name, arg, ret in manual_signatures:
|
||||
self.py_signatures.setdefault(cname, []).append(dict(name=py_name, arg=arg, ret=ret))
|
||||
|
||||
# All symbols are collected and AST is reconstructed, generating
|
||||
# typing stubs...
|
||||
self.typing_stubs_generator.generate(output_path)
|
||||
|
||||
@@ -254,17 +254,17 @@ def refine_highgui_module(root: NamespaceNode) -> None:
|
||||
)
|
||||
"""
|
||||
def setMouseCallback(
|
||||
windowName: str,
|
||||
onMouse: Callback[[int, int, int, int, Any | None], None],
|
||||
window_name: str,
|
||||
on_mouse: Callback[[int, int, int, int, Any | None], None],
|
||||
param: Any | None = ...
|
||||
) -> None: ...
|
||||
"""
|
||||
root.add_function(
|
||||
"setMouseCallback",
|
||||
[
|
||||
FunctionNode.Arg("windowName", PrimitiveTypeNode.str_()),
|
||||
FunctionNode.Arg("window_name", PrimitiveTypeNode.str_()),
|
||||
FunctionNode.Arg(
|
||||
"onMouse",
|
||||
"on_mouse",
|
||||
CallableTypeNode("MouseCallback", [
|
||||
PrimitiveTypeNode.int_(),
|
||||
PrimitiveTypeNode.int_(),
|
||||
|
||||
Reference in New Issue
Block a user