1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #18257 from OrestChura:oc/fluid_operator_bitwise_and_scalar

[G-API]: Add Fluid bitwise operations implementation for (GMat, GScalar)

* Added Fluid `bitwise` with `Scalar` + acc.tests
 - simple loop implementation for Fluid used (no `hal`);
   - `Scalar` is casted to `int` in the beginning
 - tests just modified to work with `Scalar`
 - expected output in operators' tests fixed (operators can't change Mat's depth)
 - `float` `Scalar` `RNG` added, `RNG` reworked (`time` is used now), initialization of test fixtures reworked
   - if input or output is `float` Scalar is initialized by `float`
 - some problems with Fluid/OCV floating-point comparison difference stashed by `AbsSimilarPoints()` usage, FIXME added
 - divide-by-zero is now fixed differently and everywhere

* - Added perf_tests for bitwise_Scalar operations
 - due to errors of Fluid floating-point comparison operations, added support of different validation in Cmp perf_tests; added FIXME

 - reworked integral initialization of Scalar

* Addressing comments
 - NULL -> nullptr
 - Scalar convertion moved to the function
 - avoid -> avoiding

* Addressing comments

* CV_assert -> GAPI_assert

* Addressed DM comments
 - refactored convertScalarForBitwise()
 - removed unnecessary braces for switch

* Changed the operators tests
 - switch via `enum` implemented
 - infrastructure for that refactored
This commit is contained in:
Orest Chura
2020-09-18 16:44:47 +03:00
committed by GitHub
parent 7163781639
commit d1cdef596c
17 changed files with 606 additions and 284 deletions
@@ -21,24 +21,34 @@ INSTANTIATE_TEST_CASE_P(MathOperatorTestFluid, MathOperatorMatMatTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
Values(-1),
Values(CORE_FLUID),
Values(AbsExact().to_compare_obj()),
Values( opPlusM, opMinusM, opDivM,
opGreater, opLess, opGreaterEq, opLessEq, opEq, opNotEq)));
Values( ADD, SUB, DIV,
GT, LT, GE, LE, EQ, NE)));
//FIXME: Some Mat/Scalar Fluid kernels are not there yet!
INSTANTIATE_TEST_CASE_P(DISABLED_MathOperatorTestFluid, MathOperatorMatScalarTest,
INSTANTIATE_TEST_CASE_P(MathOperatorArithmeticTestFluid, MathOperatorMatScalarTest,
Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
Values(-1),
Values(CORE_FLUID),
Values(AbsExact().to_compare_obj()),
Values( opPlus, opPlusR, opMinus, opMinusR, opMul, opMulR, // FIXIT avoid division by values near zero: opDiv, opDivR,
opGT, opLT, opGE, opLE, opEQ, opNE,
opGTR, opLTR, opGER, opLER, opEQR, opNER)));
Values( ADD, SUB, MUL, DIV,
ADDR, SUBR, MULR, DIVR)));
// FIXME: solve comparison error
INSTANTIATE_TEST_CASE_P(MathOperatorCompareTestFluid, MathOperatorMatScalarTest,
Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
Values(CORE_FLUID),
Values(AbsSimilarPoints(1, 0.01).to_compare_obj()),
Values( GT, LT, GE, LE, EQ, NE,
GTR, LTR, GER, LER, EQR, NER)));
INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestFluid, MathOperatorMatMatTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
@@ -48,10 +58,9 @@ INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestFluid, MathOperatorMatMatTest,
Values(-1),
Values(CORE_FLUID),
Values(AbsExact().to_compare_obj()),
Values( opAnd, opOr, opXor )));
Values( AND, OR, XOR )));
//FIXME: Some Mat/Scalar Fluid kernels are not there yet!
INSTANTIATE_TEST_CASE_P(DISABLED_BitwiseOperatorTestFluid, MathOperatorMatScalarTest,
INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestFluid, MathOperatorMatScalarTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
@@ -59,7 +68,8 @@ INSTANTIATE_TEST_CASE_P(DISABLED_BitwiseOperatorTestFluid, MathOperatorMatScalar
Values(-1),
Values(CORE_FLUID),
Values(AbsExact().to_compare_obj()),
Values( opAND, opOR, opXOR, opANDR, opORR, opXORR )));
Values( AND, OR, XOR,
ANDR, ORR, XORR )));
INSTANTIATE_TEST_CASE_P(BitwiseNotOperatorTestFluid, NotOperatorTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),