Skip to content

Commit

Permalink
Merge pull request nourani#5 from petermoz/master
Browse files Browse the repository at this point in the history
Added getLBPImage method to python bindings
  • Loading branch information
nourani committed Apr 9, 2013
2 parents 62631ea + f8bee72 commit 06856b2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/lbp.i
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
%include "numpy.i"
%include exception.i

/* Add documentation */
%feature("autodoc", "2");

%init %{
import_array();
%}
Expand All @@ -32,6 +35,21 @@ Mat
Mat mat(dims[0], dims[1], CV_64FC1, data);
$1 = mat;
}
%typemap(out, fragment="NumPy_Object_to_Array,NumPy_Array_Requirements")
Mat
{
/* Must be 2d image */
if($1.dims != 2)
SWIG_fail;

/* Create a new numpy array for output. */
npy_intp dims[2] = { $1.rows, $1.cols };
PyObject * array = PyArray_SimpleNew(2, dims, NPY_UINT8);

/* Copy the OpenCV data into the numpy array */
memcpy(PyArray_BYTES(array), $1.data, dims[0] * dims[1]);
$result = array;
}


/*
Expand Down
1 change: 1 addition & 0 deletions python/lbp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
hist = l.calcHist().getHist()

print(hist)
print(l.getLBPImage())

0 comments on commit 06856b2

Please sign in to comment.