[opencv] 54/71: fixed http://code.opencv.org/issues/3828
Nobuhiro Iwamatsu
iwamatsu at moszumanska.debian.org
Mon Oct 17 20:16:29 UTC 2016
This is an automated email from the git hooks/post-receive script.
iwamatsu pushed a commit to annotated tag 2.4.13.1
in repository opencv.
commit b28d13430c78e9df7e6e2a50b34c0fbd717ff8d1
Author: Rostislav Vasilikhin <rostislav.vasilikhin at intel.com>
Date: Sat Sep 3 21:49:54 2016 +0300
fixed http://code.opencv.org/issues/3828
---
modules/core/src/stat.cpp | 5 +++++
modules/core/test/test_arithm.cpp | 10 ++++++++++
2 files changed, 15 insertions(+)
diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp
index 3c24f02..e88d175 100644
--- a/modules/core/src/stat.cpp
+++ b/modules/core/src/stat.cpp
@@ -2587,6 +2587,11 @@ void cv::findNonZero( InputArray _src, OutputArray _idx )
Mat src = _src.getMat();
CV_Assert( src.type() == CV_8UC1 );
int n = countNonZero(src);
+ if (n == 0)
+ {
+ _idx.release();
+ return;
+ }
if( _idx.kind() == _InputArray::MAT && !_idx.getMatRef().isContinuous() )
_idx.release();
_idx.create(n, 1, CV_32SC2);
diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp
index ac88615..57adb89 100644
--- a/modules/core/test/test_arithm.cpp
+++ b/modules/core/test/test_arithm.cpp
@@ -1810,3 +1810,13 @@ TEST(MinMaxLoc, Mat_IntMax_Without_Mask)
ASSERT_EQ(Point(0, 0), minLoc);
ASSERT_EQ(Point(0, 0), maxLoc);
}
+
+
+TEST(Core_FindNonZero, singular)
+{
+ Mat img(10, 10, CV_8U, Scalar::all(0));
+ vector<Point> pts, pts2(10);
+ findNonZero(img, pts);
+ findNonZero(img, pts2);
+ ASSERT_TRUE(pts.empty() && pts2.empty());
+}
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git
More information about the debian-science-commits
mailing list