提交 2f9b4439 编写于 作者: A Alexander Alekhin

Merge pull request #11565 from alalek:issue_11545

......@@ -722,13 +722,10 @@ bool imwrite( const String& filename, InputArray _img,
{
CV_TRACE_FUNCTION();
std::vector<Mat> img_vec;
//Did we get a Mat or a vector of Mats?
if (_img.isMat() || _img.isUMat())
img_vec.push_back(_img.getMat());
else if (_img.isMatVector() || _img.isUMatVector())
if (_img.isMatVector() || _img.isUMatVector())
_img.getMatVector(img_vec);
else
CV_Error(Error::StsBadArg, "Unknown/unsupported input encountered");
img_vec.push_back(_img.getMat());
CV_Assert(!img_vec.empty());
return imwrite_(filename, img_vec, params, false);
......
......@@ -337,4 +337,18 @@ TEST(Imgcodecs_Pam, read_write)
}
#endif
TEST(Imgcodecs, write_parameter_type)
{
cv::Mat m(10, 10, CV_8UC1, cv::Scalar::all(0));
cv::Mat1b m_type = cv::Mat1b::zeros(10, 10);
string tmp_file = cv::tempfile(".bmp");
EXPECT_NO_THROW(cv::imwrite(tmp_file, cv::Mat(m * 2))) << "* Failed with cv::Mat";
EXPECT_NO_THROW(cv::imwrite(tmp_file, m * 2)) << "* Failed with cv::MatExpr";
EXPECT_NO_THROW(cv::imwrite(tmp_file, m_type)) << "* Failed with cv::Mat_";
EXPECT_NO_THROW(cv::imwrite(tmp_file, m_type * 2)) << "* Failed with cv::MatExpr(Mat_)";
cv::Matx<uchar, 10, 10> matx;
EXPECT_NO_THROW(cv::imwrite(tmp_file, matx)) << "* Failed with cv::Matx";
EXPECT_EQ(0, remove(tmp_file.c_str()));
}
}} // namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册