mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -1037,6 +1037,14 @@ static void flip(const Mat& src, Mat& dst, int flipcode)
|
||||
}
|
||||
}
|
||||
|
||||
static void flip_inplace(Mat& dst, int flipcode)
|
||||
{
|
||||
Mat m;
|
||||
m.create(dst.size(), dst.type());
|
||||
reference::flip(dst, m, flipcode);
|
||||
memcpy(dst.ptr<uchar>(), m.ptr<uchar>(), dst.total() * dst.elemSize());
|
||||
}
|
||||
|
||||
static void rotate(const Mat& src, Mat& dst, int rotateMode)
|
||||
{
|
||||
Mat tmp;
|
||||
@@ -1103,6 +1111,36 @@ struct FlipOp : public BaseElemWiseOp
|
||||
int flipcode;
|
||||
};
|
||||
|
||||
struct FlipInplaceOp : public BaseElemWiseOp
|
||||
{
|
||||
FlipInplaceOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) { flipcode = 0; }
|
||||
void getRandomSize(RNG& rng, vector<int>& size)
|
||||
{
|
||||
cvtest::randomSize(rng, 2, 2, ARITHM_MAX_SIZE_LOG, size);
|
||||
}
|
||||
void op(const vector<Mat>& src, Mat& dst, const Mat&)
|
||||
{
|
||||
dst.create(src[0].size(), src[0].type());
|
||||
memcpy(dst.ptr<uchar>(), src[0].ptr<uchar>(), src[0].total() * src[0].elemSize());
|
||||
cv::flip(dst, dst, flipcode);
|
||||
}
|
||||
void refop(const vector<Mat>& src, Mat& dst, const Mat&)
|
||||
{
|
||||
dst.create(src[0].size(), src[0].type());
|
||||
memcpy(dst.ptr<uchar>(), src[0].ptr<uchar>(), src[0].total() * src[0].elemSize());
|
||||
reference::flip_inplace(dst, flipcode);
|
||||
}
|
||||
void generateScalars(int, RNG& rng)
|
||||
{
|
||||
flipcode = rng.uniform(0, 3) - 1;
|
||||
}
|
||||
double getMaxErr(int)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int flipcode;
|
||||
};
|
||||
|
||||
struct RotateOp : public BaseElemWiseOp
|
||||
{
|
||||
RotateOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) { rotatecode = 0; }
|
||||
@@ -1789,6 +1827,7 @@ INSTANTIATE_TEST_CASE_P(Core_InRange, ElemWiseTest, ::testing::Values(ElemWiseOp
|
||||
INSTANTIATE_TEST_CASE_P(Core_FiniteMask, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new FiniteMaskOp)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Core_Flip, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new FlipOp)));
|
||||
INSTANTIATE_TEST_CASE_P(Core_FlipInplace, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new FlipInplaceOp)));
|
||||
INSTANTIATE_TEST_CASE_P(Core_Rotate, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new RotateOp)));
|
||||
INSTANTIATE_TEST_CASE_P(Core_Transpose, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new TransposeOp)));
|
||||
INSTANTIATE_TEST_CASE_P(Core_SetIdentity, ElemWiseTest, ::testing::Values(ElemWiseOpPtr(new SetIdentityOp)));
|
||||
|
||||
@@ -1917,6 +1917,33 @@ TEST(Core_SolveCubic, regression_27323)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Core_SolveCubic, regression_27748)
|
||||
{
|
||||
// a is extremely small relative to others (approx 1.8e-19 ratio),
|
||||
// causing instability in standard cubic formula.
|
||||
double a = 1.56041e-17;
|
||||
double b = 84.4504;
|
||||
double c = -96.795;
|
||||
double d = 13.6826;
|
||||
|
||||
Mat coeffs = (Mat_<double>(1, 4) << a, b, c, d);
|
||||
Mat roots;
|
||||
|
||||
int n = solveCubic(coeffs, roots);
|
||||
|
||||
// Expecting quadratic behavior (2 roots)
|
||||
EXPECT_GE(n, 2);
|
||||
|
||||
// Verify roots satisfy the FULL cubic equation
|
||||
for(int i = 0; i < n; i++)
|
||||
{
|
||||
double x = roots.at<double>(i);
|
||||
double val = a*x*x*x + b*x*x + c*x + d;
|
||||
// Check residual is small
|
||||
EXPECT_LE(fabs(val), 1e-6) << "Root " << x << " does not satisfy the equation";
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Core_SolvePoly, regression_5599)
|
||||
{
|
||||
// x^4 - x^2 = 0, roots: 1, -1, 0, 0
|
||||
|
||||
Reference in New Issue
Block a user