|
| 1 | +#include "perf_precomp.hpp" |
| 2 | +namespace opencv_test { namespace { |
| 3 | + |
| 4 | +typedef tuple<std::string, std::string, bool> ST_SR_IM_Sparse_t; |
| 5 | +typedef TestBaseWithParam<ST_SR_IM_Sparse_t> ST_SR_IM_Sparse; |
| 6 | +PERF_TEST_P(ST_SR_IM_Sparse, OpticalFlow_SparseRLOF, |
| 7 | + testing::Combine( |
| 8 | + testing::Values<std::string>("ST_BILINEAR", "ST_STANDART"), |
| 9 | + testing::Values<std::string>("SR_CROSS", "SR_FIXED"), |
| 10 | + testing::Values(true, false)) |
| 11 | +) |
| 12 | +{ |
| 13 | + Mat frame1 = imread(getDataPath("cv/optflow/RubberWhale1.png")); |
| 14 | + Mat frame2 = imread(getDataPath("cv/optflow/RubberWhale2.png")); |
| 15 | + ASSERT_FALSE(frame1.empty()); |
| 16 | + ASSERT_FALSE(frame2.empty()); |
| 17 | + vector<Point2f> prevPts, currPts; |
| 18 | + for (int r = 0; r < frame1.rows; r += 10) |
| 19 | + { |
| 20 | + for (int c = 0; c < frame1.cols; c += 10) |
| 21 | + { |
| 22 | + prevPts.push_back(Point2f(static_cast<float>(c), static_cast<float>(r))); |
| 23 | + } |
| 24 | + } |
| 25 | + vector<uchar> status(prevPts.size()); |
| 26 | + vector<float> err(prevPts.size()); |
| 27 | + |
| 28 | + Ptr<RLOFOpticalFlowParameter> param = Ptr<RLOFOpticalFlowParameter>(new RLOFOpticalFlowParameter); |
| 29 | + if (get<0>(GetParam()) == "ST_BILINEAR") |
| 30 | + param->solverType = ST_BILINEAR; |
| 31 | + if (get<0>(GetParam()) == "ST_STANDART") |
| 32 | + param->solverType = ST_STANDART; |
| 33 | + if (get<1>(GetParam()) == "SR_CROSS") |
| 34 | + param->supportRegionType = SR_CROSS; |
| 35 | + if (get<1>(GetParam()) == "SR_FIXED") |
| 36 | + param->supportRegionType = SR_FIXED; |
| 37 | + param->useIlluminationModel = get<2>(GetParam()); |
| 38 | + |
| 39 | + PERF_SAMPLE_BEGIN() |
| 40 | + calcOpticalFlowSparseRLOF(frame1, frame2, prevPts, currPts, status, err, param, 1.f); |
| 41 | + PERF_SAMPLE_END() |
| 42 | + |
| 43 | + SANITY_CHECK_NOTHING(); |
| 44 | +} |
| 45 | + |
| 46 | +typedef tuple<std::string, int> INTERP_GRID_Dense_t; |
| 47 | +typedef TestBaseWithParam<INTERP_GRID_Dense_t> INTERP_GRID_Dense; |
| 48 | +PERF_TEST_P(INTERP_GRID_Dense, OpticalFlow_DenseRLOF, |
| 49 | + testing::Combine( |
| 50 | + testing::Values<std::string>("INTERP_EPIC", "INTERP_GEO"), |
| 51 | + testing::Values<int>(4,10)) |
| 52 | +) |
| 53 | +{ |
| 54 | + Mat flow; |
| 55 | + Mat frame1 = imread(getDataPath("cv/optflow/RubberWhale1.png")); |
| 56 | + Mat frame2 = imread(getDataPath("cv/optflow/RubberWhale1.png")); |
| 57 | + ASSERT_FALSE(frame1.empty()); |
| 58 | + ASSERT_FALSE(frame2.empty()); |
| 59 | + Ptr<RLOFOpticalFlowParameter> param = Ptr<RLOFOpticalFlowParameter>(new RLOFOpticalFlowParameter);; |
| 60 | + Ptr< DenseRLOFOpticalFlow> algo = DenseRLOFOpticalFlow::create(); |
| 61 | + InterpolationType interp_type = INTERP_EPIC; |
| 62 | + if (get<0>(GetParam()) == "INTERP_EPIC") |
| 63 | + interp_type = INTERP_EPIC; |
| 64 | + if (get<0>(GetParam()) == "INTERP_GEO") |
| 65 | + interp_type = INTERP_GEO; |
| 66 | + PERF_SAMPLE_BEGIN() |
| 67 | + calcOpticalFlowDenseRLOF(frame1, frame2,flow, param, 1.0f, Size(get<1>(GetParam()), get<1>(GetParam())), interp_type); |
| 68 | + PERF_SAMPLE_END() |
| 69 | + SANITY_CHECK_NOTHING(); |
| 70 | +} |
| 71 | + |
| 72 | +}} // namespace |
0 commit comments