mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -1512,16 +1512,8 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots )
|
||||
}
|
||||
else if( d == 0 )
|
||||
{
|
||||
if(R >= 0)
|
||||
{
|
||||
x0 = -2*pow(R, 1./3) - a1/3;
|
||||
x1 = pow(R, 1./3) - a1/3;
|
||||
}
|
||||
else
|
||||
{
|
||||
x0 = 2*pow(-R, 1./3) - a1/3;
|
||||
x1 = -pow(-R, 1./3) - a1/3;
|
||||
}
|
||||
x0 = -2*std::cbrt(R) - a1/3;
|
||||
x1 = std::cbrt(R) - a1/3;
|
||||
x2 = 0;
|
||||
n = x0 == x1 ? 1 : 2;
|
||||
x1 = x0 == x1 ? 0 : x1;
|
||||
@@ -1530,7 +1522,7 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots )
|
||||
{
|
||||
double e;
|
||||
d = sqrt(-d);
|
||||
e = pow(d + fabs(R), 1./3);
|
||||
e = std::cbrt(d + fabs(R));
|
||||
if( R > 0 )
|
||||
e = -e;
|
||||
x0 = (e + Q / e) - a1 * (1./3);
|
||||
@@ -1645,15 +1637,14 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
|
||||
if( num_same_root % 2 != 0){
|
||||
Mat cube_coefs(4, 1, CV_64FC1);
|
||||
Mat cube_roots(3, 1, CV_64FC2);
|
||||
cube_coefs.at<double>(3) = -(pow(old_num_re, 3));
|
||||
cube_coefs.at<double>(2) = -(15*pow(old_num_re, 2) + 27*pow(old_num_im, 2));
|
||||
cube_coefs.at<double>(3) = -(std::pow(old_num_re, 3));
|
||||
cube_coefs.at<double>(2) = -(15*std::pow(old_num_re, 2) + 27*std::pow(old_num_im, 2));
|
||||
cube_coefs.at<double>(1) = -48*old_num_re;
|
||||
cube_coefs.at<double>(0) = 64;
|
||||
solveCubic(cube_coefs, cube_roots);
|
||||
|
||||
if(cube_roots.at<double>(0) >= 0) num.re = pow(cube_roots.at<double>(0), 1./3);
|
||||
else num.re = -pow(-cube_roots.at<double>(0), 1./3);
|
||||
num.im = sqrt(pow(num.re, 2) / 3 - old_num_re / (3*num.re));
|
||||
num.re = std::cbrt(cube_roots.at<double>(0));
|
||||
num.im = sqrt(std::pow(num.re, 2) / 3 - old_num_re / (3*num.re));
|
||||
}
|
||||
}
|
||||
roots[i] = p - num;
|
||||
|
||||
@@ -989,7 +989,7 @@ void Mat::release()
|
||||
datastart = dataend = datalimit = data = 0;
|
||||
for(int i = 0; i < dims; i++)
|
||||
size.p[i] = 0;
|
||||
flags = MAGIC_VAL;
|
||||
flags = (flags & CV_MAT_TYPE_MASK) | MAGIC_VAL;
|
||||
dims = rows = cols = 0;
|
||||
size.clear();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ DECLARE_CV_PAUSE
|
||||
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("" ::: "memory"); } } while (0)
|
||||
# elif defined __GNUC__ && defined __mips__ && __mips_isa_rev >= 2
|
||||
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("pause" ::: "memory"); } } while (0)
|
||||
# elif defined __APPLE__ && defined __POWERPC__
|
||||
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("or r27,r27,r27" ::: "memory"); } } while (0)
|
||||
# elif defined __GNUC__ && defined __PPC64__
|
||||
# define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("or 27,27,27" ::: "memory"); } } while (0)
|
||||
# elif defined __GNUC__ && defined __riscv
|
||||
|
||||
@@ -1340,8 +1340,7 @@ void error( const Exception& exc )
|
||||
|
||||
if(breakOnError)
|
||||
{
|
||||
static volatile int* p = 0;
|
||||
*p = 0;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
throw exc;
|
||||
|
||||
@@ -176,14 +176,18 @@ void RotatedRect::points(Point2f pt[]) const
|
||||
float b = (float)cos(_angle)*0.5f;
|
||||
float a = (float)sin(_angle)*0.5f;
|
||||
|
||||
pt[0].x = center.x - a*size.height - b*size.width;
|
||||
pt[0].y = center.y + b*size.height - a*size.width;
|
||||
pt[1].x = center.x + a*size.height - b*size.width;
|
||||
pt[1].y = center.y - b*size.height - a*size.width;
|
||||
pt[2].x = 2*center.x - pt[0].x;
|
||||
pt[2].y = 2*center.y - pt[0].y;
|
||||
pt[3].x = 2*center.x - pt[1].x;
|
||||
pt[3].y = 2*center.y - pt[1].y;
|
||||
const float ah = a*size.height;
|
||||
const float aw = a*size.width;
|
||||
const float bh = b*size.height;
|
||||
const float bw = b*size.width;
|
||||
pt[0].x = center.x - ah - bw;
|
||||
pt[0].y = center.y + bh - aw;
|
||||
pt[1].x = center.x + ah - bw;
|
||||
pt[1].y = center.y - bh - aw;
|
||||
pt[2].x = center.x + ah + bw;
|
||||
pt[2].y = center.y - bh + aw;
|
||||
pt[3].x = center.x - ah + bw;
|
||||
pt[3].y = center.y + bh + aw;
|
||||
}
|
||||
|
||||
void RotatedRect::points(std::vector<Point2f>& pts) const {
|
||||
|
||||
Reference in New Issue
Block a user