[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd/cvd/python interface.h types.h
From: |
Damian Eads |
Subject: |
[libcvd-members] libcvd/cvd/python interface.h types.h |
Date: |
Fri, 22 Aug 2008 19:18:34 +0000 |
CVSROOT: /sources/libcvd
Module name: libcvd
Changes by: Damian Eads <eads> 08/08/22 19:18:34
Added files:
cvd/python : interface.h types.h
Log message:
Added header files for the Python header files.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/python/interface.h?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/python/types.h?cvsroot=libcvd&rev=1.1
Patches:
Index: interface.h
===================================================================
RCS file: interface.h
diff -N interface.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ interface.h 22 Aug 2008 19:18:34 -0000 1.1
@@ -0,0 +1,68 @@
+/**
+ * interface.h
+ *
+ * @author Damian Eads
+ * @author Edward Rosten
+ *
+ * This file is part of the CVD Library.
+ * Copyright (C) 2005 The Authors
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef PYCVD_INTERFACE_HPP
+#define PYCVD_INTERFACE_HPP
+
+#include <Python.h>
+#include <numpy/arrayobject.h>
+#include <vector>
+#include <sstream>
+#include <cvd/image.h>
+#include <cvd/image_io.h>
+#include <cvd/vector_image_ref.h>
+#include <cvd/convolution.h>
+
+#include "types.h"
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// This code provides the lists needed for python to C++ type mangling
+//
+////////////////////////////////////////////////////////////////////////////////
+
+namespace PyCVD {
+
+ template <class T>
+ PyArrayObject *fromBasicImageToNumpy(const CVD::BasicImage<T> &image) {
+ npy_intp a[] = {image.size().y, image.size().x};
+ PyArrayObject *retval = (PyArrayObject*)PyArray_SimpleNew(2, a,
NumpyType<T>::type);
+ T *data = (T*)retval->data;
+ copy(image.begin(), image.end(), data);
+ return retval;
+ }
+
+ template <class T>
+ void allocateNumpyCVDImageSiblings(int width, int height,
+ /**out: */ CVD::BasicImage<T> *image,
+ PyArrayObject **numpy) {
+ npy_intp a[] = {height, width};
+ *numpy = (PyArrayObject*)PyArray_SimpleNew(2, a, NumpyType<T>::type);
+ *image = CVD::BasicImage<T>((T*)(*numpy)->data, CVD::ImageRef(width,
height));
+ }
+
+}
+
+#endif
Index: types.h
===================================================================
RCS file: types.h
diff -N types.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ types.h 22 Aug 2008 19:18:34 -0000 1.1
@@ -0,0 +1,75 @@
+/**
+ * types.h
+ *
+ * @author Damian Eads
+ * @author Edward Rosten
+ *
+ * This file is part of the CVD Library.
+ * Copyright (C) 2005 The Authors
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef PYCVD_TYPES_HPP
+#define PYCVD_TYPES_HPP
+
+namespace PyCVD {
+
+
+#define DEFINE_NUMPY_TYPE(Type, PyType) \
+template<> struct NumpyType<Type>\
+{\
+ static const int type = PyType;\
+ static std::string name(){ return #Type;} \
+ static char code(){ return PyType##LTR;}\
+}
+
+ template<class C> struct NumpyType
+ {
+ };
+
+ DEFINE_NUMPY_TYPE(unsigned char , NPY_UBYTE );
+ DEFINE_NUMPY_TYPE(char , NPY_BYTE );
+ DEFINE_NUMPY_TYPE(short , NPY_SHORT );
+ DEFINE_NUMPY_TYPE(unsigned short, NPY_USHORT);
+ DEFINE_NUMPY_TYPE(int , NPY_INT );
+ DEFINE_NUMPY_TYPE(long long , NPY_LONGLONG);
+ DEFINE_NUMPY_TYPE(unsigned int , NPY_UINT );
+ DEFINE_NUMPY_TYPE(float , NPY_FLOAT );
+ DEFINE_NUMPY_TYPE(double , NPY_DOUBLE);
+
+ struct End{};
+
+ template<class C, class D> struct TypeList
+ {
+ typedef C type;
+ typedef D next;
+ };
+
+
+ typedef TypeList<char,
+ TypeList<unsigned char,
+ TypeList<short,
+ TypeList<unsigned short,
+ TypeList<int,
+ TypeList<long long,
+ TypeList<unsigned int,
+ TypeList<float,
+ TypeList<double, End> > > > > > > > > CVDTypes;
+
+}
+
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd/cvd/python interface.h types.h,
Damian Eads <=