perf_rlof.cpp 2.8 KB

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