mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #23691 from dkurt:pycv_float16_fixes
Import and export np.float16 in Python #23691 ### Pull Request Readiness Checklist * Also, fixes `cv::norm` with `NORM_INF` and `CV_16F` resolves https://github.com/opencv/opencv/issues/23687 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:
@@ -753,7 +753,7 @@ double norm( InputArray _src, int normType, InputArray _mask )
|
||||
{
|
||||
int bsz = std::min(total - j, blockSize);
|
||||
hal::cvt16f32f((const float16_t*)ptrs[0], data0, bsz * cn);
|
||||
func((uchar*)data0, ptrs[1], (uchar*)&result.d, bsz, cn);
|
||||
func((uchar*)data0, ptrs[1], (uchar*)&result.f, bsz, cn);
|
||||
ptrs[0] += bsz*esz;
|
||||
if (ptrs[1])
|
||||
ptrs[1] += bsz;
|
||||
@@ -771,9 +771,9 @@ double norm( InputArray _src, int normType, InputArray _mask )
|
||||
|
||||
if( normType == NORM_INF )
|
||||
{
|
||||
if(depth == CV_64F || depth == CV_16F)
|
||||
if(depth == CV_64F)
|
||||
return result.d;
|
||||
else if (depth == CV_32F)
|
||||
else if (depth == CV_32F || depth == CV_16F)
|
||||
return result.f;
|
||||
else
|
||||
return result.i;
|
||||
@@ -1224,7 +1224,7 @@ double norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask
|
||||
int bsz = std::min(total - j, blockSize);
|
||||
hal::cvt16f32f((const float16_t*)ptrs[0], data0, bsz * cn);
|
||||
hal::cvt16f32f((const float16_t*)ptrs[1], data1, bsz * cn);
|
||||
func((uchar*)data0, (uchar*)data1, ptrs[2], (uchar*)&result.d, bsz, cn);
|
||||
func((uchar*)data0, (uchar*)data1, ptrs[2], (uchar*)&result.f, bsz, cn);
|
||||
ptrs[0] += bsz*esz;
|
||||
ptrs[1] += bsz*esz;
|
||||
if (ptrs[2])
|
||||
@@ -1243,9 +1243,9 @@ double norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask
|
||||
|
||||
if( normType == NORM_INF )
|
||||
{
|
||||
if (depth == CV_64F || depth == CV_16F)
|
||||
if (depth == CV_64F)
|
||||
return result.d;
|
||||
else if (depth == CV_32F)
|
||||
else if (depth == CV_32F || depth == CV_16F)
|
||||
return result.f;
|
||||
else
|
||||
return result.u;
|
||||
|
||||
Reference in New Issue
Block a user