1
0
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:
Alexander Smorkalov
2023-07-27 18:38:25 +03:00
151 changed files with 5199 additions and 1111 deletions
+18 -18
View File
@@ -46,44 +46,44 @@ mixChannels_( const T** src, const int* sdelta,
}
static void mixChannels8u( const uchar** src, const int* sdelta,
uchar** dst, const int* ddelta,
static void mixChannels8u( const void** src, const int* sdelta,
void** dst, const int* ddelta,
int len, int npairs )
{
mixChannels_(src, sdelta, dst, ddelta, len, npairs);
mixChannels_((const uchar**)src, sdelta, (uchar**)dst, ddelta, len, npairs);
}
static void mixChannels16u( const ushort** src, const int* sdelta,
ushort** dst, const int* ddelta,
static void mixChannels16u( const void** src, const int* sdelta,
void** dst, const int* ddelta,
int len, int npairs )
{
mixChannels_(src, sdelta, dst, ddelta, len, npairs);
mixChannels_((const ushort**)src, sdelta, (ushort**)dst, ddelta, len, npairs);
}
static void mixChannels32s( const int** src, const int* sdelta,
int** dst, const int* ddelta,
static void mixChannels32s( const void** src, const int* sdelta,
void** dst, const int* ddelta,
int len, int npairs )
{
mixChannels_(src, sdelta, dst, ddelta, len, npairs);
mixChannels_((const int**)src, sdelta, (int**)dst, ddelta, len, npairs);
}
static void mixChannels64s( const int64** src, const int* sdelta,
int64** dst, const int* ddelta,
static void mixChannels64s( const void** src, const int* sdelta,
void** dst, const int* ddelta,
int len, int npairs )
{
mixChannels_(src, sdelta, dst, ddelta, len, npairs);
mixChannels_((const int64**)src, sdelta, (int64**)dst, ddelta, len, npairs);
}
typedef void (*MixChannelsFunc)( const uchar** src, const int* sdelta,
uchar** dst, const int* ddelta, int len, int npairs );
typedef void (*MixChannelsFunc)( const void** src, const int* sdelta,
void** dst, const int* ddelta, int len, int npairs );
static MixChannelsFunc getMixchFunc(int depth)
{
static MixChannelsFunc mixchTab[] =
{
(MixChannelsFunc)mixChannels8u, (MixChannelsFunc)mixChannels8u, (MixChannelsFunc)mixChannels16u,
(MixChannelsFunc)mixChannels16u, (MixChannelsFunc)mixChannels32s, (MixChannelsFunc)mixChannels32s,
(MixChannelsFunc)mixChannels64s, 0
mixChannels8u, mixChannels8u, mixChannels16u,
mixChannels16u, mixChannels32s, mixChannels32s,
mixChannels64s, 0
};
return mixchTab[depth];
@@ -158,7 +158,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons
for( int t = 0; t < total; t += blocksize )
{
int bsz = std::min(total - t, blocksize);
func( srcs, sdelta, dsts, ddelta, bsz, (int)npairs );
func( (const void**)srcs, sdelta, (void **)dsts, ddelta, bsz, (int)npairs );
if( t + blocksize < total )
for( k = 0; k < npairs; k++ )
+18 -2
View File
@@ -90,7 +90,7 @@ static void swap_columns(Mat_<double>& A,int col1,int col2);
#define SWAP(type,a,b) {type tmp=(a);(a)=(b);(b)=tmp;}
//return codes:-2 (no_sol - unbdd),-1(no_sol - unfsbl), 0(single_sol), 1(multiple_sol=>least_l2_norm)
int solveLP(InputArray Func_, InputArray Constr_, OutputArray z_)
int solveLP(InputArray Func_, InputArray Constr_, OutputArray z_, double constr_eps)
{
dprintf(("call to solveLP\n"));
@@ -143,9 +143,25 @@ int solveLP(InputArray Func_, InputArray Constr_, OutputArray z_)
}
z.copyTo(z_);
//check constraints feasibility
Mat prod = Constr(Rect(0, 0, Constr.cols - 1, Constr.rows)) * z;
Mat constr_check = Constr.col(Constr.cols - 1) - prod;
double min_value = 0.0;
minMaxIdx(constr_check, &min_value);
if (min_value < -constr_eps)
{
return SOLVELP_LOST;
}
return res;
}
int solveLP(InputArray Func, InputArray Constr, OutputArray z)
{
return solveLP(Func, Constr, z, 1e-12);
}
static int initialize_simplex(Mat_<double>& c, Mat_<double>& b,double& v,vector<int>& N,vector<int>& B,vector<unsigned int>& indexToRow){
N.resize(c.cols);
N[0]=0;
@@ -255,7 +271,7 @@ static int initialize_simplex(Mat_<double>& c, Mat_<double>& b,double& v,vector<
static int inner_simplex(Mat_<double>& c, Mat_<double>& b,double& v,vector<int>& N,vector<int>& B,vector<unsigned int>& indexToRow){
for(;;){
static MatIterator_<double> pos_ptr;
MatIterator_<double> pos_ptr;
int e=-1,pos_ctr=0,min_var=INT_MAX;
bool all_nonzero=true;
for(pos_ptr=c.begin();pos_ptr!=c.end();pos_ptr++,pos_ctr++){
+4 -4
View File
@@ -603,10 +603,10 @@ flipVert( const uchar* src0, size_t sstep, uchar* dst0, size_t dstep, Size size,
{
for (; i <= size.width - CV_SIMD_WIDTH; i += CV_SIMD_WIDTH)
{
v_int32 t0 = vx_load((int*)(src0 + i));
v_int32 t1 = vx_load((int*)(src1 + i));
v_store((int*)(dst0 + i), t1);
v_store((int*)(dst1 + i), t0);
v_int32 t0 = v_reinterpret_as_s32(vx_load(src0 + i));
v_int32 t1 = v_reinterpret_as_s32(vx_load(src1 + i));
v_store(dst0 + i, v_reinterpret_as_u8(t1));
v_store(dst1 + i, v_reinterpret_as_u8(t0));
}
}
#if CV_STRONG_ALIGNMENT
+33 -33
View File
@@ -24,7 +24,7 @@ struct SumSqr_SIMD
}
};
#if CV_SIMD
#if CV_SIMD || CV_SIMD_SCALABLE
template <>
struct SumSqr_SIMD<uchar, int, int>
@@ -39,37 +39,37 @@ struct SumSqr_SIMD<uchar, int, int>
v_int32 v_sum = vx_setzero_s32();
v_int32 v_sqsum = vx_setzero_s32();
const int len0 = len & -v_uint8::nlanes;
const int len0 = len & -VTraits<v_uint8>::vlanes();
while(x < len0)
{
const int len_tmp = min(x + 256*v_uint16::nlanes, len0);
const int len_tmp = min(x + 256*VTraits<v_uint16>::vlanes(), len0);
v_uint16 v_sum16 = vx_setzero_u16();
for ( ; x < len_tmp; x += v_uint8::nlanes)
for ( ; x < len_tmp; x += VTraits<v_uint8>::vlanes())
{
v_uint16 v_src0 = vx_load_expand(src0 + x);
v_uint16 v_src1 = vx_load_expand(src0 + x + v_uint16::nlanes);
v_sum16 += v_src0 + v_src1;
v_uint16 v_src1 = vx_load_expand(src0 + x + VTraits<v_uint16>::vlanes());
v_sum16 = v_add(v_sum16, v_add(v_src0, v_src1));
v_int16 v_tmp0, v_tmp1;
v_zip(v_reinterpret_as_s16(v_src0), v_reinterpret_as_s16(v_src1), v_tmp0, v_tmp1);
v_sqsum += v_dotprod(v_tmp0, v_tmp0) + v_dotprod(v_tmp1, v_tmp1);
v_sqsum = v_add(v_sqsum, v_add(v_dotprod(v_tmp0, v_tmp0), v_dotprod(v_tmp1, v_tmp1)));
}
v_uint32 v_half0, v_half1;
v_expand(v_sum16, v_half0, v_half1);
v_sum += v_reinterpret_as_s32(v_half0 + v_half1);
v_sum = v_add(v_sum, v_reinterpret_as_s32(v_add(v_half0, v_half1)));
}
if (x <= len - v_uint16::nlanes)
if (x <= len - VTraits<v_uint16>::vlanes())
{
v_uint16 v_src = vx_load_expand(src0 + x);
v_uint16 v_half = v_combine_high(v_src, v_src);
v_uint32 v_tmp0, v_tmp1;
v_expand(v_src + v_half, v_tmp0, v_tmp1);
v_sum += v_reinterpret_as_s32(v_tmp0);
v_expand(v_add(v_src, v_half), v_tmp0, v_tmp1);
v_sum = v_add(v_sum, v_reinterpret_as_s32(v_tmp0));
v_int16 v_tmp2, v_tmp3;
v_zip(v_reinterpret_as_s16(v_src), v_reinterpret_as_s16(v_half), v_tmp2, v_tmp3);
v_sqsum += v_dotprod(v_tmp2, v_tmp2);
x += v_uint16::nlanes;
v_sqsum = v_add(v_sqsum, v_dotprod(v_tmp2, v_tmp2));
x += VTraits<v_uint16>::vlanes();
}
if (cn == 1)
@@ -79,13 +79,13 @@ struct SumSqr_SIMD<uchar, int, int>
}
else
{
int CV_DECL_ALIGNED(CV_SIMD_WIDTH) ar[2 * v_int32::nlanes];
int CV_DECL_ALIGNED(CV_SIMD_WIDTH) ar[2 * VTraits<v_int32>::max_nlanes];
v_store(ar, v_sum);
v_store(ar + v_int32::nlanes, v_sqsum);
for (int i = 0; i < v_int32::nlanes; ++i)
v_store(ar + VTraits<v_int32>::vlanes(), v_sqsum);
for (int i = 0; i < VTraits<v_int32>::vlanes(); ++i)
{
sum[i % cn] += ar[i];
sqsum[i % cn] += ar[v_int32::nlanes + i];
sqsum[i % cn] += ar[VTraits<v_int32>::vlanes() + i];
}
}
v_cleanup();
@@ -106,37 +106,37 @@ struct SumSqr_SIMD<schar, int, int>
v_int32 v_sum = vx_setzero_s32();
v_int32 v_sqsum = vx_setzero_s32();
const int len0 = len & -v_int8::nlanes;
const int len0 = len & -VTraits<v_int8>::vlanes();
while (x < len0)
{
const int len_tmp = min(x + 256 * v_int16::nlanes, len0);
const int len_tmp = min(x + 256 * VTraits<v_int16>::vlanes(), len0);
v_int16 v_sum16 = vx_setzero_s16();
for (; x < len_tmp; x += v_int8::nlanes)
for (; x < len_tmp; x += VTraits<v_int8>::vlanes())
{
v_int16 v_src0 = vx_load_expand(src0 + x);
v_int16 v_src1 = vx_load_expand(src0 + x + v_int16::nlanes);
v_sum16 += v_src0 + v_src1;
v_int16 v_src1 = vx_load_expand(src0 + x + VTraits<v_int16>::vlanes());
v_sum16 = v_add(v_sum16, v_add(v_src0, v_src1));
v_int16 v_tmp0, v_tmp1;
v_zip(v_src0, v_src1, v_tmp0, v_tmp1);
v_sqsum += v_dotprod(v_tmp0, v_tmp0) + v_dotprod(v_tmp1, v_tmp1);
v_sqsum = v_add(v_sqsum, v_add(v_dotprod(v_tmp0, v_tmp0), v_dotprod(v_tmp1, v_tmp1)));
}
v_int32 v_half0, v_half1;
v_expand(v_sum16, v_half0, v_half1);
v_sum += v_half0 + v_half1;
v_sum = v_add(v_sum, v_add(v_half0, v_half1));
}
if (x <= len - v_int16::nlanes)
if (x <= len - VTraits<v_int16>::vlanes())
{
v_int16 v_src = vx_load_expand(src0 + x);
v_int16 v_half = v_combine_high(v_src, v_src);
v_int32 v_tmp0, v_tmp1;
v_expand(v_src + v_half, v_tmp0, v_tmp1);
v_sum += v_tmp0;
v_expand(v_add(v_src, v_half), v_tmp0, v_tmp1);
v_sum = v_add(v_sum, v_tmp0);
v_int16 v_tmp2, v_tmp3;
v_zip(v_src, v_half, v_tmp2, v_tmp3);
v_sqsum += v_dotprod(v_tmp2, v_tmp2);
x += v_int16::nlanes;
v_sqsum = v_add(v_sqsum, v_dotprod(v_tmp2, v_tmp2));
x += VTraits<v_int16>::vlanes();
}
if (cn == 1)
@@ -146,13 +146,13 @@ struct SumSqr_SIMD<schar, int, int>
}
else
{
int CV_DECL_ALIGNED(CV_SIMD_WIDTH) ar[2 * v_int32::nlanes];
int CV_DECL_ALIGNED(CV_SIMD_WIDTH) ar[2 * VTraits<v_int32>::max_nlanes];
v_store(ar, v_sum);
v_store(ar + v_int32::nlanes, v_sqsum);
for (int i = 0; i < v_int32::nlanes; ++i)
v_store(ar + VTraits<v_int32>::vlanes(), v_sqsum);
for (int i = 0; i < VTraits<v_int32>::vlanes(); ++i)
{
sum[i % cn] += ar[i];
sqsum[i % cn] += ar[v_int32::nlanes + i];
sqsum[i % cn] += ar[VTraits<v_int32>::vlanes() + i];
}
}
v_cleanup();
-1
View File
@@ -51,7 +51,6 @@
#include <set>
#include <string>
#include <sstream>
#include <iostream> // std::cerr
#include <fstream>
#if !(defined _MSC_VER) || (defined _MSC_VER && _MSC_VER > 1700)
#include <inttypes.h>
+2
View File
@@ -128,6 +128,8 @@
#include <ppltasks.h>
#elif defined HAVE_CONCURRENCY
#include <ppl.h>
#elif defined HAVE_PTHREADS_PF
#include <pthread.h>
#endif
+3 -3
View File
@@ -2522,7 +2522,7 @@ public:
ippStatus = ippGetCpuFeatures(&cpuFeatures, NULL);
if(ippStatus < 0)
{
std::cerr << "ERROR: IPP cannot detect CPU features, IPP was disabled " << std::endl;
CV_LOG_ERROR(NULL, "ERROR: IPP cannot detect CPU features, IPP was disabled");
useIPP = false;
return;
}
@@ -2560,7 +2560,7 @@ public:
if(env == "disabled")
{
std::cerr << "WARNING: IPP was disabled by OPENCV_IPP environment variable" << std::endl;
CV_LOG_WARNING(NULL, "WARNING: IPP was disabled by OPENCV_IPP environment variable");
useIPP = false;
}
else if(env == "sse42")
@@ -2574,7 +2574,7 @@ public:
#endif
#endif
else
std::cerr << "ERROR: Improper value of OPENCV_IPP: " << env.c_str() << ". Correct values are: disabled, sse42, avx2, avx512 (Intel64 only)" << std::endl;
CV_LOG_ERROR(NULL, "ERROR: Improper value of OPENCV_IPP: " << env.c_str() << ". Correct values are: disabled, sse42, avx2, avx512 (Intel64 only)");
// Trim unsupported features
ippFeatures &= cpuFeatures;
+5
View File
@@ -186,6 +186,11 @@ void RotatedRect::points(Point2f pt[]) const
pt[3].y = 2*center.y - pt[1].y;
}
void RotatedRect::points(std::vector<Point2f>& pts) const {
pts.resize(4);
points(pts.data());
}
Rect RotatedRect::boundingRect() const
{
Point2f pt[4];