Skip to content

Commit

Permalink
Merge pull request opencv#17455 from mshabunin:check-count-non-zero
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Jun 4, 2020
2 parents e454c48 + 5960890 commit dbbfa00
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/core/src/count_non_zero.dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ static bool ipp_countNonZero( Mat &src, int &res )
{
CV_INSTRUMENT_REGION_IPP();

#if defined __APPLE__ || (defined _MSC_VER && defined _M_IX86)
// see https://github.com/opencv/opencv/issues/17453
if (src.dims <= 2 && src.step > 520000)
return false;
#endif

#if IPP_VERSION_X100 < 201801
// Poor performance of SSE42
if(cv::ipp::getIppTopFeatures() == ippCPUID_SSE42)
Expand Down
19 changes: 19 additions & 0 deletions modules/core/test/test_countnonzero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,23 @@ INSTANTIATE_TEST_CASE_P(Core, CountNonZeroND,
)
);


typedef testing::TestWithParam<tuple<int, cv::Size> > CountNonZeroBig;

TEST_P(CountNonZeroBig, /**/)
{
const int type = get<0>(GetParam());
const Size sz = get<1>(GetParam());

EXPECT_EQ(0, cv::countNonZero(cv::Mat::zeros(sz, type)));
EXPECT_EQ(sz.area(), cv::countNonZero(cv::Mat::ones(sz, type)));
}

INSTANTIATE_TEST_CASE_P(Core, CountNonZeroBig,
testing::Combine(
testing::Values(CV_8UC1, CV_32FC1),
testing::Values(Size(1, 524190), Size(524190, 1), Size(3840, 2160))
)
);

}} // namespace

0 comments on commit dbbfa00

Please sign in to comment.