Fixed #1613: removed YUV420i color conversion constants

This commit is contained in:
Andrey Kamaev 2012-02-21 15:08:03 +00:00
parent 9a88aea697
commit e426dfc396
7 changed files with 47 additions and 63 deletions

View File

@ -291,8 +291,8 @@ CameraHandler* CameraHandler::initCameraConnect(const CameraCallback& callback,
format_to_set = "yuv420sp"; format_to_set = "yuv420sp";
break; break;
} }
if (0 == strncmp(pos, "yuv420i", ptr - pos)) if (0 == strncmp(pos, "yvu420sp", ptr - pos))
format_to_set = "yuv420i"; format_to_set = "yvu420sp";
} }
if (*ptr == 0) if (*ptr == 0)
break; break;

View File

@ -181,6 +181,7 @@ namespace cv { namespace gpu { namespace device
OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(rgb_to_hls) OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(rgb_to_hls)
OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(rgba_to_hls) OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(rgba_to_hls)
OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(rgb_to_hls4) OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(rgb_to_hls4)
OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(rgba_to_hls4) OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(rgba_to_hls4)
OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(bgr_to_hls) OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(bgr_to_hls)
OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(bgra_to_hls) OPENCV_GPU_DECLARE_CVTCOLOR_8U32F(bgra_to_hls)
@ -1409,12 +1410,7 @@ void cv::gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, Stream
0, // CV_BayerBG2GRAY = 86 0, // CV_BayerBG2GRAY = 86
0, // CV_BayerGB2GRAY = 87 0, // CV_BayerGB2GRAY = 87
0, // CV_BayerRG2GRAY = 88 0, // CV_BayerRG2GRAY = 88
0, // CV_BayerGR2GRAY = 89 0 // CV_BayerGR2GRAY = 89
0, // CV_YUV420i2RGB = 90
0, // CV_YUV420i2BGR = 91
0, // CV_YUV420sp2RGB = 92
0 // CV_YUV420sp2BGR = 93
}; };
CV_Assert(code < 94); CV_Assert(code < 94);

View File

