mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
Merge pull request #8697 from sovrasov:cvt_col_bgra_bgra_fix
This commit is contained in:
commit
03aa69da99
@ -688,7 +688,7 @@ template<typename _Tp> struct RGB2RGB
|
||||
for( int i = 0; i < n; i += 4 )
|
||||
{
|
||||
_Tp t0 = src[i], t1 = src[i+1], t2 = src[i+2], t3 = src[i+3];
|
||||
dst[i] = t2; dst[i+1] = t1; dst[i+2] = t0; dst[i+3] = t3;
|
||||
dst[i+bidx] = t0; dst[i+1] = t1; dst[i+(bidx^2)] = t2; dst[i+3] = t3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -802,25 +802,25 @@ template<> struct RGB2RGB<uchar>
|
||||
for ( ; i <= n - 64; i += 64 )
|
||||
{
|
||||
uint8x16x4_t v_src = vld4q_u8(src + i), v_dst;
|
||||
v_dst.val[0] = v_src.val[2];
|
||||
v_dst.val[0] = v_src.val[bidx];
|
||||
v_dst.val[1] = v_src.val[1];
|
||||
v_dst.val[2] = v_src.val[0];
|
||||
v_dst.val[2] = v_src.val[bidx^2];
|
||||
v_dst.val[3] = v_src.val[3];
|
||||
vst4q_u8(dst + i, v_dst);
|
||||
}
|
||||
for ( ; i <= n - 32; i += 32 )
|
||||
{
|
||||
uint8x8x4_t v_src = vld4_u8(src + i), v_dst;
|
||||
v_dst.val[0] = v_src.val[2];
|
||||
v_dst.val[0] = v_src.val[bidx];
|
||||
v_dst.val[1] = v_src.val[1];
|
||||
v_dst.val[2] = v_src.val[0];
|
||||
v_dst.val[2] = v_src.val[bidx^2];
|
||||
v_dst.val[3] = v_src.val[3];
|
||||
vst4_u8(dst + i, v_dst);
|
||||
}
|
||||
for ( ; i < n; i += 4)
|
||||
{
|
||||
uchar t0 = src[i], t1 = src[i+1], t2 = src[i+2], t3 = src[i+3];
|
||||
dst[i] = t2; dst[i+1] = t1; dst[i+2] = t0; dst[i+3] = t3;
|
||||
dst[i+bidx] = t0; dst[i+1] = t1; dst[i+(bidx^2)] = t2; dst[i+3] = t3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2190,3 +2190,28 @@ TEST(ImgProc_Bayer2RGBA, accuracy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ImgProc_BGR2RGBA, regression_8696)
|
||||
{
|
||||
Mat src(Size(80, 10), CV_8UC4);
|
||||
src.setTo(Scalar(255, 0, 200, 100));
|
||||
|
||||
Mat dst;
|
||||
cvtColor(src, dst, COLOR_BGR2BGRA);
|
||||
|
||||
EXPECT_DOUBLE_EQ(norm(dst - src, NORM_INF), 0.);
|
||||
}
|
||||
|
||||
TEST(ImgProc_BGR2RGBA, 3ch24ch)
|
||||
{
|
||||
Mat src(Size(80, 10), CV_8UC3);
|
||||
src.setTo(Scalar(200, 0, 200));
|
||||
|
||||
Mat dst;
|
||||
cvtColor(src, dst, COLOR_BGR2BGRA);
|
||||
|
||||
Mat expected(Size(80, 10), CV_8UC4);
|
||||
expected.setTo(Scalar(80, 0, 200, 255));
|
||||
|
||||
EXPECT_DOUBLE_EQ(norm(expected - dst, NORM_INF), 0.);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user