1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Alekhin
2021-12-30 16:23:27 +00:00
951 changed files with 158314 additions and 152668 deletions
+8 -8
View File
@@ -454,7 +454,7 @@ icvGetNodePtr( CvSparseMat* mat, const int* idx, int* _type,
int i, tabidx;
unsigned hashval = 0;
CvSparseNode *node;
assert( CV_IS_SPARSE_MAT( mat ));
CV_Assert( CV_IS_SPARSE_MAT( mat ));
if( !precalc_hashval )
{
@@ -503,7 +503,7 @@ icvGetNodePtr( CvSparseMat* mat, const int* idx, int* _type,
int newrawsize = newsize*sizeof(newtable[0]);
CvSparseMatIterator iterator;
assert( (newsize & (newsize - 1)) == 0 );
CV_Assert( (newsize & (newsize - 1)) == 0 );
// resize hash table
newtable = (void**)cvAlloc( newrawsize );
@@ -548,7 +548,7 @@ icvDeleteNode( CvSparseMat* mat, const int* idx, unsigned* precalc_hashval )
int i, tabidx;
unsigned hashval = 0;
CvSparseNode *node, *prev = 0;
assert( CV_IS_SPARSE_MAT( mat ));
CV_Assert( CV_IS_SPARSE_MAT( mat ));
if( !precalc_hashval )
{
@@ -1207,7 +1207,7 @@ cvScalarToRawData( const CvScalar* scalar, void* data, int type, int extend_to_1
int cn = CV_MAT_CN( type );
int depth = type & CV_MAT_DEPTH_MASK;
assert( scalar && data );
CV_Assert( scalar && data );
if( (unsigned)(cn - 1) >= 4 )
CV_Error( CV_StsOutOfRange, "The number of channels must be 1, 2, 3 or 4" );
@@ -1254,7 +1254,7 @@ cvScalarToRawData( const CvScalar* scalar, void* data, int type, int extend_to_1
((double*)data)[cn] = (double)(scalar->val[cn]);
break;
default:
assert(0);
CV_Assert(0);
CV_Error( CV_BadDepth, "" );
}
@@ -1279,7 +1279,7 @@ cvRawDataToScalar( const void* data, int flags, CvScalar* scalar )
{
int cn = CV_MAT_CN( flags );
assert( scalar && data );
CV_Assert( scalar && data );
if( (unsigned)(cn - 1) >= 4 )
CV_Error( CV_StsOutOfRange, "The number of channels must be 1, 2, 3 or 4" );
@@ -1317,7 +1317,7 @@ cvRawDataToScalar( const void* data, int flags, CvScalar* scalar )
scalar->val[cn] = ((double*)data)[cn];
break;
default:
assert(0);
CV_Assert(0);
CV_Error( CV_BadDepth, "" );
}
}
@@ -2438,7 +2438,7 @@ CV_IMPL IplImage *
cvCreateImage( CvSize size, int depth, int channels )
{
IplImage *img = cvCreateImageHeader( size, depth, channels );
assert( img );
CV_Assert( img );
cvCreateData( img );
return img;
+30 -30
View File
@@ -97,7 +97,7 @@ icvInitMemStorage( CvMemStorage* storage, int block_size )
block_size = CV_STORAGE_BLOCK_SIZE;
block_size = cvAlign( block_size, CV_STRUCT_ALIGN );
assert( sizeof(CvMemBlock) % CV_STRUCT_ALIGN == 0 );
CV_Assert( sizeof(CvMemBlock) % CV_STRUCT_ALIGN == 0 );
memset( storage, 0, sizeof( *storage ));
storage->signature = CV_STORAGE_MAGIC_VAL;
@@ -240,7 +240,7 @@ icvGoNextMemBlock( CvMemStorage * storage )
if( block == parent->top ) /* the single allocated block */
{
assert( parent->bottom == block );
CV_Assert( parent->bottom == block );
parent->top = parent->bottom = 0;
parent->free_space = 0;
}
@@ -266,7 +266,7 @@ icvGoNextMemBlock( CvMemStorage * storage )
if( storage->top->next )
storage->top = storage->top->next;
storage->free_space = storage->block_size - sizeof(CvMemBlock);
assert( storage->free_space % CV_STRUCT_ALIGN == 0 );
CV_Assert( storage->free_space % CV_STRUCT_ALIGN == 0 );
}
@@ -331,7 +331,7 @@ cvMemStorageAlloc( CvMemStorage* storage, size_t size )
if( size > INT_MAX )
CV_Error( CV_StsOutOfRange, "Too large memory block is requested" );
assert( storage->free_space % CV_STRUCT_ALIGN == 0 );
CV_Assert( storage->free_space % CV_STRUCT_ALIGN == 0 );
if( (size_t)storage->free_space < size )
{
@@ -343,7 +343,7 @@ cvMemStorageAlloc( CvMemStorage* storage, size_t size )
}
ptr = ICV_FREE_PTR(storage);
assert( (size_t)ptr % CV_STRUCT_ALIGN == 0 );
CV_Assert( (size_t)ptr % CV_STRUCT_ALIGN == 0 );
storage->free_space = cvAlignLeft(storage->free_space - (int)size, CV_STRUCT_ALIGN );
return ptr;
@@ -683,7 +683,7 @@ icvGrowSeq( CvSeq *seq, int in_front_of )
else
{
icvGoNextMemBlock( storage );
assert( storage->free_space >= delta );
CV_Assert( storage->free_space >= delta );
}
}
@@ -716,7 +716,7 @@ icvGrowSeq( CvSeq *seq, int in_front_of )
* For used blocks it means current number
* of sequence elements in the block:
*/
assert( block->count % seq->elem_size == 0 && block->count > 0 );
CV_Assert( block->count % seq->elem_size == 0 && block->count > 0 );
if( !in_front_of )
{
@@ -732,7 +732,7 @@ icvGrowSeq( CvSeq *seq, int in_front_of )
if( block != block->prev )
{
assert( seq->first->start_index == 0 );
CV_Assert( seq->first->start_index == 0 );
seq->first = block;
}
else
@@ -760,7 +760,7 @@ icvFreeSeqBlock( CvSeq *seq, int in_front_of )
{
CvSeqBlock *block = seq->first;
assert( (in_front_of ? block : block->prev)->count == 0 );
CV_Assert( (in_front_of ? block : block->prev)->count == 0 );
if( block == block->prev ) /* single block case */
{
@@ -775,7 +775,7 @@ icvFreeSeqBlock( CvSeq *seq, int in_front_of )
if( !in_front_of )
{
block = block->prev;
assert( seq->ptr == block->data );
CV_Assert( seq->ptr == block->data );
block->count = (int)(seq->block_max - seq->ptr);
seq->block_max = seq->ptr = block->prev->data +
@@ -804,7 +804,7 @@ icvFreeSeqBlock( CvSeq *seq, int in_front_of )
block->next->prev = block->prev;
}
assert( block->count > 0 && block->count % seq->elem_size == 0 );
CV_Assert( block->count > 0 && block->count % seq->elem_size == 0 );
block->next = seq->free_blocks;
seq->free_blocks = block;
}
@@ -861,7 +861,7 @@ cvFlushSeqWriter( CvSeqWriter * writer )
CvSeqBlock *block = first_block;
writer->block->count = (int)((writer->ptr - writer->block->data) / seq->elem_size);
assert( writer->block->count > 0 );
CV_Assert( writer->block->count > 0 );
do
{
@@ -891,7 +891,7 @@ cvEndWriteSeq( CvSeqWriter * writer )
CvMemStorage *storage = seq->storage;
schar *storage_block_max = (schar *) storage->top + storage->block_size;
assert( writer->block->count > 0 );
CV_Assert( writer->block->count > 0 );
if( (unsigned)((storage_block_max - storage->free_space)
- seq->block_max) < CV_STRUCT_ALIGN )
@@ -1147,7 +1147,7 @@ cvSeqPush( CvSeq *seq, const void *element )
icvGrowSeq( seq, 0 );
ptr = seq->ptr;
assert( ptr + elem_size <= seq->block_max /*&& ptr == seq->block_min */ );
CV_Assert( ptr + elem_size <= seq->block_max /*&& ptr == seq->block_min */ );
}
if( element )
@@ -1183,7 +1183,7 @@ cvSeqPop( CvSeq *seq, void *element )
if( --(seq->first->prev->count) == 0 )
{
icvFreeSeqBlock( seq, 0 );
assert( seq->ptr == seq->block_max );
CV_Assert( seq->ptr == seq->block_max );
}
}
@@ -1207,7 +1207,7 @@ cvSeqPushFront( CvSeq *seq, const void *element )
icvGrowSeq( seq, 1 );
block = seq->first;
assert( block->start_index > 0 );
CV_Assert( block->start_index > 0 );
}
ptr = block->data -= elem_size;
@@ -1289,7 +1289,7 @@ cvSeqInsert( CvSeq *seq, int before_index, const void *element )
icvGrowSeq( seq, 0 );
ptr = seq->ptr + elem_size;
assert( ptr <= seq->block_max );
CV_Assert( ptr <= seq->block_max );
}
delta_index = seq->first->start_index;
@@ -1307,7 +1307,7 @@ cvSeqInsert( CvSeq *seq, int before_index, const void *element )
block = prev_block;
/* Check that we don't fall into an infinite loop: */
assert( block != seq->first->prev );
CV_Assert( block != seq->first->prev );
}
before_index = (before_index - block->start_index + delta_index) * elem_size;
@@ -1346,7 +1346,7 @@ cvSeqInsert( CvSeq *seq, int before_index, const void *element )
block = next_block;
/* Check that we don't fall into an infinite loop: */
assert( block != seq->first );
CV_Assert( block != seq->first );
}
before_index = (before_index - block->start_index + delta_index) * elem_size;
@@ -1502,7 +1502,7 @@ cvSeqPushMulti( CvSeq *seq, const void *_elements, int count, int front )
icvGrowSeq( seq, 1 );
block = seq->first;
assert( block->start_index > 0 );
CV_Assert( block->start_index > 0 );
}
delta = MIN( block->start_index, count );
@@ -1543,7 +1543,7 @@ cvSeqPopMulti( CvSeq *seq, void *_elements, int count, int front )
int delta = seq->first->prev->count;
delta = MIN( delta, count );
assert( delta > 0 );
CV_Assert( delta > 0 );
seq->first->prev->count -= delta;
seq->total -= delta;
@@ -1568,7 +1568,7 @@ cvSeqPopMulti( CvSeq *seq, void *_elements, int count, int front )
int delta = seq->first->count;
delta = MIN( delta, count );
assert( delta > 0 );
CV_Assert( delta > 0 );
seq->first->count -= delta;
seq->total -= delta;
@@ -2418,7 +2418,7 @@ cvSeqPartition( const CvSeq* seq, CvMemStorage* storage, CvSeq** labels,
root2->rank += root->rank == root2->rank;
root = root2;
}
assert( root->parent == 0 );
CV_Assert( root->parent == 0 );
// Compress path from node2 to the root:
while( node2->parent )
@@ -2521,7 +2521,7 @@ cvSetAdd( CvSet* set, CvSetElem* element, CvSetElem** inserted_element )
((CvSetElem*)ptr)->flags = count | CV_SET_ELEM_FREE_FLAG;
((CvSetElem*)ptr)->next_free = (CvSetElem*)(ptr + elem_size);
}
assert( count <= CV_SET_ELEM_IDX_MASK+1 );
CV_Assert( count <= CV_SET_ELEM_IDX_MASK+1 );
((CvSetElem*)(ptr - elem_size))->next_free = 0;
set->first->prev->count += count - set->total;
set->total = count;
@@ -2720,7 +2720,7 @@ cvFindGraphEdgeByPtr( const CvGraph* graph,
for( ; edge; edge = edge->next[ofs] )
{
ofs = start_vtx == edge->vtx[1];
assert( ofs == 1 || start_vtx == edge->vtx[0] );
CV_Assert( ofs == 1 || start_vtx == edge->vtx[0] );
if( edge->vtx[1] == end_vtx )
break;
}
@@ -2784,7 +2784,7 @@ cvGraphAddEdgeByPtr( CvGraph* graph,
"vertex pointers coincide (or set to NULL)" );
edge = (CvGraphEdge*)cvSetNew( (CvSet*)(graph->edges) );
assert( edge->flags >= 0 );
CV_Assert( edge->flags >= 0 );
edge->vtx[0] = start_vtx;
edge->vtx[1] = end_vtx;
@@ -2861,7 +2861,7 @@ cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, CvGraphVtx* end_v
prev_ofs = ofs, prev_edge = edge, edge = edge->next[ofs] )
{
ofs = start_vtx == edge->vtx[1];
assert( ofs == 1 || start_vtx == edge->vtx[0] );
CV_Assert( ofs == 1 || start_vtx == edge->vtx[0] );
if( edge->vtx[1] == end_vtx )
break;
}
@@ -2879,7 +2879,7 @@ cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, CvGraphVtx* end_v
prev_ofs = ofs, prev_edge = edge, edge = edge->next[ofs] )
{
ofs = end_vtx == edge->vtx[1];
assert( ofs == 1 || end_vtx == edge->vtx[0] );
CV_Assert( ofs == 1 || end_vtx == edge->vtx[0] );
if( edge->vtx[0] == start_vtx )
break;
}
@@ -3396,7 +3396,7 @@ cvInsertNodeIntoTree( void* _node, void* _parent, void* _frame )
node->v_prev = _parent != _frame ? parent : 0;
node->h_next = parent->v_next;
assert( parent->v_next != node );
CV_Assert( parent->v_next != node );
if( parent->v_next )
parent->v_next->h_prev = node;
@@ -3430,7 +3430,7 @@ cvRemoveNodeFromTree( void* _node, void* _frame )
if( parent )
{
assert( parent->v_next == node );
CV_Assert( parent->v_next == node );
parent->v_next = node->h_next;
}
}
+13 -13
View File
@@ -238,7 +238,7 @@ DFTInit( int n0, int nf, const int* factors, int* itab, int elem_size, void* _wa
else
{
// radix[] is initialized from index 'nf' down to zero
assert (nf < 34);
CV_Assert (nf < 34);
radix[nf] = 1;
digits[nf] = 0;
for( i = 0; i < nf; i++ )
@@ -374,7 +374,7 @@ DFTInit( int n0, int nf, const int* factors, int* itab, int elem_size, void* _wa
else
{
Complex<float>* wave = (Complex<float>*)_wave;
assert( elem_size == sizeof(Complex<float>) );
CV_Assert( elem_size == sizeof(Complex<float>) );
wave[0].re = 1.f;
wave[0].im = 0.f;
@@ -874,13 +874,13 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
// 0. shuffle data
if( dst != src )
{
assert( !c.noPermute );
CV_Assert( !c.noPermute );
if( !inv )
{
for( i = 0; i <= n - 2; i += 2, itab += 2*tab_step )
{
int k0 = itab[0], k1 = itab[tab_step];
assert( (unsigned)k0 < (unsigned)n && (unsigned)k1 < (unsigned)n );
CV_Assert( (unsigned)k0 < (unsigned)n && (unsigned)k1 < (unsigned)n );
dst[i] = src[k0]; dst[i+1] = src[k1];
}
@@ -892,7 +892,7 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
for( i = 0; i <= n - 2; i += 2, itab += 2*tab_step )
{
int k0 = itab[0], k1 = itab[tab_step];
assert( (unsigned)k0 < (unsigned)n && (unsigned)k1 < (unsigned)n );
CV_Assert( (unsigned)k0 < (unsigned)n && (unsigned)k1 < (unsigned)n );
t.re = src[k0].re; t.im = -src[k0].im;
dst[i] = t;
t.re = src[k1].re; t.im = -src[k1].im;
@@ -921,7 +921,7 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
for( i = 0; i < n2; i += 2, itab += tab_step*2 )
{
j = itab[0];
assert( (unsigned)j < (unsigned)n2 );
CV_Assert( (unsigned)j < (unsigned)n2 );
CV_SWAP(dst[i+1], dsth[j], t);
if( j > i )
@@ -938,7 +938,7 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
for( i = 0; i < n; i++, itab += tab_step )
{
j = itab[0];
assert( (unsigned)j < (unsigned)n );
CV_Assert( (unsigned)j < (unsigned)n );
if( j > i )
CV_SWAP(dst[i], dst[j], t);
}
@@ -1218,7 +1218,7 @@ RealDFT(const OcvDftOptions & c, const T* src, T* dst)
setIppErrorStatus();
#endif
}
assert( c.tab_size == n );
CV_Assert( c.tab_size == n );
if( n == 1 )
{
@@ -1338,11 +1338,11 @@ CCSIDFT(const OcvDftOptions & c, const T* src, T* dst)
T save_s1 = 0.;
T t0, t1, t2, t3, t;
assert( c.tab_size == n );
CV_Assert( c.tab_size == n );
if( complex_input )
{
assert( src != dst );
CV_Assert( src != dst );
save_s1 = src[1];
((T*)src)[1] = src[0];
src++;
@@ -3177,7 +3177,7 @@ protected:
}
else
{
assert( !inv );
CV_Assert( !inv );
CopyColumn( dbuf0, complex_elem_size, dptr0,
dst_step, len, complex_elem_size );
if( even )
@@ -3874,7 +3874,7 @@ DCTInit( int n, int elem_size, void* _wave, int inv )
if( n == 1 )
return;
assert( (n&1) == 0 );
CV_Assert( (n&1) == 0 );
if( (n & (n - 1)) == 0 )
{
@@ -3912,7 +3912,7 @@ DCTInit( int n, int elem_size, void* _wave, int inv )
else
{
Complex<float>* wave = (Complex<float>*)_wave;
assert( elem_size == sizeof(Complex<float>) );
CV_Assert( elem_size == sizeof(Complex<float>) );
w.re = (float)scale;
w.im = 0.f;
+18 -18
View File
@@ -163,9 +163,9 @@ lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n
if(n == 1 && b_step == sizeof(fptype))
{
if(typeid(fptype) == typeid(float))
sposv_(L, &m, &n, (float*)a, &lda, (float*)b, &m, &lapackStatus);
OCV_LAPACK_FUNC(sposv)(L, &m, &n, (float*)a, &lda, (float*)b, &m, &lapackStatus);
else if(typeid(fptype) == typeid(double))
dposv_(L, &m, &n, (double*)a, &lda, (double*)b, &m, &lapackStatus);
OCV_LAPACK_FUNC(dposv)(L, &m, &n, (double*)a, &lda, (double*)b, &m, &lapackStatus);
}
else
{
@@ -174,9 +174,9 @@ lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n
transpose(b, ldb, tmpB, m, m, n);
if(typeid(fptype) == typeid(float))
sposv_(L, &m, &n, (float*)a, &lda, (float*)tmpB, &m, &lapackStatus);
OCV_LAPACK_FUNC(sposv)(L, &m, &n, (float*)a, &lda, (float*)tmpB, &m, &lapackStatus);
else if(typeid(fptype) == typeid(double))
dposv_(L, &m, &n, (double*)a, &lda, (double*)tmpB, &m, &lapackStatus);
OCV_LAPACK_FUNC(dposv)(L, &m, &n, (double*)a, &lda, (double*)tmpB, &m, &lapackStatus);
transpose(tmpB, m, b, ldb, n, m);
delete[] tmpB;
@@ -185,9 +185,9 @@ lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n
else
{
if(typeid(fptype) == typeid(float))
spotrf_(L, &m, (float*)a, &lda, &lapackStatus);
OCV_LAPACK_FUNC(spotrf)(L, &m, (float*)a, &lda, &lapackStatus);
else if(typeid(fptype) == typeid(double))
dpotrf_(L, &m, (double*)a, &lda, &lapackStatus);
OCV_LAPACK_FUNC(dpotrf)(L, &m, (double*)a, &lda, &lapackStatus);
}
if(lapackStatus == 0) *info = true;
@@ -229,10 +229,10 @@ lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype
}
if(typeid(fptype) == typeid(float))
sgesdd_(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu,
OCV_LAPACK_FUNC(sgesdd)(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu,
(float*)vt, &ldv, (float*)&work1, &lwork, &iworkBuf[0], info);
else if(typeid(fptype) == typeid(double))
dgesdd_(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu,
OCV_LAPACK_FUNC(dgesdd)(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu,
(double*)vt, &ldv, (double*)&work1, &lwork, &iworkBuf[0], info);
if(*info < 0)
@@ -242,10 +242,10 @@ lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype
std::vector<fptype> buffer(lwork + 1);
if(typeid(fptype) == typeid(float))
sgesdd_(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu,
OCV_LAPACK_FUNC(sgesdd)(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu,
(float*)vt, &ldv, (float*)&buffer[0], &lwork, &iworkBuf[0], info);
else if(typeid(fptype) == typeid(double))
dgesdd_(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu,
OCV_LAPACK_FUNC(dgesdd)(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu,
(double*)vt, &ldv, (double*)&buffer[0], &lwork, &iworkBuf[0], info);
if(!(flags & CV_HAL_SVD_NO_UV))
@@ -296,9 +296,9 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
if (k == 1 && b_step == sizeof(fptype))
{
if (typeid(fptype) == typeid(float))
sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)b, &m, (float*)&work1, &lwork, info);
OCV_LAPACK_FUNC(sgels)(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)b, &m, (float*)&work1, &lwork, info);
else if (typeid(fptype) == typeid(double))
dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)&work1, &lwork, info);
OCV_LAPACK_FUNC(dgels)(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)&work1, &lwork, info);
if (*info < 0)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
@@ -308,9 +308,9 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
fptype* buffer = &workBufMemHolder.front();
if (typeid(fptype) == typeid(float))
sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)b, &m, (float*)buffer, &lwork, info);
OCV_LAPACK_FUNC(sgels)(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)b, &m, (float*)buffer, &lwork, info);
else if (typeid(fptype) == typeid(double))
dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)buffer, &lwork, info);
OCV_LAPACK_FUNC(dgels)(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)buffer, &lwork, info);
}
else
{
@@ -320,9 +320,9 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
transpose(b, ldb, tmpB, m, m, k);
if (typeid(fptype) == typeid(float))
sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)tmpB, &m, (float*)&work1, &lwork, info);
OCV_LAPACK_FUNC(sgels)(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)tmpB, &m, (float*)&work1, &lwork, info);
else if (typeid(fptype) == typeid(double))
dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)&work1, &lwork, info);
OCV_LAPACK_FUNC(dgels)(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)&work1, &lwork, info);
if (*info < 0)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
@@ -332,9 +332,9 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
fptype* buffer = &workBufMemHolder.front();
if (typeid(fptype) == typeid(float))
sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)tmpB, &m, (float*)buffer, &lwork, info);
OCV_LAPACK_FUNC(sgels)(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)tmpB, &m, (float*)buffer, &lwork, info);
else if (typeid(fptype) == typeid(double))
dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)buffer, &lwork, info);
OCV_LAPACK_FUNC(dgels)(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)buffer, &lwork, info);
transpose(tmpB, m, b, ldb, k, m);
}
+15 -10
View File
@@ -47,12 +47,15 @@
#include "opencv2/core/hal/interface.h"
#if defined __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-parameter"
#elif defined _MSC_VER
# pragma warning( push )
# pragma warning( disable: 4100 )
#if defined(__clang__) // clang or MSVC clang
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#elif defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4100)
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
//! @addtogroup core_hal_interface
@@ -731,10 +734,12 @@ inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, i
//! @}
#if defined __GNUC__
# pragma GCC diagnostic pop
#elif defined _MSC_VER
# pragma warning( pop )
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(_MSC_VER)
#pragma warning(pop)
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#include "hal_internal.hpp"
+2 -2
View File
@@ -1020,7 +1020,7 @@ double invert( InputArray _src, OutputArray _dst, int method )
}
else
{
assert( n == 1 );
CV_Assert( n == 1 );
if( type == CV_32FC1 )
{
@@ -1208,7 +1208,7 @@ bool solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int method )
}
else
{
assert( src.rows == 1 );
CV_Assert( src.rows == 1 );
if( type == CV_32FC1 )
{
+21 -5
View File
@@ -181,17 +181,33 @@ LogLevel getLogLevel()
namespace internal {
static int getShowTimestampMode()
{
static bool param_timestamp_enable = utils::getConfigurationParameterBool("OPENCV_LOG_TIMESTAMP", true);
static bool param_timestamp_ns_enable = utils::getConfigurationParameterBool("OPENCV_LOG_TIMESTAMP_NS", false);
return (param_timestamp_enable ? 1 : 0) + (param_timestamp_ns_enable ? 2 : 0);
}
void writeLogMessage(LogLevel logLevel, const char* message)
{
const int threadID = cv::utils::getThreadID();
std::string message_id;
switch (getShowTimestampMode())
{
case 1: message_id = cv::format("%d@%0.3f", threadID, getTimestampNS() * 1e-9); break;
case 1+2: message_id = cv::format("%d@%llu", threadID, (long long unsigned int)getTimestampNS()); break;
default: message_id = cv::format("%d", threadID); break;
}
std::ostringstream ss;
switch (logLevel)
{
case LOG_LEVEL_FATAL: ss << "[FATAL:" << threadID << "] " << message << std::endl; break;
case LOG_LEVEL_ERROR: ss << "[ERROR:" << threadID << "] " << message << std::endl; break;
case LOG_LEVEL_WARNING: ss << "[ WARN:" << threadID << "] " << message << std::endl; break;
case LOG_LEVEL_INFO: ss << "[ INFO:" << threadID << "] " << message << std::endl; break;
case LOG_LEVEL_DEBUG: ss << "[DEBUG:" << threadID << "] " << message << std::endl; break;
case LOG_LEVEL_FATAL: ss << "[FATAL:" << message_id << "] " << message << std::endl; break;
case LOG_LEVEL_ERROR: ss << "[ERROR:" << message_id << "] " << message << std::endl; break;
case LOG_LEVEL_WARNING: ss << "[ WARN:" << message_id << "] " << message << std::endl; break;
case LOG_LEVEL_INFO: ss << "[ INFO:" << message_id << "] " << message << std::endl; break;
case LOG_LEVEL_DEBUG: ss << "[DEBUG:" << message_id << "] " << message << std::endl; break;
case LOG_LEVEL_VERBOSE: ss << message << std::endl; break;
case LOG_LEVEL_SILENT: return; // avoid compiler warning about incomplete switch
case ENUM_LOG_LEVEL_FORCE_INT: return; // avoid compiler warning about incomplete switch
+2 -2
View File
@@ -169,7 +169,7 @@ GEMM_TransposeBlock( const uchar* src, size_t src_step,
}
break;
default:
assert(0);
CV_Assert(0);
return;
}
}
@@ -2062,7 +2062,7 @@ MulTransposedR(const Mat& srcmat, const Mat& dstmat, const Mat& deltamat, double
if( delta && delta_cols < size.width )
{
assert( delta_cols == 1 );
CV_Assert( delta_cols == 1 );
buf_size *= 5;
}
buf.allocate(buf_size);
+1 -1
View File
@@ -463,7 +463,7 @@ Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
}
else
{
CV_Assert(_step >= minstep);
CV_CheckGE(_step, minstep, "");
if (_step % esz1 != 0)
{
+1 -1
View File
@@ -638,7 +638,7 @@ void SparseMat::resizeHashTab(size_t newsize)
uchar* SparseMat::newNode(const int* idx, size_t hashval)
{
const int HASH_MAX_FILL_FACTOR=3;
assert(hdr);
CV_Assert(hdr);
size_t hsize = hdr->hashtab.size();
if( ++hdr->nodeCount > hsize*HASH_MAX_FILL_FACTOR )
{
+118
View File
@@ -7,6 +7,9 @@
#include "opencl_kernels_core.hpp"
#include "opencv2/core/openvx/ovx_defs.hpp"
#include "stat.hpp"
#include "opencv2/core/detail/dispatch_helper.impl.hpp"
#include <algorithm>
#undef HAVE_IPP
#undef CV_IPP_RUN_FAST
@@ -1570,3 +1573,118 @@ void cv::minMaxLoc( InputArray _img, double* minVal, double* maxVal,
if( maxLoc )
std::swap(maxLoc->x, maxLoc->y);
}
enum class ReduceMode
{
FIRST_MIN = 0, //!< get index of first min occurrence
LAST_MIN = 1, //!< get index of last min occurrence
FIRST_MAX = 2, //!< get index of first max occurrence
LAST_MAX = 3, //!< get index of last max occurrence
};
template <typename T>
struct reduceMinMaxImpl
{
void operator()(const cv::Mat& src, cv::Mat& dst, ReduceMode mode, const int axis) const
{
switch(mode)
{
case ReduceMode::FIRST_MIN:
reduceMinMaxApply<std::less>(src, dst, axis);
break;
case ReduceMode::LAST_MIN:
reduceMinMaxApply<std::less_equal>(src, dst, axis);
break;
case ReduceMode::FIRST_MAX:
reduceMinMaxApply<std::greater>(src, dst, axis);
break;
case ReduceMode::LAST_MAX:
reduceMinMaxApply<std::greater_equal>(src, dst, axis);
break;
}
}
template <template<class> class Cmp>
static void reduceMinMaxApply(const cv::Mat& src, cv::Mat& dst, const int axis)
{
Cmp<T> cmp;
const auto *src_ptr = src.ptr<T>();
auto *dst_ptr = dst.ptr<int32_t>();
const size_t outer_size = src.total(0, axis);
const auto mid_size = static_cast<size_t>(src.size[axis]);
const size_t outer_step = src.total(axis);
const size_t dst_step = dst.total(axis);
const size_t mid_step = src.total(axis + 1);
for (size_t outer = 0; outer < outer_size; ++outer)
{
const size_t outer_offset = outer * outer_step;
const size_t dst_offset = outer * dst_step;
for (size_t mid = 0; mid != mid_size; ++mid)
{
const size_t src_offset = outer_offset + mid * mid_step;
for (size_t inner = 0; inner < mid_step; inner++)
{
int32_t& index = dst_ptr[dst_offset + inner];
const size_t prev = outer_offset + index * mid_step + inner;
const size_t curr = src_offset + inner;
if (cmp(src_ptr[curr], src_ptr[prev]))
{
index = static_cast<int32_t>(mid);
}
}
}
}
}
};
static void reduceMinMax(cv::InputArray src, cv::OutputArray dst, ReduceMode mode, int axis)
{
CV_INSTRUMENT_REGION();
cv::Mat srcMat = src.getMat();
axis = (axis + srcMat.dims) % srcMat.dims;
CV_Assert(srcMat.channels() == 1 && axis >= 0 && axis < srcMat.dims);
std::vector<int> sizes(srcMat.dims);
std::copy(srcMat.size.p, srcMat.size.p + srcMat.dims, sizes.begin());
sizes[axis] = 1;
dst.create(srcMat.dims, sizes.data(), CV_32SC1); // indices
cv::Mat dstMat = dst.getMat();
dstMat.setTo(cv::Scalar::all(0));
if (!srcMat.isContinuous())
{
srcMat = srcMat.clone();
}
bool needs_copy = !dstMat.isContinuous();
if (needs_copy)
{
dstMat = dstMat.clone();
}
cv::detail::depthDispatch<reduceMinMaxImpl>(srcMat.depth(), srcMat, dstMat, mode, axis);
if (needs_copy)
{
dstMat.copyTo(dst);
}
}
void cv::reduceArgMin(InputArray src, OutputArray dst, int axis, bool lastIndex)
{
reduceMinMax(src, dst, lastIndex ? ReduceMode::LAST_MIN : ReduceMode::FIRST_MIN, axis);
}
void cv::reduceArgMax(InputArray src, OutputArray dst, int axis, bool lastIndex)
{
reduceMinMax(src, dst, lastIndex ? ReduceMode::LAST_MAX : ReduceMode::FIRST_MAX, axis);
}
+17
View File
@@ -153,6 +153,17 @@ static bool isRaiseError()
}
#endif
static void onOpenCLKernelBuildError()
{
// NB: no need to cache this value
bool value = cv::utils::getConfigurationParameterBool("OPENCV_OPENCL_ABORT_ON_BUILD_ERROR", false);
if (value)
{
fprintf(stderr, "Abort on OpenCL kernel build failure!\n");
abort();
}
}
#if CV_OPENCL_TRACE_CHECK
static inline
void traceOpenCLCheck(cl_int status, const char* message)
@@ -4574,6 +4585,12 @@ struct Program::Impl
CV_OCL_DBG_CHECK(clReleaseProgram(handle));
handle = NULL;
}
if (retval != CL_SUCCESS &&
sourceName_ != "dummy" // used for testing of compilation flags
)
{
onOpenCLKernelBuildError();
}
}
#if CV_OPENCL_VALIDATE_BINARY_PROGRAMS
if (handle && CV_OPENCL_VALIDATE_BINARY_PROGRAMS_VALUE)
@@ -113,7 +113,7 @@ static void* openclamdblas_check_fn(int ID);
static void* openclamdblas_check_fn(int ID)
{
assert(ID >= 0 && ID < (int)(sizeof(openclamdblas_fn)/sizeof(openclamdblas_fn[0])));
CV_Assert(ID >= 0 && ID < (int)(sizeof(openclamdblas_fn)/sizeof(openclamdblas_fn[0])));
const struct DynamicFnEntry* e = openclamdblas_fn[ID];
void* func = CV_CL_GET_PROC_ADDRESS(e->fnName);
if (!func)
@@ -113,7 +113,7 @@ static void* openclamdfft_check_fn(int ID);
static void* openclamdfft_check_fn(int ID)
{
assert(ID >= 0 && ID < (int)(sizeof(openclamdfft_fn)/sizeof(openclamdfft_fn[0])));
CV_Assert(ID >= 0 && ID < (int)(sizeof(openclamdfft_fn)/sizeof(openclamdfft_fn[0])));
const struct DynamicFnEntry* e = openclamdfft_fn[ID];
void* func = CV_CL_GET_PROC_ADDRESS(e->fnName);
if (!func)
@@ -411,7 +411,7 @@ static void* opencl_gl_check_fn(int ID);
static void* opencl_gl_check_fn(int ID)
{
const struct DynamicFnEntry* e = NULL;
assert(ID >= 0 && ID < (int)(sizeof(opencl_gl_fn_list)/sizeof(opencl_gl_fn_list[0])));
CV_Assert(ID >= 0 && ID < (int)(sizeof(opencl_gl_fn_list)/sizeof(opencl_gl_fn_list[0])));
e = opencl_gl_fn_list[ID];
void* func = CV_CL_GET_PROC_ADDRESS(e->fnName);
if (!func)
+1 -1
View File
@@ -175,7 +175,7 @@ int decodeFormat( const char* dt, int* fmt_pairs, int max_len )
if( !dt || !len )
return 0;
assert( fmt_pairs != 0 && max_len > 0 );
CV_Assert( fmt_pairs != 0 && max_len > 0 );
fmt_pairs[0] = 0;
max_len *= 2;
+2 -2
View File
@@ -387,7 +387,7 @@ public:
if( c == '-' )
{
assert( ptr[1] == '-' && ptr[2] == '>' );
CV_Assert( ptr[1] == '-' && ptr[2] == '>' );
mode = 0;
ptr += 3;
}
@@ -694,7 +694,7 @@ public:
else if( *ptr == '!' )
{
tag_type = CV_XML_DIRECTIVE_TAG;
assert( ptr[1] != '-' || ptr[2] != '-' );
CV_Assert( ptr[1] != '-' || ptr[2] != '-' );
ptr++;
}
else
+1 -1
View File
@@ -98,7 +98,7 @@ public:
/*
if( !FileNode::isFlow(parent_flags) )
fs->struct_indent -= CV_YML_INDENT + FileNode::isFlow(struct_flags);
assert( fs->struct_indent >= 0 );*/
CV_Assert( fs->struct_indent >= 0 );*/
}
void write(const char* key, int value)
+4 -1
View File
@@ -62,7 +62,6 @@
#include "opencv2/core/ocl.hpp"
#endif
#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
@@ -368,6 +367,10 @@ bool __termination; // skip some cleanups, because process is terminating
cv::Mutex& getInitializationMutex();
/// @brief Returns timestamp in nanoseconds since program launch
int64 getTimestampNS();
#define CV_SINGLETON_LAZY_INIT_(TYPE, INITIALIZER, RET_VALUE) \
static TYPE* const instance = INITIALIZER; \
return RET_VALUE;
+63 -4
View File
@@ -131,7 +131,7 @@ void* allocSingletonNewBuffer(size_t size) { return malloc(size); }
#if defined __ANDROID__ || defined __unix__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __HAIKU__ || defined __Fuchsia__
# include <unistd.h>
# include <fcntl.h>
#if defined __QNXNTO__
#if defined __QNX__
# include <sys/elf.h>
#else
# include <elf.h>
@@ -157,6 +157,9 @@ void* allocSingletonNewBuffer(size_t size) { return malloc(size); }
# ifndef PPC_FEATURE2_ARCH_3_00
# define PPC_FEATURE2_ARCH_3_00 0x00800000
# endif
# ifndef PPC_FEATURE_HAS_VSX
# define PPC_FEATURE_HAS_VSX 0x00000080
# endif
#endif
#if defined _WIN32 || defined WINCE
@@ -551,7 +554,7 @@ struct HWFeatures
}
#endif // CV_CPUID_X86
#if defined __ANDROID__ || defined __linux__ || defined __FreeBSD__
#if defined __ANDROID__ || defined __linux__ || defined __FreeBSD__ || defined __QNX__
#ifdef __aarch64__
have[CV_CPU_NEON] = true;
have[CV_CPU_FP16] = true;
@@ -616,7 +619,7 @@ struct HWFeatures
have[CV_CPU_MSA] = true;
#endif
#if (defined __ppc64__ || defined __PPC64__) && defined __unix__
#if (defined __ppc64__ || defined __PPC64__) && defined __linux__
unsigned int hwcap = getauxval(AT_HWCAP);
if (hwcap & PPC_FEATURE_HAS_VSX) {
hwcap = getauxval(AT_HWCAP2);
@@ -626,8 +629,19 @@ struct HWFeatures
have[CV_CPU_VSX] = (hwcap & PPC_FEATURE2_ARCH_2_07) != 0;
}
}
#elif (defined __ppc64__ || defined __PPC64__) && defined __FreeBSD__
unsigned int hwcap = 0;
elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
if (hwcap & PPC_FEATURE_HAS_VSX) {
elf_aux_info(AT_HWCAP2, &hwcap, sizeof(hwcap));
if (hwcap & PPC_FEATURE2_ARCH_3_00) {
have[CV_CPU_VSX] = have[CV_CPU_VSX3] = true;
} else {
have[CV_CPU_VSX] = (hwcap & PPC_FEATURE2_ARCH_2_07) != 0;
}
}
#else
// TODO: AIX, FreeBSD
// TODO: AIX, OpenBSD
#if CV_VSX || defined _ARCH_PWR8 || defined __POWER9_VECTOR__
have[CV_CPU_VSX] = true;
#endif
@@ -930,6 +944,51 @@ int64 getCPUTickCount(void)
#endif
namespace internal {
class Timestamp
{
public:
const int64 zeroTickCount;
const double ns_in_ticks;
Timestamp()
: zeroTickCount(getTickCount())
, ns_in_ticks(1e9 / getTickFrequency())
{
// nothing
}
int64 getTimestamp()
{
int64 t = getTickCount();
return (int64)((t - zeroTickCount) * ns_in_ticks);
}
static Timestamp& getInstance()
{
static Timestamp g_timestamp;
return g_timestamp;
}
};
class InitTimestamp {
public:
InitTimestamp() {
Timestamp::getInstance();
}
};
static InitTimestamp g_initialize_timestamp; // force zero timestamp initialization
} // namespace
int64 getTimestampNS()
{
return internal::Timestamp::getInstance().getTimestamp();
}
const String& getBuildInformation()
{
static String build_info =
+4 -13
View File
@@ -63,15 +63,6 @@ namespace details {
#pragma warning(disable:4065) // switch statement contains 'default' but no 'case' labels
#endif
static int64 g_zero_timestamp = 0;
static int64 getTimestamp()
{
int64 t = getTickCount();
static double tick_to_ns = 1e9 / getTickFrequency();
return (int64)((t - g_zero_timestamp) * tick_to_ns);
}
static bool getParameterTraceEnable()
{
static bool param_traceEnable = utils::getConfigurationParameterBool("OPENCV_TRACE", false);
@@ -485,7 +476,7 @@ Region::Region(const LocationStaticStorage& location) :
}
}
int64 beginTimestamp = getTimestamp();
int64 beginTimestamp = getTimestampNS();
int currentDepth = ctx.getCurrentDepth() + 1;
switch (location.flags & REGION_FLAG_IMPL_MASK)
@@ -635,7 +626,7 @@ void Region::destroy()
}
}
int64 endTimestamp = getTimestamp();
int64 endTimestamp = getTimestampNS();
int64 duration = endTimestamp - ctx.stackTopBeginTimestamp();
bool active = isActive();
@@ -844,7 +835,7 @@ static bool isInitialized = false;
TraceManager::TraceManager()
{
g_zero_timestamp = cv::getTickCount();
(void)cv::getTimestampNS();
isInitialized = true;
CV_LOG("TraceManager ctor: " << (void*)this);
@@ -990,7 +981,7 @@ void parallelForFinalize(const Region& rootRegion)
{
TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
int64 endTimestamp = getTimestamp();
int64 endTimestamp = getTimestampNS();
int64 duration = endTimestamp - ctx.stackTopBeginTimestamp();
CV_LOG_PARALLEL(NULL, "parallel_for duration: " << duration << " " << &rootRegion);