Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
9b959072
Commit
9b959072
authored
Jun 20, 2016
by
Matthew Skolaut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added python binding for createButton
parent
e3844e0f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
cv2.cpp
modules/python/src2/cv2.cpp
+51
-0
No files found.
modules/python/src2/cv2.cpp
View file @
9b959072
...
...
@@ -1251,6 +1251,7 @@ static void OnChange(int pos, void *param)
}
#ifdef HAVE_OPENCV_HIGHGUI
static
PyObject
*
pycvCreateTrackbar
(
PyObject
*
,
PyObject
*
args
)
{
PyObject
*
on_change
;
...
...
@@ -1270,6 +1271,55 @@ static PyObject *pycvCreateTrackbar(PyObject*, PyObject *args)
}
#endif
static
void
OnButtonChange
(
int
state
,
void
*
param
)
{
PyGILState_STATE
gstate
;
gstate
=
PyGILState_Ensure
();
PyObject
*
o
=
(
PyObject
*
)
param
;
PyObject
*
args
;
if
(
PyTuple_GetItem
(
o
,
1
)
!=
NULL
)
{
args
=
Py_BuildValue
(
"(iO)"
,
state
,
PyTuple_GetItem
(
o
,
1
));
}
else
{
args
=
Py_BuildValue
(
"(i)"
,
state
);
}
PyObject
*
r
=
PyObject_Call
(
PyTuple_GetItem
(
o
,
0
),
args
,
NULL
);
if
(
r
==
NULL
)
PyErr_Print
();
Py_DECREF
(
args
);
PyGILState_Release
(
gstate
);
}
#ifdef HAVE_OPENCV_HIGHGUI
static
PyObject
*
pycvCreateButton
(
PyObject
*
,
PyObject
*
args
,
PyObject
*
kw
)
{
const
char
*
keywords
[]
=
{
"buttonName"
,
"onChange"
,
"userData"
,
"buttonType"
,
"initialButtonState"
,
NULL
};
PyObject
*
on_change
;
PyObject
*
userdata
=
NULL
;
char
*
button_name
;
int
button_type
=
0
;
int
initial_button_state
=
0
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"sO|Oii"
,
(
char
**
)
keywords
,
&
button_name
,
&
on_change
,
&
userdata
,
&
button_type
,
&
initial_button_state
))
return
NULL
;
if
(
!
PyCallable_Check
(
on_change
))
{
PyErr_SetString
(
PyExc_TypeError
,
"onChange must be callable"
);
return
NULL
;
}
if
(
userdata
==
NULL
)
{
userdata
=
Py_None
;
}
ERRWRAP2
(
createButton
(
button_name
,
OnButtonChange
,
Py_BuildValue
(
"OO"
,
on_change
,
userdata
),
button_type
,
initial_button_state
));
Py_RETURN_NONE
;
}
#endif
///////////////////////////////////////////////////////////////////////////////////////
static
int
convert_to_char
(
PyObject
*
o
,
char
*
dst
,
const
char
*
name
=
"no_name"
)
...
...
@@ -1300,6 +1350,7 @@ static int convert_to_char(PyObject *o, char *dst, const char *name = "no_name")
static
PyMethodDef
special_methods
[]
=
{
#ifdef HAVE_OPENCV_HIGHGUI
{
"createTrackbar"
,
pycvCreateTrackbar
,
METH_VARARGS
,
"createTrackbar(trackbarName, windowName, value, count, onChange) -> None"
},
{
"createButton"
,
(
PyCFunction
)
pycvCreateButton
,
METH_VARARGS
|
METH_KEYWORDS
,
"createButton(buttonName, onChange [, userData, buttonType, initialButtonState]) -> None"
},
{
"setMouseCallback"
,
(
PyCFunction
)
pycvSetMouseCallback
,
METH_VARARGS
|
METH_KEYWORDS
,
"setMouseCallback(windowName, onMouse [, param]) -> None"
},
#endif
{
NULL
,
NULL
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment