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 ShiftBilinearDataTest(bool create, int width, int height, View::Format format, const Func & 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 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 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 DifferenceSumsDataTest(bool create, int width, int height, const FuncS & 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)); Sums64 s1(count, 0), s2(count, 0); if(create) { FillRandom(a); FillRandom(b); TEST_SAVE(a); TEST_SAVE(b); f.Call(a, b, s1.data()); TEST_SAVE(s1); } else { TEST_LOAD(a); TEST_LOAD(b); TEST_LOAD(s1); f.Call(a, b, s2.data()); TEST_SAVE(s2); result = result && Compare(s1, s2, 0, true, count); } 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 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 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 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; }
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 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; }