File: yarp.i.diff

package info (click to toggle)
morse-simulator 1.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 169,784 kB
  • ctags: 3,593
  • sloc: python: 23,947; ansic: 1,370; cpp: 786; makefile: 120; xml: 34; sh: 7
file content (61 lines) | stat: -rw-r--r-- 2,618 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--- example/swig/yarp.i.base	2010-09-01 15:53:56.000000000 +0200
+++ example/swig/yarp.i	2010-11-22 19:13:49.380914000 +0100
@@ -318,6 +318,13 @@
 typedef yarp::os::BufferedPort<ImageRgba> BufferedPortImageRgba;
 %}
 
+%{
+typedef yarp::sig::ImageOf<yarp::sig::PixelMono> ImageMono;
+typedef yarp::os::TypedReader<ImageMono> TypedReaderImageMono;
+typedef yarp::os::TypedReaderCallback<ImageMono> TypedReaderCallbackImageMono;
+typedef yarp::os::BufferedPort<ImageMono> BufferedPortImageMono;
+%}
+
 %feature("notabstract") ImageRgb;
 %feature("notabstract") yarp::os::BufferedPort<ImageRgb>;
 %feature("notabstract") BufferedPortImageRgb;
@@ -326,6 +333,10 @@
 %feature("notabstract") yarp::os::BufferedPort<ImageRgba>;
 %feature("notabstract") BufferedPortImageRgba;
 
+%feature("notabstract") ImageMono;
+%feature("notabstract") yarp::os::BufferedPort<ImageMono>;
+%feature("notabstract") BufferedPortImageMono;
+
 %template(ImageRgb) yarp::sig::ImageOf<yarp::sig::PixelRgb>;
 %template(TypedReaderImageRgb) yarp::os::TypedReader<yarp::sig::ImageOf<yarp::sig::PixelRgb> >;
 %template(TypedReaderCallbackImageRgb) yarp::os::TypedReaderCallback<yarp::sig::ImageOf<yarp::sig::PixelRgb> >;
@@ -337,6 +348,10 @@
 %template(TypedReaderCallbackImageRgba) yarp::os::TypedReaderCallback<yarp::sig::ImageOf<yarp::sig::PixelRgba> >;
 %template(BufferedPortImageRgba) yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgba> >;
 
+%template(ImageMono) yarp::sig::ImageOf<yarp::sig::PixelMono>;
+%template(TypedReaderImageMono) yarp::os::TypedReader<yarp::sig::ImageOf<yarp::sig::PixelMono> >;
+%template(TypedReaderCallbackImageMono) yarp::os::TypedReaderCallback<yarp::sig::ImageOf<yarp::sig::PixelMono> >;
+%template(BufferedPortImageMono) yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelMono> >;
 
 // Now we do ImageFloat - it is a little trickey too..
 //%template(ImageFloat) yarp::sig::ImageOf<yarp::sig::PixelFloat>;
@@ -650,3 +665,22 @@
         self->setExternal((void*)mem, w, h);
         }
 }
+
+// Conversion of Python buffer type object into a pointer
+%extend yarp::sig::Image {
+    void setExternal(PyObject* mem, int w, int h) {
+        Py_buffer img_buffer;
+        int reply;
+        reply = PyObject_GetBuffer(mem, &img_buffer, PyBUF_SIMPLE);
+        // exit if the buffer could not be read
+        if (reply != 0)
+        {
+            fprintf(stderr, "Couldn not read Python buffers: %d\n", reply);
+            return;
+        }
+        self->setExternal((void*)img_buffer.buf, w, h);
+        // release the Python buffers
+        PyBuffer_Release(&img_buffer);
+
+    }
+}