output = fopen( filename, "wb" );
if( output != NULL )
{
- int hasbg;
int i;
int inverse;
- hasbg = 0;
- hasbg = (bgfilename != NULL && icvInitBackgroundReaders( bgfilename,
+ const int hasbg = (bgfilename != NULL && icvInitBackgroundReaders( bgfilename,
Size( winwidth,winheight ) ) );
Mat sample( winheight, winwidth, CV_8UC1 );
CV_Assert(!corners.empty());
outsideCorners.clear();
//find two pairs of the most nearest corners
- int i, j, n = (int)corners.size();
+ const size_t n = corners.size();
#ifdef DEBUG_CIRCLES
Mat cornersImage(1024, 1248, CV_8UC1, Scalar(0));
imshow("corners", cornersImage);
#endif
- std::vector<Point2f> tangentVectors(corners.size());
- for(size_t k=0; k<corners.size(); k++)
+ std::vector<Point2f> tangentVectors(n);
+ for(size_t k=0; k < n; k++)
{
- Point2f diff = corners[(k + 1) % corners.size()] - corners[k];
+ Point2f diff = corners[(k + 1) % n] - corners[k];
tangentVectors[k] = diff * (1.0f / norm(diff));
}
//compute angles between all sides
- Mat cosAngles(n, n, CV_32FC1, 0.0f);
- for(i = 0; i < n; i++)
+ Mat cosAngles((int)n, (int)n, CV_32FC1, 0.0f);
+ for(size_t i = 0; i < n; i++)
{
- for(j = i + 1; j < n; j++)
+ for(size_t j = i + 1; j < n; j++)
{
float val = fabs(tangentVectors[i].dot(tangentVectors[j]));
- cosAngles.at<float>(i, j) = val;
- cosAngles.at<float>(j, i) = val;
+ cosAngles.at<float>((int)i, (int)j) = val;
+ cosAngles.at<float>((int)j, (int)i) = val;
}
}
const int bigDiff = 4;
if(maxIdx - minIdx == bigDiff)
{
- minIdx += n;
+ minIdx += (int)n;
std::swap(maxIdx, minIdx);
}
- if(maxIdx - minIdx != n - bigDiff)
+ if(maxIdx - minIdx != (int)n - bigDiff)
{
return;
}
void dls::build_coeff_matrix(const cv::Mat& pp, cv::Mat& Mtilde, cv::Mat& D)
{
- CV_Assert(!pp.empty());
+ CV_Assert(!pp.empty() && N > 0);
cv::Mat eye = cv::Mat::eye(3, 3, CV_64F);
// build coeff matrix
tmp = cv::norm(cur - mat(i + 1, j + 1)); // TODO cvtest
if (tmp < minNeibDist)
- tmp = minNeibDist;
+ minNeibDist = tmp;
tmp = cv::norm(cur - mat(i - 1, j + 1)); // TODO cvtest
if (tmp < minNeibDist)
- tmp = minNeibDist;
+ minNeibDist = tmp;
tmp = cv::norm(cur - mat(i + 1, j - 1)); // TODO cvtest
if (tmp < minNeibDist)
- tmp = minNeibDist;
+ minNeibDist = tmp;
tmp = cv::norm(cur - mat(i - 1, j - 1)); // TODO cvtest
if (tmp < minNeibDist)
- tmp = minNeibDist;
+ minNeibDist = tmp;
}
const double threshold = 0.25;
CV_PARSE_ERROR( "Key must start with \'\"\'" );
char * beg = ptr + 1;
- char * end = beg;
do {
++ptr;
if( *ptr != '"' )
CV_PARSE_ERROR( "Key must end with \'\"\'" );
- end = ptr;
+ const char * end = ptr;
ptr++;
ptr = icvJSONSkipSpaces( fs, ptr );
if ( ptr == 0 || fs->dummy_eof )
if ( *ptr == '{' )
{
CvFileNode* root_node = (CvFileNode*)cvSeqPush( fs->roots, 0 );
- ptr = icvJSONParseMap( fs, ptr, root_node );
+ icvJSONParseMap( fs, ptr, root_node );
}
else if ( *ptr == '[' )
{
CvFileNode* root_node = (CvFileNode*)cvSeqPush( fs->roots, 0 );
- ptr = icvJSONParseSeq( fs, ptr, root_node );
+ icvJSONParseSeq( fs, ptr, root_node );
}
else
{
*ptr++ = '\n';
*ptr++ = '\0';
::icvPuts( fs, fs->buffer_start );
- ptr = fs->buffer = fs->buffer_start;
+ fs->buffer = fs->buffer_start;
}
ptr = icvFSFlush(fs);
}
Size mSize(rng.uniform(minMSize, maxMSize), rng.uniform(minMSize, maxMSize));
size_t mvSize = rng.uniform(1, maxMvSize);
- int res = cvtest::TS::OK, curRes = res;
- curRes = run_case(CV_8U, mvSize, mSize, rng);
+ int res = cvtest::TS::OK;
+ int curRes = run_case(CV_8U, mvSize, mSize, rng);
res = curRes != cvtest::TS::OK ? curRes : res;
curRes = run_case(CV_8S, mvSize, mSize, rng);
int bufsz = 128; //enough for 14 doubles
AutoBuffer<uchar> buffer(bufsz);
size_t offset = 0;
- cv::Mat_<cv::Point2d> x(2, 3, (cv::Point2d*)(buffer.data()+offset)); offset += x.total()*x.elemSize();
- double& param1 = *(double*)(buffer.data()+offset); offset += sizeof(double);
- double& param2 = *(double*)(buffer.data()+offset); offset += sizeof(double);
+ cv::Mat_<cv::Point2d> x(2, 3, (cv::Point2d*)(buffer.data()+offset));
+ offset += x.total()*x.elemSize();
+ double& param1 = *(double*)(buffer.data()+offset);
+ offset += sizeof(double);
+ double& param2 = *(double*)(buffer.data()+offset);
param1 = -9; param2 = 2;
cv::theRNG().fill(x, cv::RNG::NORMAL, param1, param2);
int ngroups = ngroups_, batchSize = input_->size[0]*ngroups;
int outW = output_->size[3], outH = output_->size[2], outCn = output_->size[1]/ngroups;
int width = input_->size[3], height = input_->size[2], inpCn = input_->size[1]/ngroups;
- int nstripes = nstripes_;
+ const int nstripes = nstripes_;
int kernel_w = kernel_.width, kernel_h = kernel_.height;
int pad_w = pad_.width, pad_h = pad_.height;
int stride_w = stride_.width, stride_h = stride_.height;
int samplesPerStripe = std::max((batchSize + nstripes - 1)/nstripes, 1);
r.start *= samplesPerStripe;
r.end *= samplesPerStripe;
- nstripes *= samplesPerStripe;
stripeSize = outPlaneSize;
}
int c, j, k, n = nsrcs;
const float* coeffsptr = coeffs && !coeffs->empty() ? &coeffs->at(0) : 0;
float* dstptr0 = dst->ptr<float>();
- int blockSize0 = 1 << 12, blockSize = blockSize0;
+ int blockSize0 = 1 << 12, blockSize;
for( size_t ofs = stripeStart; ofs < stripeEnd; ofs += blockSize )
{
size_t num = total(shape(inp0.size), 0, startAxis);
size_t numPlanes = total(shape(inp0.size), startAxis, endAxis + 1);
+ CV_Assert(num * numPlanes != 0);
size_t planeSize = inp0.total() / (num * numPlanes);
for (size_t n = 0; n < num; ++n)
{
else
outTailShape_.assign(1, _numOut);
- int _numTimeStamps, _numSamples;
+ int _numSamples;
if (useTimestampDim)
{
CV_Assert(inp0.size() >= 2 && total(inp0, 2) == _numInp);
- _numTimeStamps = inp0[0];
_numSamples = inp0[1];
- outResShape.push_back(_numTimeStamps);
+ outResShape.push_back(inp0[0]);
}
else
{
CV_Assert(inp0.size() >= 2 && total(inp0, 1) == _numInp);
- _numTimeStamps = 1;
_numSamples = inp0[0];
}
{
// in this case, we have to analyze the situation more carefully:
// the values are gaussian blurred and then we really decide
- data = scores.ptr() + y_layer * scorescols + x_layer;
int smoothedcenter = 4 * center + 2 * (s_10 + s10 + s0_1 + s01) + s_1_1 + s1_1 + s_11 + s11;
for (unsigned int i = 0; i < deltasize; i += 2)
{
int s_2_2 = l.getAgastScore_5_8(x_layer + 1, y_layer + 1, 1);
max_below = std::max(s_2_2, max_below);
- max_below_float = subpixel2D(s_0_0, s_0_1, s_0_2, s_1_0, s_1_1, s_1_2, s_2_0, s_2_1, s_2_2, delta_x_below,
- delta_y_below);
+ subpixel2D(s_0_0, s_0_1, s_0_2, s_1_0, s_1_1, s_1_2, s_2_0, s_2_1, s_2_2, delta_x_below, delta_y_below);
max_below_float = (float)max_below;
}
else
is_out = true;
}
- is_out = false;
-
if (is_out == false) {
if (is_repeated == false) {
kpts.push_back(kpts_par_[i][j]);
CV_THROW (ExifParsingError());
}
m_stream.read( reinterpret_cast<char*>(&m_data[0]), exifSize - offsetToTiffHeader );
- count = m_stream.gcount();
exifFound = true;
break;
for(;;)
{
int code = m_strm.getWord();
- int len = code & 255;
+ const int len = code & 255;
code >>= 8;
if( len != 0 ) // encoded mode
{
else
{
int x_shift3 = (int)(line_end - data);
- int y_shift = m_height - y;
if( code == 2 )
{
x_shift3 = m_strm.getByte()*nch;
- y_shift = m_strm.getByte();
+ m_strm.getByte();
}
- len = x_shift3 + ((y_shift * width3) & ((code == 0) - 1));
-
if( color )
data = FillUniColor( data, line_end, step, width3,
y, m_height, x_shift3,
tmp += sprintf( buffer + tmp, "MAXVAL %d\n", (1 << img.elemSize1()*8) - 1);
if (fmt)
tmp += sprintf( buffer + tmp, "TUPLTYPE %s\n", fmt->name );
- tmp += sprintf( buffer + tmp, "ENDHDR\n" );
+ sprintf( buffer + tmp, "ENDHDR\n" );
strm.putBytes( buffer, (int)strlen(buffer) );
/* write data */
{
case 8:
m_type = CV_MAKETYPE(CV_8U, photometric > 1 ? wanted_channels : 1);
+ result = true;
break;
case 16:
m_type = CV_MAKETYPE(CV_16U, photometric > 1 ? wanted_channels : 1);
+ result = true;
break;
-
case 32:
m_type = CV_MAKETYPE(CV_32F, photometric > 1 ? 3 : 1);
+ result = true;
break;
case 64:
m_type = CV_MAKETYPE(CV_64F, photometric > 1 ? 3 : 1);
+ result = true;
break;
-
- default:
- result = false;
}
- result = true;
}
}
for( ;; )
{
CV_Assert(i3 != NULL);
- s_end = s;
s = std::min(s, MAX_SIZE - 1);
while( s < MAX_SIZE - 1 )
cv::Ptr<CvMemStorage> storage01;
CvSeq* first = 0;
- int i, j, k, n;
+ int j, k, n;
uchar* src_data = 0;
int img_step = 0;
// First line. None of runs is binded
tmp.pt.y = 0;
- i = 0;
CV_WRITE_SEQ_ELEM( tmp, writer );
upper_line = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer );
last_elem = tmp_prev;
tmp_prev->next = 0;
- for( i = 1; i < img_size.height; i++ )
+ for( int i = 1; i < img_size.height; i++ )
{
//------// Find runs in next line
src_data += img_step;
if( ax > ay )
{
- dx = ax;
dy = (dy ^ j) - j;
pt1.x ^= pt2.x & j;
pt2.x ^= pt1.x & j;
}
else
{
- dy = ay;
dx = (dx ^ i) - i;
pt1.x ^= pt2.x & i;
pt2.x ^= pt1.x & i;
if( ax > ay )
{
- dx = ax;
dy = (dy ^ j) - j;
pt1.x ^= pt2.x & j;
pt2.x ^= pt1.x & j;
}
else
{
- dy = ay;
dx = (dx ^ i) - i;
pt1.x ^= pt2.x & i;
pt2.x ^= pt1.x & i;
for( k = 1; k <= ksize2; k++ )
{
f = _mm_set1_ps(ky[k]);
- S = src[k] + i;
- S2 = src[-k] + i;
x0 = _mm_add_ps(_mm_load_ps(src[k]+i), _mm_load_ps(src[-k] + i));
s0 = _mm_add_ps(s0, _mm_mul_ps(x0, f));
}
int SymmColumnVec_32f_Unsymm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2)
{
int i = 0, k;
- const float *S, *S2;
+ const float *S2;
const __m128 d4 = _mm_set1_ps(delta);
const __m256 d8 = _mm256_set1_ps(delta);
{
__m256 f, s0 = d8, s1 = d8;
__m256 x0;
- S = src[0] + i;
for (k = 1; k <= ksize2; k++)
{
- S = src[k] + i;
+ const float *S = src[k] + i;
S2 = src[-k] + i;
f = _mm256_set1_ps(ky[k]);
x0 = _mm256_sub_ps(_mm256_loadu_ps(S), _mm256_loadu_ps(S2));
if( rect )
*rect = Rect();
- int i, connectivity = flags & 255;
+ int i;
union {
uchar b[4];
int i[4];
CV_Error( CV_StsBadArg, "Number of channels in input image must be 1 or 3" );
}
- if( connectivity == 0 )
- connectivity = 4;
- else if( connectivity != 4 && connectivity != 8 )
+ const int connectivity = flags & 255;
+ if( connectivity != 0 && connectivity != 4 && connectivity != 8 )
CV_Error( CV_StsBadFlag, "Connectivity must be 4, 0(=4) or 8" );
bool is_simple = mask.empty() && (flags & FLOODFILL_MASK_ONLY) == 0;
Mat planes[2];
NAryMatIterator it(arrays, planes);
double result = 0;
- int j, len = (int)it.size;
+ int j;
CV_Assert( H1.type() == H2.type() && H1.depth() == CV_32F );
{
const float* h1 = it.planes[0].ptr<float>();
const float* h2 = it.planes[1].ptr<float>();
- len = it.planes[0].rows*it.planes[0].cols*H1.channels();
+ const int len = it.planes[0].rows*it.planes[0].cols*H1.channels();
j = 0;
if( (method == CV_COMP_CHISQR) || (method == CV_COMP_CHISQR_ALT))
// Find peaks in maccum...
for( index = 0; index < sfn; index++ )
{
- i = 0;
int pos = (int)(lst.size() - 1);
if( pos < 0 || lst[pos].value < mcaccum[index] )
{
a = 1;
b = 2;
- c = 0;
// Main algorithm steps
prev_dEdw_sign[i] = Mat::zeros(weights[i].size(), CV_8S);
dEdw[i] = Mat::zeros(weights[i].size(), CV_64F);
}
-
+ CV_Assert(total > 0);
int dcount0 = max_buf_size/(2*total);
dcount0 = std::max( dcount0, 1 );
dcount0 = std::min( dcount0, count );
c->codec_type = AVMEDIA_TYPE_VIDEO;
// put sample parameters
- unsigned long long lbit_rate = static_cast<unsigned long long>(bitrate);
- lbit_rate += (bitrate / 4);
- lbit_rate = std::min(lbit_rate, static_cast<unsigned long long>(std::numeric_limits<int>::max()));
c->bit_rate = bitrate;
// took advice from
if(m_file_stream && strh.m_four_cc == STRH_CC)
{
- uint64_t next_strl_list = m_file_stream->tellg();
- next_strl_list += strh.m_size;
-
AviStreamHeader strm_hdr;
*m_file_stream >> strm_hdr;