Merge branch '2.4'

This commit is contained in:
Andrey Kamaev 2013-04-17 12:07:17 +04:00
commit 8fdab9f631
38 changed files with 1462 additions and 1178 deletions

11
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,11 @@
We greatly appreciate your support and contributions and they are always welcomed!
Github pull requests are the convenient way to contribute to OpenCV project. Good pull requests have all of these attributes:
* Are scoped to one specific issue
* Include a test to demonstrate the correctness
* Update the docs if relevant
* Match the [coding style guidelines](http://code.opencv.org/projects/opencv/wiki/CodingStyleGuide)
* Don't messed by "oops" commits
You can find more detailes about contributing process on http://opencv.org/contribute.html

View File

@ -15,7 +15,7 @@ PERF_TEST_P( Size_MatType_CmpType, compare,
testing::Combine(
testing::Values(::perf::szVGA, ::perf::sz1080p),
testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1),
testing::ValuesIn(CmpType::all())
CmpType::all()
)
)
{
@ -38,7 +38,7 @@ PERF_TEST_P( Size_MatType_CmpType, compareScalar,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(TYPICAL_MAT_TYPES),
testing::ValuesIn(CmpType::all())
CmpType::all()
)
)
{

View File

@ -16,7 +16,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceR,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(TYPICAL_MAT_TYPES),
testing::ValuesIn(ROp::all())
ROp::all()
)
)
{
@ -43,7 +43,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceC,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(TYPICAL_MAT_TYPES),
testing::ValuesIn(ROp::all())
ROp::all()
)
)
{

View File

@ -18,7 +18,7 @@ typedef perf::TestBaseWithParam<File_Type_t> fast;
PERF_TEST_P(fast, detect, testing::Combine(
testing::Values(FAST_IMAGES),
testing::ValuesIn(FastType::all())
FastType::all()
))
{
string filename = getDataPath(get<0>(GetParam()));

View File

@ -712,15 +712,14 @@ PERF_TEST_P(Sz_Depth_Power, Core_Pow,
//////////////////////////////////////////////////////////////////////
// CompareMat
CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE)
#define ALL_CMP_CODES ValuesIn(CmpCode::all())
CV_ENUM(CmpCode, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE)
DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CmpCode);
PERF_TEST_P(Sz_Depth_Code, Core_CompareMat,
Combine(GPU_TYPICAL_MAT_SIZES,
ARITHM_MAT_DEPTH,
ALL_CMP_CODES))
CmpCode::all()))
{
const cv::Size size = GET_PARAM(0);
const int depth = GET_PARAM(1);
@ -758,7 +757,7 @@ PERF_TEST_P(Sz_Depth_Code, Core_CompareMat,
PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar,
Combine(GPU_TYPICAL_MAT_SIZES,
ARITHM_MAT_DEPTH,
ALL_CMP_CODES))
CmpCode::all()))
{
const cv::Size size = GET_PARAM(0);
const int depth = GET_PARAM(1);
@ -1304,7 +1303,7 @@ PERF_TEST_P(Sz_3Depth, Core_AddWeighted,
//////////////////////////////////////////////////////////////////////
// GEMM
CV_FLAGS(GemmFlags, 0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T)
CV_FLAGS(GemmFlags, 0, GEMM_1_T, GEMM_2_T, GEMM_3_T)
#define ALL_GEMM_FLAGS Values(0, (int)cv::GEMM_1_T, (int)cv::GEMM_2_T, (int)cv::GEMM_3_T, \
(int)cv::GEMM_1_T | cv::GEMM_2_T, (int)cv::GEMM_1_T | cv::GEMM_3_T, \
(int)cv::GEMM_1_T | cv::GEMM_2_T | cv::GEMM_3_T)
@ -1391,7 +1390,6 @@ PERF_TEST_P(Sz_Type, Core_Transpose,
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
#define ALL_FLIP_CODES ValuesIn(FlipCode::all())
DEF_PARAM_TEST(Sz_Depth_Cn_Code, cv::Size, MatDepth, MatCn, FlipCode);
@ -1399,7 +1397,7 @@ PERF_TEST_P(Sz_Depth_Cn_Code, Core_Flip,
Combine(GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
GPU_CHANNELS_1_3_4,
ALL_FLIP_CODES))
FlipCode::all()))
{
const cv::Size size = GET_PARAM(0);
const int depth = GET_PARAM(1);
@ -2073,12 +2071,9 @@ PERF_TEST_P(Sz_Depth, Core_CountNonZero,
//////////////////////////////////////////////////////////////////////
// Reduce
CV_ENUM(ReduceCode, cv::REDUCE_SUM, cv::REDUCE_AVG, cv::REDUCE_MAX, cv::REDUCE_MIN)
#define ALL_REDUCE_CODES ValuesIn(ReduceCode::all())
enum {Rows = 0, Cols = 1};
CV_ENUM(ReduceCode, REDUCE_SUM, REDUCE_AVG, REDUCE_MAX, REDUCE_MIN)
CV_ENUM(ReduceDim, Rows, Cols)
#define ALL_REDUCE_DIMS ValuesIn(ReduceDim::all())
DEF_PARAM_TEST(Sz_Depth_Cn_Code_Dim, cv::Size, MatDepth, MatCn, ReduceCode, ReduceDim);
@ -2086,8 +2081,8 @@ PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Core_Reduce,
Combine(GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values(1, 2, 3, 4),
ALL_REDUCE_CODES,
ALL_REDUCE_DIMS))
ReduceCode::all(),
ReduceDim::all()))
{
const cv::Size size = GET_PARAM(0);
const int depth = GET_PARAM(1);

View File

@ -291,12 +291,11 @@ PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
//////////////////////////////////////////////////////////////////////
// MorphologyEx
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)
#define ALL_MORPH_OPS ValuesIn(MorphOp::all())
CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT)
DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, MorphOp);
PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), ALL_MORPH_OPS))
PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), MorphOp::all()))
{
declare.time(20.0);

View File

@ -51,7 +51,6 @@ using namespace perf;
enum { HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH };
CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH);
#define ALL_REMAP_MODES ValuesIn(RemapMode::all())
void generateMap(cv::Mat& map_x, cv::Mat& map_y, int remapMode)
{
@ -98,7 +97,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap,
GPU_CHANNELS_1_3_4,
Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
ALL_BORDER_MODES,
ALL_REMAP_MODES))
RemapMode::all()))
{
declare.time(20.0);
@ -369,15 +368,14 @@ PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder,
//////////////////////////////////////////////////////////////////////
// Threshold
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
#define ALL_THRESH_OPS ValuesIn(ThreshOp::all())
CV_ENUM(ThreshOp, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV)
DEF_PARAM_TEST(Sz_Depth_Op, cv::Size, MatDepth, ThreshOp);
PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold,
Combine(GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F, CV_64F),
ALL_THRESH_OPS))
ThreshOp::all()))
{
const cv::Size size = GET_PARAM(0);
const int depth = GET_PARAM(1);
@ -894,8 +892,7 @@ PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve,
////////////////////////////////////////////////////////////////////////////////
// MatchTemplate8U
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
#define ALL_TEMPLATE_METHODS ValuesIn(TemplateMethod::all())
CV_ENUM(TemplateMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
DEF_PARAM_TEST(Sz_TemplateSz_Cn_Method, cv::Size, cv::Size, MatCn, TemplateMethod);
@ -903,7 +900,7 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U,
Combine(GPU_TYPICAL_MAT_SIZES,
Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
GPU_CHANNELS_1_3_4,
ALL_TEMPLATE_METHODS))
TemplateMethod::all()))
{
declare.time(300.0);
@ -979,7 +976,7 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F,
//////////////////////////////////////////////////////////////////////
// MulSpectrums
CV_FLAGS(DftFlags, 0, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)
CV_FLAGS(DftFlags, 0, DFT_INVERSE, DFT_SCALE, DFT_ROWS, DFT_COMPLEX_OUTPUT, DFT_REAL_OUTPUT)
DEF_PARAM_TEST(Sz_Flags, cv::Size, DftFlags);
@ -1454,16 +1451,16 @@ PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColorBayer,
}
CV_ENUM(DemosaicingCode,
cv::COLOR_BayerBG2BGR, cv::COLOR_BayerGB2BGR, cv::COLOR_BayerRG2BGR, cv::COLOR_BayerGR2BGR,
cv::COLOR_BayerBG2GRAY, cv::COLOR_BayerGB2GRAY, cv::COLOR_BayerRG2GRAY, cv::COLOR_BayerGR2GRAY,
cv::gpu::COLOR_BayerBG2BGR_MHT, cv::gpu::COLOR_BayerGB2BGR_MHT, cv::gpu::COLOR_BayerRG2BGR_MHT, cv::gpu::COLOR_BayerGR2BGR_MHT,
cv::gpu::COLOR_BayerBG2GRAY_MHT, cv::gpu::COLOR_BayerGB2GRAY_MHT, cv::gpu::COLOR_BayerRG2GRAY_MHT, cv::gpu::COLOR_BayerGR2GRAY_MHT)
COLOR_BayerBG2BGR, COLOR_BayerGB2BGR, COLOR_BayerRG2BGR, COLOR_BayerGR2BGR,
COLOR_BayerBG2GRAY, COLOR_BayerGB2GRAY, COLOR_BayerRG2GRAY, COLOR_BayerGR2GRAY,
COLOR_BayerBG2BGR_MHT, COLOR_BayerGB2BGR_MHT, COLOR_BayerRG2BGR_MHT, COLOR_BayerGR2BGR_MHT,
COLOR_BayerBG2GRAY_MHT, COLOR_BayerGB2GRAY_MHT, COLOR_BayerRG2GRAY_MHT, COLOR_BayerGR2GRAY_MHT)
DEF_PARAM_TEST(Sz_Code, cv::Size, DemosaicingCode);
PERF_TEST_P(Sz_Code, ImgProc_Demosaicing,
Combine(GPU_TYPICAL_MAT_SIZES,
ValuesIn(DemosaicingCode::all())))
DemosaicingCode::all()))
{
const cv::Size size = GET_PARAM(0);
const int code = GET_PARAM(1);
@ -1527,15 +1524,14 @@ PERF_TEST_P(Sz, ImgProc_SwapChannels,
//////////////////////////////////////////////////////////////////////
// AlphaComp
CV_ENUM(AlphaOp, cv::gpu::ALPHA_OVER, cv::gpu::ALPHA_IN, cv::gpu::ALPHA_OUT, cv::gpu::ALPHA_ATOP, cv::gpu::ALPHA_XOR, cv::gpu::ALPHA_PLUS, cv::gpu::ALPHA_OVER_PREMUL, cv::gpu::ALPHA_IN_PREMUL, cv::gpu::ALPHA_OUT_PREMUL, cv::gpu::ALPHA_ATOP_PREMUL, cv::gpu::ALPHA_XOR_PREMUL, cv::gpu::ALPHA_PLUS_PREMUL, cv::gpu::ALPHA_PREMUL)
#define ALL_ALPHA_OPS ValuesIn(AlphaOp::all())
CV_ENUM(AlphaOp, ALPHA_OVER, ALPHA_IN, ALPHA_OUT, ALPHA_ATOP, ALPHA_XOR, ALPHA_PLUS, ALPHA_OVER_PREMUL, ALPHA_IN_PREMUL, ALPHA_OUT_PREMUL, ALPHA_ATOP_PREMUL, ALPHA_XOR_PREMUL, ALPHA_PLUS_PREMUL, ALPHA_PREMUL)
DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, AlphaOp);
PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp,
Combine(GPU_TYPICAL_MAT_SIZES,
Values(CV_8UC4, CV_16UC4, CV_32SC4, CV_32FC4),
ALL_ALPHA_OPS))
AlphaOp::all()))
{
const cv::Size size = GET_PARAM(0);
const int type = GET_PARAM(1);

View File

@ -1613,8 +1613,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Exp, testing::Combine(
////////////////////////////////////////////////////////////////////////////////
// Compare_Array
CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE)
#define ALL_CMP_CODES testing::Values(CmpCode(cv::CMP_EQ), CmpCode(cv::CMP_NE), CmpCode(cv::CMP_GT), CmpCode(cv::CMP_GE), CmpCode(cv::CMP_LT), CmpCode(cv::CMP_LE))
CV_ENUM(CmpCode, CMP_EQ, CMP_NE, CMP_GT, CMP_GE, CMP_LT, CMP_LE)
PARAM_TEST_CASE(Compare_Array, cv::gpu::DeviceInfo, cv::Size, MatDepth, CmpCode, UseRoi)
{
@ -1669,7 +1668,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Compare_Array, testing::Combine(
ALL_DEVICES,
DIFFERENT_SIZES,
ALL_DEPTH,
ALL_CMP_CODES,
CmpCode::all(),
WHOLE_SUBMAT));
////////////////////////////////////////////////////////////////////////////////
@ -1780,7 +1779,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Compare_Scalar, testing::Combine(
ALL_DEVICES,
DIFFERENT_SIZES,
TYPES(CV_8U, CV_64F, 1, 4),
ALL_CMP_CODES,
CmpCode::all(),
WHOLE_SUBMAT));
//////////////////////////////////////////////////////////////////////////////
@ -2371,7 +2370,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, AddWeighted, testing::Combine(
#ifdef HAVE_CUBLAS
CV_FLAGS(GemmFlags, 0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T);
CV_FLAGS(GemmFlags, 0, GEMM_1_T, GEMM_2_T, GEMM_3_T);
#define ALL_GEMM_FLAGS testing::Values(GemmFlags(0), GemmFlags(cv::GEMM_1_T), GemmFlags(cv::GEMM_2_T), GemmFlags(cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T | cv::GEMM_3_T))
PARAM_TEST_CASE(GEMM, cv::gpu::DeviceInfo, cv::Size, MatType, GemmFlags, UseRoi)

View File

@ -123,7 +123,7 @@ namespace
IMPLEMENT_PARAM_CLASS(ORB_BlurForDescriptor, bool)
}
CV_ENUM(ORB_ScoreType, cv::ORB::HARRIS_SCORE, cv::ORB::FAST_SCORE)
CV_ENUM(ORB_ScoreType, ORB::HARRIS_SCORE, ORB::FAST_SCORE)
PARAM_TEST_CASE(ORB, cv::gpu::DeviceInfo, ORB_FeaturesCount, ORB_ScaleFactor, ORB_LevelsCount, ORB_EdgeThreshold, ORB_firstLevel, ORB_WTA_K, ORB_ScoreType, ORB_PatchSize, ORB_BlurForDescriptor)
{

View File

@ -471,8 +471,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Filter, Dilate, testing::Combine(
/////////////////////////////////////////////////////////////////////////////////////////////////
// MorphEx
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)
#define ALL_MORPH_OPS testing::Values(MorphOp(cv::MORPH_OPEN), MorphOp(cv::MORPH_CLOSE), MorphOp(cv::MORPH_GRADIENT), MorphOp(cv::MORPH_TOPHAT), MorphOp(cv::MORPH_BLACKHAT))
CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT)
PARAM_TEST_CASE(MorphEx, cv::gpu::DeviceInfo, cv::Size, MatType, MorphOp, Anchor, Iterations, UseRoi)
{
@ -518,7 +517,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Filter, MorphEx, testing::Combine(
ALL_DEVICES,
DIFFERENT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),
ALL_MORPH_OPS,
MorphOp::all(),
testing::Values(Anchor(cv::Point(-1, -1)), Anchor(cv::Point(0, 0)), Anchor(cv::Point(2, 2))),
testing::Values(Iterations(1), Iterations(2), Iterations(3)),
WHOLE_SUBMAT));

