Commit 715887fc authored by Maksim Shabunin's avatar Maksim Shabunin

Coverity: fixed some negative argument issues

parent fc641e2b
......@@ -2331,10 +2331,10 @@ static void addChildContour(InputArrayOfArrays contours,
int h_next = hierarchy[i][0], h_prev = hierarchy[i][1],
v_next = hierarchy[i][2], v_prev = hierarchy[i][3];
seq[i].h_next = (size_t)h_next < ncontours ? &seq[h_next] : 0;
seq[i].h_prev = (size_t)h_prev < ncontours ? &seq[h_prev] : 0;
seq[i].v_next = (size_t)v_next < ncontours ? &seq[v_next] : 0;
seq[i].v_prev = (size_t)v_prev < ncontours ? &seq[v_prev] : 0;
seq[i].h_next = (0 <= h_next && h_next < (int)ncontours) ? &seq[h_next] : 0;
seq[i].h_prev = (0 <= h_prev && h_prev < (int)ncontours) ? &seq[h_prev] : 0;
seq[i].v_next = (0 <= v_next && v_next < (int)ncontours) ? &seq[v_next] : 0;
seq[i].v_prev = (0 <= v_prev && v_prev < (int)ncontours) ? &seq[v_prev] : 0;
if( v_next >= 0 )
addChildContour(contours, ncontours, hierarchy, v_next, seq, block);
......
......@@ -510,8 +510,11 @@ protected:
void calculateSum(std::vector<Mat>& x_contrast, std::vector<Mat>& y_contrast, Mat& sum)
{
sum = Mat::zeros(x_contrast[x_contrast.size() - 1].size(), CV_32F);
for(int i = (int)x_contrast.size() - 1; i >= 0; i--)
if (x_contrast.empty())
return;
const int last = (int)x_contrast.size() - 1;
sum = Mat::zeros(x_contrast[last].size(), CV_32F);
for(int i = last; i >= 0; i--)
{
Mat grad_x, grad_y;
getGradient(x_contrast[i], grad_x, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment