mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Fixed issues found by static analysis (mostly DBZ)
This commit is contained in:
@@ -546,10 +546,10 @@ static bool ocl_Laplacian5(InputArray _src, OutputArray _dst,
|
||||
size_t lmsz = dev.localMemSize();
|
||||
size_t src_step = _src.step(), src_offset = _src.offset();
|
||||
const size_t tileSizeYmax = wgs / tileSizeX;
|
||||
CV_Assert(src_step != 0 && esz != 0);
|
||||
|
||||
// workaround for NVIDIA: 3 channel vector type takes 4*elem_size in local memory
|
||||
int loc_mem_cn = dev.vendorID() == ocl::Device::VENDOR_NVIDIA && cn == 3 ? 4 : cn;
|
||||
|
||||
if (((src_offset % src_step) % esz == 0) &&
|
||||
(
|
||||
(borderType == BORDER_CONSTANT || borderType == BORDER_REPLICATE) ||
|
||||
|
||||
@@ -4284,10 +4284,14 @@ static bool ocl_sepFilter2D_SinglePass(InputArray _src, OutputArray _dst,
|
||||
size_t src_step = _src.step(), src_offset = _src.offset();
|
||||
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
|
||||
|
||||
if ((src_offset % src_step) % esz != 0 || (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F)) ||
|
||||
!(borderType == BORDER_CONSTANT || borderType == BORDER_REPLICATE ||
|
||||
borderType == BORDER_REFLECT || borderType == BORDER_WRAP ||
|
||||
borderType == BORDER_REFLECT_101))
|
||||
if (esz == 0
|
||||
|| (src_offset % src_step) % esz != 0
|
||||
|| (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F))
|
||||
|| !(borderType == BORDER_CONSTANT
|
||||
|| borderType == BORDER_REPLICATE
|
||||
|| borderType == BORDER_REFLECT
|
||||
|| borderType == BORDER_WRAP
|
||||
|| borderType == BORDER_REFLECT_101))
|
||||
return false;
|
||||
|
||||
size_t lt2[2] = { optimizedSepFilterLocalWidth, optimizedSepFilterLocalHeight };
|
||||
|
||||
@@ -174,6 +174,7 @@ void GMM::addSample( int ci, const Vec3d color )
|
||||
|
||||
void GMM::endLearning()
|
||||
{
|
||||
CV_Assert(totalSampleCount > 0);
|
||||
const double variance = 0.01;
|
||||
for( int ci = 0; ci < componentsCount; ci++ )
|
||||
{
|
||||
|
||||
@@ -3286,6 +3286,7 @@ void cv::warpPolar(InputArray _src, OutputArray _dst, Size dsize,
|
||||
|
||||
if (!(flags & CV_WARP_INVERSE_MAP))
|
||||
{
|
||||
CV_Assert(!dsize.empty());
|
||||
double Kangle = CV_2PI / dsize.height;
|
||||
int phi, rho;
|
||||
|
||||
@@ -3332,6 +3333,7 @@ void cv::warpPolar(InputArray _src, OutputArray _dst, Size dsize,
|
||||
Mat src = _dst.getMat();
|
||||
Size ssize = _dst.size();
|
||||
ssize.height -= 2 * ANGLE_BORDER;
|
||||
CV_Assert(!ssize.empty());
|
||||
const double Kangle = CV_2PI / ssize.height;
|
||||
double Kmag;
|
||||
if (semiLog)
|
||||
|
||||
@@ -47,6 +47,7 @@ static const double eps = 1e-6;
|
||||
|
||||
static void fitLine2D_wods( const Point2f* points, int count, float *weights, float *line )
|
||||
{
|
||||
CV_Assert(count > 0);
|
||||
double x = 0, y = 0, x2 = 0, y2 = 0, xy = 0, w = 0;
|
||||
double dx2, dy2, dxy;
|
||||
int i;
|
||||
@@ -98,6 +99,7 @@ static void fitLine2D_wods( const Point2f* points, int count, float *weights, fl
|
||||
|
||||
static void fitLine3D_wods( const Point3f * points, int count, float *weights, float *line )
|
||||
{
|
||||
CV_Assert(count > 0);
|
||||
int i;
|
||||
float w0 = 0;
|
||||
float x0 = 0, y0 = 0, z0 = 0;
|
||||
|
||||
@@ -772,6 +772,7 @@ bool LineSegmentDetectorImpl::refine(std::vector<RegionPoint>& reg, double reg_a
|
||||
++n;
|
||||
}
|
||||
}
|
||||
CV_Assert(n > 0);
|
||||
double mean_angle = sum / double(n);
|
||||
// 2 * standard deviation
|
||||
double tau = 2.0 * sqrt((s_sum - 2.0 * mean_angle * sum) / double(n) + mean_angle * mean_angle);
|
||||
|
||||
@@ -495,6 +495,13 @@ static bool ocl_moments( InputArray _src, Moments& m, bool binary)
|
||||
const int TILE_SIZE = 32;
|
||||
const int K = 10;
|
||||
|
||||
Size sz = _src.getSz();
|
||||
int xtiles = divUp(sz.width, TILE_SIZE);
|
||||
int ytiles = divUp(sz.height, TILE_SIZE);
|
||||
int ntiles = xtiles*ytiles;
|
||||
if (ntiles == 0)
|
||||
return false;
|
||||
|
||||
ocl::Kernel k = ocl::Kernel("moments", ocl::imgproc::moments_oclsrc,
|
||||
format("-D TILE_SIZE=%d%s",
|
||||
TILE_SIZE,
|
||||
@@ -504,10 +511,6 @@ static bool ocl_moments( InputArray _src, Moments& m, bool binary)
|
||||
return false;
|
||||
|
||||
UMat src = _src.getUMat();
|
||||
Size sz = src.size();
|
||||
int xtiles = (sz.width + TILE_SIZE-1)/TILE_SIZE;
|
||||
int ytiles = (sz.height + TILE_SIZE-1)/TILE_SIZE;
|
||||
int ntiles = xtiles*ytiles;
|
||||
UMat umbuf(1, ntiles*K, CV_32S);
|
||||
|
||||
size_t globalsize[] = {(size_t)xtiles, std::max((size_t)TILE_SIZE, (size_t)sz.height)};
|
||||
|
||||
@@ -1709,6 +1709,7 @@ void cv::sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth,
|
||||
|
||||
cv::Mat cv::getGaussianKernel( int n, double sigma, int ktype )
|
||||
{
|
||||
CV_Assert(n > 0);
|
||||
const int SMALL_GAUSSIAN_SIZE = 7;
|
||||
static const float small_gaussian_tab[][SMALL_GAUSSIAN_SIZE] =
|
||||
{
|
||||
@@ -1747,6 +1748,7 @@ cv::Mat cv::getGaussianKernel( int n, double sigma, int ktype )
|
||||
}
|
||||
}
|
||||
|
||||
CV_DbgAssert(fabs(sum) > 0);
|
||||
sum = 1./sum;
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
@@ -5334,6 +5336,7 @@ public:
|
||||
wsum += w;
|
||||
}
|
||||
// overflow is not possible here => there is no need to use cv::saturate_cast
|
||||
CV_DbgAssert(fabs(wsum) > 0);
|
||||
dptr[j] = (uchar)cvRound(sum/wsum);
|
||||
}
|
||||
}
|
||||
@@ -5419,6 +5422,7 @@ public:
|
||||
sum_b += b*w; sum_g += g*w; sum_r += r*w;
|
||||
wsum += w;
|
||||
}
|
||||
CV_DbgAssert(fabs(wsum) > 0);
|
||||
wsum = 1.f/wsum;
|
||||
b0 = cvRound(sum_b*wsum);
|
||||
g0 = cvRound(sum_g*wsum);
|
||||
@@ -5678,6 +5682,7 @@ public:
|
||||
sum += val*w;
|
||||
wsum += w;
|
||||
}
|
||||
CV_DbgAssert(fabs(wsum) > 0);
|
||||
dptr[j] = (float)(sum/wsum);
|
||||
}
|
||||
}
|
||||
@@ -5768,6 +5773,7 @@ public:
|
||||
sum_b += b*w; sum_g += g*w; sum_r += r*w;
|
||||
wsum += w;
|
||||
}
|
||||
CV_DbgAssert(fabs(wsum) > 0);
|
||||
wsum = 1.f/wsum;
|
||||
b0 = sum_b*wsum;
|
||||
g0 = sum_g*wsum;
|
||||
|
||||
Reference in New Issue
Block a user