mirror of
https://github.com/opencv/opencv.git
synced 2025-07-24 14:06:27 +08:00
Merge pull request #13544 from eightco:bugfix
Fix a bug in cv :: merge when array of 3-channel mat is input (#13544) * Mat merge function bug fix - Bug fix of merge function of 3-channel vector <Mat> of 3 or 4 matrices * Add Core_merge test for opencv#13544 * fixups
This commit is contained in:
parent
14d943f588
commit
71aee662bd
@ -305,7 +305,7 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
|
||||
return;
|
||||
}
|
||||
|
||||
CV_IPP_RUN_FAST(ipp_merge(mv, dst, (int)n));
|
||||
CV_IPP_RUN(allch1, ipp_merge(mv, dst, (int)n));
|
||||
|
||||
if( !allch1 )
|
||||
{
|
||||
|
@ -1888,6 +1888,29 @@ TEST(Core_Split, crash_12171)
|
||||
EXPECT_EQ(2, dst2.ptr<uchar>(1)[1]);
|
||||
}
|
||||
|
||||
TEST(Core_Merge, bug_13544)
|
||||
{
|
||||
Mat src1(2, 2, CV_8UC3, Scalar::all(1));
|
||||
Mat src2(2, 2, CV_8UC3, Scalar::all(2));
|
||||
Mat src3(2, 2, CV_8UC3, Scalar::all(3));
|
||||
Mat src_arr[] = { src1, src2, src3 };
|
||||
Mat dst;
|
||||
merge(src_arr, 3, dst);
|
||||
ASSERT_EQ(9, dst.channels()); // Avoid memory access out of buffer
|
||||
EXPECT_EQ(3, (int)dst.ptr<uchar>(0)[6]);
|
||||
EXPECT_EQ(3, (int)dst.ptr<uchar>(0)[7]);
|
||||
EXPECT_EQ(3, (int)dst.ptr<uchar>(0)[8]);
|
||||
EXPECT_EQ(1, (int)dst.ptr<uchar>(1)[0]);
|
||||
EXPECT_EQ(1, (int)dst.ptr<uchar>(1)[1]);
|
||||
EXPECT_EQ(1, (int)dst.ptr<uchar>(1)[2]);
|
||||
EXPECT_EQ(2, (int)dst.ptr<uchar>(1)[3]);
|
||||
EXPECT_EQ(2, (int)dst.ptr<uchar>(1)[4]);
|
||||
EXPECT_EQ(2, (int)dst.ptr<uchar>(1)[5]);
|
||||
EXPECT_EQ(3, (int)dst.ptr<uchar>(1)[6]);
|
||||
EXPECT_EQ(3, (int)dst.ptr<uchar>(1)[7]);
|
||||
EXPECT_EQ(3, (int)dst.ptr<uchar>(1)[8]);
|
||||
}
|
||||
|
||||
struct CustomType // like cv::Keypoint
|
||||
{
|
||||
Point2f pt;
|
||||
|
Loading…
Reference in New Issue
Block a user