1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

imgproc: fixed imread with output image argument, minor refactoring, fixes in HDR

This commit is contained in:
Maksim Shabunin
2024-06-04 14:44:39 +03:00
parent 2624929ec6
commit b77c74b6fc
4 changed files with 72 additions and 83 deletions
-13
View File
@@ -7,19 +7,6 @@ namespace opencv_test { namespace {
#if defined(HAVE_PNG) || defined(HAVE_SPNG)
TEST(Imgcodecs_Png, imread_passing_mat)
{
const string root = cvtest::TS::ptr()->get_data_path();
const string imgName = root + "../cv/shared/lena.png";
Mat ref = imread(imgName);
Mat img(ref.size(), ref.type());
void* ptr = img.data;
imread(imgName, img);
EXPECT_EQ(cv::norm(ref, img, NORM_INF), 0);
EXPECT_EQ(img.data, ptr);
}
TEST(Imgcodecs_Png, write_big)
{
const string root = cvtest::TS::ptr()->get_data_path();
@@ -282,6 +282,35 @@ TEST(Imgcodecs_Image, regression_9376)
EXPECT_EQ(32, m.rows);
}
TEST(Imgcodecs_Image, imread_overload)
{
const string root = cvtest::TS::ptr()->get_data_path();
const string imgName = findDataFile("../highgui/readwrite/ordinary.bmp");
Mat ref = imread(imgName);
ASSERT_FALSE(ref.empty());
{
Mat img(ref.size(), ref.type(), Scalar::all(0)); // existing image
void * ptr = img.data;
imread(imgName, img);
ASSERT_FALSE(img.empty());
EXPECT_EQ(cv::norm(ref, img, NORM_INF), 0);
EXPECT_EQ(img.data, ptr); // no reallocation
}
{
Mat img; // empty image
imread(imgName, img);
ASSERT_FALSE(img.empty());
EXPECT_EQ(cv::norm(ref, img, NORM_INF), 0);
}
{
UMat img; // empty UMat
imread(imgName, img);
ASSERT_FALSE(img.empty());
EXPECT_EQ(cv::norm(ref, img, NORM_INF), 0);
}
}
//==================================================================================================
TEST(Imgcodecs_Image, write_umat)