mirror of
https://github.com/opencv/opencv.git
synced 2025-06-15 22:20:58 +08:00
Fixed IPP based implementation of setTo() for infinity value
This commit is contained in:
parent
fb6db3dcfc
commit
ccd16f107d
@ -478,6 +478,11 @@ static bool ipp_Mat_setTo_Mat(Mat &dst, Mat &_val, Mat &mask)
|
|||||||
if(dst.channels() > 4)
|
if(dst.channels() > 4)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (dst.depth() == CV_32F)
|
||||||
|
for (int i = 0; i < (int)(_val.total()); i++)
|
||||||
|
if (_val.at<double>(i) < iwTypeGetMin(ipp32f) || _val.at<double>(i) > iwTypeGetMax(ipp32f))
|
||||||
|
return false;
|
||||||
|
|
||||||
if(dst.dims <= 2)
|
if(dst.dims <= 2)
|
||||||
{
|
{
|
||||||
IppiSize size = ippiSize(dst.size());
|
IppiSize size = ippiSize(dst.size());
|
||||||
|
@ -2039,4 +2039,49 @@ TEST(Core_minMaxIdx, regression_9207_2)
|
|||||||
EXPECT_EQ(14, maxIdx[1]);
|
EXPECT_EQ(14, maxIdx[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Core_Set, regression_11044)
|
||||||
|
{
|
||||||
|
Mat testFloat(Size(3, 3), CV_32FC1);
|
||||||
|
Mat testDouble(Size(3, 3), CV_64FC1);
|
||||||
|
|
||||||
|
testFloat.setTo(1);
|
||||||
|
EXPECT_EQ(1, testFloat.at<float>(0,0));
|
||||||
|
testFloat.setTo(std::numeric_limits<float>::infinity());
|
||||||
|
EXPECT_EQ(std::numeric_limits<float>::infinity(), testFloat.at<float>(0, 0));
|
||||||
|
testFloat.setTo(1);
|
||||||
|
EXPECT_EQ(1, testFloat.at<float>(0, 0));
|
||||||
|
testFloat.setTo(std::numeric_limits<double>::infinity());
|
||||||
|
EXPECT_EQ(std::numeric_limits<float>::infinity(), testFloat.at<float>(0, 0));
|
||||||
|
|
||||||
|
testDouble.setTo(1);
|
||||||
|
EXPECT_EQ(1, testDouble.at<double>(0, 0));
|
||||||
|
testDouble.setTo(std::numeric_limits<float>::infinity());
|
||||||
|
EXPECT_EQ(std::numeric_limits<double>::infinity(), testDouble.at<double>(0, 0));
|
||||||
|
testDouble.setTo(1);
|
||||||
|
EXPECT_EQ(1, testDouble.at<double>(0, 0));
|
||||||
|
testDouble.setTo(std::numeric_limits<double>::infinity());
|
||||||
|
EXPECT_EQ(std::numeric_limits<double>::infinity(), testDouble.at<double>(0, 0));
|
||||||
|
|
||||||
|
Mat testMask(Size(3, 3), CV_8UC1, Scalar(1));
|
||||||
|
|
||||||
|
testFloat.setTo(1);
|
||||||
|
EXPECT_EQ(1, testFloat.at<float>(0, 0));
|
||||||
|
testFloat.setTo(std::numeric_limits<float>::infinity(), testMask);
|
||||||
|
EXPECT_EQ(std::numeric_limits<float>::infinity(), testFloat.at<float>(0, 0));
|
||||||
|
testFloat.setTo(1);
|
||||||
|
EXPECT_EQ(1, testFloat.at<float>(0, 0));
|
||||||
|
testFloat.setTo(std::numeric_limits<double>::infinity(), testMask);
|
||||||
|
EXPECT_EQ(std::numeric_limits<float>::infinity(), testFloat.at<float>(0, 0));
|
||||||
|
|
||||||
|
|
||||||
|
testDouble.setTo(1);
|
||||||
|
EXPECT_EQ(1, testDouble.at<double>(0, 0));
|
||||||
|
testDouble.setTo(std::numeric_limits<float>::infinity(), testMask);
|
||||||
|
EXPECT_EQ(std::numeric_limits<double>::infinity(), testDouble.at<double>(0, 0));
|
||||||
|
testDouble.setTo(1);
|
||||||
|
EXPECT_EQ(1, testDouble.at<double>(0, 0));
|
||||||
|
testDouble.setTo(std::numeric_limits<double>::infinity(), testMask);
|
||||||
|
EXPECT_EQ(std::numeric_limits<double>::infinity(), testDouble.at<double>(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
}} // namespace
|
}} // namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user