mirror of
https://github.com/opencv/opencv.git
synced 2026-09-13 13:55:39 -05:00
extract test list into a separate .py file
This commit is contained in:
@@ -127,16 +127,25 @@ bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo& info)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool needcopy = false;
|
||||
int typenum = PyArray_TYPE(oarr);
|
||||
bool needcopy = false, needcast = false;
|
||||
int typenum = PyArray_TYPE(oarr), new_typenum = typenum;
|
||||
int type = numpyTypeToCvDepth(typenum);
|
||||
|
||||
if( type < 0 )
|
||||
{
|
||||
const std::string dtype_name = getArrayTypeName(oarr);
|
||||
failmsg("%s data type = %s is not supported", info.name,
|
||||
dtype_name.c_str());
|
||||
return false;
|
||||
if( typenum == NPY_INT64 || typenum == NPY_LONG || typenum == NPY_LONGLONG )
|
||||
{
|
||||
needcopy = needcast = true;
|
||||
new_typenum = NPY_INT;
|
||||
type = CV_32S;
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::string dtype_name = getArrayTypeName(oarr);
|
||||
failmsg("%s data type = %s is not supported", info.name,
|
||||
dtype_name.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CV_MAX_DIM
|
||||
@@ -211,8 +220,14 @@ bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo& info)
|
||||
return false;
|
||||
}
|
||||
|
||||
oarr = PyArray_GETCONTIGUOUS(oarr);
|
||||
o = (PyObject*) oarr;
|
||||
if( needcast ) {
|
||||
o = PyArray_Cast(oarr, new_typenum);
|
||||
oarr = (PyArrayObject*) o;
|
||||
}
|
||||
else {
|
||||
oarr = PyArray_GETCONTIGUOUS(oarr);
|
||||
o = (PyObject*) oarr;
|
||||
}
|
||||
|
||||
_strides = PyArray_STRIDES(oarr);
|
||||
}
|
||||
|
||||
@@ -43,10 +43,8 @@ int numpyTypeToCvDepth(int typenum)
|
||||
case NPY_UINT: return CV_32U;
|
||||
case NPY_INT: return CV_32S;
|
||||
case NPY_ULONGLONG: return CV_64U;
|
||||
case NPY_LONGLONG: return CV_64S;
|
||||
// 'long' is 64-bit on LP64 but 32-bit on LLP64, so decide by size, not by name.
|
||||
case NPY_ULONG: return NPY_SIZEOF_LONG == 8 ? CV_64U : CV_32U;
|
||||
case NPY_LONG: return NPY_SIZEOF_LONG == 8 ? CV_64S : CV_32S;
|
||||
case NPY_HALF: return CV_16F;
|
||||
case NPY_FLOAT: return CV_32F;
|
||||
case NPY_DOUBLE: return CV_64F;
|
||||
|
||||
Reference in New Issue
Block a user