1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-28 14:53:03 +04:00

Merge pull request #27779 from dkurt:dlpack_5.x_types

Add 5.x types for DLPack. Keep uint32/int64/uint64 data type for conversion to Numpy. More types support for GpuMat::convertTo #27779

### Pull Request Readiness Checklist

**Merge with contrib**: https://github.com/opencv/opencv_contrib/pull/4000

related: https://github.com/opencv/opencv/pull/27581

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Dmitry Kurtaev
2025-09-25 10:14:46 +03:00
committed by GitHub
parent 9d232fe7f2
commit 4159c0ad98
7 changed files with 144 additions and 24 deletions
+3 -2
View File
@@ -36,8 +36,9 @@ UMatData* NumpyAllocator::allocate(int dims0, const int* sizes, int type, void*
const int f = (int)(sizeof(size_t)/8);
int typenum = depth == CV_8U ? NPY_UBYTE : depth == CV_8S ? NPY_BYTE :
depth == CV_16U ? NPY_USHORT : depth == CV_16S ? NPY_SHORT :
depth == CV_32S ? NPY_INT : depth == CV_32F ? NPY_FLOAT :
depth == CV_64F ? NPY_DOUBLE : depth == CV_16F ? NPY_HALF : depth == CV_Bool ? NPY_BOOL : f*NPY_ULONGLONG + (f^1)*NPY_UINT;
depth == CV_32U ? NPY_UINT32 : depth == CV_32S ? NPY_INT32 : depth == CV_64S ? NPY_INT64 :
depth == CV_32F ? NPY_FLOAT : depth == CV_64F ? NPY_DOUBLE : depth == CV_16F ? NPY_HALF :
depth == CV_Bool ? NPY_BOOL : f*NPY_ULONGLONG + (f^1)*NPY_UINT;
int i, dims = dims0;
cv::AutoBuffer<npy_intp> _sizes(dims + 1);
for( i = 0; i < dims; i++ )