mirror of
https://github.com/opencv/opencv.git
synced 2026-07-28 23:03:03 +04:00
Merge branch '4.x' into '5.x'
This commit is contained in:
@@ -68,8 +68,14 @@ if(DEFINED OPENCV_PYTHON_INSTALL_PATH)
|
||||
endif()
|
||||
set(CMAKE_PYTHON_BINARIES_PATH "${CMAKE_PYTHON_BINARIES_INSTALL_PATH}")
|
||||
if (WIN32 AND HAVE_CUDA)
|
||||
if (DEFINED CUDA_TOOLKIT_ROOT_DIR)
|
||||
list(APPEND CMAKE_PYTHON_BINARIES_PATH "os.path.join(os.getenv('CUDA_PATH', '${CUDA_TOOLKIT_ROOT_DIR}'), 'bin')")
|
||||
if (ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
|
||||
if (DEFINED CUDAToolkit_LIBRARY_ROOT)
|
||||
list(APPEND CMAKE_PYTHON_BINARIES_PATH "os.path.join(os.getenv('CUDA_PATH', '${CUDAToolkit_LIBRARY_ROOT}'), 'bin')")
|
||||
endif()
|
||||
else()
|
||||
if (DEFINED CUDA_TOOLKIT_ROOT_DIR)
|
||||
list(APPEND CMAKE_PYTHON_BINARIES_PATH "os.path.join(os.getenv('CUDA_PATH', '${CUDA_TOOLKIT_ROOT_DIR}'), 'bin')")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
string(REPLACE ";" ",\n " CMAKE_PYTHON_BINARIES_PATH "${CMAKE_PYTHON_BINARIES_PATH}")
|
||||
|
||||
@@ -56,7 +56,7 @@ bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo& info)
|
||||
if(!o || o == Py_None)
|
||||
{
|
||||
if( !m.data )
|
||||
m.allocator = &g_numpyAllocator;
|
||||
m.allocator = &GetNumpyAllocator();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -298,14 +298,14 @@ bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo& info)
|
||||
#endif
|
||||
|
||||
m = Mat(ndims, size, type, PyArray_DATA(oarr), step);
|
||||
m.u = g_numpyAllocator.allocate(o, ndims, size, type, step);
|
||||
m.u = GetNumpyAllocator().allocate(o, ndims, size, type, step);
|
||||
m.addref();
|
||||
|
||||
if( !needcopy )
|
||||
{
|
||||
Py_INCREF(o);
|
||||
}
|
||||
m.allocator = &g_numpyAllocator;
|
||||
m.allocator = &GetNumpyAllocator();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -316,9 +316,9 @@ PyObject* pyopencv_from(const cv::Mat& m)
|
||||
if( !m.data )
|
||||
Py_RETURN_NONE;
|
||||
cv::Mat temp, *p = (cv::Mat*)&m;
|
||||
if(!p->u || p->allocator != &g_numpyAllocator)
|
||||
if(!p->u || p->allocator != &GetNumpyAllocator())
|
||||
{
|
||||
temp.allocator = &g_numpyAllocator;
|
||||
temp.allocator = &GetNumpyAllocator();
|
||||
ERRWRAP2(m.copyTo(temp));
|
||||
p = &temp;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include "cv2_numpy.hpp"
|
||||
#include "cv2_util.hpp"
|
||||
|
||||
NumpyAllocator g_numpyAllocator;
|
||||
|
||||
using namespace cv;
|
||||
|
||||
UMatData* NumpyAllocator::allocate(PyObject* o, int dims, const int* sizes, int type, size_t* step) const
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
const cv::MatAllocator* stdAllocator;
|
||||
};
|
||||
|
||||
extern NumpyAllocator g_numpyAllocator;
|
||||
inline NumpyAllocator& GetNumpyAllocator() {static NumpyAllocator gNumpyAllocator;return gNumpyAllocator;}
|
||||
|
||||
//======================================================================================================================
|
||||
|
||||
|
||||
@@ -515,9 +515,9 @@ class CppHeaderParser(object):
|
||||
if rettype == classname or rettype == "~" + classname:
|
||||
rettype, funcname = "", rettype
|
||||
else:
|
||||
if bool(re.match('\w+\s+\(\*\w+\)\s*\(.*\)', decl_str)):
|
||||
if bool(re.match(r'\w+\s+\(\*\w+\)\s*\(.*\)', decl_str)):
|
||||
return [] # function typedef
|
||||
elif bool(re.match('\w+\s+\(\w+::\*\w+\)\s*\(.*\)', decl_str)):
|
||||
elif bool(re.match(r'\w+\s+\(\w+::\*\w+\)\s*\(.*\)', decl_str)):
|
||||
return [] # class method typedef
|
||||
elif bool(re.match('[A-Z_]+', decl_start)):
|
||||
return [] # it seems to be a macro instantiation
|
||||
|
||||
@@ -325,6 +325,7 @@ def _find_argument_index(arguments: Sequence[FunctionNode.Arg],
|
||||
NODES_TO_REFINE = {
|
||||
SymbolName(("cv", ), (), "resize"): make_optional_arg("dsize"),
|
||||
SymbolName(("cv", ), (), "calcHist"): make_optional_arg("mask"),
|
||||
SymbolName(("cv", ), (), "floodFill"): make_optional_arg("mask"),
|
||||
}
|
||||
|
||||
ERROR_CLASS_PROPERTIES = (
|
||||
|
||||
@@ -194,6 +194,13 @@ _PREDEFINED_TYPES = (
|
||||
export_name="ExtractMetaCallback"
|
||||
),
|
||||
AliasTypeNode.class_("LayerId", "DictValue"),
|
||||
AliasTypeNode.dict_("LayerParams",
|
||||
key_type=PrimitiveTypeNode.str_(),
|
||||
value_type=UnionTypeNode("DictValue", items=(
|
||||
PrimitiveTypeNode.int_(),
|
||||
PrimitiveTypeNode.float_(),
|
||||
PrimitiveTypeNode.str_())
|
||||
)),
|
||||
PrimitiveTypeNode.int_("cvflann_flann_distance_t"),
|
||||
PrimitiveTypeNode.int_("flann_flann_distance_t"),
|
||||
PrimitiveTypeNode.int_("cvflann_flann_algorithm_t"),
|
||||
|
||||
@@ -446,7 +446,7 @@ class Arguments(NewOpenCVTests):
|
||||
try_to_convert = partial(self._try_to_convert, cv.utils.dumpFloat)
|
||||
min_float, max_float = get_limits(ctypes.c_float)
|
||||
for convertible in (2, -13, 1.24, np.float32(32.45), float(32), np.double(12.23),
|
||||
np.float32(-12.3), np.float64(3.22), np.float_(-1.5), min_float,
|
||||
np.float32(-12.3), np.float64(3.22), min_float,
|
||||
max_float, np.inf, -np.inf, float('Inf'), -float('Inf'),
|
||||
np.double(np.inf), np.double(-np.inf), np.double(float('Inf')),
|
||||
np.double(-float('Inf'))):
|
||||
@@ -490,7 +490,7 @@ class Arguments(NewOpenCVTests):
|
||||
min_float, max_float = get_limits(ctypes.c_float)
|
||||
min_double, max_double = get_limits(ctypes.c_double)
|
||||
for convertible in (2, -13, 1.24, np.float32(32.45), float(2), np.double(12.23),
|
||||
np.float32(-12.3), np.float64(3.22), np.float_(-1.5), min_float,
|
||||
np.float32(-12.3), np.float64(3.22), min_float,
|
||||
max_float, min_double, max_double, np.inf, -np.inf, float('Inf'),
|
||||
-float('Inf'), np.double(np.inf), np.double(-np.inf),
|
||||
np.double(float('Inf')), np.double(-float('Inf'))):
|
||||
|
||||
Reference in New Issue
Block a user