From 181de064457aaea383621e9e8d01ef4aead6a842 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Tue, 26 Apr 2011 00:01:41 +0000 Subject: [PATCH] restore data matrix --- modules/python/src/cv.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/python/src/cv.cpp b/modules/python/src/cv.cpp index 0280fcd9fa..3ac32d3d4d 100644 --- a/modules/python/src/cv.cpp +++ b/modules/python/src/cv.cpp @@ -3677,6 +3677,28 @@ static PyObject *pycvClipLine(PyObject *self, PyObject *args) } } +static PyObject *pyfinddatamatrix(PyObject *self, PyObject *args) +{ + PyObject *pyim; + if (!PyArg_ParseTuple(args, "O", &pyim)) + return NULL; + + CvMat *image; + if (!convert_to_CvMat(pyim, &image, "image")) return NULL; + + std::deque codes; + ERRWRAP(codes = cvFindDataMatrix(image)); + + PyObject *pycodes = PyList_New(codes.size()); + int i; + for (i = 0; i < codes.size(); i++) { + DataMatrixCode *pc = &codes[i]; + PyList_SetItem(pycodes, i, Py_BuildValue("(sOO)", pc->msg, FROM_CvMat(pc->corners), FROM_CvMat(pc->original))); + } + + return pycodes; +} + static PyObject *temp_test(PyObject *self, PyObject *args) { #if 0 @@ -3971,6 +3993,7 @@ static PyMethodDef methods[] = { //{"_HOGDetect", (PyCFunction)pycvHOGDetect, METH_KEYWORDS, "_HOGDetect(image, svm_classifier, win_stride=block_stride, locations=None, padding=(0,0), win_size=(64,128), block_size=(16,16), block_stride=(8,8), cell_size=(8,8), nbins=9, gammaCorrection=true) -> list_of_points"}, //{"_HOGDetectMultiScale", (PyCFunction)pycvHOGDetectMultiScale, METH_KEYWORDS, "_HOGDetectMultiScale(image, svm_classifier, win_stride=block_stride, scale=1.05, group_threshold=2, padding=(0,0), win_size=(64,128), block_size=(16,16), block_stride=(8,8), cell_size=(8,8), nbins=9, gammaCorrection=true) -> list_of_points"}, + {"FindDataMatrix", pyfinddatamatrix, METH_VARARGS}, {"temp_test", temp_test, METH_VARARGS}, #include "generated1.i"