예제 #1
0
PERF_TEST_P(Size_MatType, buildPyramid, testing::Combine(
                testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
                testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4)
                )
            )
{
    Size sz = get<0>(GetParam());
    int matType = get<1>(GetParam());
    int maxLevel = 5;
    const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
    perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
    Mat src(sz, matType);
    std::vector<Mat> dst(maxLevel);

    declare.in(src, WARMUP_RNG);

    TEST_CYCLE() buildPyramid(src, dst, maxLevel);

    Mat dst0 = dst[0], dst1 = dst[1], dst2 = dst[2], dst3 = dst[3], dst4 = dst[4];

    SANITY_CHECK(dst0, eps, error_type);
    SANITY_CHECK(dst1, eps, error_type);
    SANITY_CHECK(dst2, eps, error_type);
    SANITY_CHECK(dst3, eps, error_type);
    SANITY_CHECK(dst4, eps, error_type);
}
예제 #2
0
PERF_TEST_P(TestWarpAffine, WarpAffine_ovx,
    Combine(
        Values(szVGA, sz720p, sz1080p),
        InterType::all(),
        BorderMode::all()
    )
)
{
    Size sz, szSrc(512, 512);
    int borderMode, interType;
    sz = get<0>(GetParam());
    interType = get<1>(GetParam());
    borderMode = get<2>(GetParam());
    Scalar borderColor = Scalar::all(150);

    Mat src(szSrc, CV_8UC1), dst(sz, CV_8UC1);
    cvtest::fillGradient(src);
    if (borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
    Mat warpMat = getRotationMatrix2D(Point2f(src.cols / 2.f, src.rows / 2.f), 30., 2.2);
    declare.in(src).out(dst);

    TEST_CYCLE() warpAffine(src, dst, warpMat, sz, interType, borderMode, borderColor);

#ifdef __ANDROID__
    SANITY_CHECK(dst, interType == INTER_LINEAR ? 5 : 10);
#else
    SANITY_CHECK(dst, 1);
#endif
}
예제 #3
0
PERF_TEST_P(InpaintArea_InpaintingMethod, inpaint,
            testing::Combine(
                testing::Values(::perf::szSmall24, ::perf::szSmall32, ::perf::szSmall64),
                InpaintingMethod::all()
                )
            )
{
    Mat src = imread(getDataPath("gpu/hog/road.png"));

    Size sz = get<0>(GetParam());
    int inpaintingMethod = get<1>(GetParam());

    Mat mask(src.size(), CV_8UC1, Scalar(0));
    Mat result(src.size(), src.type());

    Rect inpaintArea(src.cols/3, src.rows/3, sz.width, sz.height);
    mask(inpaintArea).setTo(255);

    declare.in(src, mask).out(result).time(120);

    TEST_CYCLE() inpaint(src, mask, result, 10.0, inpaintingMethod);

    Mat inpaintedArea = result(inpaintArea);
    SANITY_CHECK(inpaintedArea);
}
예제 #4
0
PERF_TEST_P(Size_MatType, pyrDown, testing::Combine(
                testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
                testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
                )
            )
{
    Size sz = get<0>(GetParam());
    int matType = get<1>(GetParam());
    const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
    perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;

    Mat src(sz, matType);
    Mat dst((sz.height + 1)/2, (sz.width + 1)/2, matType);

    declare.in(src, WARMUP_RNG).out(dst);

    TEST_CYCLE() pyrDown(src, dst);

    SANITY_CHECK(dst, eps, error_type);
}
예제 #5
0
PERF_TEST_P( Size_MatType, AccumulateWeighted,
             testing::Combine(
                 testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
                 testing::Values(CV_32FC1)
             )
           )
#endif
{
    Size sz = get<0>(GetParam());
    int dstType = get<1>(GetParam());

    Mat src(sz, CV_8UC1);
    Mat dst(sz, dstType);

    declare.time(100);
    declare.in(src, WARMUP_RNG).out(dst);

    TEST_CYCLE() accumulateWeighted(src, dst, 0.314);

    SANITY_CHECK_NOTHING();
}
예제 #6
0
PERF_TEST_P(Size_CvtMode_Bayer, cvtColorBayer8u,
            testing::Combine(
                testing::Values(::perf::szODD, ::perf::szVGA),
                CvtModeBayer::all()
                )
            )
{
    Size sz = get<0>(GetParam());
    int mode = get<1>(GetParam());
    ChPair ch = getConversionInfo(mode);
    mode %= COLOR_COLORCVT_MAX;

    Mat src(sz, CV_8UC(ch.scn));
    Mat dst(sz, CV_8UC(ch.dcn));

    declare.time(100);
    declare.in(src, WARMUP_RNG).out(dst);

    TEST_CYCLE() cvtColor(src, dst, mode, ch.dcn);

    SANITY_CHECK(dst, 1);
}
예제 #7
0
PERF_TEST_P( TestWarpPerspective, WarpPerspective,
             Combine(
                Values( szVGA, sz720p, sz1080p ),
                InterType::all(),
                BorderMode::all()
             )
)
{
    Size sz, szSrc(512, 512);
    int borderMode, interType;
    sz         = get<0>(GetParam());
    interType  = get<1>(GetParam());
    borderMode = get<2>(GetParam());
    Scalar borderColor = Scalar::all(150);

    Mat src(szSrc,CV_8UC4), dst(sz, CV_8UC4);
    cvtest::fillGradient(src);
    if(borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
    Mat rotMat = getRotationMatrix2D(Point2f(src.cols/2.f, src.rows/2.f), 30., 2.2);
    Mat warpMat(3, 3, CV_64FC1);
    for(int r=0; r<2; r++)
        for(int c=0; c<3; c++)
            warpMat.at<double>(r, c) = rotMat.at<double>(r, c);
    warpMat.at<double>(2, 0) = .3/sz.width;
    warpMat.at<double>(2, 1) = .3/sz.height;
    warpMat.at<double>(2, 2) = 1;

    declare.in(src).out(dst);

    TEST_CYCLE() warpPerspective( src, dst, warpMat, sz, interType, borderMode, borderColor );

#ifdef __ANDROID__
    SANITY_CHECK(dst, interType==INTER_LINEAR? 5 : 10);
#else
    SANITY_CHECK(dst, 1);
#endif
}
예제 #8
0
PERF_TEST_P(Sz, DISABLED_GeneralizedHoughGuil, CUDA_TYPICAL_MAT_SIZES)
{
    declare.time(10);

    const cv::Size imageSize = GetParam();

    const cv::Mat templ = readImage("cv/shared/templ.png", cv::IMREAD_GRAYSCALE);
    ASSERT_FALSE(templ.empty());

    cv::Mat image(imageSize, CV_8UC1, cv::Scalar::all(0));
    templ.copyTo(image(cv::Rect(50, 50, templ.cols, templ.rows)));

    cv::RNG rng(123456789);
    const int objCount = rng.uniform(5, 15);
    for (int i = 0; i < objCount; ++i)
    {
        double scale = rng.uniform(0.7, 1.3);
        bool rotate = 1 == rng.uniform(0, 2);

        cv::Mat obj;
        cv::resize(templ, obj, cv::Size(), scale, scale);
        if (rotate)
            obj = obj.t();

        cv::Point pos;

        pos.x = rng.uniform(0, image.cols - obj.cols);
        pos.y = rng.uniform(0, image.rows - obj.rows);

        cv::Mat roi = image(cv::Rect(pos, obj.size()));
        cv::add(roi, obj, roi);
    }

    cv::Mat edges;
    cv::Canny(image, edges, 50, 100);

    cv::Mat dx, dy;
    cv::Sobel(image, dx, CV_32F, 1, 0);
    cv::Sobel(image, dy, CV_32F, 0, 1);

    if (PERF_RUN_CUDA())
    {
        cv::Ptr<cv::GeneralizedHoughGuil> alg = cv::cuda::createGeneralizedHoughGuil();
        alg->setMaxAngle(90.0);
        alg->setAngleStep(2.0);

        const cv::cuda::GpuMat d_edges(edges);
        const cv::cuda::GpuMat d_dx(dx);
        const cv::cuda::GpuMat d_dy(dy);
        cv::cuda::GpuMat positions;

        alg->setTemplate(cv::cuda::GpuMat(templ));

        TEST_CYCLE() alg->detect(d_edges, d_dx, d_dy, positions);
    }
    else
    {
        cv::Ptr<cv::GeneralizedHoughGuil> alg = cv::createGeneralizedHoughGuil();
        alg->setMaxAngle(90.0);
        alg->setAngleStep(2.0);

        cv::Mat positions;

        alg->setTemplate(templ);

        TEST_CYCLE() alg->detect(edges, dx, dy, positions);
    }

    // The algorithm is not stable yet.
    SANITY_CHECK_NOTHING();
}