mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Extended several core functions to support new types (#24962)
* started adding support for new types (16f, 16bf, 32u, 64u, 64s) to arithmetic functions * fixed several tests; refactored and extended sum(), extended inRange(). * extended countNonZero(), mean(), meanStdDev(), minMaxIdx(), norm() and sum() to support new types (F16, BF16, U32, U64, S64) * put missing CV_DEPTH_MAX to some function dispatcher tables * extended findnonzero, hasnonzero with the new types support * extended mixChannels() to support new types * minor fix * fixed a few compile errors on Linux and a few failures in core tests * fixed a few more warnings and test failures * trying to fix the remaining warnings and test failures. The test `MulTestGPU.MathOpTest` was disabled - not clear whether to set tolerance - it's not bit-exact operation, as possibly assumed by the test, due to the use of scale and possibly limited accuracy of the intermediate floating-point calculations. * found that in the current snapshot G-API produces incorrect results in Mul, Div and AddWeighted (at least when using OpenCL on Windows x64 or MacOS x64). Disabled the respective tests.
This commit is contained in:
@@ -161,13 +161,11 @@ void findNonZero(InputArray _src, OutputArray _idx)
|
||||
AutoBuffer<int> buf_(cols + 1);
|
||||
int* buf = buf_.data();
|
||||
|
||||
CV_Assert( depth < CV_16F );
|
||||
|
||||
for( int i = 0; i < rows; i++ )
|
||||
{
|
||||
int j, k = 0;
|
||||
const uchar* ptr8 = src.ptr(i);
|
||||
if( depth == CV_8U || depth == CV_8S )
|
||||
if( depth == CV_8U || depth == CV_8S || depth == CV_Bool )
|
||||
{
|
||||
for( j = 0; j < cols; j++ )
|
||||
if( ptr8[j] != 0 ) buf[k++] = j;
|
||||
@@ -178,23 +176,35 @@ void findNonZero(InputArray _src, OutputArray _idx)
|
||||
for( j = 0; j < cols; j++ )
|
||||
if( ptr16[j] != 0 ) buf[k++] = j;
|
||||
}
|
||||
else if( depth == CV_32S )
|
||||
else if( depth == CV_32S || depth == CV_32U )
|
||||
{
|
||||
const int* ptr32s = (const int*)ptr8;
|
||||
for( j = 0; j < cols; j++ )
|
||||
if( ptr32s[j] != 0 ) buf[k++] = j;
|
||||
}
|
||||
else if( depth == CV_64S || depth == CV_64U )
|
||||
{
|
||||
const int64* ptr64s = (const int64*)ptr8;
|
||||
for( j = 0; j < cols; j++ )
|
||||
if( ptr64s[j] != 0 ) buf[k++] = j;
|
||||
}
|
||||
else if( depth == CV_32F )
|
||||
{
|
||||
const float* ptr32f = (const float*)ptr8;
|
||||
const int* ptr32s = (const int*)ptr8;
|
||||
for( j = 0; j < cols; j++ )
|
||||
if( ptr32f[j] != 0 ) buf[k++] = j;
|
||||
if( (ptr32s[j]<<1) != 0 ) buf[k++] = j;
|
||||
}
|
||||
else if( depth == CV_16F || depth == CV_16BF )
|
||||
{
|
||||
const ushort* ptr16 = (const ushort*)ptr8;
|
||||
for( j = 0; j < cols; j++ )
|
||||
if( (ptr16[j]<<1) != 0 ) buf[k++] = j;
|
||||
}
|
||||
else
|
||||
{
|
||||
const double* ptr64f = (const double*)ptr8;
|
||||
const int64* ptr64s = (const int64*)ptr8;
|
||||
for( j = 0; j < cols; j++ )
|
||||
if( ptr64f[j] != 0 ) buf[k++] = j;
|
||||
if( (ptr64s[j]<<1) != 0 ) buf[k++] = j;
|
||||
}
|
||||
|
||||
if( k > 0 )
|
||||
|
||||
Reference in New Issue
Block a user