View File

@ -663,8 +663,7 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Convolve, testing::Combine(
////////////////////////////////////////////////////////////////////////////////
// MatchTemplate8U
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
#define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_CCOEFF_NORMED))
CV_ENUM(TemplateMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
namespace
{
@ -710,7 +709,7 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate8U, testing::Combine(
DIFFERENT_SIZES,
testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))),
testing::Values(Channels(1), Channels(3), Channels(4)),
ALL_TEMPLATE_METHODS));
TemplateMethod::all()));
////////////////////////////////////////////////////////////////////////////////
// MatchTemplate32F
@ -919,7 +918,7 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate_CanFindBigTemplate, ALL_DEVIC
////////////////////////////////////////////////////////////////////////////
// MulSpectrums
CV_FLAGS(DftFlags, 0, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)
CV_FLAGS(DftFlags, 0, DFT_INVERSE, DFT_SCALE, DFT_ROWS, DFT_COMPLEX_OUTPUT, DFT_REAL_OUTPUT)
PARAM_TEST_CASE(MulSpectrums, cv::gpu::DeviceInfo, cv::Size, DftFlags)
{

View File

@ -333,7 +333,7 @@ namespace
{
IMPLEMENT_PARAM_CLASS(PyrScale, double)
IMPLEMENT_PARAM_CLASS(PolyN, int)
CV_FLAGS(FarnebackOptFlowFlags, 0, cv::OPTFLOW_FARNEBACK_GAUSSIAN)
CV_FLAGS(FarnebackOptFlowFlags, 0, OPTFLOW_FARNEBACK_GAUSSIAN)
IMPLEMENT_PARAM_CLASS(UseInitFlow, bool)
}

View File

@ -46,8 +46,7 @@
using namespace cvtest;
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
#define ALL_THRESH_OPS testing::Values(ThreshOp(cv::THRESH_BINARY), ThreshOp(cv::THRESH_BINARY_INV), ThreshOp(cv::THRESH_TRUNC), ThreshOp(cv::THRESH_TOZERO), ThreshOp(cv::THRESH_TOZERO_INV))
CV_ENUM(ThreshOp, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV)
PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, cv::Size, MatType, ThreshOp, UseRoi)
{
@ -88,7 +87,7 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Threshold, testing::Combine(
ALL_DEVICES,
DIFFERENT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_16SC1), MatType(CV_32FC1)),
ALL_THRESH_OPS,
ThreshOp::all(),
WHOLE_SUBMAT));
#endif // HAVE_CUDA

View File

@ -15,7 +15,7 @@ PERF_TEST_P( TestBilateralFilter, BilateralFilter,
Combine(
Values( szVGA, sz1080p ), // image size
Values( 3, 5 ), // d
ValuesIn( Mat_Type::all() ) // image type
Mat_Type::all() // image type
)
)
{

View File

@ -47,7 +47,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, gaussianBlur3x3,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
testing::ValuesIn(BorderType3x3::all())
BorderType3x3::all()
)
)
{
@ -69,7 +69,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, blur3x3,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
testing::ValuesIn(BorderType3x3::all())
BorderType3x3::all()
)
)
{
@ -91,7 +91,7 @@ PERF_TEST_P(Size_MatType_BorderType, blur16x16,
testing::Combine(
testing::Values(szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
testing::ValuesIn(BorderType::all())
BorderType::all()
)
)
{
@ -113,7 +113,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, box3x3,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_32FC3),
testing::ValuesIn(BorderType3x3::all())
BorderType3x3::all()
)
)
{
@ -135,7 +135,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, box3x3_inplace,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_32FC3),
testing::ValuesIn(BorderType3x3::all())
BorderType3x3::all()
)
)
{
@ -163,7 +163,7 @@ PERF_TEST_P(Size_MatType_BorderType, gaussianBlur5x5,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
testing::ValuesIn(BorderType::all())
BorderType::all()
)
)
{
@ -185,7 +185,7 @@ PERF_TEST_P(Size_MatType_BorderType, blur5x5,
testing::Combine(
testing::Values(szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1, CV_32FC3),
testing::ValuesIn(BorderType::all())
BorderType::all()
)
)
{

View File

@ -16,7 +16,7 @@ PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerEigenValsAndVecs,
testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
testing::Values( 3, 5 ),
testing::Values( 3, 5 ),
testing::ValuesIn(BorderType::all())
BorderType::all()
)
)
{

View File

@ -17,7 +17,7 @@ PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris,
testing::Values( 3, 5 ),
testing::Values( 3, 5 ),
testing::Values( 0.04, 0.1 ),
testing::ValuesIn(BorderType::all())
BorderType::all()
)
)
{

View File

@ -243,7 +243,7 @@ typedef perf::TestBaseWithParam<Size_CvtMode_t> Size_CvtMode;
PERF_TEST_P(Size_CvtMode, cvtColor8u,
testing::Combine(
testing::Values(::perf::szODD, ::perf::szVGA, ::perf::sz1080p),
testing::ValuesIn(CvtMode::all())
CvtMode::all()
)
)
{
@ -269,7 +269,7 @@ typedef perf::TestBaseWithParam<Size_CvtMode_Bayer_t> Size_CvtMode_Bayer;
PERF_TEST_P(Size_CvtMode_Bayer, cvtColorBayer8u,
testing::Combine(
testing::Values(::perf::szODD, ::perf::szVGA),
testing::ValuesIn(CvtModeBayer::all())
CvtModeBayer::all()
)
)
{
@ -295,7 +295,7 @@ typedef perf::TestBaseWithParam<Size_CvtMode2_t> Size_CvtMode2;
PERF_TEST_P(Size_CvtMode2, cvtColorYUV420,
testing::Combine(
testing::Values(szVGA, sz1080p, Size(130, 60)),
testing::ValuesIn(CvtMode2::all())
CvtMode2::all()
)
)
{
@ -320,7 +320,7 @@ typedef perf::TestBaseWithParam<Size_CvtMode3_t> Size_CvtMode3;
PERF_TEST_P(Size_CvtMode3, cvtColorRGB2YUV420p,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p, Size(130, 60)),
testing::ValuesIn(CvtMode3::all())
CvtMode3::all()
)
)
{
@ -347,7 +347,7 @@ typedef perf::TestBaseWithParam<EdgeAwareParams> EdgeAwareDemosaicingTest;
PERF_TEST_P(EdgeAwareDemosaicingTest, demosaicingEA,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p, Size(130, 60)),
testing::ValuesIn(EdgeAwareBayerMode::all())
EdgeAwareBayerMode::all()
)
)
{

View File

@ -17,7 +17,7 @@ PERF_TEST_P( TestFilter2d, Filter2d,
Combine(
Values( Size(320, 240), sz1080p ),
Values( 3, 5 ),
ValuesIn( BorderMode::all() )
BorderMode::all()
)
)
{

View File

@ -18,7 +18,7 @@ PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateSmall,
cv::Size(1024, 768), cv::Size(1280, 1024)),
testing::Values(cv::Size(12, 12), cv::Size(28, 9),
cv::Size(8, 30), cv::Size(16, 16)),
testing::ValuesIn(MethodType::all())
MethodType::all()
)
)
{
@ -52,7 +52,7 @@ PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateBig,
testing::Combine(
testing::Values(cv::Size(1280, 1024)),
testing::Values(cv::Size(1260, 1000), cv::Size(1261, 1013)),
testing::ValuesIn(MethodType::all())
MethodType::all()
)
)
{

View File

@ -16,7 +16,7 @@ PERF_TEST_P( TestRemap, Remap,
Values( szVGA, sz1080p ),
Values( CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( CV_16SC2, CV_32FC1, CV_32FC2 ),
ValuesIn( InterType::all() )
InterType::all()
)
)
{

View File

@ -34,7 +34,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3, sobelFilter,
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0), make_tuple(1, 1), make_tuple(0, 2), make_tuple(2, 0), make_tuple(2, 2)),
testing::ValuesIn(BorderType3x3::all())
BorderType3x3::all()
)
)
{
@ -59,7 +59,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, sobelFilter,
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0), make_tuple(1, 1), make_tuple(0, 2), make_tuple(2, 0), make_tuple(2, 2)),
testing::ValuesIn(BorderType3x3ROI::all())
BorderType3x3ROI::all()
)
)
{
@ -87,7 +87,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border5x5, sobelFilter,
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0), make_tuple(1, 1), make_tuple(0, 2), make_tuple(2, 0)),
testing::ValuesIn(BorderType::all())
BorderType::all()
)
)
{
@ -112,7 +112,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border5x5ROI, sobelFilter,
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0), make_tuple(1, 1), make_tuple(0, 2), make_tuple(2, 0)),
testing::ValuesIn(BorderTypeROI::all())
BorderTypeROI::all()
)
)
{
@ -142,7 +142,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3, scharrFilter,
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0)),
testing::ValuesIn(BorderType3x3::all())
BorderType3x3::all()
)
)
{
@ -167,7 +167,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, scharrFilter,
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0)),
testing::ValuesIn(BorderType3x3ROI::all())
BorderType3x3ROI::all()
)
)
{
@ -195,7 +195,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3, scharrViaSobelFilter,
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0)),
testing::ValuesIn(BorderType3x3::all())
BorderType3x3::all()
)
)
{
@ -220,7 +220,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, scharrViaSobelFilter,
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0)),
testing::ValuesIn(BorderType3x3ROI::all())
BorderType3x3ROI::all()
)
)
{

View File

@ -15,7 +15,7 @@ PERF_TEST_P(Size_MatType_ThreshType, threshold,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16SC1),
testing::ValuesIn(ThreshType::all())
ThreshType::all()
)
)
{
@ -65,8 +65,8 @@ typedef perf::TestBaseWithParam<Size_AdaptThreshType_AdaptThreshMethod_BlockSize
PERF_TEST_P(Size_AdaptThreshType_AdaptThreshMethod_BlockSize, adaptiveThreshold,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::ValuesIn(AdaptThreshType::all()),
testing::ValuesIn(AdaptThreshMethod::all()),
AdaptThreshType::all(),
AdaptThreshMethod::all(),
testing::Values(3, 5)
)
)

View File

