Path: blob/master/modules/imgproc/perf/perf_floodfill.cpp
16339 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.34// Copyright (C) 2014, Itseez, Inc., all rights reserved.5// Third party copyrights are property of their respective owners.67#include "perf_precomp.hpp"89namespace opencv_test {1011typedef tuple<string, Point, int, int, int, int> Size_Source_Fl_t;12typedef perf::TestBaseWithParam<Size_Source_Fl_t> Size_Source_Fl;1314PERF_TEST_P(Size_Source_Fl, floodFill1, Combine(15testing::Values("cv/shared/fruits.png", "cv/optflow/RubberWhale1.png"), //images16testing::Values(Point(120, 82), Point(200, 140)), //seed points17testing::Values(4,8), //connectivity18testing::Values((int)IMREAD_COLOR, (int)IMREAD_GRAYSCALE), //color image, or not19testing::Values(0, 1, 2), //use fixed(1), gradient (2) or simple(0) mode20testing::Values((int)CV_8U, (int)CV_32F, (int)CV_32S) //image depth21))22{23//test given image(s)24string filename = getDataPath(get<0>(GetParam()));25Point pseed;26pseed = get<1>(GetParam());2728int connectivity = get<2>(GetParam());29int colorType = get<3>(GetParam());30int modeType = get<4>(GetParam());31int imdepth = get<5>(GetParam());3233Mat image0 = imread(filename, colorType);3435Scalar newval, loVal, upVal;36if (modeType == 0)37{38loVal = Scalar(0, 0, 0);39upVal = Scalar(0, 0, 0);40}41else42{43loVal = Scalar(4, 4, 4);44upVal = Scalar(20, 20, 20);45}46int newMaskVal = 255; //base mask for floodfill type47int flags = connectivity + (newMaskVal << 8) + (modeType == 1 ? FLOODFILL_FIXED_RANGE : 0);4849int b = 152;//(unsigned)theRNG() & 255;50int g = 136;//(unsigned)theRNG() & 255;51int r = 53;//(unsigned)theRNG() & 255;52newval = (colorType == IMREAD_COLOR) ? Scalar(b, g, r) : Scalar(r*0.299 + g*0.587 + b*0.114);5354Rect outputRect = Rect();55Mat source = Mat();5657for (; next(); )58{59image0.convertTo(source, imdepth);60startTimer();61cv::floodFill(source, pseed, newval, &outputRect, loVal, upVal, flags);62stopTimer();63}64EXPECT_EQ(image0.cols, source.cols);65EXPECT_EQ(image0.rows, source.rows);66SANITY_CHECK_NOTHING();67}6869} // namespace707172