Added color YUV422 perf test

This commit is contained in:
Daniil Osokin 2012-08-10 15:32:15 +04:00
parent 8f6a2438a7
commit bbc8605530
2 changed files with 444 additions and 437 deletions

View File

@ -1,269 +1,276 @@
#include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
//extra color conversions supported implicitly
enum
{
CX_BGRA2HLS = CV_COLORCVT_MAX + CV_BGR2HLS,
CX_BGRA2HLS_FULL = CV_COLORCVT_MAX + CV_BGR2HLS_FULL,
CX_BGRA2HSV = CV_COLORCVT_MAX + CV_BGR2HSV,
CX_BGRA2HSV_FULL = CV_COLORCVT_MAX + CV_BGR2HSV_FULL,
CX_BGRA2Lab = CV_COLORCVT_MAX + CV_BGR2Lab,
CX_BGRA2Luv = CV_COLORCVT_MAX + CV_BGR2Luv,
CX_BGRA2XYZ = CV_COLORCVT_MAX + CV_BGR2XYZ,
CX_BGRA2YCrCb = CV_COLORCVT_MAX + CV_BGR2YCrCb,
CX_BGRA2YUV = CV_COLORCVT_MAX + CV_BGR2YUV,
CX_HLS2BGRA = CV_COLORCVT_MAX + CV_HLS2BGR,
CX_HLS2BGRA_FULL = CV_COLORCVT_MAX + CV_HLS2BGR_FULL,
CX_HLS2RGBA = CV_COLORCVT_MAX + CV_HLS2RGB,
CX_HLS2RGBA_FULL = CV_COLORCVT_MAX + CV_HLS2RGB_FULL,
CX_HSV2BGRA = CV_COLORCVT_MAX + CV_HSV2BGR,
CX_HSV2BGRA_FULL = CV_COLORCVT_MAX + CV_HSV2BGR_FULL,
CX_HSV2RGBA = CV_COLORCVT_MAX + CV_HSV2RGB,
CX_HSV2RGBA_FULL = CV_COLORCVT_MAX + CV_HSV2RGB_FULL,
CX_Lab2BGRA = CV_COLORCVT_MAX + CV_Lab2BGR,
CX_Lab2LBGRA = CV_COLORCVT_MAX + CV_Lab2LBGR,
CX_Lab2LRGBA = CV_COLORCVT_MAX + CV_Lab2LRGB,
CX_Lab2RGBA = CV_COLORCVT_MAX + CV_Lab2RGB,
CX_LBGRA2Lab = CV_COLORCVT_MAX + CV_LBGR2Lab,
CX_LBGRA2Luv = CV_COLORCVT_MAX + CV_LBGR2Luv,
CX_LRGBA2Lab = CV_COLORCVT_MAX + CV_LRGB2Lab,
CX_LRGBA2Luv = CV_COLORCVT_MAX + CV_LRGB2Luv,
CX_Luv2BGRA = CV_COLORCVT_MAX + CV_Luv2BGR,
CX_Luv2LBGRA = CV_COLORCVT_MAX + CV_Luv2LBGR,
CX_Luv2LRGBA = CV_COLORCVT_MAX + CV_Luv2LRGB,
CX_Luv2RGBA = CV_COLORCVT_MAX + CV_Luv2RGB,
CX_RGBA2HLS = CV_COLORCVT_MAX + CV_RGB2HLS,
CX_RGBA2HLS_FULL = CV_COLORCVT_MAX + CV_RGB2HLS_FULL,
CX_RGBA2HSV = CV_COLORCVT_MAX + CV_RGB2HSV,
CX_RGBA2HSV_FULL = CV_COLORCVT_MAX + CV_RGB2HSV_FULL,
CX_RGBA2Lab = CV_COLORCVT_MAX + CV_RGB2Lab,
CX_RGBA2Luv = CV_COLORCVT_MAX + CV_RGB2Luv,
CX_RGBA2XYZ = CV_COLORCVT_MAX + CV_RGB2XYZ,
CX_RGBA2YCrCb = CV_COLORCVT_MAX + CV_RGB2YCrCb,
CX_RGBA2YUV = CV_COLORCVT_MAX + CV_RGB2YUV,
CX_XYZ2BGRA = CV_COLORCVT_MAX + CV_XYZ2BGR,
CX_XYZ2RGBA = CV_COLORCVT_MAX + CV_XYZ2RGB,
CX_YCrCb2BGRA = CV_COLORCVT_MAX + CV_YCrCb2BGR,
CX_YCrCb2RGBA = CV_COLORCVT_MAX + CV_YCrCb2RGB,
CX_YUV2BGRA = CV_COLORCVT_MAX + CV_YUV2BGR,
CX_YUV2RGBA = CV_COLORCVT_MAX + CV_YUV2RGB
};
CV_ENUM(CvtMode,
CV_BayerBG2BGR, CV_BayerBG2BGR_VNG, CV_BayerBG2GRAY,
CV_BayerGB2BGR, CV_BayerGB2BGR_VNG, CV_BayerGB2GRAY,
CV_BayerGR2BGR, CV_BayerGR2BGR_VNG, CV_BayerGR2GRAY,
CV_BayerRG2BGR, CV_BayerRG2BGR_VNG, CV_BayerRG2GRAY,
CV_BGR2BGR555, CV_BGR2BGR565, CV_BGR2BGRA, CV_BGR2GRAY,
CV_BGR2HLS, CV_BGR2HLS_FULL, CV_BGR2HSV, CV_BGR2HSV_FULL,
CV_BGR2Lab, CV_BGR2Luv, CV_BGR2RGB, CV_BGR2RGBA, CV_BGR2XYZ,
CV_BGR2YCrCb, CV_BGR2YUV, CV_BGR5552BGR, CV_BGR5552BGRA,
CV_BGR5552GRAY, CV_BGR5552RGB, CV_BGR5552RGBA, CV_BGR5652BGR,
CV_BGR5652BGRA, CV_BGR5652GRAY, CV_BGR5652RGB, CV_BGR5652RGBA,
CV_BGRA2BGR, CV_BGRA2BGR555, CV_BGRA2BGR565, CV_BGRA2GRAY, CV_BGRA2RGBA,
CX_BGRA2HLS, CX_BGRA2HLS_FULL, CX_BGRA2HSV, CX_BGRA2HSV_FULL,
CX_BGRA2Lab, CX_BGRA2Luv, CX_BGRA2XYZ,
CX_BGRA2YCrCb, CX_BGRA2YUV,
CV_GRAY2BGR, CV_GRAY2BGR555, CV_GRAY2BGR565, CV_GRAY2BGRA,
CV_HLS2BGR, CV_HLS2BGR_FULL, CV_HLS2RGB, CV_HLS2RGB_FULL,
CX_HLS2BGRA, CX_HLS2BGRA_FULL, CX_HLS2RGBA, CX_HLS2RGBA_FULL,
CV_HSV2BGR, CV_HSV2BGR_FULL, CV_HSV2RGB, CV_HSV2RGB_FULL,
CX_HSV2BGRA, CX_HSV2BGRA_FULL, CX_HSV2RGBA, CX_HSV2RGBA_FULL,
CV_Lab2BGR, CV_Lab2LBGR, CV_Lab2LRGB, CV_Lab2RGB,
CX_Lab2BGRA, CX_Lab2LBGRA, CX_Lab2LRGBA, CX_Lab2RGBA,
CV_LBGR2Lab, CV_LBGR2Luv, CV_LRGB2Lab, CV_LRGB2Luv,
CX_LBGRA2Lab, CX_LBGRA2Luv, CX_LRGBA2Lab, CX_LRGBA2Luv,
CV_Luv2BGR, CV_Luv2LBGR, CV_Luv2LRGB, CV_Luv2RGB,
CX_Luv2BGRA, CX_Luv2LBGRA, CX_Luv2LRGBA, CX_Luv2RGBA,
CV_RGB2BGR555, CV_RGB2BGR565, CV_RGB2GRAY,
CV_RGB2HLS, CV_RGB2HLS_FULL, CV_RGB2HSV, CV_RGB2HSV_FULL,
CV_RGB2Lab, CV_RGB2Luv, CV_RGB2XYZ, CV_RGB2YCrCb, CV_RGB2YUV,
CV_RGBA2BGR, CV_RGBA2BGR555, CV_RGBA2BGR565, CV_RGBA2GRAY,
CX_RGBA2HLS, CX_RGBA2HLS_FULL, CX_RGBA2HSV, CX_RGBA2HSV_FULL,
CX_RGBA2Lab, CX_RGBA2Luv, CX_RGBA2XYZ,
CX_RGBA2YCrCb, CX_RGBA2YUV,
CV_XYZ2BGR, CV_XYZ2RGB, CX_XYZ2BGRA, CX_XYZ2RGBA,
CV_YCrCb2BGR, CV_YCrCb2RGB, CX_YCrCb2BGRA, CX_YCrCb2RGBA,
CV_YUV2BGR, CV_YUV2RGB, CX_YUV2BGRA, CX_YUV2RGBA
)
CV_ENUM(CvtMode2, CV_YUV2BGR_NV12, CV_YUV2BGRA_NV12, CV_YUV2RGB_NV12, CV_YUV2RGBA_NV12, CV_YUV2BGR_NV21, CV_YUV2BGRA_NV21, CV_YUV2RGB_NV21, CV_YUV2RGBA_NV21,
CV_YUV2BGR_YV12, CV_YUV2BGRA_YV12, CV_YUV2RGB_YV12, CV_YUV2RGBA_YV12, CV_YUV2BGR_IYUV, CV_YUV2BGRA_IYUV, CV_YUV2RGB_IYUV, CV_YUV2RGBA_IYUV,
COLOR_YUV2GRAY_420)
struct ChPair
{
ChPair(int _scn, int _dcn): scn(_scn), dcn(_dcn) {}
int scn, dcn;
};
ChPair getConversionInfo(int cvtMode)
{
switch(cvtMode)
{
case CV_BayerBG2GRAY: case CV_BayerGB2GRAY:
case CV_BayerGR2GRAY: case CV_BayerRG2GRAY:
case CV_YUV2GRAY_420:
return ChPair(1,1);
case CV_GRAY2BGR555: case CV_GRAY2BGR565:
return ChPair(1,2);
case CV_BayerBG2BGR: case CV_BayerBG2BGR_VNG:
case CV_BayerGB2BGR: case CV_BayerGB2BGR_VNG:
case CV_BayerGR2BGR: case CV_BayerGR2BGR_VNG:
case CV_BayerRG2BGR: case CV_BayerRG2BGR_VNG:
case CV_GRAY2BGR:
case CV_YUV2BGR_NV12: case CV_YUV2RGB_NV12:
case CV_YUV2BGR_NV21: case CV_YUV2RGB_NV21:
case CV_YUV2BGR_YV12: case CV_YUV2RGB_YV12:
case CV_YUV2BGR_IYUV: case CV_YUV2RGB_IYUV:
return ChPair(1,3);
case CV_GRAY2BGRA:
case CV_YUV2BGRA_NV12: case CV_YUV2RGBA_NV12:
case CV_YUV2BGRA_NV21: case CV_YUV2RGBA_NV21:
case CV_YUV2BGRA_YV12: case CV_YUV2RGBA_YV12:
case CV_YUV2BGRA_IYUV: case CV_YUV2RGBA_IYUV:
return ChPair(1,4);
case CV_BGR5552GRAY: case CV_BGR5652GRAY:
return ChPair(2,1);
case CV_BGR5552BGR: case CV_BGR5552RGB:
case CV_BGR5652BGR: case CV_BGR5652RGB:
return ChPair(2,3);
case CV_BGR5552BGRA: case CV_BGR5552RGBA:
case CV_BGR5652BGRA: case CV_BGR5652RGBA:
return ChPair(2,4);
case CV_BGR2GRAY: case CV_RGB2GRAY:
return ChPair(3,1);
case CV_BGR2BGR555: case CV_BGR2BGR565:
case CV_RGB2BGR555: case CV_RGB2BGR565:
return ChPair(3,2);
case CV_BGR2HLS: case CV_BGR2HLS_FULL:
case CV_BGR2HSV: case CV_BGR2HSV_FULL:
case CV_BGR2Lab: case CV_BGR2Luv:
case CV_BGR2RGB: case CV_BGR2XYZ:
case CV_BGR2YCrCb: case CV_BGR2YUV:
case CV_HLS2BGR: case CV_HLS2BGR_FULL:
case CV_HLS2RGB: case CV_HLS2RGB_FULL:
case CV_HSV2BGR: case CV_HSV2BGR_FULL:
case CV_HSV2RGB: case CV_HSV2RGB_FULL:
case CV_Lab2BGR: case CV_Lab2LBGR:
case CV_Lab2LRGB: case CV_Lab2RGB:
case CV_LBGR2Lab: case CV_LBGR2Luv:
case CV_LRGB2Lab: case CV_LRGB2Luv:
case CV_Luv2BGR: case CV_Luv2LBGR:
case CV_Luv2LRGB: case CV_Luv2RGB:
case CV_RGB2HLS: case CV_RGB2HLS_FULL:
case CV_RGB2HSV: case CV_RGB2HSV_FULL:
case CV_RGB2Lab: case CV_RGB2Luv:
case CV_RGB2XYZ: case CV_RGB2YCrCb:
case CV_RGB2YUV: case CV_XYZ2BGR:
case CV_XYZ2RGB: case CV_YCrCb2BGR:
case CV_YCrCb2RGB: case CV_YUV2BGR:
case CV_YUV2RGB:
return ChPair(3,3);
case CV_BGR2BGRA: case CV_BGR2RGBA:
case CX_HLS2BGRA: case CX_HLS2BGRA_FULL:
case CX_HLS2RGBA: case CX_HLS2RGBA_FULL:
case CX_HSV2BGRA: case CX_HSV2BGRA_FULL:
case CX_HSV2RGBA: case CX_HSV2RGBA_FULL:
case CX_Lab2BGRA: case CX_Lab2LBGRA:
case CX_Lab2LRGBA: case CX_Lab2RGBA:
case CX_Luv2BGRA: case CX_Luv2LBGRA:
case CX_Luv2LRGBA: case CX_Luv2RGBA:
case CX_XYZ2BGRA: case CX_XYZ2RGBA:
case CX_YCrCb2BGRA: case CX_YCrCb2RGBA:
case CX_YUV2BGRA: case CX_YUV2RGBA:
return ChPair(3,4);
case CV_BGRA2GRAY: case CV_RGBA2GRAY:
return ChPair(4,1);
case CV_BGRA2BGR555: case CV_BGRA2BGR565:
case CV_RGBA2BGR555: case CV_RGBA2BGR565:
return ChPair(4,2);
case CV_BGRA2BGR: case CX_BGRA2HLS:
case CX_BGRA2HLS_FULL: case CX_BGRA2HSV:
case CX_BGRA2HSV_FULL: case CX_BGRA2Lab:
case CX_BGRA2Luv: case CX_BGRA2XYZ:
case CX_BGRA2YCrCb: case CX_BGRA2YUV:
case CX_LBGRA2Lab: case CX_LBGRA2Luv:
case CX_LRGBA2Lab: case CX_LRGBA2Luv:
case CV_RGBA2BGR: case CX_RGBA2HLS:
case CX_RGBA2HLS_FULL: case CX_RGBA2HSV:
case CX_RGBA2HSV_FULL: case CX_RGBA2Lab:
case CX_RGBA2Luv: case CX_RGBA2XYZ:
case CX_RGBA2YCrCb: case CX_RGBA2YUV:
return ChPair(4,3);
case CV_BGRA2RGBA:
return ChPair(4,4);
default:
ADD_FAILURE() << "Unknown conversion type";
break;
};
return ChPair(0,0);
}
typedef std::tr1::tuple<Size, CvtMode> Size_CvtMode_t;
typedef perf::TestBaseWithParam<Size_CvtMode_t> Size_CvtMode;
PERF_TEST_P(Size_CvtMode, cvtColor8u,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::ValuesIn(CvtMode::all())
)
)
{
Size sz = get<0>(GetParam());
int mode = get<1>(GetParam());
ChPair ch = getConversionInfo(mode);
mode %= CV_COLORCVT_MAX;
Mat src(sz, CV_8UC(ch.scn));
Mat dst(sz, CV_8UC(ch.dcn));
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() cvtColor(src, dst, mode, ch.dcn);
SANITY_CHECK(dst, 1);
}
typedef std::tr1::tuple<Size, CvtMode2> Size_CvtMode2_t;
typedef perf::TestBaseWithParam<Size_CvtMode2_t> Size_CvtMode2;
PERF_TEST_P(Size_CvtMode2, cvtColorYUV420,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p, Size(130, 60)),
testing::ValuesIn(CvtMode2::all())
)
)
{
Size sz = get<0>(GetParam());
int mode = get<1>(GetParam());
ChPair ch = getConversionInfo(mode);
Mat src(sz.height + sz.height / 2, sz.width, CV_8UC(ch.scn));
Mat dst(sz, CV_8UC(ch.dcn));
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() cvtColor(src, dst, mode, ch.dcn);
SANITY_CHECK(dst, 1);
}
#include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
//extra color conversions supported implicitly
enum
{
CX_BGRA2HLS = CV_COLORCVT_MAX + CV_BGR2HLS,
CX_BGRA2HLS_FULL = CV_COLORCVT_MAX + CV_BGR2HLS_FULL,
CX_BGRA2HSV = CV_COLORCVT_MAX + CV_BGR2HSV,
CX_BGRA2HSV_FULL = CV_COLORCVT_MAX + CV_BGR2HSV_FULL,
CX_BGRA2Lab = CV_COLORCVT_MAX + CV_BGR2Lab,
CX_BGRA2Luv = CV_COLORCVT_MAX + CV_BGR2Luv,
CX_BGRA2XYZ = CV_COLORCVT_MAX + CV_BGR2XYZ,
CX_BGRA2YCrCb = CV_COLORCVT_MAX + CV_BGR2YCrCb,
CX_BGRA2YUV = CV_COLORCVT_MAX + CV_BGR2YUV,
CX_HLS2BGRA = CV_COLORCVT_MAX + CV_HLS2BGR,
CX_HLS2BGRA_FULL = CV_COLORCVT_MAX + CV_HLS2BGR_FULL,
CX_HLS2RGBA = CV_COLORCVT_MAX + CV_HLS2RGB,
CX_HLS2RGBA_FULL = CV_COLORCVT_MAX + CV_HLS2RGB_FULL,
CX_HSV2BGRA = CV_COLORCVT_MAX + CV_HSV2BGR,
CX_HSV2BGRA_FULL = CV_COLORCVT_MAX + CV_HSV2BGR_FULL,
CX_HSV2RGBA = CV_COLORCVT_MAX + CV_HSV2RGB,
CX_HSV2RGBA_FULL = CV_COLORCVT_MAX + CV_HSV2RGB_FULL,
CX_Lab2BGRA = CV_COLORCVT_MAX + CV_Lab2BGR,
CX_Lab2LBGRA = CV_COLORCVT_MAX + CV_Lab2LBGR,
CX_Lab2LRGBA = CV_COLORCVT_MAX + CV_Lab2LRGB,
CX_Lab2RGBA = CV_COLORCVT_MAX + CV_Lab2RGB,
CX_LBGRA2Lab = CV_COLORCVT_MAX + CV_LBGR2Lab,
CX_LBGRA2Luv = CV_COLORCVT_MAX + CV_LBGR2Luv,
CX_LRGBA2Lab = CV_COLORCVT_MAX + CV_LRGB2Lab,
CX_LRGBA2Luv = CV_COLORCVT_MAX + CV_LRGB2Luv,
CX_Luv2BGRA = CV_COLORCVT_MAX + CV_Luv2BGR,
CX_Luv2LBGRA = CV_COLORCVT_MAX + CV_Luv2LBGR,
CX_Luv2LRGBA = CV_COLORCVT_MAX + CV_Luv2LRGB,
CX_Luv2RGBA = CV_COLORCVT_MAX + CV_Luv2RGB,
CX_RGBA2HLS = CV_COLORCVT_MAX + CV_RGB2HLS,
CX_RGBA2HLS_FULL = CV_COLORCVT_MAX + CV_RGB2HLS_FULL,
CX_RGBA2HSV = CV_COLORCVT_MAX + CV_RGB2HSV,
CX_RGBA2HSV_FULL = CV_COLORCVT_MAX + CV_RGB2HSV_FULL,
CX_RGBA2Lab = CV_COLORCVT_MAX + CV_RGB2Lab,
CX_RGBA2Luv = CV_COLORCVT_MAX + CV_RGB2Luv,
CX_RGBA2XYZ = CV_COLORCVT_MAX + CV_RGB2XYZ,
CX_RGBA2YCrCb = CV_COLORCVT_MAX + CV_RGB2YCrCb,
CX_RGBA2YUV = CV_COLORCVT_MAX + CV_RGB2YUV,
CX_XYZ2BGRA = CV_COLORCVT_MAX + CV_XYZ2BGR,
CX_XYZ2RGBA = CV_COLORCVT_MAX + CV_XYZ2RGB,
CX_YCrCb2BGRA = CV_COLORCVT_MAX + CV_YCrCb2BGR,
CX_YCrCb2RGBA = CV_COLORCVT_MAX + CV_YCrCb2RGB,
CX_YUV2BGRA = CV_COLORCVT_MAX + CV_YUV2BGR,
CX_YUV2RGBA = CV_COLORCVT_MAX + CV_YUV2RGB
};
CV_ENUM(CvtMode,
CV_BayerBG2BGR, CV_BayerBG2BGR_VNG, CV_BayerBG2GRAY,
CV_BayerGB2BGR, CV_BayerGB2BGR_VNG, CV_BayerGB2GRAY,
CV_BayerGR2BGR, CV_BayerGR2BGR_VNG, CV_BayerGR2GRAY,
CV_BayerRG2BGR, CV_BayerRG2BGR_VNG, CV_Bay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
{
ChPair(int _scn, int _dcn): scn(_scn), dcn(_dcn) {}
int scn, dcn;
};
ChPair getConversionInfo(int cvtMode)
{
switch(cvtMode)
{
case CV_BayerBG2GRAY: case CV_BayerGB2GRAY:
case CV_BayerGR2GRAY: case CV_BayerRG2GRAY:
case CV_YUV2GRAY_420:
return ChPair(1,1);
case CV_GRAY2BGR555: case CV_GRAY2BGR565:
return ChPair(1,2);
case CV_BayerBG2BGR: case CV_BayerBG2BGR_VNG:
case CV_BayerGB2BGR: case CV_BayerGB2BGR_VNG:
case CV_BayerGR2BGR: case CV_BayerGR2BGR_VNG:
case CV_BayerRG2BGR: case CV_BayerRG2BGR_VNG:
case CV_GRAY2BGR:
case CV_YUV2BGR_NV12: case CV_YUV2RGB_NV12:
case CV_YUV2BGR_NV21: case CV_YUV2RGB_NV21:
case CV_YUV2BGR_YV12: case CV_YUV2RGB_YV12:
case CV_YUV2BGR_IYUV: case CV_YUV2RGB_IYUV:
return ChPair(1,3);
case CV_GRAY2BGRA:
case CV_YUV2BGRA_NV12: case CV_YUV2RGBA_NV12:
case CV_YUV2BGRA_NV21: case CV_YUV2RGBA_NV21:
case CV_YUV2BGRA_YV12: case CV_YUV2RGBA_YV12:
case CV_YUV2BGRA_IYUV: case CV_YUV2RGBA_IYUV:
return ChPair(1,4);
case CV_BGR5552GRAY: case CV_BGR5652GRAY:
return ChPair(2,1);
case CV_BGR5552BGR: case CV_BGR5552RGB:
case CV_BGR5652BGR: case CV_BGR5652RGB:
case CV_YUV2RGB_UYVY: case CV_YUV2BGR_UYVY:
case CV_YUV2RGBA_UYVY: case CV_YUV2BGRA_UYVY:
case CV_YUV2RGB_YUY2: case CV_YUV2BGR_YUY2:
case CV_YUV2RGB_YVYU: case CV_YUV2BGR_YVYU:
case CV_YUV2RGBA_YUY2: case CV_YUV2BGRA_YUY2:
case CV_YUV2RGBA_YVYU: case CV_YUV2BGRA_YVYU:
return ChPair(2,3);
case CV_BGR5552BGRA: case CV_BGR5552RGBA:
case CV_BGR5652BGRA: case CV_BGR5652RGBA:
return ChPair(2,4);
case CV_BGR2GRAY: case CV_RGB2GRAY:
return ChPair(3,1);
case CV_BGR2BGR555: case CV_BGR2BGR565:
case CV_RGB2BGR555: case CV_RGB2BGR565:
return ChPair(3,2);
case CV_BGR2HLS: case CV_BGR2HLS_FULL:
case CV_BGR2HSV: case CV_BGR2HSV_FULL:
case CV_BGR2Lab: case CV_BGR2Luv:
case CV_BGR2RGB: case CV_BGR2XYZ:
case CV_BGR2YCrCb: case CV_BGR2YUV:
case CV_HLS2BGR: case CV_HLS2BGR_FULL:
case CV_HLS2RGB: case CV_HLS2RGB_FULL:
case CV_HSV2BGR: case CV_HSV2BGR_FULL:
case CV_HSV2RGB: case CV_HSV2RGB_FULL:
case CV_Lab2BGR: case CV_Lab2LBGR:
case CV_Lab2LRGB: case CV_Lab2RGB:
case CV_LBGR2Lab: case CV_LBGR2Luv:
case CV_LRGB2Lab: case CV_LRGB2Luv:
case CV_Luv2BGR: case CV_Luv2LBGR:
case CV_Luv2LRGB: case CV_Luv2RGB:
case CV_RGB2HLS: case CV_RGB2HLS_FULL:
case CV_RGB2HSV: case CV_RGB2HSV_FULL:
case CV_RGB2Lab: case CV_RGB2Luv:
case CV_RGB2XYZ: case CV_RGB2YCrCb:
case CV_RGB2YUV: case CV_XYZ2BGR:
case CV_XYZ2RGB: case CV_YCrCb2BGR:
case CV_YCrCb2RGB: case CV_YUV2BGR:
case CV_YUV2RGB:
return ChPair(3,3);
case CV_BGR2BGRA: case CV_BGR2RGBA:
case CX_HLS2BGRA: case CX_HLS2BGRA_FULL:
case CX_HLS2RGBA: case CX_HLS2RGBA_FULL:
case CX_HSV2BGRA: case CX_HSV2BGRA_FULL:
case CX_HSV2RGBA: case CX_HSV2RGBA_FULL:
case CX_Lab2BGRA: case CX_Lab2LBGRA:
case CX_Lab2LRGBA: case CX_Lab2RGBA:
case CX_Luv2BGRA: case CX_Luv2LBGRA:
case CX_Luv2LRGBA: case CX_Luv2RGBA:
case CX_XYZ2BGRA: case CX_XYZ2RGBA:
case CX_YCrCb2BGRA: case CX_YCrCb2RGBA:
case CX_YUV2BGRA: case CX_YUV2RGBA:
return ChPair(3,4);
case CV_BGRA2GRAY: case CV_RGBA2GRAY:
return ChPair(4,1);
case CV_BGRA2BGR555: case CV_BGRA2BGR565:
case CV_RGBA2BGR555: case CV_RGBA2BGR565:
return ChPair(4,2);
case CV_BGRA2BGR: case CX_BGRA2HLS:
case CX_BGRA2HLS_FULL: case CX_BGRA2HSV:
case CX_BGRA2HSV_FULL: case CX_BGRA2Lab:
case CX_BGRA2Luv: case CX_BGRA2XYZ:
case CX_BGRA2YCrCb: case CX_BGRA2YUV:
case CX_LBGRA2Lab: case CX_LBGRA2Luv:
case CX_LRGBA2Lab: case CX_LRGBA2Luv:
case CV_RGBA2BGR: case CX_RGBA2HLS:
case CX_RGBA2HLS_FULL: case CX_RGBA2HSV:
case CX_RGBA2HSV_FULL: case CX_RGBA2Lab:
case CX_RGBA2Luv: case CX_RGBA2XYZ:
case CX_RGBA2YCrCb: case CX_RGBA2YUV:
return ChPair(4,3);
case CV_BGRA2RGBA:
return ChPair(4,4);
default:
ADD_FAILURE() << "Unknown conversion type";
break;
};
return ChPair(0,0);
}
typedef std::tr1::tuple<Size, CvtMode> Size_CvtMode_t;
typedef perf::TestBaseWithParam<Size_CvtMode_t> Size_CvtMode;
PERF_TEST_P(Size_CvtMode, cvtColor8u,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::ValuesIn(CvtMode::all())
)
)
{
Size sz = get<0>(GetParam());
int mode = get<1>(GetParam());
ChPair ch = getConversionInfo(mode);
mode %= CV_COLORCVT_MAX;
Mat src(sz, CV_8UC(ch.scn));
Mat dst(sz, CV_8UC(ch.dcn));
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() cvtColor(src, dst, mode, ch.dcn);
SANITY_CHECK(dst, 1);
}
typedef std::tr1::tuple<Size, CvtMode2> Size_CvtMode2_t;
typedef perf::TestBaseWithParam<Size_CvtMode2_t> Size_CvtMode2;
PERF_TEST_P(Size_CvtMode2, cvtColorYUV420,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p, Size(130, 60)),
testing::ValuesIn(CvtMode2::all())
)
)
{
Size sz = get<0>(GetParam());
int mode = get<1>(GetParam());
ChPair ch = getConversionInfo(mode);
Mat src(sz.height + sz.height / 2, sz.width, CV_8UC(ch.scn));
Mat dst(sz, CV_8UC(ch.dcn));
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() cvtColor(src, dst, mode, ch.dcn);
SANITY_CHECK(dst, 1);
}

