From cd292972d4d4d0ddecaec62a47450f678a786f38 Mon Sep 17 00:00:00 2001 From: Vilson Vieira Date: Wed, 16 Mar 2016 17:51:33 -0300 Subject: [PATCH 1/2] Log errors for now --- components/GetSaliency-node.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/components/GetSaliency-node.coffee b/components/GetSaliency-node.coffee index c932da0..23eb516 100644 --- a/components/GetSaliency-node.coffee +++ b/components/GetSaliency-node.coffee @@ -40,6 +40,7 @@ runSaliency = (tmpFile, callback) -> exec "#{bin} #{tmpFile.path}", (err, stdout, stderr) -> tmpFile.unlink() if err + console.log 'GetSaliency ERROR:', err callback err return else From f1d43c17935d46951c9c8e4d47d5b01de19cfa83 Mon Sep 17 00:00:00 2001 From: Vilson Vieira Date: Wed, 16 Mar 2016 17:51:51 -0300 Subject: [PATCH 2/2] Safe check rect and polygons --- saliency.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/saliency.cpp b/saliency.cpp index 5fb715e..915392c 100644 --- a/saliency.cpp +++ b/saliency.cpp @@ -50,6 +50,11 @@ string jsonify(Rect &bigRect, float entropy) { ostringstream out; + if (contours_poly.size() <= 0) { + out << "{\"saliency\": null}" << endl; + return out.str(); + } + out << "{\"saliency\": "; float x = bigRect.tl().x; float y = bigRect.tl().y; @@ -266,22 +271,28 @@ int main(int argc, char *argv[]) { ymax = 0; xmin = INFINITY; ymin = INFINITY; - for (size_t j=0, max = boundRect.size(); j xmax) - xmax = xmaxB; - if (ymaxB > ymax) - ymax = ymaxB; + if (boundRect.size() > 0) { + for (size_t j=0, max = boundRect.size(); j xmax) + xmax = xmaxB; + if (ymaxB > ymax) + ymax = ymaxB; + } + } else { + xmin = 0; + ymin = 0; + xmax = 0; + ymax = 0; } Rect bigRect = Rect(xmin, ymin, xmax-xmin, ymax-ymin); - #ifdef DEBUG // Draw polygonal contour + bonding rects + circles Mat drawing = Mat::zeros( filtered.size(), CV_8UC3 );