@ -23,8 +23,8 @@ 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() )
InterType::all(),
BorderMode::all()
)
)
{
@ -53,8 +53,8 @@ PERF_TEST_P( TestWarpAffine, WarpAffine,
PERF_TEST_P( TestWarpPerspective, WarpPerspective,
Combine(
Values( szVGA, sz720p, sz1080p ),
ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() )
InterType::all(),
BorderMode::all()
)
)
{
@ -91,8 +91,8 @@ PERF_TEST_P( TestWarpPerspective, WarpPerspective,
PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear,
Combine(
Values( Size(640,480), Size(1920,1080), Size(2592,1944) ),
ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() ),
InterType::all(),
BorderMode::all(),
Values( CV_8UC1, CV_8UC4 )
)
)
@ -138,9 +138,9 @@ PERF_TEST_P( TestRemap, remap,
Combine(
Values( TYPICAL_MAT_TYPES ),
Values( szVGA, sz720p, sz1080p ),
ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() ),
ValuesIn( RemapMode::all() )
InterType::all(),
BorderMode::all(),
RemapMode::all()
)
)
{

View File

@ -68,7 +68,7 @@ namespace cv
void CV_EXPORTS openCLMallocPitch(Context *clCxt, void **dev_ptr, size_t *pitch,
size_t widthInBytes, size_t height);
void CV_EXPORTS openCLMallocPitchEx(Context *clCxt, void **dev_ptr, size_t *pitch,
size_t widthInBytes, size_t height,
size_t widthInBytes, size_t height,
DevMemRW rw_type, DevMemType mem_type, void* hptr = 0);
void CV_EXPORTS openCLMemcpy2D(Context *clCxt, void *dst, size_t dpitch,
const void *src, size_t spitch,

View File

@ -16,6 +16,7 @@
//
// @Authors
// Nathan, liujun@multicorewareinc.com
// Peng Xiao, pengxiao@outlook.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
@ -60,11 +61,21 @@ namespace cv
}
}
static const int OPT_SIZE = 100;
static const char * T_ARR [] = {
"uchar",
"char",
"ushort",
"short",
"int",
"float -D T_FLOAT",
"double"};
template < int BLOCK_SIZE, int MAX_DESC_LEN/*, typename Mask*/ >
void matchUnrolledCached(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
const oclMat &trainIdx, const oclMat &distance, int distType)
{
CV_Assert(query.type() == CV_32F);
cv::ocl::Context *ctx = query.clCxt;
size_t globalSize[] = {(query.rows + BLOCK_SIZE - 1) / BLOCK_SIZE * BLOCK_SIZE, BLOCK_SIZE, 1};
size_t localSize[] = {BLOCK_SIZE, BLOCK_SIZE, 1};
@ -73,6 +84,11 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, const oclMat
int m_size = MAX_DESC_LEN;
std::vector< std::pair<size_t, const void *> > args;
char opt [OPT_SIZE] = "";
sprintf(opt,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d",
T_ARR[query.depth()], distType, block_size, m_size);
if(globalSize[0] != 0)
{
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data ));
@ -81,18 +97,15 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, const oclMat
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data ));
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data ));
args.push_back( std::make_pair( smemSize, (void *)NULL));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&m_size ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType ));
String kernelName = "BruteForceMatch_UnrollMatch";
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, query.depth());
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, -1, opt);
}
}
@ -106,7 +119,6 @@ template < int BLOCK_SIZE/*, typename Mask*/ >
void match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
const oclMat &trainIdx, const oclMat &distance, int distType)
{
CV_Assert(query.type() == CV_32F);
cv::ocl::Context *ctx = query.clCxt;
size_t globalSize[] = {(query.rows + BLOCK_SIZE - 1) / BLOCK_SIZE * BLOCK_SIZE, BLOCK_SIZE, 1};
size_t localSize[] = {BLOCK_SIZE, BLOCK_SIZE, 1};
@ -114,6 +126,10 @@ void match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
int block_size = BLOCK_SIZE;
std::vector< std::pair<size_t, const void *> > args;
char opt [OPT_SIZE] = "";
sprintf(opt,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d",
T_ARR[query.depth()], distType, block_size);
if(globalSize[0] != 0)
{
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data ));
@ -122,17 +138,15 @@ void match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data ));
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data ));
args.push_back( std::make_pair( smemSize, (void *)NULL));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType ));
String kernelName = "BruteForceMatch_Match";
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, query.depth());
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, -1, opt);
}
}
@ -147,7 +161,6 @@ template < int BLOCK_SIZE, int MAX_DESC_LEN/*, typename Mask*/ >
void matchUnrolledCached(const oclMat &query, const oclMat &train, float maxDistance, const oclMat &/*mask*/,
const oclMat &trainIdx, const oclMat &distance, const oclMat &nMatches, int distType)
{
CV_Assert(query.type() == CV_32F);
cv::ocl::Context *ctx = query.clCxt;
size_t globalSize[] = {(train.rows + BLOCK_SIZE - 1) / BLOCK_SIZE * BLOCK_SIZE, (query.rows + BLOCK_SIZE - 1) / BLOCK_SIZE * BLOCK_SIZE, 1};
size_t localSize[] = {BLOCK_SIZE, BLOCK_SIZE, 1};
@ -156,6 +169,11 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, float maxDist
int m_size = MAX_DESC_LEN;
std::vector< std::pair<size_t, const void *> > args;
char opt [OPT_SIZE] = "";
sprintf(opt,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d",
T_ARR[query.depth()], distType, block_size, m_size);
if(globalSize[0] != 0)
{
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data ));
@ -166,8 +184,6 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, float maxDist
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data ));
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&nMatches.data ));
args.push_back( std::make_pair( smemSize, (void *)NULL));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&m_size ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows ));
@ -175,11 +191,10 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, float maxDist
args.push_back( std::make_pair( sizeof(cl_int), (void *)&trainIdx.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&trainIdx.step ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType ));
String kernelName = "BruteForceMatch_RadiusUnrollMatch";
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, query.depth());
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, -1, opt);
}
}
@ -188,7 +203,6 @@ template < int BLOCK_SIZE/*, typename Mask*/ >
void radius_match(const oclMat &query, const oclMat &train, float maxDistance, const oclMat &/*mask*/,
const oclMat &trainIdx, const oclMat &distance, const oclMat &nMatches, int distType)
{
CV_Assert(query.type() == CV_32F);
cv::ocl::Context *ctx = query.clCxt;
size_t globalSize[] = {(train.rows + BLOCK_SIZE - 1) / BLOCK_SIZE * BLOCK_SIZE, (query.rows + BLOCK_SIZE - 1) / BLOCK_SIZE * BLOCK_SIZE, 1};
size_t localSize[] = {BLOCK_SIZE, BLOCK_SIZE, 1};
@ -196,6 +210,11 @@ void radius_match(const oclMat &query, const oclMat &train, float maxDistance, c
int block_size = BLOCK_SIZE;
std::vector< std::pair<size_t, const void *> > args;
char opt [OPT_SIZE] = "";
sprintf(opt,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d",
T_ARR[query.depth()], distType, block_size);
if(globalSize[0] != 0)
{
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data ));
@ -206,7 +225,6 @@ void radius_match(const oclMat &query, const oclMat &train, float maxDistance, c
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data ));
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&nMatches.data ));
args.push_back( std::make_pair( smemSize, (void *)NULL));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows ));
@ -214,11 +232,10 @@ void radius_match(const oclMat &query, const oclMat &train, float maxDistance, c
args.push_back( std::make_pair( sizeof(cl_int), (void *)&trainIdx.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&trainIdx.step ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType ));
String kernelName = "BruteForceMatch_RadiusMatch";
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, query.depth());
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, -1, opt);
}
}
@ -293,6 +310,11 @@ void knn_matchUnrolledCached(const oclMat &query, const oclMat &train, const ocl
int m_size = MAX_DESC_LEN;
std::vector< std::pair<size_t, const void *> > args;
char opt [OPT_SIZE] = "";
sprintf(opt,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d",
T_ARR[query.depth()], distType, block_size, m_size);
if(globalSize[0] != 0)
{
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data ));
@ -301,18 +323,15 @@ void knn_matchUnrolledCached(const oclMat &query, const oclMat &train, const ocl
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data ));
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data ));
args.push_back( std::make_pair( smemSize, (void *)NULL));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&m_size ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType ));
String kernelName = "BruteForceMatch_knnUnrollMatch";
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, query.depth());
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, -1, opt);
}
}
@ -327,6 +346,11 @@ void knn_match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
int block_size = BLOCK_SIZE;
std::vector< std::pair<size_t, const void *> > args;
char opt [OPT_SIZE] = "";
sprintf(opt,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d",
T_ARR[query.depth()], distType, block_size);
if(globalSize[0] != 0)
{
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data ));
@ -335,17 +359,15 @@ void knn_match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&trainIdx.data ));
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&distance.data ));
args.push_back( std::make_pair( smemSize, (void *)NULL));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&block_size ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType ));
String kernelName = "BruteForceMatch_knnMatch";
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, query.depth());
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, -1, opt);
}
}
@ -360,6 +382,11 @@ void calcDistanceUnrolled(const oclMat &query, const oclMat &train, const oclMat
int m_size = MAX_DESC_LEN;
std::vector< std::pair<size_t, const void *> > args;
char opt [OPT_SIZE] = "";
sprintf(opt,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d",
T_ARR[query.depth()], distType, block_size, m_size);
if(globalSize[0] != 0)
{
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data ));
@ -374,11 +401,10 @@ void calcDistanceUnrolled(const oclMat &query, const oclMat &train, const oclMat
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType ));
String kernelName = "BruteForceMatch_calcDistanceUnrolled";
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, query.depth());
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, -1, opt);
}
}
@ -392,6 +418,11 @@ void calcDistance(const oclMat &query, const oclMat &train, const oclMat &/*mask
int block_size = BLOCK_SIZE;
std::vector< std::pair<size_t, const void *> > args;
char opt [OPT_SIZE] = "";
sprintf(opt,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d",
T_ARR[query.depth()], distType, block_size);
if(globalSize[0] != 0)
{
args.push_back( std::make_pair( sizeof(cl_mem), (void *)&query.data ));
@ -405,11 +436,10 @@ void calcDistance(const oclMat &query, const oclMat &train, const oclMat &/*mask
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.rows ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step ));
args.push_back( std::make_pair( sizeof(cl_int), (void *)&distType ));
String kernelName = "BruteForceMatch_calcDistance";
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, query.depth());
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, -1, opt);
}
}
@ -471,7 +501,7 @@ void findKnnMatch(int k, const oclMat &trainIdx, const oclMat &distance, const o
//args.push_back( std::make_pair( sizeof(cl_int), (void *)&train.cols ));
//args.push_back( std::make_pair( sizeof(cl_int), (void *)&query.step ));
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, trainIdx.depth(), -1);
openCLExecuteKernel(ctx, &brute_force_match, kernelName, globalSize, localSize, args, -1, -1);
}
}
@ -531,24 +561,15 @@ void cv::ocl::BruteForceMatcher_OCL_base::matchSingle(const oclMat &query, const
if (query.empty() || train.empty())
return;
// match1 doesn't support signed char type, match2 only support float, hamming support uchar, ushort and int
int callType = query.depth();
if (callType != 5)
CV_Error(Error::StsUnsupportedFormat, "BruteForceMatch OpenCL only support float type query!\n");
if ((distType == 0 && callType == 1 ) || (distType == 1 && callType != 5) || (distType == 2 && (callType != 0
|| callType != 2 || callType != 4)))
{
CV_Error(Error::BadDepth, "BruteForceMatch OpenCL only support float type query!\n");
}
CV_Assert(query.channels() == 1 && query.depth() < CV_64F);
CV_Assert(train.cols == query.cols && train.type() == query.type());
trainIdx.create(1, query.rows, CV_32S);
distance.create(1, query.rows, CV_32F);
ensureSizeIsEnough(1, query.rows, CV_32S, trainIdx);
ensureSizeIsEnough(1, query.rows, CV_32F, distance);
matchDispatcher(query, train, mask, trainIdx, distance, distType);
return;
}
void cv::ocl::BruteForceMatcher_OCL_base::matchDownload(const oclMat &trainIdx, const oclMat &distance, std::vector<DMatch> &matches)
@ -594,7 +615,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::matchConvert(const Mat &trainIdx, cons
void cv::ocl::BruteForceMatcher_OCL_base::match(const oclMat &query, const oclMat &train, std::vector<DMatch> &matches, const oclMat &mask)
{
CV_Assert(mask.empty()); // mask is not supported at the moment
assert(mask.empty()); // mask is not supported at the moment
oclMat trainIdx, distance;
matchSingle(query, train, trainIdx, distance, mask);
matchDownload(trainIdx, distance, matches);
@ -650,24 +671,17 @@ void cv::ocl::BruteForceMatcher_OCL_base::matchCollection(const oclMat &query, c
if (query.empty() || trainCollection.empty())
return;
// match1 doesn't support signed char type, match2 only support float, hamming support uchar, ushort and int
int callType = query.depth();
if (callType != 5)
CV_Error(Error::StsUnsupportedFormat, "BruteForceMatch OpenCL only support float type query!\n");
if ((distType == 0 && callType == 1 ) || (distType == 1 && callType != 5) || (distType == 2 && (callType != 0
|| callType != 2 || callType != 4)))
{
CV_Error(Error::BadDepth, "BruteForceMatch OpenCL only support float type query!\n");
}
CV_Assert(query.channels() == 1 && query.depth() < CV_64F);
trainIdx.create(1, query.rows, CV_32S);
imgIdx.create(1, query.rows, CV_32S);
distance.create(1, query.rows, CV_32F);
const int nQuery = query.rows;
ensureSizeIsEnough(1, nQuery, CV_32S, trainIdx);
ensureSizeIsEnough(1, nQuery, CV_32S, imgIdx);
ensureSizeIsEnough(1, nQuery, CV_32F, distance);
matchDispatcher(query, (const oclMat *)trainCollection.ptr(), trainCollection.cols, masks, trainIdx, imgIdx, distance, distType);
return;
}
void cv::ocl::BruteForceMatcher_OCL_base::matchDownload(const oclMat &trainIdx, const oclMat &imgIdx, const oclMat &distance, std::vector<DMatch> &matches)
@ -736,36 +750,29 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatchSingle(const oclMat &query, co
if (query.empty() || train.empty())
return;
// match1 doesn't support signed char type, match2 only support float, hamming support uchar, ushort and int
int callType = query.depth();
if (callType != 5)
CV_Error(Error::StsUnsupportedFormat, "BruteForceMatch OpenCL only support float type query!\n");
if ((distType == 0 && callType == 1 ) || (distType == 1 && callType != 5) || (distType == 2 && (callType != 0
|| callType != 2 || callType != 4)))
{
CV_Error(Error::BadDepth, "BruteForceMatch OpenCL only support float type query!\n");
}
CV_Assert(query.channels() == 1 && query.depth() < CV_64F);
CV_Assert(train.type() == query.type() && train.cols == query.cols);
const int nQuery = query.rows;
const int nTrain = train.rows;
if (k == 2)
{
trainIdx.create(1, query.rows, CV_32SC2);
distance.create(1, query.rows, CV_32FC2);
ensureSizeIsEnough(1, nQuery, CV_32SC2, trainIdx);
ensureSizeIsEnough(1, nQuery, CV_32FC2, distance);
}
else
{
trainIdx.create(query.rows, k, CV_32S);
distance.create(query.rows, k, CV_32F);
allDist.create(query.rows, train.rows, CV_32FC1);
ensureSizeIsEnough(nQuery, k, CV_32S, trainIdx);
ensureSizeIsEnough(nQuery, k, CV_32F, distance);
ensureSizeIsEnough(nQuery, nTrain, CV_32FC1, allDist);
}
trainIdx.setTo(Scalar::all(-1));
kmatchDispatcher(query, train, k, mask, trainIdx, distance, allDist, distType);
return;
}
void cv::ocl::BruteForceMatcher_OCL_base::knnMatchDownload(const oclMat &trainIdx, const oclMat &distance, std::vector< std::vector<DMatch> > &matches, bool compactResult)
@ -839,33 +846,14 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatch2Collection(const oclMat &quer
typedef void (*caller_t)(const oclMat & query, const oclMat & trains, const oclMat & masks,
const oclMat & trainIdx, const oclMat & imgIdx, const oclMat & distance);
#if 0
static const caller_t callers[3][6] =
{
{
ocl_match2L1_gpu<unsigned char>, 0/*match2L1_gpu<signed char>*/,
ocl_match2L1_gpu<unsigned short>, ocl_match2L1_gpu<short>,
ocl_match2L1_gpu<int>, ocl_match2L1_gpu<float>
},
{
0/*match2L2_gpu<unsigned char>*/, 0/*match2L2_gpu<signed char>*/,
0/*match2L2_gpu<unsigned short>*/, 0/*match2L2_gpu<short>*/,
0/*match2L2_gpu<int>*/, ocl_match2L2_gpu<float>
},
{
ocl_match2Hamming_gpu<unsigned char>, 0/*match2Hamming_gpu<signed char>*/,
ocl_match2Hamming_gpu<unsigned short>, 0/*match2Hamming_gpu<short>*/,
ocl_match2Hamming_gpu<int>, 0/*match2Hamming_gpu<float>*/
}
};
#endif
CV_Assert(query.channels() == 1 && query.depth() < CV_64F);
const int nQuery = query.rows;
trainIdx.create(1, nQuery, CV_32SC2);
imgIdx.create(1, nQuery, CV_32SC2);
distance.create(1, nQuery, CV_32SC2);
ensureSizeIsEnough(1, nQuery, CV_32SC2, trainIdx);
ensureSizeIsEnough(1, nQuery, CV_32SC2, imgIdx);
ensureSizeIsEnough(1, nQuery, CV_32FC2, distance);
trainIdx.setTo(Scalar::all(-1));
@ -972,7 +960,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat &query, std::vec
temp.reserve(2 * k);
matches.resize(query.rows);
std::for_each(matches.begin(), matches.end(), std::bind2nd(std::mem_fun_ref(&std::vector<DMatch>::reserve), k));
for_each(matches.begin(), matches.end(), bind2nd(mem_fun_ref(&std::vector<DMatch>::reserve), k));
for (size_t imgIdx = 0, size = trainDescCollection.size(); imgIdx < size; ++imgIdx)
{
@ -996,7 +984,7 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat &query, std::vec
if (compactResult)
{
std::vector< std::vector<DMatch> >::iterator new_end = std::remove_if(matches.begin(), matches.end(), std::mem_fun_ref(&std::vector<DMatch>::empty));
std::vector< std::vector<DMatch> >::iterator new_end = remove_if(matches.begin(), matches.end(), mem_fun_ref(&std::vector<DMatch>::empty));
matches.erase(new_end, matches.end());
}
}
@ -1004,36 +992,30 @@ void cv::ocl::BruteForceMatcher_OCL_base::knnMatch(const oclMat &query, std::vec
// radiusMatchSingle
void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchSingle(const oclMat &query, const oclMat &train,
oclMat &trainIdx, oclMat &distance, oclMat &nMatches, float maxDistance, const oclMat &mask)
oclMat &trainIdx, oclMat &distance, oclMat &nMatches, float maxDistance, const oclMat &mask)
{
if (query.empty() || train.empty())
return;
// match1 doesn't support signed char type, match2 only support float, hamming support uchar, ushort and int
int callType = query.depth();
if (callType != 5)
CV_Error(Error::StsUnsupportedFormat, "BruteForceMatch OpenCL only support float type query!\n");
if ((distType == 0 && callType == 1 ) || (distType == 1 && callType != 5) || (distType == 2 && (callType != 0
|| callType != 2 || callType != 4)))
{
CV_Error(Error::BadDepth, "BruteForceMatch OpenCL only support float type query!\n");
}
const int nQuery = query.rows;
const int nTrain = train.rows;
CV_Assert(query.channels() == 1 && query.depth() < CV_64F);
CV_Assert(train.type() == query.type() && train.cols == query.cols);
CV_Assert(trainIdx.empty() || (trainIdx.rows == query.rows && trainIdx.size() == distance.size()));
nMatches.create(1, query.rows, CV_32SC1);
ensureSizeIsEnough(1, nQuery, CV_32SC1, nMatches);
if (trainIdx.empty())
{
trainIdx.create(query.rows, std::max((train.rows/ 100), 10), CV_32SC1);
distance.create(query.rows, std::max((train.rows/ 100), 10), CV_32FC1);
ensureSizeIsEnough(nQuery, std::max((nTrain / 100), 10), CV_32SC1, trainIdx);
ensureSizeIsEnough(nQuery, std::max((nTrain / 100), 10), CV_32FC1, distance);
}
nMatches.setTo(Scalar::all(0));
matchDispatcher(query, train, maxDistance, mask, trainIdx, distance, nMatches, distType);
return;
}
void cv::ocl::BruteForceMatcher_OCL_base::radiusMatchDownload(const oclMat &trainIdx, const oclMat &distance, const oclMat &nMatches,

View File

@ -362,6 +362,13 @@ namespace cv
{
case WAVEFRONT_SIZE:
{
bool is_cpu = false;
queryDeviceInfo(IS_CPU_DEVICE, &is_cpu);
if(is_cpu)
{
*(int*)info = 1;
return;
}
#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
try
{

View File

@ -47,6 +47,10 @@
#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics:enable
#define MAX_FLOAT 3.40282e+038f
#ifndef T
#define T float
#endif
#ifndef BLOCK_SIZE
#define BLOCK_SIZE 16
#endif
@ -54,68 +58,85 @@
#define MAX_DESC_LEN 64
#endif
int bit1Count(float x)
{
int c = 0;
int ix = (int)x;
for (int i = 0 ; i < 32 ; i++)
{
c += ix & 0x1;
ix >>= 1;
}
return (float)c;
}
#ifndef DIST_TYPE
#define DIST_TYPE 0
#endif
#if (DIST_TYPE == 0)
#define DIST(x, y) fabs((x) - (y))
#elif (DIST_TYPE == 1)
#define DIST(x, y) (((x) - (y)) * ((x) - (y)))
#elif (DIST_TYPE == 2)
#define DIST(x, y) bit1Count((uint)(x) ^ (uint)(y))
#endif
float reduce_block(__local float *s_query,
__local float *s_train,
int lidx,
int lidy
)
//http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
int bit1Count(int v)
{
float result = 0;
#pragma unroll
for (int j = 0 ; j < BLOCK_SIZE ; j++)
{
result += DIST(s_query[lidy * BLOCK_SIZE + j], s_train[j * BLOCK_SIZE + lidx]);
}
return result;
v = v - ((v >> 1) & 0x55555555); // reuse input as temporary
v = (v & 0x33333333) + ((v >> 2) & 0x33333333); // temp
return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; // count
}
float reduce_multi_block(__local float *s_query,
__local float *s_train,
int block_index,
int lidx,
int lidy
)
// dirty fix for non-template support
#if (DIST_TYPE == 0) // L1Dist
# ifdef T_FLOAT
# define DIST(x, y) fabs((x) - (y))
typedef float value_type;
typedef float result_type;
# else
# define DIST(x, y) abs((x) - (y))
typedef int value_type;
typedef int result_type;
# endif
#define DIST_RES(x) (x)
#elif (DIST_TYPE == 1) // L2Dist
#define DIST(x, y) (((x) - (y)) * ((x) - (y)))
typedef float value_type;
typedef float result_type;
#define DIST_RES(x) sqrt(x)
#elif (DIST_TYPE == 2) // Hamming
#define DIST(x, y) bit1Count( (x) ^ (y) )
typedef int value_type;
typedef int result_type;
#define DIST_RES(x) (x)
#endif
result_type reduce_block(
__local value_type *s_query,
__local value_type *s_train,
int lidx,
int lidy
)
{
float result = 0;
result_type result = 0;
#pragma unroll
for (int j = 0 ; j < BLOCK_SIZE ; j++)
{
result += DIST(s_query[lidy * MAX_DESC_LEN + block_index * BLOCK_SIZE + j], s_train[j * BLOCK_SIZE + lidx]);
result += DIST(
s_query[lidy * BLOCK_SIZE + j],
s_train[j * BLOCK_SIZE + lidx]);
}
return result;
return DIST_RES(result);
}
result_type reduce_multi_block(
__local value_type *s_query,
__local value_type *s_train,
int block_index,
int lidx,
int lidy
)
{
result_type result = 0;
#pragma unroll
for (int j = 0 ; j < BLOCK_SIZE ; j++)
{
result += DIST(
s_query[lidy * MAX_DESC_LEN + block_index * BLOCK_SIZE + j],
s_train[j * BLOCK_SIZE + lidx]);
}
return DIST_RES(result);
}
/* 2dim launch, global size: dim0 is (query rows + BLOCK_SIZE - 1) / BLOCK_SIZE * BLOCK_SIZE, dim1 is BLOCK_SIZE
local size: dim0 is BLOCK_SIZE, dim1 is BLOCK_SIZE.
*/
__kernel void BruteForceMatch_UnrollMatch_D5(
__global float *query,
__global float *train,
__kernel void BruteForceMatch_UnrollMatch(
__global T *query,
__global T *train,
//__global float *mask,
__global int *bestTrainIdx,
__global float *bestDistance,
@ -127,13 +148,12 @@ __kernel void BruteForceMatch_UnrollMatch_D5(
int step
)
{
const int lidx = get_local_id(0);
const int lidy = get_local_id(1);
const int groupidx = get_group_id(0);
__local float *s_query = sharebuffer;
__local float *s_train = sharebuffer + BLOCK_SIZE * MAX_DESC_LEN;
__local value_type *s_query = (__local value_type *)sharebuffer;
__local value_type *s_train = (__local value_type *)sharebuffer + BLOCK_SIZE * MAX_DESC_LEN;
int queryIdx = groupidx * BLOCK_SIZE + lidy;
// load the query into local memory.
@ -151,7 +171,7 @@ __kernel void BruteForceMatch_UnrollMatch_D5(
volatile int imgIdx = 0;
for (int t = 0, endt = (train_rows + BLOCK_SIZE - 1) / BLOCK_SIZE; t < endt; t++)
{
float result = 0;
result_type result = 0;
#pragma unroll
for (int i = 0 ; i < MAX_DESC_LEN / BLOCK_SIZE ; i++)
{
@ -207,9 +227,9 @@ __kernel void BruteForceMatch_UnrollMatch_D5(
}
}
__kernel void BruteForceMatch_Match_D5(
__global float *query,
__global float *train,
__kernel void BruteForceMatch_Match(
__global T *query,
__global T *train,
//__global float *mask,
__global int *bestTrainIdx,
__global float *bestDistance,
@ -230,14 +250,13 @@ __kernel void BruteForceMatch_Match_D5(
float myBestDistance = MAX_FLOAT;
int myBestTrainIdx = -1;
__local float *s_query = sharebuffer;
__local float *s_train = sharebuffer + BLOCK_SIZE * BLOCK_SIZE;
__local value_type *s_query = (__local value_type *)sharebuffer;
__local value_type *s_train = (__local value_type *)sharebuffer + BLOCK_SIZE * BLOCK_SIZE;
// loop
for (int t = 0 ; t < (train_rows + BLOCK_SIZE - 1) / BLOCK_SIZE ; t++)
{
//Dist dist;
float result = 0;
result_type result = 0;
for (int i = 0 ; i < (query_cols + BLOCK_SIZE - 1) / BLOCK_SIZE ; i++)
{
const int loadx = lidx + i * BLOCK_SIZE;
@ -299,9 +318,9 @@ __kernel void BruteForceMatch_Match_D5(
}
//radius_unrollmatch
__kernel void BruteForceMatch_RadiusUnrollMatch_D5(
__global float *query,
__global float *train,
__kernel void BruteForceMatch_RadiusUnrollMatch(
__global T *query,
__global T *train,
float maxDistance,
//__global float *mask,
__global int *bestTrainIdx,
@ -325,10 +344,10 @@ __kernel void BruteForceMatch_RadiusUnrollMatch_D5(
const int queryIdx = groupidy * BLOCK_SIZE + lidy;
const int trainIdx = groupidx * BLOCK_SIZE + lidx;
__local float *s_query = sharebuffer;
__local float *s_train = sharebuffer + BLOCK_SIZE * BLOCK_SIZE;
__local value_type *s_query = (__local value_type *)sharebuffer;
__local value_type *s_train = (__local value_type *)sharebuffer + BLOCK_SIZE * BLOCK_SIZE;
float result = 0;
result_type result = 0;
for (int i = 0 ; i < MAX_DESC_LEN / BLOCK_SIZE ; ++i)
{
//load a BLOCK_SIZE * BLOCK_SIZE block into local train.
@ -345,7 +364,8 @@ __kernel void BruteForceMatch_RadiusUnrollMatch_D5(
barrier(CLK_LOCAL_MEM_FENCE);
}
if (queryIdx < query_rows && trainIdx < train_rows && result < maxDistance/* && mask(queryIdx, trainIdx)*/)
if (queryIdx < query_rows && trainIdx < train_rows &&
convert_float(result) < maxDistance/* && mask(queryIdx, trainIdx)*/)
{
unsigned int ind = atom_inc(nMatches + queryIdx/*, (unsigned int) -1*/);
@ -359,9 +379,9 @@ __kernel void BruteForceMatch_RadiusUnrollMatch_D5(
}
//radius_match
__kernel void BruteForceMatch_RadiusMatch_D5(
__global float *query,
__global float *train,
__kernel void BruteForceMatch_RadiusMatch(
__global T *query,
__global T *train,
float maxDistance,
//__global float *mask,
__global int *bestTrainIdx,
@ -385,10 +405,10 @@ __kernel void BruteForceMatch_RadiusMatch_D5(
const int queryIdx = groupidy * BLOCK_SIZE + lidy;
const int trainIdx = groupidx * BLOCK_SIZE + lidx;
__local float *s_query = sharebuffer;
__local float *s_train = sharebuffer + BLOCK_SIZE * BLOCK_SIZE;
__local value_type *s_query = (__local value_type *)sharebuffer;
__local value_type *s_train = (__local value_type *)sharebuffer + BLOCK_SIZE * BLOCK_SIZE;
float result = 0;
result_type result = 0;
for (int i = 0 ; i < (query_cols + BLOCK_SIZE - 1) / BLOCK_SIZE ; ++i)
{
//load a BLOCK_SIZE * BLOCK_SIZE block into local train.
@ -405,7 +425,8 @@ __kernel void BruteForceMatch_RadiusMatch_D5(
barrier(CLK_LOCAL_MEM_FENCE);
}
if (queryIdx < query_rows && trainIdx < train_rows && result < maxDistance/* && mask(queryIdx, trainIdx)*/)
if (queryIdx < query_rows && trainIdx < train_rows &&
convert_float(result) < maxDistance/* && mask(queryIdx, trainIdx)*/)
{
unsigned int ind = atom_inc(nMatches + queryIdx);
@ -419,9 +440,9 @@ __kernel void BruteForceMatch_RadiusMatch_D5(
}
__kernel void BruteForceMatch_knnUnrollMatch_D5(
__global float *query,
__global float *train,
__kernel void BruteForceMatch_knnUnrollMatch(
__global T *query,
__global T *train,
//__global float *mask,
__global int2 *bestTrainIdx,
__global float2 *bestDistance,
@ -438,8 +459,8 @@ __kernel void BruteForceMatch_knnUnrollMatch_D5(
const int groupidx = get_group_id(0);
const int queryIdx = groupidx * BLOCK_SIZE + lidy;
local float *s_query = sharebuffer;
local float *s_train = sharebuffer + BLOCK_SIZE * MAX_DESC_LEN;
__local value_type *s_query = (__local value_type *)sharebuffer;
__local value_type *s_train = (__local value_type *)sharebuffer + BLOCK_SIZE * MAX_DESC_LEN;
// load the query into local memory.
for (int i = 0 ; i < MAX_DESC_LEN / BLOCK_SIZE; i ++)
@ -457,10 +478,9 @@ __kernel void BruteForceMatch_knnUnrollMatch_D5(
volatile int imgIdx = 0;
for (int t = 0 ; t < (train_rows + BLOCK_SIZE - 1) / BLOCK_SIZE ; t++)
{
float result = 0;
result_type result = 0;
for (int i = 0 ; i < MAX_DESC_LEN / BLOCK_SIZE ; i++)
{
const int loadX = lidx + i * BLOCK_SIZE;
//load a BLOCK_SIZE * BLOCK_SIZE block into local train.
const int loadx = lidx + i * BLOCK_SIZE;
s_train[lidx * BLOCK_SIZE + lidy] = loadx < train_cols ? train[min(t * BLOCK_SIZE + lidy, train_rows - 1) * (step / sizeof(float)) + loadx] : 0;
@ -494,8 +514,8 @@ __kernel void BruteForceMatch_knnUnrollMatch_D5(
barrier(CLK_LOCAL_MEM_FENCE);
local float *s_distance = (local float *)sharebuffer;
local int *s_trainIdx = (local int *)(sharebuffer + BLOCK_SIZE * BLOCK_SIZE);
__local float *s_distance = (local float *)sharebuffer;
__local int *s_trainIdx = (local int *)(sharebuffer + BLOCK_SIZE * BLOCK_SIZE);
// find BestMatch
s_distance += lidy * BLOCK_SIZE;
@ -565,9 +585,9 @@ __kernel void BruteForceMatch_knnUnrollMatch_D5(
}
}
__kernel void BruteForceMatch_knnMatch_D5(
__global float *query,
__global float *train,
__kernel void BruteForceMatch_knnMatch(
__global T *query,
__global T *train,
//__global float *mask,
__global int2 *bestTrainIdx,
__global float2 *bestDistance,
@ -584,8 +604,8 @@ __kernel void BruteForceMatch_knnMatch_D5(
const int groupidx = get_group_id(0);
const int queryIdx = groupidx * BLOCK_SIZE + lidy;
local float *s_query = sharebuffer;
local float *s_train = sharebuffer + BLOCK_SIZE * BLOCK_SIZE;
__local value_type *s_query = (__local value_type *)sharebuffer;
__local value_type *s_train = (__local value_type *)sharebuffer + BLOCK_SIZE * BLOCK_SIZE;
float myBestDistance1 = MAX_FLOAT;
float myBestDistance2 = MAX_FLOAT;
@ -595,7 +615,7 @@ __kernel void BruteForceMatch_knnMatch_D5(
//loop
for (int t = 0 ; t < (train_rows + BLOCK_SIZE - 1) / BLOCK_SIZE ; t++)
{
float result = 0.0f;
result_type result = 0.0f;
for (int i = 0 ; i < (query_cols + BLOCK_SIZE -1) / BLOCK_SIZE ; i++)
{
const int loadx = lidx + i * BLOCK_SIZE;
@ -708,9 +728,9 @@ __kernel void BruteForceMatch_knnMatch_D5(
}
}
kernel void BruteForceMatch_calcDistanceUnrolled_D5(
__global float *query,
__global float *train,
kernel void BruteForceMatch_calcDistanceUnrolled(
__global T *query,
__global T *train,
//__global float *mask,
__global float *allDist,
__local float *sharebuffer,
@ -723,9 +743,9 @@ kernel void BruteForceMatch_calcDistanceUnrolled_D5(
/* Todo */
}
kernel void BruteForceMatch_calcDistance_D5(
__global float *query,
__global float *train,
kernel void BruteForceMatch_calcDistance(
__global T *query,
__global T *train,
//__global float *mask,
__global float *allDist,
__local float *sharebuffer,
@ -738,7 +758,7 @@ kernel void BruteForceMatch_calcDistance_D5(
/* Todo */
}
kernel void BruteForceMatch_findBestMatch_D5(
kernel void BruteForceMatch_findBestMatch(
__global float *allDist,
__global int *bestTrainIdx,
__global float *bestDistance,
@ -746,4 +766,4 @@ kernel void BruteForceMatch_findBestMatch_D5(
)
{
/* Todo */
}
}

View File

@ -69,8 +69,10 @@ inline float calc(int x, int y)
// dx_buf output dx buffer
// dy_buf output dy buffer
__kernel
void calcSobelRowPass
(
void
__attribute__((reqd_work_group_size(16,16,1)))
calcSobelRowPass
(
__global const uchar * src,
__global int * dx_buf,
__global int * dy_buf,
@ -82,10 +84,8 @@ __kernel
int dx_buf_offset,
int dy_buf_step,
int dy_buf_offset
)
)
{
//src_step /= sizeof(*src);
//src_offset /= sizeof(*src);
dx_buf_step /= sizeof(*dx_buf);
dx_buf_offset /= sizeof(*dx_buf);
dy_buf_step /= sizeof(*dy_buf);
@ -99,24 +99,23 @@ __kernel
__local int smem[16][18];
smem[lidy][lidx + 1] = src[gidx + gidy * src_step + src_offset];
smem[lidy][lidx + 1] =
src[gidx + min(gidy, rows - 1) * src_step + src_offset];
if(lidx == 0)
{
smem[lidy][0] = src[max(gidx - 1, 0) + gidy * src_step + src_offset];
smem[lidy][17] = src[min(gidx + 16, cols - 1) + gidy * src_step + src_offset];
smem[lidy][0] =
src[max(gidx - 1, 0) + min(gidy, rows - 1) * src_step + src_offset];
smem[lidy][17] =
src[min(gidx + 16, cols - 1) + min(gidy, rows - 1) * src_step + src_offset];
}
barrier(CLK_LOCAL_MEM_FENCE);
if(gidy < rows)
if(gidy < rows && gidx < cols)
{
if(gidx < cols)
{
dx_buf[gidx + gidy * dx_buf_step + dx_buf_offset] =
-smem[lidy][lidx] + smem[lidy][lidx + 2];
dy_buf[gidx + gidy * dy_buf_step + dy_buf_offset] =
smem[lidy][lidx] + 2 * smem[lidy][lidx + 1] + smem[lidy][lidx + 2];
}
dx_buf[gidx + gidy * dx_buf_step + dx_buf_offset] =
-smem[lidy][lidx] + smem[lidy][lidx + 2];
dy_buf[gidx + gidy * dy_buf_step + dy_buf_offset] =
smem[lidy][lidx] + 2 * smem[lidy][lidx + 1] + smem[lidy][lidx + 2];
}
}
@ -129,8 +128,10 @@ __kernel
// dy direvitive in y direction output
// mag magnitude direvitive of xy output
__kernel
void calcMagnitude_buf
(
void
__attribute__((reqd_work_group_size(16,16,1)))
calcMagnitude_buf
(
__global const int * dx_buf,
__global const int * dy_buf,
__global int * dx,
@ -148,7 +149,7 @@ __kernel
int dy_offset,
int mag_step,
int mag_offset
)
)
{
dx_buf_step /= sizeof(*dx_buf);
dx_buf_offset /= sizeof(*dx_buf);
@ -170,30 +171,33 @@ __kernel
__local int sdx[18][16];
__local int sdy[18][16];
sdx[lidy + 1][lidx] = dx_buf[gidx + gidy * dx_buf_step + dx_buf_offset];
sdy[lidy + 1][lidx] = dy_buf[gidx + gidy * dy_buf_step + dy_buf_offset];
sdx[lidy + 1][lidx] =
dx_buf[gidx + min(gidy, rows - 1) * dx_buf_step + dx_buf_offset];
sdy[lidy + 1][lidx] =
dy_buf[gidx + min(gidy, rows - 1) * dy_buf_step + dy_buf_offset];
if(lidy == 0)
{
sdx[0][lidx] = dx_buf[gidx + max(gidy - 1, 0) * dx_buf_step + dx_buf_offset];
sdx[17][lidx] = dx_buf[gidx + min(gidy + 16, rows - 1) * dx_buf_step + dx_buf_offset];
sdx[0][lidx] =
dx_buf[gidx + min(max(gidy-1,0),rows-1) * dx_buf_step + dx_buf_offset];
sdx[17][lidx] =
dx_buf[gidx + min(gidy + 16, rows - 1) * dx_buf_step + dx_buf_offset];
sdy[0][lidx] = dy_buf[gidx + max(gidy - 1, 0) * dy_buf_step + dy_buf_offset];
sdy[17][lidx] = dy_buf[gidx + min(gidy + 16, rows - 1) * dy_buf_step + dy_buf_offset];
sdy[0][lidx] =
dy_buf[gidx + min(max(gidy-1,0),rows-1) * dy_buf_step + dy_buf_offset];
sdy[17][lidx] =
dy_buf[gidx + min(gidy + 16, rows - 1) * dy_buf_step + dy_buf_offset];
}
barrier(CLK_LOCAL_MEM_FENCE);
if(gidx < cols)
if(gidx < cols && gidy < rows)
{
if(gidy < rows)
{
int x = sdx[lidy][lidx] + 2 * sdx[lidy + 1][lidx] + sdx[lidy + 2][lidx];
int y = -sdy[lidy][lidx] + sdy[lidy + 2][lidx];
int x = sdx[lidy][lidx] + 2 * sdx[lidy + 1][lidx] + sdx[lidy + 2][lidx];
int y = -sdy[lidy][lidx] + sdy[lidy + 2][lidx];
dx[gidx + gidy * dx_step + dx_offset] = x;
dy[gidx + gidy * dy_step + dy_offset] = y;
dx[gidx + gidy * dx_step + dx_offset] = x;
dy[gidx + gidy * dy_step + dy_offset] = y;
mag[(gidx + 1) + (gidy + 1) * mag_step + mag_offset] = calc(x, y);
}
mag[(gidx + 1) + (gidy + 1) * mag_step + mag_offset] = calc(x, y);
}
}
@ -206,8 +210,8 @@ __kernel
// dy direvitive in y direction output
// mag magnitude direvitive of xy output
__kernel
void calcMagnitude
(
void calcMagnitude
(
__global const int * dx,
__global const int * dy,
__global float * mag,
@ -219,7 +223,7 @@ __kernel
int dy_offset,
int mag_step,
int mag_offset
)
)
{
dx_step /= sizeof(*dx);
dx_offset /= sizeof(*dx);
@ -235,9 +239,9 @@ __kernel
{
mag[(gidx + 1) + (gidy + 1) * mag_step + mag_offset] =
calc(
dx[gidx + gidy * dx_step + dx_offset],
dy[gidx + gidy * dy_step + dy_offset]
);
dx[gidx + gidy * dx_step + dx_offset],
dy[gidx + gidy * dy_step + dy_offset]
);
}
}
@ -262,8 +266,10 @@ __kernel
// mag magnitudes calculated from calcMagnitude function
// map output containing raw edge types
__kernel
void calcMap
(
void
__attribute__((reqd_work_group_size(16,16,1)))
calcMap
(
__global const int * dx,
__global const int * dy,
__global const float * mag,
@ -280,7 +286,7 @@ __kernel
int mag_offset,
int map_step,
int map_offset
)
)
{
dx_step /= sizeof(*dx);
dx_offset /= sizeof(*dx);
@ -307,11 +313,13 @@ __kernel
int ly = tid / 18;
if(ly < 14)
{
smem[ly][lx] = mag[grp_idx + lx + (grp_idy + ly) * mag_step];
smem[ly][lx] =
mag[grp_idx + lx + min(grp_idy + ly, rows - 1) * mag_step];
}
if(ly < 4 && grp_idy + ly + 14 <= rows && grp_idx + lx <= cols)
{
smem[ly + 14][lx] = mag[grp_idx + lx + (grp_idy + ly + 14) * mag_step];
smem[ly + 14][lx] =
mag[grp_idx + lx + min(grp_idy + ly + 14, rows -1) * mag_step];
}
barrier(CLK_LOCAL_MEM_FENCE);
@ -375,8 +383,10 @@ __kernel
// st the potiential edge points found in this kernel call
// counter the number of potiential edge points
__kernel
void edgesHysteresisLocal
(
void
__attribute__((reqd_work_group_size(16,16,1)))
edgesHysteresisLocal
(
__global int * map,
__global ushort2 * st,
volatile __global unsigned int * counter,
@ -384,7 +394,7 @@ __kernel
int cols,
int map_step,
int map_offset
)
)
{
map_step /= sizeof(*map);
map_offset /= sizeof(*map);
@ -405,11 +415,13 @@ __kernel
int ly = tid / 18;
if(ly < 14)
{
smem[ly][lx] = map[grp_idx + lx + (grp_idy + ly) * map_step + map_offset];
smem[ly][lx] =
map[grp_idx + lx + min(grp_idy + ly, rows - 1) * map_step + map_offset];
}
if(ly < 4 && grp_idy + ly + 14 <= rows && grp_idx + lx <= cols)
{
smem[ly + 14][lx] = map[grp_idx + lx + (grp_idy + ly + 14) * map_step + map_offset];
smem[ly + 14][lx] =
map[grp_idx + lx + min(grp_idy + ly + 14, rows - 1) * map_step + map_offset];
}
barrier(CLK_LOCAL_MEM_FENCE);
@ -472,8 +484,8 @@ __constant int c_dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
#define stack_size 512
__kernel
void edgesHysteresisGlobal
(
void edgesHysteresisGlobal
(
__global int * map,
__global ushort2 * st1,
__global ushort2 * st2,
@ -483,7 +495,7 @@ __kernel
int count,
int map_step,
int map_offset
)
)
{
map_step /= sizeof(*map);
@ -535,7 +547,7 @@ __kernel
while (s_counter > 0 && s_counter <= stack_size - get_local_size(0))
{
const int subTaskIdx = lidx >> 3;
const int portion = min(s_counter, get_local_size(0)>> 3);
const int portion = min(s_counter, (uint)(get_local_size(0)>> 3));
pos.x = pos.y = 0;
@ -589,8 +601,8 @@ __kernel
// map edge type mappings
// dst edge output
__kernel
void getEdges
(
void getEdges
(
__global const int * map,
__global uchar * dst,
int rows,
@ -599,19 +611,16 @@ __kernel
int map_offset,
int dst_step,
int dst_offset
)
)
{
map_step /= sizeof(*map);
map_offset /= sizeof(*map);
//dst_step /= sizeof(*dst);
//dst_offset /= sizeof(*dst);
int gidx = get_global_id(0);
int gidy = get_global_id(1);
if(gidy < rows && gidx < cols)
{
//dst[gidx + gidy * dst_step] = map[gidx + 1 + (gidy + 1) * map_step] == 2 ? 255: 0;
dst[gidx + gidy * dst_step] = (uchar)(-(map[gidx + 1 + (gidy + 1) * map_step] / 2));
dst[gidx + gidy * dst_step] = (uchar)(-(map[gidx + 1 + (gidy + 1) * map_step] >> 1));
}
}

View File

@ -45,9 +45,9 @@ namespace
{
/////////////////////////////////////////////////////////////////////////////////////////////////
// BruteForceMatcher
CV_ENUM(DistType, cv::ocl::BruteForceMatcher_OCL_base::L1Dist,\
cv::ocl::BruteForceMatcher_OCL_base::L2Dist,\
cv::ocl::BruteForceMatcher_OCL_base::HammingDist)
CV_ENUM(DistType, BruteForceMatcher_OCL_base::L1Dist,
BruteForceMatcher_OCL_base::L2Dist,
BruteForceMatcher_OCL_base::HammingDist)
IMPLEMENT_PARAM_CLASS(DescriptorSize, int)
PARAM_TEST_CASE(BruteForceMatcher, DistType, DescriptorSize)
{
@ -158,11 +158,7 @@ namespace
TEST_P(BruteForceMatcher, RadiusMatch_Single)
{
float radius;
if(distType == cv::ocl::BruteForceMatcher_OCL_base::L2Dist)
radius = 1.f / countFactor / countFactor;
else
radius = 1.f / countFactor;
float radius = 1.f / countFactor;
cv::ocl::BruteForceMatcher_OCL_base matcher(distType);
@ -191,8 +187,20 @@ namespace
INSTANTIATE_TEST_CASE_P(OCL_Features2D, BruteForceMatcher,
testing::Combine(
testing::Values(DistType(cv::ocl::BruteForceMatcher_OCL_base::L1Dist), DistType(cv::ocl::BruteForceMatcher_OCL_base::L2Dist)),
testing::Values(DescriptorSize(57), DescriptorSize(64), DescriptorSize(83), DescriptorSize(128), DescriptorSize(179), DescriptorSize(256), DescriptorSize(304))));
testing::Values(
DistType(cv::ocl::BruteForceMatcher_OCL_base::L1Dist),
DistType(cv::ocl::BruteForceMatcher_OCL_base::L2Dist)/*,
DistType(cv::ocl::BruteForceMatcher_OCL_base::HammingDist)*/
),
testing::Values(
DescriptorSize(57),
DescriptorSize(64),
DescriptorSize(83),
DescriptorSize(128),
DescriptorSize(179),
DescriptorSize(256),
DescriptorSize(304))
)
);
} // namespace
#endif

View File

@ -132,30 +132,21 @@ private:
void PrintTo(const Inverse &useRoi, std::ostream *os);
CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE)
CV_ENUM(NormCode, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_TYPE_MASK, cv::NORM_RELATIVE, cv::NORM_MINMAX)
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
CV_ENUM(ReduceOp, cv::REDUCE_SUM, cv::REDUCE_AVG, cv::REDUCE_MAX, cv::REDUCE_MIN)
CV_ENUM(CmpCode, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE)
CV_ENUM(NormCode, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX)
CV_ENUM(ReduceOp, REDUCE_SUM, REDUCE_AVG, REDUCE_MAX, REDUCE_MIN)
CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT)
CV_ENUM(ThreshOp, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV)
CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC)
CV_ENUM(Border, BORDER_REFLECT101, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_WRAP)
CV_ENUM(TemplateMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
CV_FLAGS(GemmFlags, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T);
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC)
CV_ENUM(Border, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
CV_FLAGS(WarpFlags, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::WARP_INVERSE_MAP)
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
CV_FLAGS(DftFlags, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)
CV_FLAGS(GemmFlags, GEMM_1_T, GEMM_2_T, GEMM_3_T);
CV_FLAGS(WarpFlags, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, WARP_INVERSE_MAP)
CV_FLAGS(DftFlags, DFT_INVERSE, DFT_SCALE, DFT_ROWS, DFT_COMPLEX_OUTPUT, DFT_REAL_OUTPUT)
void run_perf_test();

View File

@ -14,7 +14,7 @@ typedef perf::TestBaseWithParam<InpaintArea_InpaintingMethod_t> InpaintArea_Inpa
PERF_TEST_P(InpaintArea_InpaintingMethod, inpaint,
testing::Combine(
testing::Values(::perf::szSmall24, ::perf::szSmall32, ::perf::szSmall64),
testing::ValuesIn(InpaintingMethod::all())
InpaintingMethod::all()
)
)
{

View File

@ -50,16 +50,16 @@
namespace perf
{
CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
#define ALL_BORDER_MODES testing::ValuesIn(BorderMode::all())
#define ALL_BORDER_MODES BorderMode::all()
#define ALL_INTERPOLATIONS Interpolation::all()
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA)
#define ALL_INTERPOLATIONS testing::ValuesIn(Interpolation::all())
CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_HAMMING, cv::NORM_MINMAX)
CV_ENUM(BorderMode, BORDER_REFLECT101, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_WRAP)
CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_AREA)
CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2, NORM_HAMMING, NORM_MINMAX)
enum { Gray = 1, TwoChannel = 2, BGR = 3, BGRA = 4 };
CV_ENUM(MatCn, Gray, TwoChannel, BGR, BGRA)
#define GPU_CHANNELS_1_3_4 testing::Values(MatCn(Gray), MatCn(BGR), MatCn(BGRA))
#define GPU_CHANNELS_1_3 testing::Values(MatCn(Gray), MatCn(BGR))

View File

@ -312,14 +312,14 @@ namespace cvtest
// Flags and enums
CV_ENUM(NormCode, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_TYPE_MASK, cv::NORM_RELATIVE, cv::NORM_MINMAX)
CV_ENUM(NormCode, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX)
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA)
CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_AREA)
CV_ENUM(BorderType, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
CV_ENUM(BorderType, BORDER_REFLECT101, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_WRAP)
#define ALL_BORDER_TYPES testing::Values(BorderType(cv::BORDER_REFLECT101), BorderType(cv::BORDER_REPLICATE), BorderType(cv::BORDER_CONSTANT), BorderType(cv::BORDER_REFLECT), BorderType(cv::BORDER_WRAP))
CV_FLAGS(WarpFlags, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::WARP_INVERSE_MAP)
CV_FLAGS(WarpFlags, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, WARP_INVERSE_MAP)
//////////////////////////////////////////////////////////////////////
// Features2D

View File

@ -128,6 +128,10 @@
// Low-level types and utilities for porting Google Test to various
// platforms. They are subject to change without notice. DO NOT USE
// THEM IN USER CODE.
//
// This file is fundamental to Google Test. All other Google Test source
// files are expected to #include this. Therefore, it cannot #include
// any other Google Test header.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
@ -1942,6 +1946,11 @@ class Message;
namespace internal {
// A secret type that Google Test users don't know about. It has no
// definition on purpose. Therefore it's impossible to create a
// Secret object, which is what we want.
class Secret;
// The GTEST_COMPILE_ASSERT_ macro can be used to verify that a compile time
// expression is true. For example, you could use it to verify the
// size of a static array:
@ -1962,8 +1971,8 @@ struct CompileAssert {
};
#define GTEST_COMPILE_ASSERT_(expr, msg) \
typedef ::testing::internal::CompileAssert<(bool(expr))> \
msg[bool(expr) ? 1 : -1]
typedef ::testing::internal::CompileAssert<(static_cast<bool>(expr))> \
msg[static_cast<bool>(expr) ? 1 : -1] GTEST_ATTRIBUTE_UNUSED_
// Implementation details of GTEST_COMPILE_ASSERT_:
//
@ -3102,12 +3111,265 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val);
# include <unistd.h>
#endif // GTEST_OS_LINUX
#if GTEST_HAS_EXCEPTIONS
# include <stdexcept>
#endif
#include <ctype.h>
#include <string.h>
#include <iomanip>
#include <limits>
#include <set>
// Copyright 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
// The Google C++ Testing Framework (Google Test)
//
// This header file defines the Message class.
//
// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
// leave some internal implementation details in this header file.
// They are clearly marked by comments like this:
//
// // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
//
// Such code is NOT meant to be used by a user directly, and is subject
// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
// program!
#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
#include <limits>
// Ensures that there is at least one operator<< in the global namespace.
// See Message& operator<<(...) below for why.
void operator<<(const testing::internal::Secret&, int);
namespace testing {
// The Message class works like an ostream repeater.
//
// Typical usage:
//
// 1. You stream a bunch of values to a Message object.
// It will remember the text in a stringstream.
// 2. Then you stream the Message object to an ostream.
// This causes the text in the Message to be streamed
// to the ostream.
//
// For example;
//
// testing::Message foo;
// foo << 1 << " != " << 2;
// std::cout << foo;
//
// will print "1 != 2".
//
// Message is not intended to be inherited from. In particular, its
// destructor is not virtual.
//
// Note that stringstream behaves differently in gcc and in MSVC. You
// can stream a NULL char pointer to it in the former, but not in the
// latter (it causes an access violation if you do). The Message
// class hides this difference by treating a NULL char pointer as
// "(null)".
class GTEST_API_ Message {
private:
// The type of basic IO manipulators (endl, ends, and flush) for
// narrow streams.
typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
public:
// Constructs an empty Message.
Message();
// Copy constructor.
Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT
*ss_ << msg.GetString();
}
// Constructs a Message from a C-string.
explicit Message(const char* str) : ss_(new ::std::stringstream) {
*ss_ << str;
}
#if GTEST_OS_SYMBIAN
// Streams a value (either a pointer or not) to this object.
template <typename T>
inline Message& operator <<(const T& value) {
StreamHelper(typename internal::is_pointer<T>::type(), value);
return *this;
}
#else
// Streams a non-pointer value to this object.
template <typename T>
inline Message& operator <<(const T& val) {
// Some libraries overload << for STL containers. These
// overloads are defined in the global namespace instead of ::std.
//
// C++'s symbol lookup rule (i.e. Koenig lookup) says that these
// overloads are visible in either the std namespace or the global
// namespace, but not other namespaces, including the testing
// namespace which Google Test's Message class is in.
//
// To allow STL containers (and other types that has a << operator
// defined in the global namespace) to be used in Google Test
// assertions, testing::Message must access the custom << operator
// from the global namespace. With this using declaration,
// overloads of << defined in the global namespace and those
// visible via Koenig lookup are both exposed in this function.
using ::operator <<;
*ss_ << val;
return *this;
}
// Streams a pointer value to this object.
//
// This function is an overload of the previous one. When you
// stream a pointer to a Message, this definition will be used as it
// is more specialized. (The C++ Standard, section
// [temp.func.order].) If you stream a non-pointer, then the
// previous definition will be used.
//
// The reason for this overload is that streaming a NULL pointer to
// ostream is undefined behavior. Depending on the compiler, you
// may get "0", "(nil)", "(null)", or an access violation. To
// ensure consistent result across compilers, we always treat NULL
// as "(null)".
template <typename T>
inline Message& operator <<(T* const& pointer) { // NOLINT
if (pointer == NULL) {
*ss_ << "(null)";
} else {
*ss_ << pointer;
}
return *this;
}
#endif // GTEST_OS_SYMBIAN
// Since the basic IO manipulators are overloaded for both narrow
// and wide streams, we have to provide this specialized definition
// of operator <<, even though its body is the same as the
// templatized version above. Without this definition, streaming
// endl or other basic IO manipulators to Message will confuse the
// compiler.
Message& operator <<(BasicNarrowIoManip val) {
*ss_ << val;
return *this;
}
// Instead of 1/0, we want to see true/false for bool values.
Message& operator <<(bool b) {
return *this << (b ? "true" : "false");
}
// These two overloads allow streaming a wide C string to a Message
// using the UTF-8 encoding.
Message& operator <<(const wchar_t* wide_c_str);
Message& operator <<(wchar_t* wide_c_str);
#if GTEST_HAS_STD_WSTRING
// Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object.
Message& operator <<(const ::std::wstring& wstr);
#endif // GTEST_HAS_STD_WSTRING
#if GTEST_HAS_GLOBAL_WSTRING
// Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object.
Message& operator <<(const ::wstring& wstr);
#endif // GTEST_HAS_GLOBAL_WSTRING
// Gets the text streamed to this object so far as an std::string.
// Each '\0' character in the buffer is replaced with "\\0".
//
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
std::string GetString() const;
private:
#if GTEST_OS_SYMBIAN
// These are needed as the Nokia Symbian Compiler cannot decide between
// const T& and const T* in a function template. The Nokia compiler _can_
// decide between class template specializations for T and T*, so a
// tr1::type_traits-like is_pointer works, and we can overload on that.
template <typename T>
inline void StreamHelper(internal::true_type /*is_pointer*/, T* pointer) {
if (pointer == NULL) {
*ss_ << "(null)";
} else {
*ss_ << pointer;
}
}
template <typename T>
inline void StreamHelper(internal::false_type /*is_pointer*/,
const T& value) {
// See the comments in Message& operator <<(const T&) above for why
// we need this using statement.
using ::operator <<;
*ss_ << value;
}
#endif // GTEST_OS_SYMBIAN
// We'll hold the text streamed to this object here.
const internal::scoped_ptr< ::std::stringstream> ss_;
// We declare (but don't implement) this to prevent the compiler
// from implementing the assignment operator.
void operator=(const Message&);
};
// Streams a Message to an ostream.
inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
return os << sb.GetString();
}
namespace internal {
// Converts a streamable value to an std::string. A NULL pointer is
// converted to "(null)". When the input value is a ::string,
// ::std::string, ::wstring, or ::std::wstring object, each NUL
// character in it is replaced with "\\0".
template <typename T>
std::string StreamableToString(const T& streamable) {
return (Message() << streamable).GetString();
}
} // namespace internal
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
// Copyright 2005, Google Inc.
// All rights reserved.
//
@ -3253,16 +3515,14 @@ class GTEST_API_ String {
static bool EndsWithCaseInsensitive(
const std::string& str, const std::string& suffix);
// Formats a list of arguments to an std::string, using the same format
// spec string as for printf.
//
// We do not use the StringPrintf class as it is not universally
// available.
//
// The result is limited to 4096 characters (including the tailing
// 0). If 4096 characters are not enough to format the input,
// "<buffer exceeded>" is returned.
static std::string Format(const char* format, ...);
// Formats an int value as "%02d".
static std::string FormatIntWidth2(int value); // "%02d" for width == 2
// Formats an int value as "%X".
static std::string FormatHexInt(int value);
// Formats a byte as "%02X".
static std::string FormatByte(unsigned char value);
private:
String(); // Not meant to be instantiated.
@ -3272,17 +3532,6 @@ class GTEST_API_ String {
// character in the buffer is replaced with "\\0".
GTEST_API_ std::string StringStreamToString(::std::stringstream* stream);
// Converts a streamable value to an std::string. A NULL pointer is
// converted to "(null)". When the input value is a ::string,
// ::std::string, ::wstring, or ::std::wstring object, each NUL
// character in it is replaced with "\\0".
// Declared here but defined in gtest.h, so that it has access
// to the definition of the Message class, required by the ARM
// compiler.
template <typename T>
std::string StreamableToString(const T& streamable);
} // namespace internal
} // namespace testing
@ -6834,36 +7083,6 @@ struct TypeList<Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
// Google Test defines the testing::Message class to allow construction of
// test messages via the << operator. The idea is that anything
// streamable to std::ostream can be streamed to a testing::Message.
// This allows a user to use his own types in Google Test assertions by
// overloading the << operator.
//
// util/gtl/stl_logging.h overloads << for STL containers. These
// overloads cannot be defined in the std namespace, as that will be
// undefined behavior. Therefore, they are defined in the global
// namespace instead.
//
// C++'s symbol lookup rule (i.e. Koenig lookup) says that these
// overloads are visible in either the std namespace or the global
// namespace, but not other namespaces, including the testing
// namespace which Google Test's Message class is in.
//
// To allow STL containers (and other types that has a << operator
// defined in the global namespace) to be used in Google Test assertions,
// testing::Message must access the custom << operator from the global
// namespace. Hence this helper function.
//
// Note: Jeffrey Yasskin suggested an alternative fix by "using
// ::operator<<;" in the definition of Message's operator<<. That fix
// doesn't require a helper function, but unfortunately doesn't
// compile with MSVC.
template <typename T>
inline void GTestStreamToHelper(std::ostream* os, const T& val) {
*os << val;
}
class ProtocolMessage;
namespace proto2 { class Message; }
@ -6895,11 +7114,6 @@ GTEST_API_ extern int g_init_gtest_count;
// stack trace.
GTEST_API_ extern const char kStackTraceMarker[];
// A secret type that Google Test users don't know about. It has no
// definition on purpose. Therefore it's impossible to create a
// Secret object, which is what we want.
class Secret;
// Two overloaded helpers for checking at compile time whether an
// expression is a null pointer literal (i.e. NULL or any 0-valued
// compile-time integral constant). Their return values have
@ -6933,6 +7147,31 @@ char (&IsNullLiteralHelper(...))[2]; // NOLINT
GTEST_API_ std::string AppendUserMessage(
const std::string& gtest_msg, const Message& user_msg);
#if GTEST_HAS_EXCEPTIONS
// This exception is thrown by (and only by) a failed Google Test
// assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions
// are enabled). We derive it from std::runtime_error, which is for
// errors presumably detectable only at run time. Since
// std::runtime_error inherits from std::exception, many testing
// frameworks know how to extract and print the message inside it.
#ifdef _MSC_VER
# pragma warning(push) // Saves the current warning state.
# pragma warning(disable:4275) // Temporarily disables warning 4275.
#endif // _MSC_VER
class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {
public:
explicit GoogleTestFailureException(const TestPartResult& failure);
};
#ifdef _MSC_VER
# pragma warning(pop) // Restores the warning state.
#endif // _MSC_VER
#endif // GTEST_HAS_EXCEPTIONS
// A helper class for creating scoped traces in user programs.
class GTEST_API_ ScopedTrace {
public:
@ -6952,16 +7191,6 @@ class GTEST_API_ ScopedTrace {
// c'tor and d'tor. Therefore it doesn't
// need to be used otherwise.
// Converts a streamable value to an std::string. A NULL pointer is
// converted to "(null)". When the input value is a ::string,
// ::std::string, ::wstring, or ::std::wstring object, each NUL
// character in it is replaced with "\\0".
// Declared here but defined in gtest.h, so that it has access
// to the definition of the Message class, required by the ARM
// compiler.
template <typename T>
std::string StreamableToString(const T& streamable);
// Constructs and returns the message for an equality assertion
// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
//
@ -7059,7 +7288,7 @@ class FloatingPoint {
// bits. Therefore, 4 should be enough for ordinary use.
//
// See the following article for more details on ULP:
// http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm.
// http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
static const size_t kMaxUlps = 4;
// Constructs a FloatingPoint from a raw floating-point number.
@ -7260,7 +7489,7 @@ typedef void (*TearDownTestCaseFunc)();
// test_case_name: name of the test case
// name: name of the test
// type_param the name of the test's type parameter, or NULL if
// this is not a typed or a type-parameterized test.
// this is not a typed or a type-parameterized test.
// value_param text representation of the test's value parameter,
// or NULL if this is not a type-parameterized test.
// fixture_class_id: ID of the test fixture class
@ -7270,7 +7499,8 @@ typedef void (*TearDownTestCaseFunc)();
// The newly created TestInfo instance will assume
// ownership of the factory object.
GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
const char* test_case_name, const char* name,
const char* test_case_name,
const char* name,
const char* type_param,
const char* value_param,
TypeId fixture_class_id,
@ -7358,8 +7588,8 @@ class TypeParameterizedTest {
// First, registers the first type-parameterized test in the type
// list.
MakeAndRegisterTestInfo(
String::Format("%s%s%s/%d", prefix, prefix[0] == '\0' ? "" : "/",
case_name, index).c_str(),
(std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name + "/"
+ StreamableToString(index)).c_str(),
GetPrefixUntilComma(test_names).c_str(),
GetTypeName<Type>().c_str(),
NULL, // No value parameter.
@ -8547,234 +8777,6 @@ class GTEST_API_ KilledBySignal {
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
// Copyright 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
// The Google C++ Testing Framework (Google Test)
//
// This header file defines the Message class.
//
// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
// leave some internal implementation details in this header file.
// They are clearly marked by comments like this:
//
// // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
//
// Such code is NOT meant to be used by a user directly, and is subject
// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
// program!
#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
#include <limits>
namespace testing {
// The Message class works like an ostream repeater.
//
// Typical usage:
//
// 1. You stream a bunch of values to a Message object.
// It will remember the text in a stringstream.
// 2. Then you stream the Message object to an ostream.
// This causes the text in the Message to be streamed
// to the ostream.
//
// For example;
//
// testing::Message foo;
// foo << 1 << " != " << 2;
// std::cout << foo;
//
// will print "1 != 2".
//
// Message is not intended to be inherited from. In particular, its
// destructor is not virtual.
//
// Note that stringstream behaves differently in gcc and in MSVC. You
// can stream a NULL char pointer to it in the former, but not in the
// latter (it causes an access violation if you do). The Message
// class hides this difference by treating a NULL char pointer as
// "(null)".
class GTEST_API_ Message {
private:
// The type of basic IO manipulators (endl, ends, and flush) for
// narrow streams.
typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
public:
// Constructs an empty Message.
// We allocate the stringstream separately because otherwise each use of
// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
// stack frame leading to huge stack frames in some cases; gcc does not reuse
// the stack space.
Message() : ss_(new ::std::stringstream) {
// By default, we want there to be enough precision when printing
// a double to a Message.
*ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);
}
// Copy constructor.
Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT
*ss_ << msg.GetString();
}
// Constructs a Message from a C-string.
explicit Message(const char* str) : ss_(new ::std::stringstream) {
*ss_ << str;
}
#if GTEST_OS_SYMBIAN
// Streams a value (either a pointer or not) to this object.
template <typename T>
inline Message& operator <<(const T& value) {
StreamHelper(typename internal::is_pointer<T>::type(), value);
return *this;
}
#else
// Streams a non-pointer value to this object.
template <typename T>
inline Message& operator <<(const T& val) {
::GTestStreamToHelper(ss_.get(), val);
return *this;
}
// Streams a pointer value to this object.
//
// This function is an overload of the previous one. When you
// stream a pointer to a Message, this definition will be used as it
// is more specialized. (The C++ Standard, section
// [temp.func.order].) If you stream a non-pointer, then the
// previous definition will be used.
//
// The reason for this overload is that streaming a NULL pointer to
// ostream is undefined behavior. Depending on the compiler, you
// may get "0", "(nil)", "(null)", or an access violation. To
// ensure consistent result across compilers, we always treat NULL
// as "(null)".
template <typename T>
inline Message& operator <<(T* const& pointer) { // NOLINT
if (pointer == NULL) {
*ss_ << "(null)";
} else {
::GTestStreamToHelper(ss_.get(), pointer);
}
return *this;
}
#endif // GTEST_OS_SYMBIAN
// Since the basic IO manipulators are overloaded for both narrow
// and wide streams, we have to provide this specialized definition
// of operator <<, even though its body is the same as the
// templatized version above. Without this definition, streaming
// endl or other basic IO manipulators to Message will confuse the
// compiler.
Message& operator <<(BasicNarrowIoManip val) {
*ss_ << val;
return *this;
}
// Instead of 1/0, we want to see true/false for bool values.
Message& operator <<(bool b) {
return *this << (b ? "true" : "false");
}
// These two overloads allow streaming a wide C string to a Message
// using the UTF-8 encoding.
Message& operator <<(const wchar_t* wide_c_str) {
return *this << internal::String::ShowWideCString(wide_c_str);
}
Message& operator <<(wchar_t* wide_c_str) {
return *this << internal::String::ShowWideCString(wide_c_str);
}
#if GTEST_HAS_STD_WSTRING
// Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object.
Message& operator <<(const ::std::wstring& wstr);
#endif // GTEST_HAS_STD_WSTRING
#if GTEST_HAS_GLOBAL_WSTRING
// Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object.
Message& operator <<(const ::wstring& wstr);
#endif // GTEST_HAS_GLOBAL_WSTRING
// Gets the text streamed to this object so far as an std::string.
// Each '\0' character in the buffer is replaced with "\\0".
//
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
std::string GetString() const {
return internal::StringStreamToString(ss_.get());
}
private:
#if GTEST_OS_SYMBIAN
// These are needed as the Nokia Symbian Compiler cannot decide between
// const T& and const T* in a function template. The Nokia compiler _can_
// decide between class template specializations for T and T*, so a
// tr1::type_traits-like is_pointer works, and we can overload on that.
template <typename T>
inline void StreamHelper(internal::true_type /*dummy*/, T* pointer) {
if (pointer == NULL) {
*ss_ << "(null)";
} else {
::GTestStreamToHelper(ss_.get(), pointer);
}
}
template <typename T>
inline void StreamHelper(internal::false_type /*dummy*/, const T& value) {
::GTestStreamToHelper(ss_.get(), value);
}
#endif // GTEST_OS_SYMBIAN
// We'll hold the text streamed to this object here.
const internal::scoped_ptr< ::std::stringstream> ss_;
// We declare (but don't implement) this to prevent the compiler
// from implementing the assignment operator.
void operator=(const Message&);
};
// Streams a Message to an ostream.
inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
return os << sb.GetString();
}
} // namespace testing
#endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
// This file was GENERATED by command:
// pump.py gtest-param-test.h.pump
// DO NOT EDIT BY HAND!!!
@ -10541,10 +10543,10 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
const string& instantiation_name = gen_it->first;
ParamGenerator<ParamType> generator((*gen_it->second)());
Message test_case_name_stream;
string test_case_name;
if ( !instantiation_name.empty() )
test_case_name_stream << instantiation_name << "/";
test_case_name_stream << test_info->test_case_base_name;
test_case_name = instantiation_name + "/";
test_case_name += test_info->test_case_base_name;
int i = 0;
for (typename ParamGenerator<ParamType>::iterator param_it =
@ -10553,7 +10555,7 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
Message test_name_stream;
test_name_stream << test_info->test_base_name << "/" << i;
MakeAndRegisterTestInfo(
test_case_name_stream.GetString().c_str(),
test_case_name.c_str(),
test_name_stream.GetString().c_str(),
NULL, // No type parameter.
PrintToString(*param_it).c_str(),
@ -17615,26 +17617,16 @@ class ExecDeathTest;
class NoExecDeathTest;
class FinalSuccessChecker;
class GTestFlagSaver;
class StreamingListenerTest;
class TestResultAccessor;
class TestEventListenersAccessor;
class TestEventRepeater;
class UnitTestRecordPropertyTestHelper;
class WindowsDeathTest;
class UnitTestImpl* GetUnitTestImpl();
void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
const std::string& message);
// Converts a streamable value to an std::string. A NULL pointer is
// converted to "(null)". When the input value is a ::string,
// ::std::string, ::wstring, or ::std::wstring object, each NUL
// character in it is replaced with "\\0".
// Declared in gtest-internal.h but defined here, so that it has access
// to the definition of the Message class, required by the ARM
// compiler.
template <typename T>
std::string StreamableToString(const T& streamable) {
return (Message() << streamable).GetString();
}
} // namespace internal
// The friend relationship of some of these classes is cyclic.
@ -17853,20 +17845,21 @@ class GTEST_API_ Test {
// non-fatal) failure.
static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
// Logs a property for the current test. Only the last value for a given
// key is remembered.
// These are public static so they can be called from utility functions
// that are not members of the test fixture.
// The arguments are const char* instead strings, as Google Test is used
// on platforms where string doesn't compile.
//
// Note that a driving consideration for these RecordProperty methods
// was to produce xml output suited to the Greenspan charting utility,
// which at present will only chart values that fit in a 32-bit int. It
// is the user's responsibility to restrict their values to 32-bit ints
// if they intend them to be used with Greenspan.
static void RecordProperty(const char* key, const char* value);
static void RecordProperty(const char* key, int value);
// Logs a property for the current test, test case, or for the entire
// invocation of the test program when used outside of the context of a
// test case. Only the last value for a given key is remembered. These
// are public static so they can be called from utility functions that are
// not members of the test fixture. Calls to RecordProperty made during
// lifespan of the test (from the moment its constructor starts to the
// moment its destructor finishes) will be output in XML as attributes of
// the <testcase> element. Properties recorded from fixture's
// SetUpTestCase or TearDownTestCase are logged as attributes of the
// corresponding <testsuite> element. Calls to RecordProperty made in the
// global context (before or after invocation of RUN_ALL_TESTS and from
// SetUp/TearDown method of Environment objects registered with Google
// Test) will be output as attributes of the <testsuites> element.
static void RecordProperty(const std::string& key, const std::string& value);
static void RecordProperty(const std::string& key, int value);
protected:
// Creates a Test object.
@ -17935,7 +17928,7 @@ class TestProperty {
// C'tor. TestProperty does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestProperty object.
TestProperty(const char* a_key, const char* a_value) :
TestProperty(const std::string& a_key, const std::string& a_value) :
key_(a_key), value_(a_value) {
}
@ -17950,7 +17943,7 @@ class TestProperty {
}
// Sets a new value, overriding the one supplied in the constructor.
void SetValue(const char* new_value) {
void SetValue(const std::string& new_value) {
value_ = new_value;
}
@ -18009,6 +18002,7 @@ class GTEST_API_ TestResult {
private:
friend class TestInfo;
friend class TestCase;
friend class UnitTest;
friend class internal::DefaultGlobalTestPartResultReporter;
friend class internal::ExecDeathTest;
@ -18033,13 +18027,16 @@ class GTEST_API_ TestResult {
// a non-fatal failure if invalid (e.g., if it conflicts with reserved
// key names). If a property is already recorded for the same key, the
// value will be updated, rather than storing multiple values for the same
// key.
void RecordProperty(const TestProperty& test_property);
// key. xml_element specifies the element for which the property is being
// recorded and is used for validation.
void RecordProperty(const std::string& xml_element,
const TestProperty& test_property);
// Adds a failure if the key is a reserved attribute of Google Test
// testcase tags. Returns true if the property is valid.
// TODO(russr): Validate attribute names are legal and human readable.
static bool ValidateTestProperty(const TestProperty& test_property);
static bool ValidateTestProperty(const std::string& xml_element,
const TestProperty& test_property);
// Adds a test part result to the list.
void AddTestPartResult(const TestPartResult& test_part_result);
@ -18140,8 +18137,10 @@ class GTEST_API_ TestInfo {
friend class Test;
friend class TestCase;
friend class internal::UnitTestImpl;
friend class internal::StreamingListenerTest;
friend TestInfo* internal::MakeAndRegisterTestInfo(
const char* test_case_name, const char* name,
const char* test_case_name,
const char* name,
const char* type_param,
const char* value_param,
internal::TypeId fixture_class_id,
@ -18151,9 +18150,10 @@ class GTEST_API_ TestInfo {
// Constructs a TestInfo object. The newly constructed instance assumes
// ownership of the factory object.
TestInfo(const char* test_case_name, const char* name,
const char* a_type_param,
const char* a_value_param,
TestInfo(const std::string& test_case_name,
const std::string& name,
const char* a_type_param, // NULL if not a type-parameterized test
const char* a_value_param, // NULL if not a value-parameterized test
internal::TypeId fixture_class_id,
internal::TestFactoryBase* factory);
@ -18261,6 +18261,10 @@ class GTEST_API_ TestCase {
// total_test_count() - 1. If i is not in that range, returns NULL.
const TestInfo* GetTestInfo(int i) const;
// Returns the TestResult that holds test properties recorded during
// execution of SetUpTestCase and TearDownTestCase.
const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }
private:
friend class Test;
friend class internal::UnitTestImpl;
@ -18349,6 +18353,9 @@ class GTEST_API_ TestCase {
bool should_run_;
// Elapsed time, in milliseconds.
TimeInMillis elapsed_time_;
// Holds test properties recorded during execution of SetUpTestCase and
// TearDownTestCase.
TestResult ad_hoc_test_result_;
// We disallow copying TestCases.
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestCase);
@ -18634,6 +18641,10 @@ class GTEST_API_ UnitTest {
// total_test_case_count() - 1. If i is not in that range, returns NULL.
const TestCase* GetTestCase(int i) const;
// Returns the TestResult containing information on test failures and
// properties logged outside of individual test cases.
const TestResult& ad_hoc_test_result() const;
// Returns the list of event listeners that can be used to track events
// inside Google Test.
TestEventListeners& listeners();
@ -18661,9 +18672,12 @@ class GTEST_API_ UnitTest {
const std::string& os_stack_trace)
GTEST_LOCK_EXCLUDED_(mutex_);
// Adds a TestProperty to the current TestResult object. If the result already
// contains a property with the same key, the value will be updated.
void RecordPropertyForCurrentTest(const char* key, const char* value);
// Adds a TestProperty to the current TestResult object when invoked from
// inside a test, to current TestCase's ad_hoc_test_result_ when invoked
// from SetUpTestCase or TearDownTestCase, or to the global property set
// when invoked elsewhere. If the result already contains a property with
// the same key, the value will be updated.
void RecordProperty(const std::string& key, const std::string& value);
// Gets the i-th test case among all the test cases. i can range from 0 to
// total_test_case_count() - 1. If i is not in that range, returns NULL.
@ -18678,6 +18692,8 @@ class GTEST_API_ UnitTest {
friend class Test;
friend class internal::AssertHelper;
friend class internal::ScopedTrace;
friend class internal::StreamingListenerTest;
friend class internal::UnitTestRecordPropertyTestHelper;
friend Environment* AddGlobalTestEnvironment(Environment* env);
friend internal::UnitTestImpl* internal::GetUnitTestImpl();
friend void internal::ReportFailureInUnknownLocation(
@ -19223,7 +19239,12 @@ class WithParamInterface {
// references static data, to reduce the opportunity for incorrect uses
// like writing 'WithParamInterface<bool>::GetParam()' for a test that
// uses a fixture whose parameter type is int.
const ParamType& GetParam() const { return *parameter_; }
const ParamType& GetParam() const {
GTEST_CHECK_(parameter_ != NULL)
<< "GetParam() can only be called inside a value-parameterized test "
<< "-- did you intend to write TEST_P instead of TEST_F?";
return *parameter_;
}
private:
// Sets parameter value. The caller is responsible for making sure the value
@ -20040,15 +20061,20 @@ bool StaticAssertTypeEq() {
GTEST_TEST_(test_fixture, test_name, test_fixture, \
::testing::internal::GetTypeId<test_fixture>())
// Use this macro in main() to run all tests. It returns 0 if all
} // namespace testing
// Use this function in main() to run all tests. It returns 0 if all
// tests are successful, or 1 otherwise.
//
// RUN_ALL_TESTS() should be invoked after the command line has been
// parsed by InitGoogleTest().
//
// This function was formerly a macro; thus, it is in the global
// namespace and has an all-caps name.
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;
#define RUN_ALL_TESTS()\
(::testing::UnitTest::GetInstance()->Run())
} // namespace testing
inline int RUN_ALL_TESTS() {
return ::testing::UnitTest::GetInstance()->Run();
}
#endif // GTEST_INCLUDE_GTEST_GTEST_H_

View File

@ -31,6 +31,9 @@
# endif
#endif
// declare major namespaces to avoid errors on unknown namespace
namespace cv { namespace gpu {} namespace ocl {} }
namespace perf
{
class TestBase;
@ -97,66 +100,64 @@ private:
* CV_ENUM and CV_FLAGS - macro to create printable wrappers for defines and enums *
\*****************************************************************************************/
#define CV_ENUM(class_name, ...) \
namespace { class CV_EXPORTS class_name {\
public:\
class_name(int val = 0) : _val(val) {}\
operator int() const {return _val;}\
void PrintTo(std::ostream* os) const {\
const int vals[] = {__VA_ARGS__};\
const char* svals = #__VA_ARGS__;\
for(int i = 0, pos = 0; i < (int)(sizeof(vals)/sizeof(int)); ++i){\
while(isspace(svals[pos]) || svals[pos] == ',') ++pos;\
int start = pos;\
while(!(isspace(svals[pos]) || svals[pos] == ',' || svals[pos] == 0)) ++pos;\
if (_val == vals[i]) {\
*os << std::string(svals + start, svals + pos);\
return;\
}\
}\
*os << "UNKNOWN";\
}\
struct Container{\
typedef class_name value_type;\
Container(class_name* first, size_t len): _begin(first), _end(first+len){}\
const class_name* begin() const {return _begin;}\
const class_name* end() const {return _end;}\
private: class_name *_begin, *_end;\
};\
static Container all(){\
static int vals[] = {__VA_ARGS__};\
return Container((class_name*)vals, sizeof(vals)/sizeof(vals[0]));\
}\
private: int _val;\
};\
inline void PrintTo(const class_name& t, std::ostream* os) { t.PrintTo(os); } }
#define CV_ENUM(class_name, ...) \
namespace { \
struct class_name { \
class_name(int val = 0) : val_(val) {} \
operator int() const { return val_; } \
void PrintTo(std::ostream* os) const { \
using namespace cv;using namespace cv::gpu; using namespace cv::ocl; \
const int vals[] = { __VA_ARGS__ }; \
const char* svals = #__VA_ARGS__; \
for(int i = 0, pos = 0; i < (int)(sizeof(vals)/sizeof(int)); ++i) { \
while(isspace(svals[pos]) || svals[pos] == ',') ++pos; \
int start = pos; \
while(!(isspace(svals[pos]) || svals[pos] == ',' || svals[pos] == 0)) \
++pos; \
if (val_ == vals[i]) { \
*os << std::string(svals + start, svals + pos); \
return; \
} \
} \
*os << "UNKNOWN"; \
} \
static ::testing::internal::ParamGenerator<class_name> all() { \
using namespace cv;using namespace cv::gpu; using namespace cv::ocl; \
static class_name vals[] = { __VA_ARGS__ }; \
return ::testing::ValuesIn(vals); \
} \
private: int val_; \
}; \
inline void PrintTo(const class_name& t, std::ostream* os) { t.PrintTo(os); } }
#define CV_FLAGS(class_name, ...) \
class CV_EXPORTS class_name {\
public:\
class_name(int val = 0) : _val(val) {}\
operator int() const {return _val;}\
void PrintTo(std::ostream* os) const {\
const int vals[] = {__VA_ARGS__};\
const char* svals = #__VA_ARGS__;\
int value = _val;\
bool first = true;\
for(int i = 0, pos = 0; i < (int)(sizeof(vals)/sizeof(int)); ++i){\
while(isspace(svals[pos]) || svals[pos] == ',') ++pos;\
int start = pos;\
while(!(isspace(svals[pos]) || svals[pos] == ',' || svals[pos] == 0)) ++pos;\
if ((value & vals[i]) == vals[i]) {\
value &= ~vals[i]; \
if (first) first = false; else *os << "|"; \
*os << std::string(svals + start, svals + pos);\
if (!value) return;\
}\
}\
if (first) *os << "UNKNOWN";\
}\
private: int _val;\
};\
inline void PrintTo(const class_name& t, std::ostream* os) { t.PrintTo(os); }
#define CV_FLAGS(class_name, ...) \
namespace { \
struct class_name { \
class_name(int val = 0) : val_(val) {} \
operator int() const { return val_; } \
void PrintTo(std::ostream* os) const { \
using namespace cv;using namespace cv::gpu; using namespace cv::ocl; \
const int vals[] = { __VA_ARGS__ }; \
const char* svals = #__VA_ARGS__; \
int value = val_; \
bool first = true; \
for(int i = 0, pos = 0; i < (int)(sizeof(vals)/sizeof(int)); ++i) { \
while(isspace(svals[pos]) || svals[pos] == ',') ++pos; \
int start = pos; \
while(!(isspace(svals[pos]) || svals[pos] == ',' || svals[pos] == 0)) \
++pos; \
if ((value & vals[i]) == vals[i]) { \
value &= ~vals[i]; \
if (first) first = false; else *os << "|"; \
*os << std::string(svals + start, svals + pos); \
if (!value) return; \
} \
} \
if (first) *os << "UNKNOWN"; \
} \
private: int val_; \
}; \
inline void PrintTo(const class_name& t, std::ostream* os) { t.PrintTo(os); } }
CV_ENUM(MatDepth, CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F, CV_USRTYPE1)

File diff suppressed because it is too large Load Diff

View File

@ -185,7 +185,7 @@ PERF_TEST_P(Path_Win_Deriv_Border_Reuse, OpticalFlowPyrLK_pyr, testing::Combine(
testing::Values<std::string>("cv/optflow/frames/720p_01.png"),
testing::Values(7, 11),
testing::Bool(),
testing::ValuesIn(PyrBorderMode::all()),
PyrBorderMode::all(),
testing::Bool()
)
)