@ -93,7 +93,7 @@ protected:
{ {
noformat = 0, noformat = 0,
yuv420sp, yuv420sp,
yuv420i, yvu420sp,
yuvUnknown yuvUnknown
}; };
@ -371,8 +371,8 @@ IplImage* CvCapture_Android::retrieveFrame( int outputType )
u.prop = getProperty(CV_CAP_PROP_PREVIEW_FORMAT); u.prop = getProperty(CV_CAP_PROP_PREVIEW_FORMAT);
if (0 == strcmp(u.name, "yuv420sp")) if (0 == strcmp(u.name, "yuv420sp"))
m_frameFormat = yuv420sp; m_frameFormat = yuv420sp;
else if (0 == strcmp(u.name, "yuv420i")) else if (0 == strcmp(u.name, "yvu420sp"))
m_frameFormat = yuv420i; m_frameFormat = yvu420sp;
else else
m_frameFormat = yuvUnknown; m_frameFormat = yuvUnknown;
} }
@ -467,7 +467,7 @@ void CvCapture_Android::prepareCacheForYUV(int width, int height)
bool CvCapture_Android::convertYUV2Grey(int width, int height, const unsigned char* yuv, cv::Mat& resmat) bool CvCapture_Android::convertYUV2Grey(int width, int height, const unsigned char* yuv, cv::Mat& resmat)
{ {
if (yuv == 0) return false; if (yuv == 0) return false;
if (m_frameFormat != yuv420sp && m_frameFormat != yuv420i) return false; if (m_frameFormat != yuv420sp && m_frameFormat != yvu420sp) return false;
#define ALWAYS_COPY_GRAY 0 #define ALWAYS_COPY_GRAY 0
#if ALWAYS_COPY_GRAY #if ALWAYS_COPY_GRAY
resmat.create(height, width, CV_8UC1); resmat.create(height, width, CV_8UC1);
@ -482,7 +482,7 @@ bool CvCapture_Android::convertYUV2Grey(int width, int height, const unsigned ch
bool CvCapture_Android::convertYUV2BGR(int width, int height, const unsigned char* yuv, cv::Mat& resmat, bool inRGBorder, bool withAlpha) bool CvCapture_Android::convertYUV2BGR(int width, int height, const unsigned char* yuv, cv::Mat& resmat, bool inRGBorder, bool withAlpha)
{ {
if (yuv == 0) return false; if (yuv == 0) return false;
if (m_frameFormat != yuv420sp && m_frameFormat != yuv420i) return false; if (m_frameFormat != yuv420sp && m_frameFormat != yvu420sp) return false;
CV_Assert(width % 2 == 0 && height % 2 == 0); CV_Assert(width % 2 == 0 && height % 2 == 0);
@ -490,8 +490,8 @@ bool CvCapture_Android::convertYUV2BGR(int width, int height, const unsigned cha
if (m_frameFormat == yuv420sp) if (m_frameFormat == yuv420sp)
cv::cvtColor(src, resmat, inRGBorder ? CV_YUV420sp2RGB : CV_YUV420sp2BGR, withAlpha ? 4 : 3); cv::cvtColor(src, resmat, inRGBorder ? CV_YUV420sp2RGB : CV_YUV420sp2BGR, withAlpha ? 4 : 3);
else if (m_frameFormat == yuv420i) else if (m_frameFormat == yvu420sp)
cv::cvtColor(src, resmat, inRGBorder ? CV_YUV420i2RGB : CV_YUV420i2BGR, withAlpha ? 4 : 3); cv::cvtColor(src, resmat, inRGBorder ? CV_YUV2RGB_NV12 : CV_YUV2BGR_NV12, withAlpha ? 4 : 3);
return !resmat.empty(); return !resmat.empty();
} }

View File

@ -919,25 +919,19 @@ enum
COLOR_BayerRG2GRAY = 88, COLOR_BayerRG2GRAY = 88,
COLOR_BayerGR2GRAY = 89, COLOR_BayerGR2GRAY = 89,
COLOR_YUV420i2RGB = 90, COLOR_YUV2RGB_NV12 = 90,
COLOR_YUV420i2BGR = 91, COLOR_YUV2BGR_NV12 = 91,
COLOR_YUV420sp2RGB = 92, COLOR_YUV2RGB_NV21 = 92,
COLOR_YUV420sp2BGR = 93, COLOR_YUV2BGR_NV21 = 93,
COLOR_YUV420sp2RGB = COLOR_YUV2RGB_NV21,
COLOR_YUV420sp2BGR = COLOR_YUV2BGR_NV21,
COLOR_YUV2RGB_NV12 = COLOR_YUV420i2RGB, COLOR_YUV2RGBA_NV12 = 94,
COLOR_YUV2BGR_NV12 = COLOR_YUV420i2BGR, COLOR_YUV2BGRA_NV12 = 95,
COLOR_YUV2RGB_NV21 = COLOR_YUV420sp2RGB, COLOR_YUV2RGBA_NV21 = 96,
COLOR_YUV2BGR_NV21 = COLOR_YUV420sp2BGR, COLOR_YUV2BGRA_NV21 = 97,
COLOR_YUV420sp2RGBA = COLOR_YUV2RGBA_NV21,
COLOR_YUV420i2RGBA = 94, COLOR_YUV420sp2BGRA = COLOR_YUV2BGRA_NV21,
COLOR_YUV420i2BGRA = 95,
COLOR_YUV420sp2RGBA = 96,
COLOR_YUV420sp2BGRA = 97,
COLOR_YUV2RGBA_NV12 = COLOR_YUV420i2RGBA,
COLOR_YUV2BGRA_NV12 = COLOR_YUV420i2BGRA,
COLOR_YUV2RGBA_NV21 = COLOR_YUV420sp2RGBA,
COLOR_YUV2BGRA_NV21 = COLOR_YUV420sp2BGRA,
COLOR_COLORCVT_MAX =100 COLOR_COLORCVT_MAX =100
}; };

View File

@ -225,25 +225,19 @@ enum
CV_BayerRG2GRAY = 88, CV_BayerRG2GRAY = 88,
CV_BayerGR2GRAY = 89, CV_BayerGR2GRAY = 89,
CV_YUV420i2RGB = 90, CV_YUV2RGB_NV12 = 90,
CV_YUV420i2BGR = 91, CV_YUV2BGR_NV12 = 91,
CV_YUV420sp2RGB = 92, CV_YUV2RGB_NV21 = 92,
CV_YUV420sp2BGR = 93, CV_YUV2BGR_NV21 = 93,
CV_YUV420sp2RGB = CV_YUV2RGB_NV21,
CV_YUV420sp2BGR = CV_YUV2BGR_NV21,
CV_YUV2RGB_NV12 = CV_YUV420i2RGB, CV_YUV2RGBA_NV12 = 94,
CV_YUV2BGR_NV12 = CV_YUV420i2BGR, CV_YUV2BGRA_NV12 = 95,
CV_YUV2RGB_NV21 = CV_YUV420sp2RGB, CV_YUV2RGBA_NV21 = 96,
CV_YUV2BGR_NV21 = CV_YUV420sp2BGR, CV_YUV2BGRA_NV21 = 97,
CV_YUV420sp2RGBA = CV_YUV2RGBA_NV21,
CV_YUV420i2RGBA = 94, CV_YUV420sp2BGRA = CV_YUV2BGRA_NV21,
CV_YUV420i2BGRA = 95,
CV_YUV420sp2RGBA = 96,
CV_YUV420sp2BGRA = 97,
CV_YUV2RGBA_NV12 = CV_YUV420i2RGBA,
CV_YUV2BGRA_NV12 = CV_YUV420i2BGRA,
CV_YUV2RGBA_NV21 = CV_YUV420sp2RGBA,
CV_YUV2BGRA_NV21 = CV_YUV420sp2BGRA,
CV_COLORCVT_MAX =100 CV_COLORCVT_MAX =100
}; };

