rewrite histEven test

This commit is contained in:
Vladislav Vinogradov 2013-08-01 16:25:16 +04:00
parent c8d1fccdac
commit bfca1afd9e

View File

@ -86,13 +86,16 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Integral, testing::Combine(
/////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////
// HistEven // HistEven
struct HistEven : testing::TestWithParam<cv::gpu::DeviceInfo> PARAM_TEST_CASE(HistEven, cv::gpu::DeviceInfo, cv::Size)
{ {
cv::gpu::DeviceInfo devInfo; cv::gpu::DeviceInfo devInfo;
cv::Size size;
virtual void SetUp() virtual void SetUp()
{ {
devInfo = GetParam(); devInfo = GET_PARAM(0);
size = GET_PARAM(1);
cv::gpu::setDevice(devInfo.deviceID()); cv::gpu::setDevice(devInfo.deviceID());
} }
@ -100,35 +103,30 @@ struct HistEven : testing::TestWithParam<cv::gpu::DeviceInfo>
GPU_TEST_P(HistEven, Accuracy) GPU_TEST_P(HistEven, Accuracy)
{ {
cv::Mat img = readImage("stereobm/aloe-L.png"); cv::Mat src = randomMat(size, CV_8UC1);
ASSERT_FALSE(img.empty());
cv::Mat hsv; int hbins = 256;
cv::cvtColor(img, hsv, CV_BGR2HSV); float hranges[] = {0.0f, 256.0f};
int hbins = 30;
float hranges[] = {0.0f, 180.0f};
std::vector<cv::gpu::GpuMat> srcs;
cv::gpu::split(loadMat(hsv), srcs);
cv::gpu::GpuMat hist; cv::gpu::GpuMat hist;
cv::gpu::histEven(srcs[0], hist, hbins, (int)hranges[0], (int)hranges[1]); cv::gpu::histEven(loadMat(src), hist, hbins, (int) hranges[0], (int) hranges[1]);
cv::Mat hist_gold;
cv::MatND histnd;
int histSize[] = {hbins}; int histSize[] = {hbins};
const float* ranges[] = {hranges}; const float* ranges[] = {hranges};
int channels[] = {0}; int channels[] = {0};
cv::calcHist(&hsv, 1, channels, cv::Mat(), histnd, 1, histSize, ranges); cv::calcHist(&src, 1, channels, cv::Mat(), hist_gold, 1, histSize, ranges);
cv::Mat hist_gold = histnd;
hist_gold = hist_gold.t(); hist_gold = hist_gold.t();
hist_gold.convertTo(hist_gold, CV_32S); hist_gold.convertTo(hist_gold, CV_32S);
EXPECT_MAT_NEAR(hist_gold, hist, 0.0); EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
} }
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HistEven, ALL_DEVICES); INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HistEven, testing::Combine(
ALL_DEVICES,
DIFFERENT_SIZES));
/////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////
// CalcHist // CalcHist