Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/imgcodecs/include/opencv2/imgcodecs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ This is an overloaded member function, provided for convenience. It differs from
@note
The image passing through the img parameter can be pre-allocated. The memory is reused if the shape and the type match with the load image.
*/
CV_EXPORTS_W void imread( const String& filename, OutputArray dst, int flags = IMREAD_COLOR );
CV_EXPORTS_W bool imread( const String& filename, OutputArray dst, int flags = IMREAD_COLOR );

/** @brief Loads a multi-page image from a file.

Expand Down
6 changes: 3 additions & 3 deletions modules/imgcodecs/src/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,14 @@ Mat imread( const String& filename, int flags )
return img;
}

void imread( const String& filename, OutputArray dst, int flags )
bool imread( const String& filename, OutputArray dst, int flags )
{
CV_TRACE_FUNCTION();

Mat img = dst.getMat();
Mat& img = dst.getMatRef();

/// load the data
imread_(filename, flags, img);
return imread_(filename, flags, img);
}

/**
Expand Down
19 changes: 19 additions & 0 deletions modules/imgcodecs/test/test_read_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ TEST_P(Imgcodecs_Resize, imread_reduce_flags)
}
}

TEST_P(Imgcodecs_Resize, imread_with_output_array)
{
const string file_name = findDataFile(get<0>(get<0>(GetParam())));
const Size imageSize = get<1>(get<0>(GetParam()));

const int imread_flag = get<0>(get<1>(GetParam()));
const int scale = get<1>(get<1>(GetParam()));

const int cols = imageSize.width / scale;
const int rows = imageSize.height / scale;
{
Mat img;
imread(file_name, img, imread_flag);
ASSERT_FALSE(img.empty());
EXPECT_EQ(cols, img.cols);
EXPECT_EQ(rows, img.rows);
}
}

//==================================================================================================

TEST_P(Imgcodecs_Resize, imdecode_reduce_flags)
Expand Down