test_motempl.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
  5. // Third party copyrights are property of their respective owners.
  6. #include "../test_precomp.hpp"
  7. #include "opencv2/ts/ocl_test.hpp"
  8. #ifdef HAVE_OPENCL
  9. namespace opencv_test { namespace {
  10. PARAM_TEST_CASE(UpdateMotionHistory, bool)
  11. {
  12. double timestamp, duration;
  13. bool use_roi;
  14. TEST_DECLARE_INPUT_PARAMETER(silhouette);
  15. TEST_DECLARE_OUTPUT_PARAMETER(mhi);
  16. virtual void SetUp()
  17. {
  18. use_roi = GET_PARAM(0);
  19. }
  20. virtual void generateTestData()
  21. {
  22. Size roiSize = randomSize(1, MAX_VALUE);
  23. Border silhouetteBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
  24. randomSubMat(silhouette, silhouette_roi, roiSize, silhouetteBorder, CV_8UC1, -11, 11);
  25. Border mhiBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
  26. randomSubMat(mhi, mhi_roi, roiSize, mhiBorder, CV_32FC1, 0, 1);
  27. timestamp = randomDouble(0, 1);
  28. duration = randomDouble(0, 1);
  29. if (timestamp < duration)
  30. std::swap(timestamp, duration);
  31. UMAT_UPLOAD_INPUT_PARAMETER(silhouette);
  32. UMAT_UPLOAD_OUTPUT_PARAMETER(mhi);
  33. }
  34. };
  35. OCL_TEST_P(UpdateMotionHistory, Mat)
  36. {
  37. for (int j = 0; j < cvtest::ocl::test_loop_times; j++)
  38. {
  39. generateTestData();
  40. OCL_OFF(cv::motempl::updateMotionHistory(silhouette_roi, mhi_roi, timestamp, duration));
  41. OCL_ON(cv::motempl::updateMotionHistory(usilhouette_roi, umhi_roi, timestamp, duration));
  42. OCL_EXPECT_MATS_NEAR(mhi, 0);
  43. }
  44. }
  45. //////////////////////////////////////// Instantiation /////////////////////////////////////////
  46. OCL_INSTANTIATE_TEST_CASE_P(Video, UpdateMotionHistory, Values(false, true));
  47. }} // namespace
  48. #endif // HAVE_OPENCL