From 3b97f5d5e909441486ec824f38ea9d993de46708 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 13 Jun 2011 21:47:35 +0000 Subject: [PATCH] return Py_None for an empty mat (should fix #1120) --- modules/python/src2/cv2.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index f9cfde41c0..9737f49c3a 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -234,6 +234,11 @@ static int pyopencv_to(const PyObject* o, Mat& m, const char* name = "" static PyObject* pyopencv_from(const Mat& m) { + if( !m.data ) + { + Py_INCREF(Py_None); + return Py_None; + } Mat temp, *p = (Mat*)&m; if(!p->refcount || p->allocator != &g_numpyAllocator) {