Corrects objects matrix in case of the absence of objects
authormarina.kolpakova <marina.kolpakova@itseez.com>
Wed, 3 Oct 2012 12:39:37 +0000 (16:39 +0400)
committermarina.kolpakova <marina.kolpakova@itseez.com>
Sat, 10 Nov 2012 01:08:43 +0000 (05:08 +0400)
modules/gpu/src/softcascade.cpp

index 9ea365c..8b73ae6 100644 (file)
@@ -422,19 +422,15 @@ inline void cv::gpu::SoftCascade::Filds::calcLevels(const std::vector<device::ic
         if (::fabs(scale - maxScale) < FLT_EPSILON) break;
         scale = ::std::min(maxScale, ::expf(::log(scale) + logFactor));
 
-        // printf("level: %d (%f %f) [%f %f] (%d %d) (%d %d)\n", level.octave, level.relScale, level.shrScale,
-        //     level.scaling[0], level.scaling[1], level.workRect.x, level.workRect.y, level.objSize.x,
-        //level.objSize.y);
-
-        std::cout << "level " << sc
-                  << " octeve "
-                  << vlevels[sc].octave
-                  << " relScale "
-                  << vlevels[sc].relScale
-                  << " " << vlevels[sc].shrScale
-                  << " [" << (int)vlevels[sc].objSize.x
-                  << " " <<  (int)vlevels[sc].objSize.y << "] ["
-        <<  (int)vlevels[sc].workRect.x << " " <<  (int)vlevels[sc].workRect.y << "]" << std::endl;
+        // std::cout << "level " << sc
+        //           << " octeve "
+        //           << vlevels[sc].octave
+        //           << " relScale "
+        //           << vlevels[sc].relScale
+        //           << " " << vlevels[sc].shrScale
+        //           << " [" << (int)vlevels[sc].objSize.x
+        //           << " " <<  (int)vlevels[sc].objSize.y << "] ["
+        // <<  (int)vlevels[sc].workRect.x << " " <<  (int)vlevels[sc].workRect.y << "]" << std::endl;
     }
 
     levels.upload(cv::Mat(1, vlevels.size() * sizeof(Level), CV_8UC1, (uchar*)&(vlevels[0]) ));
@@ -578,7 +574,10 @@ void cv::gpu::SoftCascade::detectMultiScale(const GpuMat& colored, const GpuMat&
     cv::Mat out(flds.detCounter);
     int ndetections = *(out.data);
 
-    objects = GpuMat(objects, cv::Rect(0, 0, ndetections * sizeof(Detection), 1));
+    if (! ndetections)
+        objects = GpuMat();
+    else
+        objects = GpuMat(objects, cv::Rect(0, 0, ndetections * sizeof(Detection), 1));
 }
 
 void cv::gpu::SoftCascade::detectMultiScale(const GpuMat&, const GpuMat&, GpuMat&, int, GpuMat&, Stream) const