- OpenCV => 4.3
- Operating System / Platform =>Mac OS Catalina + OpenCL + IPP
- Compiler => clang
Detailed description
countNonZero is returning wrong counts for large unit8_t arrays.
The issue seems to be related to ippiCountInRange_8u_C1R which is called behind the scene returning a wrong inverse count.
Steps to reproduce
std::cout << cv::countNonZero(cv::Mat::zeros(1,524190-1,CV_8UC1)); // returns 0
std::cout << cv::countNonZero(cv::Mat::zeros(1,524190,CV_8UC1)); // returns 65536
std::cout << cv::countNonZero(cv::Mat::zeros(1,524190+1,CV_8UC1)); // returns 65536