]> rtime.felk.cvut.cz Git - opencv.git/commitdiff
Disallow 64-bit int fromarray(); tests force arrays to 32-bit floats.
authorjamesb <jamesb@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Fri, 26 Mar 2010 17:45:26 +0000 (17:45 +0000)
committerjamesb <jamesb@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Fri, 26 Mar 2010 17:45:26 +0000 (17:45 +0000)
git-svn-id: https://code.ros.org/svn/opencv/trunk@2929 73c94f0f-984f-4a5f-82bc-2d8db8d8ee08

opencv/interfaces/python/cv.cpp
opencv/tests/python/test.py

index ba8d41d6f378ffe5008ddbd6ec73a91c9cd331be..94ded4e8378fd1347ce0d6a805369a440d2e6edb 100644 (file)
@@ -2747,6 +2747,10 @@ static PyObject *fromarray(PyObject *o, int allowND)
       type = CV_16SC1;
     else if (pai->itemsize == 4)
       type = CV_32SC1;
+    else if (pai->itemsize == 8) {
+      PyErr_SetString(PyExc_TypeError, "OpenCV cannot handle 64-bit integer arrays");
+      return NULL;
+    }
     break;
 
   case 'u':
@@ -2764,6 +2768,7 @@ static PyObject *fromarray(PyObject *o, int allowND)
     break;
 
   }
+  assert(type != -1);
 
   if (!allowND) {
     cvmat_t *m = PyObject_NEW(cvmat_t, &cvmat_Type);
index 6f2806e2b69ccedd74b3b4662267fd74c1f995bf..57a0c9b15c991281a78328c7443a052e2c5a99df 100644 (file)
@@ -750,7 +750,7 @@ class AreaTests(OpenCVTests):
 
             def convert(numpydims):
                 """ Create a numpy array with specified dims, return the OpenCV CvMat """
-                a1 = numpy.array([1] * reduce(operator.__mul__, numpydims)).reshape(*numpydims)
+                a1 = numpy.array([1] * reduce(operator.__mul__, numpydims)).reshape(*numpydims).astype(numpy.float32)
                 return cv.fromarray(a1)
             def row_col_chan(m):
                 col = m.cols