Merge pull request #21635 from DumDereDum:issue_21595_3.4
Issue 21595 fix 3.4 branch * bug fix; add test * rewrite tests avoiding vector in tests
This commit is contained in:
parent
4e53f301d8
commit
1890157faa
@ -909,7 +909,8 @@ static bool ipp_calchist(const Mat &image, Mat &hist, int histSize, const float*
|
||||
#endif
|
||||
|
||||
// IPP_DISABLE_HISTOGRAM - https://github.com/opencv/opencv/issues/11544
|
||||
if (uniform && (ranges[0][1] - ranges[0][0]) != histSize)
|
||||
// and https://github.com/opencv/opencv/issues/21595
|
||||
if ((uniform && (ranges[0][1] - ranges[0][0]) != histSize) || abs(ranges[0][0]) != cvFloor(ranges[0][0]))
|
||||
return false;
|
||||
|
||||
Mat ihist = hist;
|
||||
|
||||
@ -1993,6 +1993,38 @@ TEST(Imgproc_Hist_Calc, badarg)
|
||||
EXPECT_NO_THROW(cv::calcBackProject(&img, 1, channels, hist, backProj, NULL, 1, true));
|
||||
}
|
||||
|
||||
TEST(Imgproc_Hist_Calc, IPP_ranges_with_equal_exponent_21595)
|
||||
{
|
||||
const int channels[] = { 0 };
|
||||
float range1[] = { -0.5f, 1.5f };
|
||||
const float* ranges[] = { range1 };
|
||||
const int hist_size[] = { 2 };
|
||||
|
||||
uint8_t m[1][6] = { { 0, 1, 0, 1 , 1, 1 } };
|
||||
cv::Mat images_u = Mat(1, 6, CV_8UC1, m);
|
||||
cv::Mat histogram_u;
|
||||
cv::calcHist(&images_u, 1, channels, noArray(), histogram_u, 1, hist_size, ranges);
|
||||
|
||||
ASSERT_EQ(histogram_u.at<float>(0), 2.f) << "0 not counts correctly, res: " << histogram_u.at<float>(0);
|
||||
ASSERT_EQ(histogram_u.at<float>(1), 4.f) << "1 not counts correctly, res: " << histogram_u.at<float>(0);
|
||||
}
|
||||
|
||||
TEST(Imgproc_Hist_Calc, IPP_ranges_with_nonequal_exponent_21595)
|
||||
{
|
||||
const int channels[] = { 0 };
|
||||
float range1[] = { -1.3f, 1.5f };
|
||||
const float* ranges[] = { range1 };
|
||||
const int hist_size[] = { 3 };
|
||||
|
||||
uint8_t m[1][6] = { { 0, 1, 0, 1 , 1, 1 } };
|
||||
cv::Mat images_u = Mat(1, 6, CV_8UC1, m);
|
||||
cv::Mat histogram_u;
|
||||
cv::calcHist(&images_u, 1, channels, noArray(), histogram_u, 1, hist_size, ranges);
|
||||
|
||||
ASSERT_EQ(histogram_u.at<float>(0), 0.f) << "not equal to zero, res: " << histogram_u.at<float>(0);
|
||||
ASSERT_EQ(histogram_u.at<float>(1), 2.f) << "0 not counts correctly, res: " << histogram_u.at<float>(1);
|
||||
ASSERT_EQ(histogram_u.at<float>(2), 4.f) << "1 not counts correctly, res: " << histogram_u.at<float>(2);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
/* End Of File */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user