fix test failure of cudaimgproc convert color of bgr2gray series

pull/1829/head
Tomoaki Teshima 7 years ago
parent 96c2ecb53a
commit 62f55b4f1f
  1. 16
      modules/cudev/include/opencv2/cudev/functional/detail/color_cvt.hpp

@ -93,11 +93,15 @@ namespace color_cvt_detail
enum
{
rgb_shift = 15,
yuv_shift = 14,
xyz_shift = 12,
R2Y = 4899,
G2Y = 9617,
B2Y = 1868,
RY15 = 9798,
GY15 = 19235,
BY15 = 3735,
BLOCK_SIZE = 256
};
@ -314,6 +318,18 @@ namespace color_cvt_detail
}
};
template <int scn, int bidx> struct RGB2Gray<uchar, scn, bidx>
: unary_function<typename MakeVec<uchar, scn>::type, uchar>
{
__device__ uchar operator ()(const typename MakeVec<uchar, scn>::type& src) const
{
const int b = bidx == 0 ? src.x : src.z;
const int g = src.y;
const int r = bidx == 0 ? src.z : src.x;
return (uchar)CV_CUDEV_DESCALE(b * BY15 + g * GY15 + r * RY15, rgb_shift);
}
};
template <int scn, int bidx> struct RGB2Gray<float, scn, bidx>
: unary_function<typename MakeVec<float, scn>::type, float>
{

Loading…
Cancel
Save