View File

@ -1,168 +1,168 @@
#include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace perf;
using namespace testing;
using std::tr1::make_tuple;
using std::tr1::get;
enum{HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH};
CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE);
CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR);
CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH);
typedef TestBaseWithParam< tr1::tuple<Size, InterType, BorderMode> > TestWarpAffine;
typedef TestBaseWithParam< tr1::tuple<Size, InterType, BorderMode> > TestWarpPerspective;
typedef TestBaseWithParam< tr1::tuple<MatType, Size, InterType, BorderMode, RemapMode> > TestRemap;
void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode );
PERF_TEST_P( TestWarpAffine, WarpAffine,
Combine(
Values( szVGA, sz720p, sz1080p ),
ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() )
)
)
{
Size sz;
int borderMode, interType;
sz = get<0>(GetParam());
borderMode = get<1>(GetParam());
interType = get<2>(GetParam());
Mat src, img = imread(getDataPath("cv/shared/fruits.jpg"));
cvtColor(img, src, COLOR_BGR2RGBA, 4);
Mat warpMat = getRotationMatrix2D(Point2f(src.cols/2.f, src.rows/2.f), 30., 2.2);
Mat dst(sz, CV_8UC4);
declare.in(src).out(dst);
TEST_CYCLE() warpAffine( src, dst, warpMat, sz, interType, borderMode, Scalar::all(150) );
SANITY_CHECK(dst);
}
PERF_TEST_P( TestWarpPerspective, WarpPerspective,
Combine(
Values( szVGA, sz720p, sz1080p ),
ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() )
)
)
{
Size sz;
int borderMode, interType;
sz = get<0>(GetParam());
borderMode = get<1>(GetParam());
interType = get<2>(GetParam());
Mat src, img = imread(getDataPath("cv/shared/fruits.jpg"));
cvtColor(img, src, COLOR_BGR2RGBA, 4);
Mat rotMat = getRotationMatrix2D(Point2f(src.cols/2.f, src.rows/2.f), 30., 2.2);
Mat warpMat(3, 3, CV_64FC1);
for(int r=0; r<2; r++)
for(int c=0; c<3; c++)
warpMat.at<double>(r, c) = rotMat.at<double>(r, c);
warpMat.at<double>(2, 0) = .3/sz.width;
warpMat.at<double>(2, 1) = .3/sz.height;
warpMat.at<double>(2, 2) = 1;
Mat dst(sz, CV_8UC4);
declare.in(src).out(dst);
TEST_CYCLE() warpPerspective( src, dst, warpMat, sz, interType, borderMode, Scalar::all(150) );
SANITY_CHECK(dst);
}
PERF_TEST_P( TestRemap, remap,
Combine(
Values( TYPICAL_MAT_TYPES ),
Values( szVGA, sz720p, sz1080p ),
ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() ),
ValuesIn( RemapMode::all() )
)
)
{
int type = get<0>(GetParam());
Size size = get<1>(GetParam());
int interpolationType = get<2>(GetParam());
int borderMode = get<3>(GetParam());
int remapMode = get<4>(GetParam());
unsigned int height = size.height;
unsigned int width = size.width;
Mat source(height, width, type);
Mat destination;
Mat map_x(height, width, CV_32F);
Mat map_y(height, width, CV_32F);
declare.in(source, WARMUP_RNG);
update_map(source, map_x, map_y, remapMode);
TEST_CYCLE()
{
remap(source, destination, map_x, map_y, interpolationType, borderMode);
}
SANITY_CHECK(destination, 1);
}
void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode )
{
for( int j = 0; j < src.rows; j++ )
{
for( int i = 0; i < src.cols; i++ )
{
switch( remapMode )
{
case HALF_SIZE:
if( i > src.cols*0.25 && i < src.cols*0.75 && j > src.rows*0.25 && j < src.rows*0.75 )
{
map_x.at<float>(j,i) = 2*( i - src.cols*0.25 ) + 0.5 ;
map_y.at<float>(j,i) = 2*( j - src.rows*0.25 ) + 0.5 ;
}
else
{
map_x.at<float>(j,i) = 0 ;
map_y.at<float>(j,i) = 0 ;
}
break;
case UPSIDE_DOWN:
map_x.at<float>(j,i) = i ;
map_y.at<float>(j,i) = src.rows - j ;
break;
case REFLECTION_X:
map_x.at<float>(j,i) = src.cols - i ;
map_y.at<float>(j,i) = j ;
break;
case REFLECTION_BOTH:
map_x.at<float>(j,i) = src.cols - i ;
map_y.at<float>(j,i) = src.rows - j ;
break;
} // end of switch
}
}
}
PERF_TEST(Transform, getPerspectiveTransform)
{
unsigned int size = 8;
Mat source(1, size/2, CV_32FC2);
Mat destination(1, size/2, CV_32FC2);
Mat transformCoefficient;
declare.in(source, destination, WARMUP_RNG);
TEST_CYCLE()
{
transformCoefficient = getPerspectiveTransform(source, destination);
}
}
#include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace perf;
using namespace testing;
using std::tr1::make_tuple;
using std::tr1::get;
enum{HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH};
CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE);
CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR);
CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH);
typedef TestBaseWithParam< tr1::tuple<Size, InterType, BorderMode> > TestWarpAffine;
typedef TestBaseWithParam< tr1::tuple<Size, InterType, BorderMode> > TestWarpPerspective;
typedef TestBaseWithParam< tr1::tuple<MatType, Size, InterType, BorderMode, RemapMode> > TestRemap;
void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode );
PERF_TEST_P( TestWarpAffine, WarpAffine,
Combine(
Values( szVGA, sz720p, sz1080p ),
ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() )
)
)
{
Size sz;
int borderMode, interType;
sz = get<0>(GetParam());
borderMode = get<1>(GetParam());
interType = get<2>(GetParam());
Mat src, img = imread(getDataPath("cv/shared/fruits.jpg"));
cvtColor(img, src, COLOR_BGR2RGBA, 4);
Mat warpMat = getRotationMatrix2D(Point2f(src.cols/2.f, src.rows/2.f), 30., 2.2);
Mat dst(sz, CV_8UC4);
declare.in(src).out(dst);
TEST_CYCLE() warpAffine( src, dst, warpMat, sz, interType, borderMode, Scalar::all(150) );
SANITY_CHECK(dst);
}
PERF_TEST_P( TestWarpPerspective, WarpPerspective,
Combine(
Values( szVGA, sz720p, sz1080p ),
ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() )
)
)
{
Size sz;
int borderMode, interType;
sz = get<0>(GetParam());
borderMode = get<1>(GetParam());
interType = get<2>(GetParam());
Mat src, img = imread(getDataPath("cv/shared/fruits.jpg"));
cvtColor(img, src, COLOR_BGR2RGBA, 4);
Mat rotMat = getRotationMatrix2D(Point2f(src.cols/2.f, src.rows/2.f), 30., 2.2);
Mat warpMat(3, 3, CV_64FC1);
for(int r=0; r<2; r++)
for(int c=0; c<3; c++)
warpMat.at<double>(r, c) = rotMat.at<double>(r, c);
warpMat.at<double>(2, 0) = .3/sz.width;
warpMat.at<double>(2, 1) = .3/sz.height;
warpMat.at<double>(2, 2) = 1;
Mat dst(sz, CV_8UC4);
declare.in(src).out(dst);
TEST_CYCLE() warpPerspective( src, dst, warpMat, sz, interType, borderMode, Scalar::all(150) );
SANITY_CHECK(dst);
}
PERF_TEST_P( TestRemap, remap,
Combine(
Values( TYPICAL_MAT_TYPES ),
Values( szVGA, sz720p, sz1080p ),
ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() ),
ValuesIn( RemapMode::all() )
)
)
{
int type = get<0>(GetParam());
Size size = get<1>(GetParam());
int interpolationType = get<2>(GetParam());
int borderMode = get<3>(GetParam());
int remapMode = get<4>(GetParam());
unsigned int height = size.height;
unsigned int width = size.width;
Mat source(height, width, type);
Mat destination;
Mat map_x(height, width, CV_32F);
Mat map_y(height, width, CV_32F);
declare.in(source, WARMUP_RNG);
update_map(source, map_x, map_y, remapMode);
TEST_CYCLE()
{
remap(source, destination, map_x, map_y, interpolationType, borderMode);
}
SANITY_CHECK(destination, 1);
}
void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode )
{
for( int j = 0; j < src.rows; j++ )
{
for( int i = 0; i < src.cols; i++ )
{
switch( remapMode )
{
case HALF_SIZE:
if( i > src.cols*0.25 && i < src.cols*0.75 && j > src.rows*0.25 && j < src.rows*0.75 )
{
map_x.at<float>(j,i) = 2*( i - src.cols*0.25 ) + 0.5 ;
map_y.at<float>(j,i) = 2*( j - src.rows*0.25 ) + 0.5 ;
}
else
{
map_x.at<float>(j,i) = 0 ;
map_y.at<float>(j,i) = 0 ;
}
break;
case UPSIDE_DOWN:
map_x.at<float>(j,i) = i ;
map_y.at<float>(j,i) = src.rows - j ;
break;
case REFLECTION_X:
map_x.at<float>(j,i) = src.cols - i ;
map_y.at<float>(j,i) = j ;
break;
case REFLECTION_BOTH:
map_x.at<float>(j,i) = src.cols - i ;
map_y.at<float>(j,i) = src.rows - j ;
break;
} // end of switch
}
}
}
PERF_TEST(Transform, getPerspectiveTransform)
{
unsigned int size = 8;
Mat source(1, size/2, CV_32FC2);
Mat destination(1, size/2, CV_32FC2);
Mat transformCoefficient;
declare.in(source, destination, WARMUP_RNG);
TEST_CYCLE()
{
transformCoefficient = getPerspectiveTransform(source, destination);
}
}