|
|
|
@ -508,13 +508,71 @@ static PyObject * UMatWrapper_get(cv2_UMatWrapperObject* self) |
|
|
|
|
return pyopencv_from(m); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// UMatWrapper.handle() - returns the OpenCL handle of the UMat object
|
|
|
|
|
static PyObject * UMatWrapper_handle(cv2_UMatWrapperObject* self, PyObject *args, PyObject *kwds) |
|
|
|
|
{ |
|
|
|
|
const char *kwlist[] = {"accessFlags", NULL}; |
|
|
|
|
int accessFlags; |
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", (char**) kwlist, &accessFlags)) |
|
|
|
|
return 0; |
|
|
|
|
return PyLong_FromVoidPtr(self->um->handle(accessFlags)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// UMatWrapper.isContinuous() - returns true if the matrix data is continuous
|
|
|
|
|
static PyObject * UMatWrapper_isContinuous(cv2_UMatWrapperObject* self) |
|
|
|
|
{ |
|
|
|
|
return PyBool_FromLong(self->um->isContinuous()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// UMatWrapper.isContinuous() - returns true if the matrix is a submatrix of another matrix
|
|
|
|
|
static PyObject * UMatWrapper_isSubmatrix(cv2_UMatWrapperObject* self) |
|
|
|
|
{ |
|
|
|
|
return PyBool_FromLong(self->um->isSubmatrix()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// UMatWrapper.context() - returns the OpenCL context used by OpenCV UMat
|
|
|
|
|
static PyObject * UMatWrapper_context(cv2_UMatWrapperObject*) |
|
|
|
|
{ |
|
|
|
|
return PyLong_FromVoidPtr(cv::ocl::Context::getDefault().ptr()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// UMatWrapper.context() - returns the OpenCL queue used by OpenCV UMat
|
|
|
|
|
static PyObject * UMatWrapper_queue(cv2_UMatWrapperObject*) |
|
|
|
|
{ |
|
|
|
|
return PyLong_FromVoidPtr(cv::ocl::Queue::getDefault().ptr()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static PyObject * UMatWrapper_offset_getter(cv2_UMatWrapperObject* self, void*) |
|
|
|
|
{ |
|
|
|
|
return PyLong_FromSsize_t(self->um->offset); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static PyMethodDef UMatWrapper_methods[] = { |
|
|
|
|
{"get", (PyCFunction)UMatWrapper_get, METH_NOARGS, |
|
|
|
|
"Returns numpy array" |
|
|
|
|
}, |
|
|
|
|
{"handle", (PyCFunction)UMatWrapper_handle, METH_VARARGS | METH_KEYWORDS, |
|
|
|
|
"Returns UMat native handle" |
|
|
|
|
}, |
|
|
|
|
{"isContinuous", (PyCFunction)UMatWrapper_isContinuous, METH_NOARGS, |
|
|
|
|
"Returns true if the matrix data is continuous" |
|
|
|
|
}, |
|
|
|
|
{"isSubmatrix", (PyCFunction)UMatWrapper_isSubmatrix, METH_NOARGS, |
|
|
|
|
"Returns true if the matrix is a submatrix of another matrix" |
|
|
|
|
}, |
|
|
|
|
{"context", (PyCFunction)UMatWrapper_context, METH_NOARGS | METH_STATIC, |
|
|
|
|
"Returns OpenCL context handle" |
|
|
|
|
}, |
|
|
|
|
{"queue", (PyCFunction)UMatWrapper_queue, METH_NOARGS | METH_STATIC, |
|
|
|
|
"Returns OpenCL queue handle" |
|
|
|
|
}, |
|
|
|
|
{NULL, NULL, 0, NULL} /* Sentinel */ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static PyGetSetDef UMatWrapper_getset[] = { |
|
|
|
|
{(char*) "offset", (getter) UMatWrapper_offset_getter, NULL, NULL, NULL}, |
|
|
|
|
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static PyTypeObject cv2_UMatWrapperType = { |
|
|
|
|
#if PY_MAJOR_VERSION >= 3 |
|
|
|
@ -551,7 +609,7 @@ static PyTypeObject cv2_UMatWrapperType = { |
|
|
|
|
0, /* tp_iternext */ |
|
|
|
|
UMatWrapper_methods, /* tp_methods */ |
|
|
|
|
0, /* tp_members */ |
|
|
|
|
0, /* tp_getset */ |
|
|
|
|
UMatWrapper_getset, /* tp_getset */ |
|
|
|
|
0, /* tp_base */ |
|
|
|
|
0, /* tp_dict */ |
|
|
|
|
0, /* tp_descr_get */ |
|
|
|
|