bool AddFeatureDifferenceDataTest(bool create, int width, int height, const Func & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View value(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View lo(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View hi(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View differenceSrc(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View differenceDst1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View differenceDst2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); const uint16_t weight = 256*7; if(create) { FillRandom(value); FillRandom(lo); FillRandom(hi); FillRandom(differenceSrc); TEST_SAVE(value); TEST_SAVE(lo); TEST_SAVE(hi); TEST_SAVE(differenceSrc); f.Call(value, lo, hi, weight, differenceSrc, differenceDst1); TEST_SAVE(differenceDst1); } else { TEST_LOAD(value); TEST_LOAD(lo); TEST_LOAD(hi); TEST_LOAD(differenceSrc); TEST_LOAD(differenceDst1); f.Call(value, lo, hi, weight, differenceSrc, differenceDst2); TEST_SAVE(differenceDst2); result = result && Compare(differenceDst1, differenceDst2, 0, true, 32, 0); } return result; }
bool IntegralDataTest(bool create, int width, int height, const Func & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View sum1(width + 1, height + 1, View::Int32, NULL, TEST_ALIGN(width)); View sum2(width + 1, height + 1, View::Int32, NULL, TEST_ALIGN(width)); View sqsum1(width + 1, height + 1, View::Int32, NULL, TEST_ALIGN(width)); View sqsum2(width + 1, height + 1, View::Int32, NULL, TEST_ALIGN(width)); View tilted1(width + 1, height + 1, View::Int32, NULL, TEST_ALIGN(width)); View tilted2(width + 1, height + 1, View::Int32, NULL, TEST_ALIGN(width)); if(create) { FillRandom(src); TEST_SAVE(src); f.Call(src, sum1, sqsum1, tilted1); TEST_SAVE(sum1); TEST_SAVE(sqsum1); TEST_SAVE(tilted1); } else { TEST_LOAD(src); TEST_LOAD(sum1); TEST_LOAD(sqsum1); TEST_LOAD(tilted1); f.Call(src, sum2, sqsum2, tilted2); TEST_SAVE(sum2); TEST_SAVE(sqsum2); TEST_SAVE(tilted2); result = result && Compare(sum1, sum2, 0, true, 32, 0, "sum"); result = result && Compare(sqsum1, sqsum2, 0, true, 32, 0, "sqsum"); result = result && Compare(tilted1, tilted2, 0, true, 32, 0, "tilted"); } return result; }
bool YuvToBgraDataTest(bool create, int width, int height, const Func & f, int dx, int dy) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); const int uvWidth = width/dx; const int uvHeight = height/dy; View y(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View u(uvWidth, uvHeight, View::Gray8, NULL, TEST_ALIGN(uvWidth)); View v(uvWidth, uvHeight, View::Gray8, NULL, TEST_ALIGN(uvWidth)); View bgra1(width, height, View::Bgra32, NULL, TEST_ALIGN(width)); View bgra2(width, height, View::Bgra32, NULL, TEST_ALIGN(width)); if(create) { FillRandom(y); FillRandom(u); FillRandom(v); TEST_SAVE(y); TEST_SAVE(u); TEST_SAVE(v); f.Call(y, u, v, bgra1); TEST_SAVE(bgra1); } else { TEST_LOAD(y); TEST_LOAD(u); TEST_LOAD(v); TEST_LOAD(bgra1); f.Call(y, u, v, bgra2); TEST_SAVE(bgra2); result = result && Compare(bgra1, bgra2, 0, true, 64); } return result; }
bool YuvToAnyDataTest(bool create, int width, int height, bool is420, View::Format dstType, const Func & f) { bool result = true; Data data(f.description); std::cout << (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]." << std::endl; const int uvWidth = is420 ? width/2 : width; const int uvHeight = is420 ? height/2 : height; View y(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View u(uvWidth, uvHeight, View::Gray8, NULL, TEST_ALIGN(uvWidth)); View v(uvWidth, uvHeight, View::Gray8, NULL, TEST_ALIGN(uvWidth)); View dst1(width, height, dstType, NULL, TEST_ALIGN(width)); View dst2(width, height, dstType, NULL, TEST_ALIGN(width)); if(create) { FillRandom(y); FillRandom(u); FillRandom(v); TEST_SAVE(y); TEST_SAVE(u); TEST_SAVE(v); f.Call(y, u, v, dst1); TEST_SAVE(dst1); } else { TEST_LOAD(y); TEST_LOAD(u); TEST_LOAD(v); TEST_LOAD(dst1); f.Call(y, u, v, dst2); TEST_SAVE(dst2); result = result && Compare(dst1, dst2, 0, true, 64); } return result; }
bool SegmentationPropagate2x2DataTest(bool create, int width, int height, const FuncP & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); const uint8_t currentIndex = 3, invalidIndex = 2, emptyIndex = 0, differenceThreshold = 128; View parent(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View childSrc(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width)); View difference(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width)); View childDst1(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width)); View childDst2(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width)); const uint8_t oldIndex = 3, newIndex = 2; if(create) { FillRandomMask(parent, currentIndex); FillRandom(childSrc, 0, currentIndex - 1); FillRandom(difference, 255); TEST_SAVE(parent); TEST_SAVE(childSrc); TEST_SAVE(difference); f.Call(parent, childSrc, childDst1, difference, currentIndex, invalidIndex, emptyIndex, differenceThreshold); TEST_SAVE(childDst1); } else { TEST_LOAD(parent); TEST_LOAD(childSrc); TEST_LOAD(difference); TEST_LOAD(childDst1); f.Call(parent, childSrc, childDst2, difference, currentIndex, invalidIndex, emptyIndex, differenceThreshold); TEST_SAVE(childDst2); result = result && Compare(childDst1, childDst2, 0, true, 64); } return result; }
bool Bgr48pToBgra32DataTest(bool create, int width, int height, const Func & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View blue(width, height, View::Int16, NULL, TEST_ALIGN(width)); View green(width, height, View::Int16, NULL, TEST_ALIGN(width)); View red(width, height, View::Int16, NULL, TEST_ALIGN(width)); uint8_t alpha = 0xFF; View bgra1(width, height, View::Bgra32, NULL, TEST_ALIGN(width)); View bgra2(width, height, View::Bgra32, NULL, TEST_ALIGN(width)); if(create) { FillRandom(blue); FillRandom(green); FillRandom(red); TEST_SAVE(blue); TEST_SAVE(green); TEST_SAVE(red); f.Call(blue, green, red, bgra1, alpha); TEST_SAVE(bgra1); } else { TEST_LOAD(blue); TEST_LOAD(green); TEST_LOAD(red); TEST_LOAD(bgra1); f.Call(blue, green, red, bgra2, alpha); TEST_SAVE(bgra2); result = result && Compare(bgra1, bgra2, 0, true, 32); } return result; }
bool DifferenceSumsMaskedDataTest(bool create, int width, int height, const FuncM & f, int count) { bool result = true; Data data(f.description); std::cout << (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]." << std::endl; View a(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View b(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View m(width, height, View::Gray8, NULL, TEST_ALIGN(width)); Sums64 s1(count, 0), s2(count, 0); uint8_t index = 17; if(create) { FillRandom(a); FillRandom(b); FillRandomMask(m, index); TEST_SAVE(a); TEST_SAVE(b); TEST_SAVE(m); f.Call(a, b, m, index, s1.data()); TEST_SAVE(s1); } else { TEST_LOAD(a); TEST_LOAD(b); TEST_LOAD(m); TEST_LOAD(s1); f.Call(a, b, m, index, s2.data()); TEST_SAVE(s2); result = result && Compare(s1, s2, 0, true, count); } return result; }
bool AlphaBlendingDataTest(bool create, View::Format format, int width, int height, const FuncAB & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View s(width, height, format, NULL, TEST_ALIGN(width)); View a(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View b(width, height, format, NULL, TEST_ALIGN(width)); View d1(width, height, format, NULL, TEST_ALIGN(width)); View d2(width, height, format, NULL, TEST_ALIGN(width)); if(create) { FillRandom(s); FillRandom(a); FillRandom(b); TEST_SAVE(s); TEST_SAVE(a); TEST_SAVE(b); f.Call(s, a, b, d1); TEST_SAVE(d1); } else { TEST_LOAD(s); TEST_LOAD(a); TEST_LOAD(b); TEST_LOAD(d1); f.Call(s, a, b, d2); TEST_SAVE(d2); result = result && Compare(d1, d2, 0, true, 64); } return result; }
bool TextureGetDifferenceSumDataTest(bool create, int width, int height, const Func3 & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View lo(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View hi(width, height, View::Gray8, NULL, TEST_ALIGN(width)); int64_t s1, s2; if(create) { FillRandom(src); FillRandom(lo); FillRandom(hi); TEST_SAVE(src); TEST_SAVE(lo); TEST_SAVE(hi); f.Call(src, lo, hi, &s1); TEST_SAVE(s1); } else { TEST_LOAD(src); TEST_LOAD(lo); TEST_LOAD(hi); TEST_LOAD(s1); f.Call(src, lo, hi, &s2); TEST_SAVE(s2); TEST_CHECK_VALUE(s); } return result; }
bool TextureBoostedSaturatedGradientDataTest(bool create, int width, int height, const Func1 & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dx1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dy1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dx2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dy2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); const int saturation = 16, boost = 4; if(create) { FillRandom(src); TEST_SAVE(src); f.Call(src, saturation, boost, dx1, dy1); TEST_SAVE(dx1); TEST_SAVE(dy1); } else { TEST_LOAD(src); TEST_LOAD(dx1); TEST_LOAD(dy1); f.Call(src, saturation, boost, dx2, dy2); TEST_SAVE(dx2); TEST_SAVE(dy2); result = result && Compare(dx1, dx2, 0, true, 32, 0, "dx"); result = result && Compare(dy1, dy2, 0, true, 32, 0, "dy"); } return result; }
bool AveragingBinarizationDataTest(bool create, int width, int height, SimdCompareType type, const Func2 & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dst1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dst2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); const uint8_t value = 127; const size_t neighborhood = 17; const uint8_t threshold = 128; const uint8_t positive = 7; const uint8_t negative = 3; if(create) { FillRandom(src); TEST_SAVE(src); f.Call(src, value, neighborhood, threshold, positive, negative, dst1, type); TEST_SAVE(dst1); } else { TEST_LOAD(src); TEST_LOAD(dst1); f.Call(src, value, neighborhood, threshold, positive, negative, dst2, type); TEST_SAVE(dst2); result = result && Compare(dst1, dst2, 0, true, 64); } return result; }
bool DeinterleaveUvDataTest(bool create, int width, int height, const Func & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View uv(width, height, View::Uv16, NULL, TEST_ALIGN(width)); View u1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View v1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View u2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View v2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); if(create) { FillRandom(uv); TEST_SAVE(uv); f.Call(uv, u1, v1); TEST_SAVE(u1); TEST_SAVE(v1); } else { TEST_LOAD(uv); TEST_LOAD(u1); TEST_LOAD(v1); f.Call(uv, u2, v2); TEST_SAVE(u2); TEST_SAVE(v2); result = result && Compare(u1, u2, 0, true, 32, 0, "u"); result = result && Compare(v1, v2, 0, true, 32, 0, "v"); } return result; }
bool ShiftBilinearDataTest(bool create, int width, int height, View::Format format, const Func & f) { bool result = true; Data data(f.description); std::cout << (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]." << std::endl; View s(width, height, format, NULL, TEST_ALIGN(width)); View b(width, height, format, NULL, TEST_ALIGN(width)); View d1(width, height, format, NULL, TEST_ALIGN(width)); View d2(width, height, format, NULL, TEST_ALIGN(width)); const double dx = -5.3, dy = 3.7; const int crop = 3; if(create) { FillRandom(s); FillRandom(b); TEST_SAVE(s); TEST_SAVE(b); f.Call(s, b, dx, dy, crop, crop, width - crop, height - crop, d1); TEST_SAVE(d1); } else { TEST_LOAD(s); TEST_LOAD(b); TEST_LOAD(d1); f.Call(s, b, dx, dy, crop, crop, width - crop, height - crop, d2); TEST_SAVE(d2); result = result && Compare(d1, d2, 0, true, 64); } return result; }
bool ContourMetricsMaskedDataTest(bool create, int width, int height, const FuncM & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View mask(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dst1(width, height, View::Int16, NULL, TEST_ALIGN(width)); View dst2(width, height, View::Int16, NULL, TEST_ALIGN(width)); if(create) { FillRandom(src); FillRandom(mask); TEST_SAVE(src); TEST_SAVE(mask); f.Call(src, mask, 128, dst1); TEST_SAVE(dst1); } else { TEST_LOAD(src); TEST_LOAD(mask); TEST_LOAD(dst1); f.Call(src, mask, 128, dst2); TEST_SAVE(dst2); result = result && Compare(dst1, dst2, 0, true, 32, 0); } return result; }
bool HistogramMaskedDataTest(bool create, int width, int height, const FuncHM & f) { bool result = true; Data data(f.description); std::cout << (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]." << std::endl; View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View mask(width, height, View::Gray8, NULL, TEST_ALIGN(width)); const uint8_t index = 77; Histogram h1, h2; if(create) { FillRandom(src); FillRandomMask(mask, index); TEST_SAVE(src); TEST_SAVE(mask); f.Call(src, mask, index, h1); TEST_SAVE(h1); } else { TEST_LOAD(src); TEST_LOAD(mask); TEST_LOAD(h1); f.Call(src, mask, index, h2); TEST_SAVE(h2); result = result && Compare(h1, h2, 0, true, 32); } return result; }
bool HistogramConditionalDataTest(bool create, int width, int height, SimdCompareType type, const FuncHC & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View mask(width, height, View::Gray8, NULL, TEST_ALIGN(width)); const uint8_t value = 127; Histogram h1, h2; if (create) { FillRandom(src); FillRandom(mask); TEST_SAVE(src); TEST_SAVE(mask); f.Call(src, mask, value, type, h1); TEST_SAVE(h1); } else { TEST_LOAD(src); TEST_LOAD(mask); TEST_LOAD(h1); f.Call(src, mask, value, type, h2); TEST_SAVE(h2); result = result && Compare(h1, h2, 0, true, 32); } return result; }
bool ContourAnchorsDataTest(bool create, int width, int height, const FuncA & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View s(width, height, View::Int16, NULL, TEST_ALIGN(width)); View d1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View d2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); if(create) { FillRandom(s); TEST_SAVE(s); Simd::Fill(d1, 0); f.Call(s, 3, 0, d1); TEST_SAVE(d1); } else { TEST_LOAD(s); TEST_LOAD(d1); Simd::Fill(d2, 0); f.Call(s, 3, 0, d2); TEST_SAVE(d2); result = result && Compare(d1, d2, 0, true, 32, 0); } return result; }
bool StretchGrayDataTest(bool create, int width, int height, const Func & f, int stretch) { bool result = true; Data data(f.description); std::cout << (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]." << std::endl; const int stretchedWidth = width*stretch; const int stretchedHeight = height*stretch; View s(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View d1(stretchedWidth, stretchedHeight, View::Gray8, NULL, TEST_ALIGN(stretchedWidth)); View d2(stretchedWidth, stretchedHeight, View::Gray8, NULL, TEST_ALIGN(stretchedWidth)); if(create) { FillRandom(s); TEST_SAVE(s); f.Call(s, d1); TEST_SAVE(d1); } else { TEST_LOAD(s); TEST_LOAD(d1); f.Call(s, d2); TEST_SAVE(d2); result = result && Compare(d1, d2, 0, true, 64); } return result; }
bool DifferenceSum32fDataTest(bool create, int size, const FuncF & f) { bool result = true; Data data(f.description); std::cout << (create ? "Create" : "Verify") << " test " << f.description << " [" << size << "]." << std::endl; View a(size, 1, View::Float, NULL, TEST_ALIGN(size)); View b(size, 1, View::Float, NULL, TEST_ALIGN(size)); float s1, s2; if(create) { FillRandom32f(a); FillRandom32f(b); TEST_SAVE(a); TEST_SAVE(b); f.Call(a, b, &s1); TEST_SAVE(s1); } else { TEST_LOAD(a); TEST_LOAD(b); TEST_LOAD(s1); f.Call(a, b, &s2); TEST_SAVE(s2); result = result && Compare(s1, s2, EPS, true); } return result; }
bool TexturePerformCompensationDataTest(bool create, int width, int height, const Func4 & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); FillRandom(src); View dst1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dst2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); const int shift = -7; if(create) { FillRandom(src); TEST_SAVE(src); f.Call(src, shift, dst1); TEST_SAVE(dst1); } else { TEST_LOAD(src); TEST_LOAD(dst1); f.Call(src, shift, dst2); TEST_SAVE(dst2); result = result && Compare(dst1, dst2, 0, true, 32, 0); } return result; }
bool SegmentationChangeIndexDataTest(bool create, int width, int height, const FuncCI & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View s(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View d1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View d2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); const uint8_t oldIndex = 3, newIndex = 2; if(create) { FillRandomMask(s, oldIndex); TEST_SAVE(s); f.Call(s, oldIndex, newIndex, d1); TEST_SAVE(d1); } else { TEST_LOAD(s); TEST_LOAD(d1); f.Call(s, oldIndex, newIndex, d2); TEST_SAVE(d2); result = result && Compare(d1, d2, 0, true, 64); } return result; }
bool SegmentationShrinkRegionDataTest(bool create, int width, int height, const FuncSR & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View s(width, height, View::Gray8, NULL, TEST_ALIGN(width)); Rect rs1(s.Size()), rs2(s.Size()), rd1, rd2; const uint8_t index = 3; if(create) { FillRhombMask(s, Rect(width*1/15, height*2/15, width*11/15, height*12/15), index); TEST_SAVE(s); f.Call(s, index, rs1, rd1); TEST_SAVE(rd1); } else { TEST_LOAD(s); TEST_LOAD(rd1); f.Call(s, index, rs2, rd2); TEST_SAVE(rd2); result = result && Compare(rd1, rd2, true); } return result; }
bool AnyToAnyDataTest(bool create, int width, int height, View::Format srcType, View::Format dstType, const Func & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View src(width, height, srcType, NULL, TEST_ALIGN(width)); View dst1(width, height, dstType, NULL, TEST_ALIGN(width)); View dst2(width, height, dstType, NULL, TEST_ALIGN(width)); if(create) { FillRandom(src); TEST_SAVE(src); f.Call(src, dst1); TEST_SAVE(dst1); } else { TEST_LOAD(src); TEST_LOAD(dst1); f.Call(src, dst2); TEST_SAVE(dst2); result = result && Compare(dst1, dst2, 0, true, 64, 0); } return result; }
bool AbsSecondDerivativeHistogramDataTest(bool create, int width, int height, const FuncASDH & f) { bool result = true; Data data(f.description); std::cout << (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]." << std::endl; View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); size_t step = 1, indent = 16; Histogram h1, h2; if(create) { FillRandom(src); TEST_SAVE(src); f.Call(src, step, indent, h1); TEST_SAVE(h1); } else { TEST_LOAD(src); TEST_LOAD(h1); f.Call(src, step, indent, h2); TEST_SAVE(h2); result = result && Compare(h1, h2, 0, true, 32); } return result; }
bool HistogramDataTest(bool create, int width, int height, const FuncH & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); Histogram h1, h2; if(create) { FillRandom(src); TEST_SAVE(src); f.Call(src, h1); TEST_SAVE(h1); } else { TEST_LOAD(src); TEST_LOAD(h1); f.Call(src, h2); TEST_SAVE(h2); result = result && Compare(h1, h2, 0, true, 32); } return result; }