mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
CV_ENUM(RetrMode, RETR_EXTERNAL, RETR_LIST, RETR_CCOMP, RETR_TREE)
|
||||
CV_ENUM(ApproxMode, CHAIN_APPROX_NONE, CHAIN_APPROX_SIMPLE, CHAIN_APPROX_TC89_L1, CHAIN_APPROX_TC89_KCOS)
|
||||
@@ -84,4 +84,4 @@ PERF_TEST_P(TestFindContoursFF, findContours,
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} } // namespace
|
||||
|
||||
@@ -175,7 +175,6 @@ void GMM::addSample( int ci, const Vec3d color )
|
||||
|
||||
void GMM::endLearning()
|
||||
{
|
||||
CV_Assert(totalSampleCount > 0);
|
||||
for( int ci = 0; ci < componentsCount; ci++ )
|
||||
{
|
||||
int n = sampleCounts[ci];
|
||||
@@ -183,6 +182,7 @@ void GMM::endLearning()
|
||||
coefs[ci] = 0;
|
||||
else
|
||||
{
|
||||
CV_Assert(totalSampleCount > 0);
|
||||
double inv_n = 1.0 / n;
|
||||
coefs[ci] = (double)n/totalSampleCount;
|
||||
|
||||
|
||||
@@ -74,30 +74,27 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
typedef ushort HT;
|
||||
|
||||
/**
|
||||
* This structure represents a two-tier histogram. The first tier (known as the
|
||||
* "coarse" level) is 4 bit wide and the second tier (known as the "fine" level)
|
||||
* is 8 bit wide. Pixels inserted in the fine level also get inserted into the
|
||||
* coarse bucket designated by the 4 MSBs of the fine bucket value.
|
||||
*
|
||||
* The structure is aligned on 16 bits, which is a prerequisite for SIMD
|
||||
* instructions. Each bucket is 16 bit wide, which means that extra care must be
|
||||
* taken to prevent overflow.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
HT coarse[16];
|
||||
HT fine[16][16];
|
||||
} Histogram;
|
||||
|
||||
static void
|
||||
medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
|
||||
{
|
||||
typedef ushort HT;
|
||||
|
||||
/**
|
||||
* This structure represents a two-tier histogram. The first tier (known as the
|
||||
* "coarse" level) is 4 bit wide and the second tier (known as the "fine" level)
|
||||
* is 8 bit wide. Pixels inserted in the fine level also get inserted into the
|
||||
* coarse bucket designated by the 4 MSBs of the fine bucket value.
|
||||
*
|
||||
* The structure is aligned on 16 bits, which is a prerequisite for SIMD
|
||||
* instructions. Each bucket is 16 bit wide, which means that extra care must be
|
||||
* taken to prevent overflow.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
HT coarse[16];
|
||||
HT fine[16][16];
|
||||
} Histogram;
|
||||
|
||||
/**
|
||||
* HOP is short for Histogram OPeration. This macro makes an operation \a op on
|
||||
* histogram \a h for pixel value \a x. It takes care of handling both levels.
|
||||
@@ -136,7 +133,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
|
||||
for( c = 0; c < cn; c++ )
|
||||
{
|
||||
for( j = 0; j < n; j++ )
|
||||
COP( c, j, src[cn*j+c], += (cv::HT)(r+2) );
|
||||
COP( c, j, src[cn*j+c], += (HT)(r+2) );
|
||||
|
||||
for( i = 1; i < r; i++ )
|
||||
{
|
||||
@@ -172,7 +169,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
|
||||
v_store(H[c].fine[k] + 8, v_mul_wrap(v_load(h_fine + 16 * n*(16 * c + k) + 8), v_setall_u16((ushort)(2 * r + 1))) + v_load(H[c].fine[k] + 8));
|
||||
#else
|
||||
for (int ind = 0; ind < 16; ++ind)
|
||||
H[c].fine[k][ind] += (2 * r + 1) * h_fine[16 * n*(16 * c + k) + ind];
|
||||
H[c].fine[k][ind] = (HT)(H[c].fine[k][ind] + (2 * r + 1) * h_fine[16 * n*(16 * c + k) + ind]);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -245,7 +242,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
|
||||
memset(&H[c].fine[k], 0, 16 * sizeof(HT));
|
||||
#endif
|
||||
px = h_fine + 16 * (n*(16 * c + k) + j - r);
|
||||
for (luc[c][k] = cv::HT(j - r); luc[c][k] < MIN(j + r + 1, n); ++luc[c][k], px += 16)
|
||||
for (luc[c][k] = HT(j - r); luc[c][k] < MIN(j + r + 1, n); ++luc[c][k], px += 16)
|
||||
{
|
||||
#if CV_SIMD256
|
||||
v_fine += v256_load(px);
|
||||
@@ -268,7 +265,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
|
||||
v_fineh += v_mul_wrap(v_load(px + 8), v_setall_u16((ushort)(j + r + 1 - n)));
|
||||
#else
|
||||
for (int ind = 0; ind < 16; ++ind)
|
||||
H[c].fine[k][ind] += (j + r + 1 - n) * px[ind];
|
||||
H[c].fine[k][ind] = (HT)(H[c].fine[k][ind] + (j + r + 1 - n) * px[ind]);
|
||||
#endif
|
||||
luc[c][k] = (HT)(j+r+1);
|
||||
}
|
||||
@@ -479,6 +476,8 @@ medianBlur_8u_Om( const Mat& _src, Mat& _dst, int m )
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
struct MinMax8u
|
||||
{
|
||||
typedef uchar value_type;
|
||||
|
||||
@@ -3782,9 +3782,9 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||
Size ssize = _src.size();
|
||||
|
||||
CV_Assert( !ssize.empty() );
|
||||
CV_Assert( !dsize.empty() || (inv_scale_x > 0 && inv_scale_y > 0) );
|
||||
if( dsize.empty() )
|
||||
{
|
||||
CV_Assert(inv_scale_x > 0); CV_Assert(inv_scale_y > 0);
|
||||
dsize = Size(saturate_cast<int>(ssize.width*inv_scale_x),
|
||||
saturate_cast<int>(ssize.height*inv_scale_y));
|
||||
CV_Assert( !dsize.empty() );
|
||||
@@ -3793,6 +3793,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||
{
|
||||
inv_scale_x = (double)dsize.width/ssize.width;
|
||||
inv_scale_y = (double)dsize.height/ssize.height;
|
||||
CV_Assert(inv_scale_x > 0); CV_Assert(inv_scale_y > 0);
|
||||
}
|
||||
|
||||
if (interpolation == INTER_LINEAR_EXACT && (_src.depth() == CV_32F || _src.depth() == CV_64F))
|
||||
|
||||
@@ -45,9 +45,9 @@ TEST(Resize_Bitexact, Linear8U)
|
||||
{ CV_8UC4, Size( 4, 3) },
|
||||
{ CV_8UC1, Size( 342, 384) }, // 1/3 1/2
|
||||
{ CV_8UC1, Size( 342, 256) }, // 1/3 1/3
|
||||
{ CV_8UC1, Size( 342, 256) },
|
||||
{ CV_8UC1, Size( 342, 256) },
|
||||
{ CV_8UC1, Size( 342, 256) },
|
||||
{ CV_8UC2, Size( 342, 256) },
|
||||
{ CV_8UC3, Size( 342, 256) },
|
||||
{ CV_8UC4, Size( 342, 256) },
|
||||
{ CV_8UC1, Size( 512, 256) }, // 1/2 1/3
|
||||
{ CV_8UC1, Size( 146, 110) }, // 1/7 1/7
|
||||
{ CV_8UC3, Size( 146, 110) },
|
||||
@@ -83,13 +83,13 @@ TEST(Resize_Bitexact, Linear8U)
|
||||
softdouble scale_y = softdouble::one() / softdouble(inv_scale_y);
|
||||
|
||||
Mat src(rows, cols, type), refdst(drows, dcols, type), dst;
|
||||
RNG rnd(0x123456789abcdefULL);
|
||||
for (int j = 0; j < rows; j++)
|
||||
{
|
||||
uint8_t* line = src.ptr(j);
|
||||
for (int i = 0; i < cols; i++)
|
||||
for (int c = 0; c < cn; c++)
|
||||
{
|
||||
RNG rnd(0x123456789abcdefULL);
|
||||
double val = j < rows / 2 ? ( i < cols / 2 ? ((sin((i + 1)*CV_PI / 256.)*sin((j + 1)*CV_PI / 256.)*sin((cn + 4)*CV_PI / 8.) + 1.)*128.) :
|
||||
(((i / 128 + j / 128) % 2) * 250 + (j / 128) % 2) ) :
|
||||
( i < cols / 2 ? ((i / 128) * (85 - j / 256 * 40) * ((j / 128) % 2) + (7 - i / 128) * (85 - j / 256 * 40) * ((j / 128 + 1) % 2)) :
|
||||
|
||||
Reference in New Issue
Block a user