mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Fixed several issues found by static analysis
This commit is contained in:
parent
bbb14d3746
commit
a769d69a9d
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
#include "fisheye.hpp"
|
#include "fisheye.hpp"
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace cv { namespace
|
namespace cv { namespace
|
||||||
{
|
{
|
||||||
@ -760,7 +761,7 @@ double cv::fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArray
|
|||||||
|
|
||||||
|
|
||||||
//-------------------------------Optimization
|
//-------------------------------Optimization
|
||||||
for(int iter = 0; ; ++iter)
|
for(int iter = 0; iter <= std::numeric_limits<int>::max(); ++iter)
|
||||||
{
|
{
|
||||||
if ((criteria.type == 1 && iter >= criteria.maxCount) ||
|
if ((criteria.type == 1 && iter >= criteria.maxCount) ||
|
||||||
(criteria.type == 2 && change <= criteria.epsilon) ||
|
(criteria.type == 2 && change <= criteria.epsilon) ||
|
||||||
|
@ -276,10 +276,10 @@ CommandLineParser& CommandLineParser::operator = (const CommandLineParser& parse
|
|||||||
{
|
{
|
||||||
if( this != &parser )
|
if( this != &parser )
|
||||||
{
|
{
|
||||||
|
CV_XADD(&parser.impl->refcount, 1);
|
||||||
if(CV_XADD(&impl->refcount, -1) == 1)
|
if(CV_XADD(&impl->refcount, -1) == 1)
|
||||||
delete impl;
|
delete impl;
|
||||||
impl = parser.impl;
|
impl = parser.impl;
|
||||||
CV_XADD(&impl->refcount, 1);
|
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -283,8 +283,9 @@ void Mat::copyTo( OutputArray _dst ) const
|
|||||||
}
|
}
|
||||||
_dst.create( dims, size.p, type() );
|
_dst.create( dims, size.p, type() );
|
||||||
UMat dst = _dst.getUMat();
|
UMat dst = _dst.getUMat();
|
||||||
|
CV_Assert(dst.u != NULL);
|
||||||
size_t i, sz[CV_MAX_DIM] = {0}, dstofs[CV_MAX_DIM], esz = elemSize();
|
size_t i, sz[CV_MAX_DIM] = {0}, dstofs[CV_MAX_DIM], esz = elemSize();
|
||||||
|
CV_Assert(dims >= 0 && dims < CV_MAX_DIM);
|
||||||
for( i = 0; i < (size_t)dims; i++ )
|
for( i = 0; i < (size_t)dims; i++ )
|
||||||
sz[i] = size.p[i];
|
sz[i] = size.p[i];
|
||||||
sz[dims-1] *= esz;
|
sz[dims-1] *= esz;
|
||||||
|
@ -2547,6 +2547,7 @@ cvSetAdd( CvSet* set, CvSetElem* element, CvSetElem** inserted_element )
|
|||||||
CV_IMPL void
|
CV_IMPL void
|
||||||
cvSetRemove( CvSet* set, int index )
|
cvSetRemove( CvSet* set, int index )
|
||||||
{
|
{
|
||||||
|
CV_Assert(set != NULL);
|
||||||
CvSetElem* elem = cvGetSetElem( set, index );
|
CvSetElem* elem = cvGetSetElem( set, index );
|
||||||
if( elem )
|
if( elem )
|
||||||
cvSetRemoveByPtr( set, elem );
|
cvSetRemoveByPtr( set, elem );
|
||||||
|
@ -1129,7 +1129,7 @@ Mat Mat::diag(const Mat& d)
|
|||||||
|
|
||||||
int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) const
|
int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) const
|
||||||
{
|
{
|
||||||
return (depth() == _depth || _depth <= 0) &&
|
return data && (depth() == _depth || _depth <= 0) &&
|
||||||
(isContinuous() || !_requireContinuous) &&
|
(isContinuous() || !_requireContinuous) &&
|
||||||
((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) ||
|
((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) ||
|
||||||
(cols == _elemChannels && channels() == 1))) ||
|
(cols == _elemChannels && channels() == 1))) ||
|
||||||
|
@ -804,7 +804,7 @@ cvGetFileNode( CvFileStorage* fs, CvFileNode* _map_node,
|
|||||||
|
|
||||||
if( !map_node )
|
if( !map_node )
|
||||||
map_node = (CvFileNode*)cvGetSeqElem( fs->roots, k );
|
map_node = (CvFileNode*)cvGetSeqElem( fs->roots, k );
|
||||||
|
CV_Assert(map_node != NULL);
|
||||||
if( !CV_NODE_IS_MAP(map_node->tag) )
|
if( !CV_NODE_IS_MAP(map_node->tag) )
|
||||||
{
|
{
|
||||||
if( (!CV_NODE_IS_SEQ(map_node->tag) || map_node->data.seq->total != 0) &&
|
if( (!CV_NODE_IS_SEQ(map_node->tag) || map_node->data.seq->total != 0) &&
|
||||||
@ -6777,6 +6777,7 @@ cvLoad( const char* filename, CvMemStorage* memstorage,
|
|||||||
CvSeqReader reader;
|
CvSeqReader reader;
|
||||||
|
|
||||||
node = (CvFileNode*)cvGetSeqElem( (*fs)->roots, k );
|
node = (CvFileNode*)cvGetSeqElem( (*fs)->roots, k );
|
||||||
|
CV_Assert(node != NULL);
|
||||||
if( !CV_NODE_IS_MAP( node->tag ))
|
if( !CV_NODE_IS_MAP( node->tag ))
|
||||||
return 0;
|
return 0;
|
||||||
seq = node->data.seq;
|
seq = node->data.seq;
|
||||||
|
@ -1193,10 +1193,13 @@ Mutex::Mutex(const Mutex& m)
|
|||||||
|
|
||||||
Mutex& Mutex::operator = (const Mutex& m)
|
Mutex& Mutex::operator = (const Mutex& m)
|
||||||
{
|
{
|
||||||
CV_XADD(&m.impl->refcount, 1);
|
if (this != &m)
|
||||||
if( CV_XADD(&impl->refcount, -1) == 1 )
|
{
|
||||||
delete impl;
|
CV_XADD(&m.impl->refcount, 1);
|
||||||
impl = m.impl;
|
if( CV_XADD(&impl->refcount, -1) == 1 )
|
||||||
|
delete impl;
|
||||||
|
impl = m.impl;
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,6 +225,11 @@ Region::LocationExtraData::LocationExtraData(const LocationStaticStorage& locati
|
|||||||
ittHandle_name = __itt_string_handle_create(location.name);
|
ittHandle_name = __itt_string_handle_create(location.name);
|
||||||
ittHandle_filename = __itt_string_handle_create(location.filename);
|
ittHandle_filename = __itt_string_handle_create(location.filename);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ittHandle_name = 0;
|
||||||
|
ittHandle_filename = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1019,6 +1024,10 @@ struct TraceArg::ExtraData
|
|||||||
// Consecutive calls to __itt_string_handle_create with the same name return the same value.
|
// Consecutive calls to __itt_string_handle_create with the same name return the same value.
|
||||||
ittHandle_name = __itt_string_handle_create(arg.name);
|
ittHandle_name = __itt_string_handle_create(arg.name);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ittHandle_name = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -317,9 +317,9 @@ private:
|
|||||||
|
|
||||||
struct LayerData
|
struct LayerData
|
||||||
{
|
{
|
||||||
LayerData() {}
|
LayerData() : id(-1), flag(0) {}
|
||||||
LayerData(int _id, const String &_name, const String &_type, LayerParams &_params)
|
LayerData(int _id, const String &_name, const String &_type, LayerParams &_params)
|
||||||
: id(_id), name(_name), type(_type), params(_params)
|
: id(_id), name(_name), type(_type), params(_params), flag(0)
|
||||||
{
|
{
|
||||||
//add logging info
|
//add logging info
|
||||||
params.name = name;
|
params.name = name;
|
||||||
|
@ -287,7 +287,10 @@ public:
|
|||||||
bool is1x1_;
|
bool is1x1_;
|
||||||
bool useAVX2;
|
bool useAVX2;
|
||||||
|
|
||||||
ParallelConv() {}
|
ParallelConv()
|
||||||
|
: input_(0), weights_(0), output_(0), ngroups_(0), nstripes_(0),
|
||||||
|
is1x1_(false), useAVX2(false)
|
||||||
|
{}
|
||||||
|
|
||||||
static void run( const Mat& input, Mat& output, const Mat& weights,
|
static void run( const Mat& input, Mat& output, const Mat& weights,
|
||||||
const std::vector<float>& biasvec,
|
const std::vector<float>& biasvec,
|
||||||
@ -921,7 +924,11 @@ public:
|
|||||||
int nstripes;
|
int nstripes;
|
||||||
bool is1x1;
|
bool is1x1;
|
||||||
|
|
||||||
Col2ImInvoker() {}
|
Col2ImInvoker()
|
||||||
|
: data_col(0), biasvec(0), channels(0), height(0), width(0),
|
||||||
|
kernel_h(0), kernel_w(0), pad_h(0), pad_w(0), stride_h(0), stride_w(0), data_im(0),
|
||||||
|
height_col(0), width_col(0), nstripes(0), is1x1(0)
|
||||||
|
{}
|
||||||
|
|
||||||
static void run(const float* data_col,
|
static void run(const float* data_col,
|
||||||
int channels, int height, int width,
|
int channels, int height, int width,
|
||||||
|
@ -105,7 +105,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ElementWiseLayer(const Func &f=Func()) { func = f; }
|
ElementWiseLayer(const Func &f=Func()) : run_parallel(false) { func = f; }
|
||||||
|
|
||||||
virtual bool supportBackend(int backendId)
|
virtual bool supportBackend(int backendId)
|
||||||
{
|
{
|
||||||
|
@ -83,10 +83,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
PermuteLayerImpl(const LayerParams ¶ms)
|
PermuteLayerImpl(const LayerParams ¶ms)
|
||||||
|
: _count(0), _needsPermute(false), _numAxes(0)
|
||||||
{
|
{
|
||||||
if (!params.has("order"))
|
if (!params.has("order"))
|
||||||
{
|
{
|
||||||
_needsPermute = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +160,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
PriorBoxLayerImpl(const LayerParams ¶ms)
|
PriorBoxLayerImpl(const LayerParams ¶ms)
|
||||||
|
: _boxWidth(0), _boxHeight(0)
|
||||||
{
|
{
|
||||||
setParamsFrom(params);
|
setParamsFrom(params);
|
||||||
_minSize = getParameter<unsigned>(params, "min_size");
|
_minSize = getParameter<unsigned>(params, "min_size");
|
||||||
|
@ -94,6 +94,7 @@ class LSTMLayerImpl : public LSTMLayer
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
LSTMLayerImpl(const LayerParams& params)
|
LSTMLayerImpl(const LayerParams& params)
|
||||||
|
: numTimeStamps(0), numSamples(0)
|
||||||
{
|
{
|
||||||
setParamsFrom(params);
|
setParamsFrom(params);
|
||||||
type = "LSTM";
|
type = "LSTM";
|
||||||
@ -307,6 +308,7 @@ class RNNLayerImpl : public RNNLayer
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
RNNLayerImpl(const LayerParams& params)
|
RNNLayerImpl(const LayerParams& params)
|
||||||
|
: numX(0), numH(0), numO(0), numSamples(0), numTimestamps(0), numSamplesTotal(0), dtype(0)
|
||||||
{
|
{
|
||||||
setParamsFrom(params);
|
setParamsFrom(params);
|
||||||
type = "RNN";
|
type = "RNN";
|
||||||
|
@ -556,6 +556,8 @@ static long THDiskFile_readString(THFile *self, const char *format, char **str_)
|
|||||||
total += TBRS_BSZ;
|
total += TBRS_BSZ;
|
||||||
p = (char*)THRealloc(p, total);
|
p = (char*)THRealloc(p, total);
|
||||||
}
|
}
|
||||||
|
if (p == NULL)
|
||||||
|
THError("read error: failed to allocate buffer");
|
||||||
if (fgets(p+pos, total-pos, dfself->handle) == NULL) /* eof? */
|
if (fgets(p+pos, total-pos, dfself->handle) == NULL) /* eof? */
|
||||||
{
|
{
|
||||||
if(pos == 0L)
|
if(pos == 0L)
|
||||||
|
@ -876,7 +876,7 @@ struct TorchImporter : public ::cv::dnn::Importer
|
|||||||
return mergeId;
|
return mergeId;
|
||||||
}
|
}
|
||||||
else if (module->thName == "ConcatTable") {
|
else if (module->thName == "ConcatTable") {
|
||||||
int newId, splitId;
|
int newId = -1, splitId;
|
||||||
LayerParams splitParams;
|
LayerParams splitParams;
|
||||||
|
|
||||||
splitId = net.addLayer(generateLayerName("torchSplit"), "Split", splitParams);
|
splitId = net.addLayer(generateLayerName("torchSplit"), "Split", splitParams);
|
||||||
|
@ -720,6 +720,7 @@ BRISK_Impl::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _ma
|
|||||||
const BriskLongPair* max = longPairs_ + noLongPairs_;
|
const BriskLongPair* max = longPairs_ + noLongPairs_;
|
||||||
for (BriskLongPair* iter = longPairs_; iter < max; ++iter)
|
for (BriskLongPair* iter = longPairs_; iter < max; ++iter)
|
||||||
{
|
{
|
||||||
|
CV_Assert(iter->i < points_ && iter->j < points_);
|
||||||
t1 = *(_values + iter->i);
|
t1 = *(_values + iter->i);
|
||||||
t2 = *(_values + iter->j);
|
t2 = *(_values + iter->j);
|
||||||
const int delta_t = (t1 - t2);
|
const int delta_t = (t1 - t2);
|
||||||
|
@ -80,9 +80,11 @@ NNIndex<Distance>* load_saved_index(const Matrix<typename Distance::ElementType>
|
|||||||
}
|
}
|
||||||
IndexHeader header = load_header(fin);
|
IndexHeader header = load_header(fin);
|
||||||
if (header.data_type != Datatype<ElementType>::type()) {
|
if (header.data_type != Datatype<ElementType>::type()) {
|
||||||
|
fclose(fin);
|
||||||
throw FLANNException("Datatype of saved index is different than of the one to be created.");
|
throw FLANNException("Datatype of saved index is different than of the one to be created.");
|
||||||
}
|
}
|
||||||
if ((size_t(header.rows) != dataset.rows)||(size_t(header.cols) != dataset.cols)) {
|
if ((size_t(header.rows) != dataset.rows)||(size_t(header.cols) != dataset.cols)) {
|
||||||
|
fclose(fin);
|
||||||
throw FLANNException("The index saved belongs to a different dataset");
|
throw FLANNException("The index saved belongs to a different dataset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1617,6 +1617,10 @@ CV_IMPL void cvSetTrackbarPos( const char* trackbar_name, const char* window_nam
|
|||||||
if( pos > trackbar->maxval )
|
if( pos > trackbar->maxval )
|
||||||
pos = trackbar->maxval;
|
pos = trackbar->maxval;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_ERROR( CV_StsNullPtr, "No trackbar found" );
|
||||||
|
}
|
||||||
|
|
||||||
CV_LOCK_MUTEX();
|
CV_LOCK_MUTEX();
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ RBaseStream::RBaseStream()
|
|||||||
{
|
{
|
||||||
m_start = m_end = m_current = 0;
|
m_start = m_end = m_current = 0;
|
||||||
m_file = 0;
|
m_file = 0;
|
||||||
|
m_block_pos = 0;
|
||||||
m_block_size = BS_DEF_BLOCK_SIZE;
|
m_block_size = BS_DEF_BLOCK_SIZE;
|
||||||
m_is_opened = false;
|
m_is_opened = false;
|
||||||
m_allocated = false;
|
m_allocated = false;
|
||||||
|
@ -208,9 +208,12 @@ bool ExrDecoder::readData( Mat& img )
|
|||||||
|
|
||||||
xstep = m_native_depth ? 4 : 1;
|
xstep = m_native_depth ? 4 : 1;
|
||||||
|
|
||||||
|
AutoBuffer<char> copy_buffer;
|
||||||
|
|
||||||
if( !m_native_depth || (!color && m_iscolor ))
|
if( !m_native_depth || (!color && m_iscolor ))
|
||||||
{
|
{
|
||||||
buffer = (char *)new float[ m_width * 3 ];
|
copy_buffer.allocate(sizeof(float) * m_width * 3);
|
||||||
|
buffer = copy_buffer;
|
||||||
ystep = 0;
|
ystep = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -388,11 +391,6 @@ bool ExrDecoder::readData( Mat& img )
|
|||||||
|
|
||||||
close();
|
close();
|
||||||
|
|
||||||
if( !m_native_depth || (!color && m_iscolor ))
|
|
||||||
{
|
|
||||||
delete[] buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ int my_jpeg_load_dht (struct jpeg_decompress_struct *info, unsigned char *dht,
|
|||||||
|
|
||||||
if (index & 0x10)
|
if (index & 0x10)
|
||||||
{
|
{
|
||||||
index -= 0x10;
|
index &= ~0x10;
|
||||||
hufftbl = &ac_tables[index];
|
hufftbl = &ac_tables[index];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -525,7 +525,7 @@ icvFetchContour( schar *ptr,
|
|||||||
int prev_s = -1, s, s_end;
|
int prev_s = -1, s, s_end;
|
||||||
int method = _method - 1;
|
int method = _method - 1;
|
||||||
|
|
||||||
assert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
|
CV_DbgAssert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
|
||||||
|
|
||||||
/* initialize local state */
|
/* initialize local state */
|
||||||
CV_INIT_3X3_DELTAS( deltas, step, 1 );
|
CV_INIT_3X3_DELTAS( deltas, step, 1 );
|
||||||
@ -557,6 +557,7 @@ icvFetchContour( schar *ptr,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
i3 = i0;
|
i3 = i0;
|
||||||
|
CV_Assert(i3 != NULL);
|
||||||
prev_s = s ^ 4;
|
prev_s = s ^ 4;
|
||||||
|
|
||||||
/* follow border */
|
/* follow border */
|
||||||
@ -568,6 +569,7 @@ icvFetchContour( schar *ptr,
|
|||||||
while( s < MAX_SIZE - 1 )
|
while( s < MAX_SIZE - 1 )
|
||||||
{
|
{
|
||||||
i4 = i3 + deltas[++s];
|
i4 = i3 + deltas[++s];
|
||||||
|
CV_Assert(i4 != NULL);
|
||||||
if( *i4 != 0 )
|
if( *i4 != 0 )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -615,7 +617,7 @@ icvFetchContour( schar *ptr,
|
|||||||
if( _method != CV_CHAIN_CODE )
|
if( _method != CV_CHAIN_CODE )
|
||||||
cvBoundingRect( contour, 1 );
|
cvBoundingRect( contour, 1 );
|
||||||
|
|
||||||
assert( (writer.seq->total == 0 && writer.seq->first == 0) ||
|
CV_DbgAssert( (writer.seq->total == 0 && writer.seq->first == 0) ||
|
||||||
writer.seq->total > writer.seq->first->count ||
|
writer.seq->total > writer.seq->first->count ||
|
||||||
(writer.seq->first->prev == writer.seq->first &&
|
(writer.seq->first->prev == writer.seq->first &&
|
||||||
writer.seq->first->next == writer.seq->first) );
|
writer.seq->first->next == writer.seq->first) );
|
||||||
@ -638,7 +640,7 @@ icvTraceContour( schar *ptr, int step, schar *stop_ptr, int is_hole )
|
|||||||
CV_INIT_3X3_DELTAS( deltas, step, 1 );
|
CV_INIT_3X3_DELTAS( deltas, step, 1 );
|
||||||
memcpy( deltas + 8, deltas, 8 * sizeof( deltas[0] ));
|
memcpy( deltas + 8, deltas, 8 * sizeof( deltas[0] ));
|
||||||
|
|
||||||
assert( (*i0 & -2) != 0 );
|
CV_DbgAssert( (*i0 & -2) != 0 );
|
||||||
|
|
||||||
s_end = s = is_hole ? 0 : 4;
|
s_end = s = is_hole ? 0 : 4;
|
||||||
|
|
||||||
@ -650,6 +652,7 @@ icvTraceContour( schar *ptr, int step, schar *stop_ptr, int is_hole )
|
|||||||
while( *i1 == 0 && s != s_end );
|
while( *i1 == 0 && s != s_end );
|
||||||
|
|
||||||
i3 = i0;
|
i3 = i0;
|
||||||
|
CV_Assert(i3 != NULL);
|
||||||
|
|
||||||
/* check single pixel domain */
|
/* check single pixel domain */
|
||||||
if( s != s_end )
|
if( s != s_end )
|
||||||
@ -662,6 +665,7 @@ icvTraceContour( schar *ptr, int step, schar *stop_ptr, int is_hole )
|
|||||||
while( s < MAX_SIZE - 1 )
|
while( s < MAX_SIZE - 1 )
|
||||||
{
|
{
|
||||||
i4 = i3 + deltas[++s];
|
i4 = i3 + deltas[++s];
|
||||||
|
CV_Assert(i4 != NULL);
|
||||||
if( *i4 != 0 )
|
if( *i4 != 0 )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -693,8 +697,8 @@ icvFetchContourEx( schar* ptr,
|
|||||||
int prev_s = -1, s, s_end;
|
int prev_s = -1, s, s_end;
|
||||||
int method = _method - 1;
|
int method = _method - 1;
|
||||||
|
|
||||||
assert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
|
CV_DbgAssert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
|
||||||
assert( 1 < nbd && nbd < 128 );
|
CV_DbgAssert( 1 < nbd && nbd < 128 );
|
||||||
|
|
||||||
/* initialize local state */
|
/* initialize local state */
|
||||||
CV_INIT_3X3_DELTAS( deltas, step, 1 );
|
CV_INIT_3X3_DELTAS( deltas, step, 1 );
|
||||||
@ -799,7 +803,7 @@ icvFetchContourEx( schar* ptr,
|
|||||||
if( _method != CV_CHAIN_CODE )
|
if( _method != CV_CHAIN_CODE )
|
||||||
((CvContour*)contour)->rect = rect;
|
((CvContour*)contour)->rect = rect;
|
||||||
|
|
||||||
assert( (writer.seq->total == 0 && writer.seq->first == 0) ||
|
CV_DbgAssert( (writer.seq->total == 0 && writer.seq->first == 0) ||
|
||||||
writer.seq->total > writer.seq->first->count ||
|
writer.seq->total > writer.seq->first->count ||
|
||||||
(writer.seq->first->prev == writer.seq->first &&
|
(writer.seq->first->prev == writer.seq->first &&
|
||||||
writer.seq->first->next == writer.seq->first) );
|
writer.seq->first->next == writer.seq->first) );
|
||||||
@ -882,7 +886,7 @@ icvFetchContourEx_32s( int* ptr,
|
|||||||
const int nbd0 = ccomp_val | new_flag;
|
const int nbd0 = ccomp_val | new_flag;
|
||||||
const int nbd1 = nbd0 | right_flag;
|
const int nbd1 = nbd0 | right_flag;
|
||||||
|
|
||||||
assert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
|
CV_DbgAssert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
|
||||||
|
|
||||||
/* initialize local state */
|
/* initialize local state */
|
||||||
CV_INIT_3X3_DELTAS( deltas, step, 1 );
|
CV_INIT_3X3_DELTAS( deltas, step, 1 );
|
||||||
@ -984,7 +988,7 @@ icvFetchContourEx_32s( int* ptr,
|
|||||||
if( _method != CV_CHAIN_CODE )
|
if( _method != CV_CHAIN_CODE )
|
||||||
((CvContour*)contour)->rect = rect;
|
((CvContour*)contour)->rect = rect;
|
||||||
|
|
||||||
assert( (writer.seq->total == 0 && writer.seq->first == 0) ||
|
CV_DbgAssert( (writer.seq->total == 0 && writer.seq->first == 0) ||
|
||||||
writer.seq->total > writer.seq->first->count ||
|
writer.seq->total > writer.seq->first->count ||
|
||||||
(writer.seq->first->prev == writer.seq->first &&
|
(writer.seq->first->prev == writer.seq->first &&
|
||||||
writer.seq->first->next == writer.seq->first) );
|
writer.seq->first->next == writer.seq->first) );
|
||||||
|
@ -773,6 +773,7 @@ icvNewSolution( CvEMDState * state )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* remove the leaving basic variable */
|
/* remove the leaving basic variable */
|
||||||
|
CV_Assert(leave_x != NULL);
|
||||||
i = leave_x->i;
|
i = leave_x->i;
|
||||||
j = leave_x->j;
|
j = leave_x->j;
|
||||||
state->is_x[i][j] = 0;
|
state->is_x[i][j] = 0;
|
||||||
|
@ -70,16 +70,10 @@ BaseFilter::~BaseFilter() {}
|
|||||||
void BaseFilter::reset() {}
|
void BaseFilter::reset() {}
|
||||||
|
|
||||||
FilterEngine::FilterEngine()
|
FilterEngine::FilterEngine()
|
||||||
|
: srcType(-1), dstType(-1), bufType(-1), maxWidth(0), wholeSize(-1, -1), dx1(0), dx2(0),
|
||||||
|
rowBorderType(BORDER_REPLICATE), columnBorderType(BORDER_REPLICATE),
|
||||||
|
borderElemSize(0), bufStep(0), startY(0), startY0(0), endY(0), rowCount(0), dstY(0)
|
||||||
{
|
{
|
||||||
srcType = dstType = bufType = -1;
|
|
||||||
rowBorderType = columnBorderType = BORDER_REPLICATE;
|
|
||||||
bufStep = startY = startY0 = endY = rowCount = dstY = 0;
|
|
||||||
maxWidth = 0;
|
|
||||||
|
|
||||||
wholeSize = Size(-1,-1);
|
|
||||||
dx1 = 0;
|
|
||||||
borderElemSize = 0;
|
|
||||||
dx2 = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,12 +83,10 @@ FilterEngine::FilterEngine( const Ptr<BaseFilter>& _filter2D,
|
|||||||
int _srcType, int _dstType, int _bufType,
|
int _srcType, int _dstType, int _bufType,
|
||||||
int _rowBorderType, int _columnBorderType,
|
int _rowBorderType, int _columnBorderType,
|
||||||
const Scalar& _borderValue )
|
const Scalar& _borderValue )
|
||||||
|
: srcType(-1), dstType(-1), bufType(-1), maxWidth(0), wholeSize(-1, -1), dx1(0), dx2(0),
|
||||||
|
rowBorderType(BORDER_REPLICATE), columnBorderType(BORDER_REPLICATE),
|
||||||
|
borderElemSize(0), bufStep(0), startY(0), startY0(0), endY(0), rowCount(0), dstY(0)
|
||||||
{
|
{
|
||||||
startY0 = 0;
|
|
||||||
endY = 0;
|
|
||||||
dstY = 0;
|
|
||||||
dx2 = 0;
|
|
||||||
rowCount = 0;
|
|
||||||
init(_filter2D, _rowFilter, _columnFilter, _srcType, _dstType, _bufType,
|
init(_filter2D, _rowFilter, _columnFilter, _srcType, _dstType, _bufType,
|
||||||
_rowBorderType, _columnBorderType, _borderValue);
|
_rowBorderType, _columnBorderType, _borderValue);
|
||||||
}
|
}
|
||||||
@ -194,6 +186,7 @@ int FilterEngine::start(const Size &_wholeSize, const Size &sz, const Point &ofs
|
|||||||
srcRow.resize(esz*(maxWidth + ksize.width - 1));
|
srcRow.resize(esz*(maxWidth + ksize.width - 1));
|
||||||
if( columnBorderType == BORDER_CONSTANT )
|
if( columnBorderType == BORDER_CONSTANT )
|
||||||
{
|
{
|
||||||
|
CV_Assert(constVal != NULL);
|
||||||
constBorderRow.resize(getElemSize(bufType)*(maxWidth + ksize.width - 1 + VEC_ALIGN));
|
constBorderRow.resize(getElemSize(bufType)*(maxWidth + ksize.width - 1 + VEC_ALIGN));
|
||||||
uchar *dst = alignPtr(&constBorderRow[0], VEC_ALIGN), *tdst;
|
uchar *dst = alignPtr(&constBorderRow[0], VEC_ALIGN), *tdst;
|
||||||
int n = (int)constBorderValue.size(), N;
|
int n = (int)constBorderValue.size(), N;
|
||||||
@ -227,6 +220,7 @@ int FilterEngine::start(const Size &_wholeSize, const Size &sz, const Point &ofs
|
|||||||
{
|
{
|
||||||
if( rowBorderType == BORDER_CONSTANT )
|
if( rowBorderType == BORDER_CONSTANT )
|
||||||
{
|
{
|
||||||
|
CV_Assert(constVal != NULL);
|
||||||
int nr = isSeparable() ? 1 : (int)rows.size();
|
int nr = isSeparable() ? 1 : (int)rows.size();
|
||||||
for( i = 0; i < nr; i++ )
|
for( i = 0; i < nr; i++ )
|
||||||
{
|
{
|
||||||
|
@ -1000,6 +1000,7 @@ double LineSegmentDetectorImpl::rect_nfa(const rect& rec) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CV_Assert(leftmost != NULL);
|
||||||
leftmost->taken = true;
|
leftmost->taken = true;
|
||||||
|
|
||||||
// Find rightmost untaken point;
|
// Find rightmost untaken point;
|
||||||
@ -1018,6 +1019,7 @@ double LineSegmentDetectorImpl::rect_nfa(const rect& rec) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CV_Assert(rightmost != NULL);
|
||||||
rightmost->taken = true;
|
rightmost->taken = true;
|
||||||
|
|
||||||
// Find last untaken point;
|
// Find last untaken point;
|
||||||
@ -1036,6 +1038,7 @@ double LineSegmentDetectorImpl::rect_nfa(const rect& rec) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CV_Assert(tailp != NULL);
|
||||||
tailp->taken = true;
|
tailp->taken = true;
|
||||||
|
|
||||||
double flstep = (min_y->p.y != leftmost->p.y) ?
|
double flstep = (min_y->p.y != leftmost->p.y) ?
|
||||||
|
@ -2507,6 +2507,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
|
|||||||
h_fine[ 16 * (n*(16*c+(x>>4)) + j) + (x & 0xF) ] op
|
h_fine[ 16 * (n*(16*c+(x>>4)) + j) + (x & 0xF) ] op
|
||||||
|
|
||||||
int cn = _dst.channels(), m = _dst.rows, r = (ksize-1)/2;
|
int cn = _dst.channels(), m = _dst.rows, r = (ksize-1)/2;
|
||||||
|
CV_Assert(cn > 0 && cn <= 4);
|
||||||
size_t sstep = _src.step, dstep = _dst.step;
|
size_t sstep = _src.step, dstep = _dst.step;
|
||||||
Histogram CV_DECL_ALIGNED(16) H[4];
|
Histogram CV_DECL_ALIGNED(16) H[4];
|
||||||
HT CV_DECL_ALIGNED(16) luc[4][16];
|
HT CV_DECL_ALIGNED(16) luc[4][16];
|
||||||
@ -2712,6 +2713,7 @@ medianBlur_8u_Om( const Mat& _src, Mat& _dst, int m )
|
|||||||
int src_step = (int)_src.step, dst_step = (int)_dst.step;
|
int src_step = (int)_src.step, dst_step = (int)_dst.step;
|
||||||
int cn = _src.channels();
|
int cn = _src.channels();
|
||||||
const uchar* src_max = src + size.height*src_step;
|
const uchar* src_max = src + size.height*src_step;
|
||||||
|
CV_Assert(cn > 0 && cn <= 4);
|
||||||
|
|
||||||
#define UPDATE_ACC01( pix, cn, op ) \
|
#define UPDATE_ACC01( pix, cn, op ) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -888,12 +888,14 @@ static void common_matchTemplate( Mat& img, Mat& templ, Mat& result, int method,
|
|||||||
templNorm = std::sqrt(templNorm);
|
templNorm = std::sqrt(templNorm);
|
||||||
templNorm /= std::sqrt(invArea); // care of accuracy here
|
templNorm /= std::sqrt(invArea); // care of accuracy here
|
||||||
|
|
||||||
|
CV_Assert(sqsum.data != NULL);
|
||||||
q0 = (double*)sqsum.data;
|
q0 = (double*)sqsum.data;
|
||||||
q1 = q0 + templ.cols*cn;
|
q1 = q0 + templ.cols*cn;
|
||||||
q2 = (double*)(sqsum.data + templ.rows*sqsum.step);
|
q2 = (double*)(sqsum.data + templ.rows*sqsum.step);
|
||||||
q3 = q2 + templ.cols*cn;
|
q3 = q2 + templ.cols*cn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CV_Assert(sum.data != NULL);
|
||||||
double* p0 = (double*)sum.data;
|
double* p0 = (double*)sum.data;
|
||||||
double* p1 = p0 + templ.cols*cn;
|
double* p1 = p0 + templ.cols*cn;
|
||||||
double* p2 = (double*)(sum.data + templ.rows*sum.step);
|
double* p2 = (double*)(sum.data + templ.rows*sum.step);
|
||||||
|
@ -1442,6 +1442,7 @@ float DTreesImpl::predictTrees( const Range& range, const Mat& sample, int flags
|
|||||||
CV_Error( CV_StsBadArg,
|
CV_Error( CV_StsBadArg,
|
||||||
"one of input categorical variable is not an integer" );
|
"one of input categorical variable is not an integer" );
|
||||||
|
|
||||||
|
CV_Assert(cmap != NULL);
|
||||||
while( a < b )
|
while( a < b )
|
||||||
{
|
{
|
||||||
c = (a + b) >> 1;
|
c = (a + b) >> 1;
|
||||||
|
@ -316,7 +316,7 @@ protected:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
//new grouping function with using meanshift
|
//new grouping function with using meanshift
|
||||||
static void groupRectangles_meanshift(std::vector<Rect>& rectList, double detectThreshold, std::vector<double>* foundWeights,
|
static void groupRectangles_meanshift(std::vector<Rect>& rectList, double detectThreshold, std::vector<double>& foundWeights,
|
||||||
std::vector<double>& scales, Size winDetSize)
|
std::vector<double>& scales, Size winDetSize)
|
||||||
{
|
{
|
||||||
int detectionCount = (int)rectList.size();
|
int detectionCount = (int)rectList.size();
|
||||||
@ -326,14 +326,13 @@ static void groupRectangles_meanshift(std::vector<Rect>& rectList, double detect
|
|||||||
|
|
||||||
for (int i=0; i < detectionCount; i++)
|
for (int i=0; i < detectionCount; i++)
|
||||||
{
|
{
|
||||||
hitWeights[i] = (*foundWeights)[i];
|
hitWeights[i] = foundWeights[i];
|
||||||
hitCenter = (rectList[i].tl() + rectList[i].br())*(0.5); //center of rectangles
|
hitCenter = (rectList[i].tl() + rectList[i].br())*(0.5); //center of rectangles
|
||||||
hits[i] = Point3d(hitCenter.x, hitCenter.y, std::log(scales[i]));
|
hits[i] = Point3d(hitCenter.x, hitCenter.y, std::log(scales[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
rectList.clear();
|
rectList.clear();
|
||||||
if (foundWeights)
|
foundWeights.clear();
|
||||||
foundWeights->clear();
|
|
||||||
|
|
||||||
double logZ = std::log(1.3);
|
double logZ = std::log(1.3);
|
||||||
Point3d smothing(8, 16, logZ);
|
Point3d smothing(8, 16, logZ);
|
||||||
@ -355,7 +354,7 @@ static void groupRectangles_meanshift(std::vector<Rect>& rectList, double detect
|
|||||||
if (resultWeights[i] > detectThreshold)
|
if (resultWeights[i] > detectThreshold)
|
||||||
{
|
{
|
||||||
rectList.push_back(resultRect);
|
rectList.push_back(resultRect);
|
||||||
foundWeights->push_back(resultWeights[i]);
|
foundWeights.push_back(resultWeights[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -387,7 +386,7 @@ void groupRectangles_meanshift(std::vector<Rect>& rectList, std::vector<double>&
|
|||||||
{
|
{
|
||||||
CV_INSTRUMENT_REGION()
|
CV_INSTRUMENT_REGION()
|
||||||
|
|
||||||
groupRectangles_meanshift(rectList, detectThreshold, &foundWeights, foundScales, winDetSize);
|
groupRectangles_meanshift(rectList, detectThreshold, foundWeights, foundScales, winDetSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -494,6 +494,7 @@ void EmdL1::initBVTree()
|
|||||||
}
|
}
|
||||||
if(pNxtN != pCurN->pParent)
|
if(pNxtN != pCurN->pParent)
|
||||||
{
|
{
|
||||||
|
CV_Assert(pNxtN != NULL);
|
||||||
pNxtE = pNxtN->pChild;
|
pNxtE = pNxtN->pChild;
|
||||||
if(pNxtE && pNxtE->pChild==pCurN) // has connection
|
if(pNxtE && pNxtE->pChild==pCurN) // has connection
|
||||||
{
|
{
|
||||||
@ -592,6 +593,7 @@ void EmdL1::findNewSolution()
|
|||||||
findLoopFromEnterBV();
|
findLoopFromEnterBV();
|
||||||
// Modify flow values along the loop
|
// Modify flow values along the loop
|
||||||
cvPEmdEdge pE = NULL;
|
cvPEmdEdge pE = NULL;
|
||||||
|
CV_Assert(m_pLeave != NULL);
|
||||||
float minFlow = m_pLeave->flow;
|
float minFlow = m_pLeave->flow;
|
||||||
int k;
|
int k;
|
||||||
for(k=0; k<m_iFrom; k++)
|
for(k=0; k<m_iFrom; k++)
|
||||||
|
@ -447,17 +447,19 @@ namespace
|
|||||||
{
|
{
|
||||||
CV_OCL_RUN(_dst.isUMat(),
|
CV_OCL_RUN(_dst.isUMat(),
|
||||||
ocl_calcBtvRegularization(_src, _dst, btvKernelSize, ubtvWeights))
|
ocl_calcBtvRegularization(_src, _dst, btvKernelSize, ubtvWeights))
|
||||||
(void)ubtvWeights;
|
CV_UNUSED(ubtvWeights);
|
||||||
|
if (_src.channels() == 1)
|
||||||
typedef void (*func_t)(InputArray _src, OutputArray _dst, int btvKernelSize, const std::vector<float>& btvWeights);
|
|
||||||
static const func_t funcs[] =
|
|
||||||
{
|
{
|
||||||
0, calcBtvRegularizationImpl<float>, 0, calcBtvRegularizationImpl<Point3f>, 0
|
calcBtvRegularizationImpl<float>(_src, _dst, btvKernelSize, btvWeights);
|
||||||
};
|
}
|
||||||
|
else if (_src.channels() == 3)
|
||||||
const func_t func = funcs[_src.channels()];
|
{
|
||||||
CV_Assert(func != 0);
|
calcBtvRegularizationImpl<Point3f>(_src, _dst, btvKernelSize, btvWeights);
|
||||||
func(_src, _dst, btvKernelSize, btvWeights);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CV_Error(Error::StsBadArg, "Unsupported number of channels in _src");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BTVL1_Base : public cv::superres::SuperResolution
|
class BTVL1_Base : public cv::superres::SuperResolution
|
||||||
|
@ -200,10 +200,11 @@ namespace
|
|||||||
|
|
||||||
void convertToDepth(InputArray src, OutputArray dst, int depth)
|
void convertToDepth(InputArray src, OutputArray dst, int depth)
|
||||||
{
|
{
|
||||||
CV_Assert( src.depth() <= CV_64F );
|
const int sdepth = src.depth();
|
||||||
|
CV_Assert( sdepth <= CV_64F );
|
||||||
CV_Assert( depth == CV_8U || depth == CV_32F );
|
CV_Assert( depth == CV_8U || depth == CV_32F );
|
||||||
|
|
||||||
static const double maxVals[] =
|
static const double maxVals[CV_64F + 1] =
|
||||||
{
|
{
|
||||||
(double)std::numeric_limits<uchar>::max(),
|
(double)std::numeric_limits<uchar>::max(),
|
||||||
(double)std::numeric_limits<schar>::max(),
|
(double)std::numeric_limits<schar>::max(),
|
||||||
@ -214,7 +215,7 @@ namespace
|
|||||||
1.0,
|
1.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const double scale = maxVals[depth] / maxVals[src.depth()];
|
const double scale = maxVals[depth] / maxVals[sdepth];
|
||||||
|
|
||||||
switch (src.kind())
|
switch (src.kind())
|
||||||
{
|
{
|
||||||
|
@ -654,6 +654,7 @@ void cv::detail::LKTrackerInvoker::operator()(const Range& range) const
|
|||||||
prevDelta = delta;
|
prevDelta = delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CV_Assert(status != NULL);
|
||||||
if( status[ptidx] && err && level == 0 && (flags & OPTFLOW_LK_GET_MIN_EIGENVALS) == 0 )
|
if( status[ptidx] && err && level == 0 && (flags & OPTFLOW_LK_GET_MIN_EIGENVALS) == 0 )
|
||||||
{
|
{
|
||||||
Point2f nextPoint = nextPts[ptidx] - halfWin;
|
Point2f nextPoint = nextPts[ptidx] - halfWin;
|
||||||
|
@ -209,7 +209,7 @@ static char* icvExtractPattern(const char *filename, unsigned *offset)
|
|||||||
char *at = strchr(name, '%');
|
char *at = strchr(name, '%');
|
||||||
if(at)
|
if(at)
|
||||||
{
|
{
|
||||||
int dummy;
|
unsigned int dummy;
|
||||||
if(sscanf(at + 1, "%ud", &dummy) != 1)
|
if(sscanf(at + 1, "%ud", &dummy) != 1)
|
||||||
return 0;
|
return 0;
|
||||||
name = strdup(filename);
|
name = strdup(filename);
|
||||||
@ -236,6 +236,7 @@ static char* icvExtractPattern(const char *filename, unsigned *offset)
|
|||||||
|
|
||||||
int size = (int)strlen(filename) + 20;
|
int size = (int)strlen(filename) + 20;
|
||||||
name = (char *)malloc(size);
|
name = (char *)malloc(size);
|
||||||
|
CV_Assert(name != NULL);
|
||||||
strncpy(name, filename, at - filename);
|
strncpy(name, filename, at - filename);
|
||||||
name[at - filename] = 0;
|
name[at - filename] = 0;
|
||||||
|
|
||||||
@ -245,7 +246,7 @@ static char* icvExtractPattern(const char *filename, unsigned *offset)
|
|||||||
char *extension;
|
char *extension;
|
||||||
for(i = 0, extension = at; isdigit(at[i]); i++, extension++)
|
for(i = 0, extension = at; isdigit(at[i]); i++, extension++)
|
||||||
;
|
;
|
||||||
char places[10];
|
char places[13] = {0};
|
||||||
sprintf(places, "%dd", i);
|
sprintf(places, "%dd", i);
|
||||||
|
|
||||||
strcat(name, places);
|
strcat(name, places);
|
||||||
|
Loading…
Reference in New Issue
Block a user