Fix dnn object detection sample
authorDmitry Kurtaev <dmitry.kurtaev+github@gmail.com>
Fri, 13 Sep 2019 08:50:50 +0000 (11:50 +0300)
committerDmitry Kurtaev <dmitry.kurtaev+github@gmail.com>
Fri, 13 Sep 2019 08:50:50 +0000 (11:50 +0300)
samples/dnn/object_detection.cpp
samples/dnn/object_detection.py

index 91ccd6c..83ed10d 100644 (file)
@@ -347,7 +347,7 @@ void postprocess(Mat& frame, const std::vector<Mat>& outs, Net& net)
                     int bottom = (int)data[i + 6];
                     int width  = right - left + 1;
                     int height = bottom - top + 1;
-                    if (width * height <= 1)
+                    if (width <= 2 || height <= 2)
                     {
                         left   = (int)(data[i + 3] * frame.cols);
                         top    = (int)(data[i + 4] * frame.rows);
index 30b677c..8126ee5 100644 (file)
@@ -126,7 +126,7 @@ def postprocess(frame, outs):
                     bottom = int(detection[6])
                     width = right - left + 1
                     height = bottom - top + 1
-                    if width * height <= 1:
+                    if width <= 2 or height <= 2:
                         left = int(detection[3] * frameWidth)
                         top = int(detection[4] * frameHeight)
                         right = int(detection[5] * frameWidth)