OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated0.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen.py ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/api
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen.py
)
set(the_target "cvpy")
# Accessing Elements and sub-Arrays
GetRow
CvArr arr
- CvMat submat /J:arr
+ CvMat submat /J:arr,O,A
int row
GetRows submat
CvArr arr
- CvMat submat /J:arr
+ CvMat submat /J:arr,O,A
int start_row
int end_row
int delta_row -1
GetCol submat
CvArr arr
- CvMat submat /J:arr
+ CvMat submat /J:arr,O,A
int col
GetCols submat
CvArr arr
- CvMat submat /J:arr
+ CvMat submat /J:arr,O,A
int start_col
int end_col
GetDiag submat
CvArr arr
- CvMat submat /J:arr
+ CvMat submat /J:arr,O,A
int diag 0
GetSubRect submat
CvArr arr
- CvMat submat /J:arr
+ CvMat submat /J:arr,O,A
CvRect rect
GetSize CvSize
CvArr arr
// make recipient use the donor's data, compute the offset,
// and manage reference counts.
-static PyObject *shareData(PyObject *donor, CvArr *pdonor, PyObject *recipient, CvMat *precipient)
+static void preShareData(CvArr *donor, CvMat **recipient)
{
+ *recipient = cvCreateMatHeader(4, 4, cvGetElemType(donor));
+}
+
+static PyObject *shareData(PyObject *donor, CvArr *pdonor, CvMat *precipient)
+{
+ PyObject *recipient = (PyObject*)PyObject_NEW(cvmat_t, &cvmat_Type);
+ ((cvmat_t*)recipient)->a = precipient;
((cvmat_t*)recipient)->offset = cvPtr1D(precipient, 0) - cvPtr1D(pdonor, 0);
PyObject *arr_data;
} else {
return (PyObject*)failmsg("Argument 'mat' must be either IplImage or CvMat");
}
- Py_DECREF(((cvmat_t*)recipient)->data);
((cvmat_t*)recipient)->data = arr_data;
Py_INCREF(arr_data);
- Py_INCREF(recipient);
return recipient;
}
# Do the conversions:
for a in args:
+ joinwith = [f[2:] for f in a.flags if f.startswith("J:")]
+ if len(joinwith) > 0:
+ yield 'preShareData(%s, &%s);' % (joinwith[0], a.nm)
if 'O' in a.flags:
continue
if a.ty in (conversion_types + aggregate.keys()):
af = dict([ (a.nm,a.flags) for a in args])
joinwith = [f[2:] for f in af.get(all_returns[0], []) if f.startswith("J:")]
if len(joinwith) > 0:
- yield ' return shareData(pyobj_%s, %s, pyobj_%s, %s);' % (joinwith[0], joinwith[0], all_returns[0], all_returns[0])
+ yield ' return shareData(pyobj_%s, %s, %s);' % (joinwith[0], joinwith[0], all_returns[0])
else:
yield ' return FROM_%s(%s);' % (safename(typed[all_returns[0]]), all_returns[0])
else:
iter = 77
subs = []
for i in range(iter):
- sub = cv.CreateMat(10, 10, cv.CV_8UC1)
- cv.GetSubRect(src, sub, (0, 0, 10, 10))
+ sub = cv.GetSubRect(src, (0, 0, 10, 10))
subs.append(sub)
self.assert_(sys.getrefcount(data) == (start_count + iter))
sub = cv.CreateMat(32, 32, cv.CV_8UC1)
for x in range(0, 512, 32):
for y in range(0, 512, 32):
- cv.GetSubRect(src, sub, (x, y, 32, 32))
+ sub = cv.GetSubRect(src, (x, y, 32, 32))
cv.SetImageROI(made, (x, y, 32, 32))
cv.Copy(sub, made)
cv.ResetImageROI(made)