several fixes in gpu module
authorVladislav Vinogradov <vlad.vinogradov@itseez.com>
Tue, 11 Sep 2012 10:59:52 +0000 (14:59 +0400)
committerVladislav Vinogradov <vlad.vinogradov@itseez.com>
Tue, 11 Sep 2012 11:00:59 +0000 (15:00 +0400)
fixed iterations>1 case in morphological operations
fixed possible access violation in HSV2RGB
fixed the case learningRate==0 in BackgroundSubtractorMOG2

modules/gpu/src/bgfg_mog.cpp
modules/gpu/src/filtering.cpp
modules/gpu/src/opencv2/gpu/device/detail/color_detail.hpp
modules/imgproc/src/generalized_hough.cpp

index 94668e8..67cac76 100644 (file)
@@ -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);
     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
index 1e9fbc5..d90a0d8 100644 (file)
@@ -576,8 +576,10 @@ namespace
         else if (iterations > 1 && countNonZero(_kernel) == _kernel.rows * _kernel.cols)\r
         {\r
             anchor = Point(anchor.x * iterations, anchor.y * iterations);\r
-            kernel = getStructuringElement(MORPH_RECT, Size(ksize.width + iterations * (ksize.width - 1),\r
-                ksize.height + iterations * (ksize.height - 1)), anchor);\r
+            kernel = getStructuringElement(MORPH_RECT,\r
+                                           Size(ksize.width + (iterations - 1) * (ksize.width - 1),\r
+                                                ksize.height + (iterations - 1) * (ksize.height - 1)),\r
+                                           anchor);\r
             iterations = 1;\r
         }\r
         else\r
index 900958f..61f9f2c 100644 (file)
@@ -1140,6 +1140,12 @@ namespace cv { namespace gpu { namespace device
                 int sector = __float2int_rd(h);\r
                 h -= sector;\r
 \r
+                if ( (unsigned)sector >= 6u )\r
+                {\r
+                    sector = 0;\r
+                    h = 0.f;\r
+                }\r
+\r
                 float tab[4];\r
                 tab[0] = v;\r
                 tab[1] = v * (1.f - s);\r
index e07a5f0..a42de39 100644 (file)
@@ -64,10 +64,6 @@ namespace
     {
         return fabs(v) > numeric_limits<float>::epsilon();
     }
-    /*bool notNull(double v)
-    {
-        return fabs(v) > numeric_limits<double>::epsilon();
-    }*/
 
     class GHT_Pos : public GeneralizedHough
     {