imgproc: local "CV_Assert(totalSampleCount > 0)" check
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Wed, 28 Nov 2018 20:16:37 +0000 (20:16 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Wed, 28 Nov 2018 20:16:37 +0000 (20:16 +0000)
modules/imgproc/src/grabcut.cpp

index 9cfbe0d..d68077d 100644 (file)
@@ -174,7 +174,6 @@ void GMM::addSample( int ci, const Vec3d color )
 
 void GMM::endLearning()
 {
-    CV_Assert(totalSampleCount > 0);
     for( int ci = 0; ci < componentsCount; ci++ )
     {
         int n = sampleCounts[ci];
@@ -182,6 +181,7 @@ void GMM::endLearning()
             coefs[ci] = 0;
         else
         {
+            CV_Assert(totalSampleCount > 0);
             double inv_n = 1.0 / n;
             coefs[ci] = (double)n/totalSampleCount;