Commit e975259c authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

several fixes in gpu module

fixed iterations>1 case in morphological operations
fixed possible access violation in HSV2RGB
fixed the case learningRate==0 in BackgroundSubtractorMOG2
parent 9956c428
...@@ -251,8 +251,7 @@ void cv::gpu::MOG2_GPU::operator()(const GpuMat& frame, GpuMat& fgmask, float le ...@@ -251,8 +251,7 @@ void cv::gpu::MOG2_GPU::operator()(const GpuMat& frame, GpuMat& fgmask, float le
learningRate = learningRate >= 0.0f && nframes_ > 1 ? learningRate : 1.0f / std::min(2 * nframes_, history); learningRate = learningRate >= 0.0f && nframes_ > 1 ? learningRate : 1.0f / std::min(2 * nframes_, history);
CV_Assert(learningRate >= 0.0f); CV_Assert(learningRate >= 0.0f);
if (learningRate > 0.0f) mog2_gpu(frame, frame.channels(), fgmask, bgmodelUsedModes_, weight_, variance_, mean_, learningRate, -learningRate * fCT, bShadowDetection, StreamAccessor::getStream(stream));
mog2_gpu(frame, frame.channels(), fgmask, bgmodelUsedModes_, weight_, variance_, mean_, learningRate, -learningRate * fCT, bShadowDetection, StreamAccessor::getStream(stream));
} }
void cv::gpu::MOG2_GPU::getBackgroundImage(GpuMat& backgroundImage, Stream& stream) const void cv::gpu::MOG2_GPU::getBackgroundImage(GpuMat& backgroundImage, Stream& stream) const
......
...@@ -576,8 +576,10 @@ namespace ...@@ -576,8 +576,10 @@ namespace
else if (iterations > 1 && countNonZero(_kernel) == _kernel.rows * _kernel.cols) else if (iterations > 1 && countNonZero(_kernel) == _kernel.rows * _kernel.cols)
{ {
anchor = Point(anchor.x * iterations, anchor.y * iterations); anchor = Point(anchor.x * iterations, anchor.y * iterations);
kernel = getStructuringElement(MORPH_RECT, Size(ksize.width + iterations * (ksize.width - 1), kernel = getStructuringElement(MORPH_RECT,
ksize.height + iterations * (ksize.height - 1)), anchor); Size(ksize.width + (iterations - 1) * (ksize.width - 1),
ksize.height + (iterations - 1) * (ksize.height - 1)),
anchor);
iterations = 1; iterations = 1;
} }
else else
......
...@@ -1140,6 +1140,12 @@ namespace cv { namespace gpu { namespace device ...@@ -1140,6 +1140,12 @@ namespace cv { namespace gpu { namespace device
int sector = __float2int_rd(h); int sector = __float2int_rd(h);
h -= sector; h -= sector;
if ( (unsigned)sector >= 6u )
{
sector = 0;
h = 0.f;
}
float tab[4]; float tab[4];
tab[0] = v; tab[0] = v;
tab[1] = v * (1.f - s); tab[1] = v * (1.f - s);
......
...@@ -64,10 +64,6 @@ namespace ...@@ -64,10 +64,6 @@ namespace
{ {
return fabs(v) > numeric_limits<float>::epsilon(); return fabs(v) > numeric_limits<float>::epsilon();
} }
/*bool notNull(double v)
{
return fabs(v) > numeric_limits<double>::epsilon();
}*/
class GHT_Pos : public GeneralizedHough class GHT_Pos : public GeneralizedHough
{ {
......
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