Skip to content

Commit dbbfa00

Browse files
committed
Merge pull request opencv#17455 from mshabunin:check-count-non-zero
2 parents e454c48 + 5960890 commit dbbfa00

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

modules/core/src/count_non_zero.dispatch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ static bool ipp_countNonZero( Mat &src, int &res )
6262
{
6363
CV_INSTRUMENT_REGION_IPP();
6464

65+
#if defined __APPLE__ || (defined _MSC_VER && defined _M_IX86)
66+
// see https://github.com/opencv/opencv/issues/17453
67+
if (src.dims <= 2 && src.step > 520000)
68+
return false;
69+
#endif
70+
6571
#if IPP_VERSION_X100 < 201801
6672
// Poor performance of SSE42
6773
if(cv::ipp::getIppTopFeatures() == ippCPUID_SSE42)

modules/core/test/test_countnonzero.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,23 @@ INSTANTIATE_TEST_CASE_P(Core, CountNonZeroND,
276276
)
277277
);
278278

279+
280+
typedef testing::TestWithParam<tuple<int, cv::Size> > CountNonZeroBig;
281+
282+
TEST_P(CountNonZeroBig, /**/)
283+
{
284+
const int type = get<0>(GetParam());
285+
const Size sz = get<1>(GetParam());
286+
287+
EXPECT_EQ(0, cv::countNonZero(cv::Mat::zeros(sz, type)));
288+
EXPECT_EQ(sz.area(), cv::countNonZero(cv::Mat::ones(sz, type)));
289+
}
290+
291+
INSTANTIATE_TEST_CASE_P(Core, CountNonZeroBig,
292+
testing::Combine(
293+
testing::Values(CV_8UC1, CV_32FC1),
294+
testing::Values(Size(1, 524190), Size(524190, 1), Size(3840, 2160))
295+
)
296+
);
297+
279298
}} // namespace

0 commit comments

Comments
 (0)