View File

@ -106,7 +106,7 @@ CV_ENUM(CvtMode,
CV_YUV2BGR, CV_YUV2RGB, CX_YUV2BGRA, CX_YUV2RGBA CV_YUV2BGR, CV_YUV2RGB, CX_YUV2BGRA, CX_YUV2RGBA
) )
CV_ENUM(CvtMode2, CV_YUV420i2BGR, CV_YUV420i2BGRA, CV_YUV420i2RGB, CV_YUV420i2RGBA, CV_YUV420sp2BGR, CV_YUV420sp2BGRA, CV_YUV420sp2RGB, CV_YUV420sp2RGBA) CV_ENUM(CvtMode2, CV_YUV2BGR_NV12, CV_YUV2BGRA_NV12, CV_YUV2RGB_NV12, CV_YUV2RGBA_NV12, CV_YUV420sp2BGR, CV_YUV420sp2BGRA, CV_YUV420sp2RGB, CV_YUV420sp2RGBA)
struct ChPair struct ChPair
{ {
@ -127,12 +127,12 @@ ChPair getConversionInfo(int cvtMode)
case CV_BayerGB2BGR: case CV_BayerGB2BGR_VNG: case CV_BayerGB2BGR: case CV_BayerGB2BGR_VNG:
case CV_BayerGR2BGR: case CV_BayerGR2BGR_VNG: case CV_BayerGR2BGR: case CV_BayerGR2BGR_VNG:
case CV_BayerRG2BGR: case CV_BayerRG2BGR_VNG: case CV_BayerRG2BGR: case CV_BayerRG2BGR_VNG:
case CV_GRAY2BGR: case CV_YUV420i2BGR: case CV_GRAY2BGR: case CV_YUV2BGR_NV12:
case CV_YUV420i2RGB: case CV_YUV420sp2BGR: case CV_YUV2RGB_NV12: case CV_YUV420sp2BGR:
case CV_YUV420sp2RGB: case CV_YUV420sp2RGB:
return ChPair(1,3); return ChPair(1,3);
case CV_GRAY2BGRA: case CV_YUV420i2BGRA: case CV_GRAY2BGRA: case CV_YUV2BGRA_NV12:
case CV_YUV420i2RGBA: case CV_YUV420sp2BGRA: case CV_YUV2RGBA_NV12: case CV_YUV420sp2BGRA:
case CV_YUV420sp2RGBA: case CV_YUV420sp2RGBA:
return ChPair(1,4); return ChPair(1,4);
case CV_BGR5552GRAY: case CV_BGR5652GRAY: case CV_BGR5552GRAY: case CV_BGR5652GRAY:

View File

@ -3203,10 +3203,10 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
Bayer2RGB_VNG_8u(src, dst, code); Bayer2RGB_VNG_8u(src, dst, code);
} }
break; break;
case CV_YUV420sp2BGR: case CV_YUV420sp2RGB: case CV_YUV420i2BGR: case CV_YUV420i2RGB: case CV_YUV420sp2BGR: case CV_YUV420sp2RGB: case CV_YUV2BGR_NV12: case CV_YUV2RGB_NV12:
case CV_YUV420sp2BGRA: case CV_YUV420sp2RGBA: case CV_YUV420i2BGRA: case CV_YUV420i2RGBA: case CV_YUV420sp2BGRA: case CV_YUV420sp2RGBA: case CV_YUV2BGRA_NV12: case CV_YUV2RGBA_NV12:
{ {
if (dcn <= 0) dcn = (code==CV_YUV420sp2BGRA || code==CV_YUV420sp2RGBA || code==CV_YUV420i2BGRA || code==CV_YUV420i2RGBA) ? 4 : 3; if (dcn <= 0) dcn = (code==CV_YUV420sp2BGRA || code==CV_YUV420sp2RGBA || code==CV_YUV2BGRA_NV12 || code==CV_YUV2RGBA_NV12) ? 4 : 3;
CV_Assert( dcn == 3 || dcn == 4 ); CV_Assert( dcn == 3 || dcn == 4 );
CV_Assert( sz.width % 2 == 0 && sz.height % 3 == 0 && depth == CV_8U ); CV_Assert( sz.width % 2 == 0 && sz.height % 3 == 0 && depth == CV_8U );
@ -3218,7 +3218,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
const uchar* uv = y + dstSz.area(); const uchar* uv = y + dstSz.area();
// http://www.fourcc.org/yuv.php#NV21 == yuv420sp -> a plane of 8 bit Y samples followed by an interleaved V/U plane containing 8 bit 2x2 subsampled chroma samples // http://www.fourcc.org/yuv.php#NV21 == yuv420sp -> a plane of 8 bit Y samples followed by an interleaved V/U plane containing 8 bit 2x2 subsampled chroma samples
// http://www.fourcc.org/yuv.php#NV12 == yuv420i -> a plane of 8 bit Y samples followed by an interleaved U/V plane containing 8 bit 2x2 subsampled colour difference samples // http://www.fourcc.org/yuv.php#NV12 == yvu420sp -> a plane of 8 bit Y samples followed by an interleaved U/V plane containing 8 bit 2x2 subsampled colour difference samples
if (CV_YUV420sp2RGB == code || COLOR_YUV420sp2RGBA == code) if (CV_YUV420sp2RGB == code || COLOR_YUV420sp2RGBA == code)
{ {
if (dcn == 3) if (dcn == 3)
@ -3233,14 +3233,14 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
else else
cvtYUV4202RGBA<0, 1>(dst, src.step, y, uv); cvtYUV4202RGBA<0, 1>(dst, src.step, y, uv);
} }
else if (CV_YUV420i2RGB == code || CV_YUV420i2RGBA == code) else if (CV_YUV2RGB_NV12 == code || CV_YUV2RGBA_NV12 == code)
{ {
if (dcn == 3) if (dcn == 3)
cvtYUV4202RGB<2, 0>(dst, src.step, y, uv); cvtYUV4202RGB<2, 0>(dst, src.step, y, uv);
else else
cvtYUV4202RGBA<2, 0>(dst, src.step, y, uv); cvtYUV4202RGBA<2, 0>(dst, src.step, y, uv);
} }
else //if (CV_YUV420i2BGR == code || CV_YUV420i2BGRA == code) else //if (CV_YUV2BGR_NV12 == code || CV_YUV2BGRA_NV12 == code)
{ {
if (dcn == 3) if (dcn == 3)
cvtYUV4202RGB<0, 0>(dst, src.step, y, uv); cvtYUV4202RGB<0, 0>(dst, src.step, y, uv);