perf_output.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include "perf_precomp.hpp"
  5. namespace opencv_test
  6. {
  7. using namespace perf;
  8. typedef tuple<std::string, bool> VideoWriter_Writing_t;
  9. typedef perf::TestBaseWithParam<VideoWriter_Writing_t> VideoWriter_Writing;
  10. const string image_files[] = {
  11. "python/images/QCIF_00.bmp",
  12. "python/images/QCIF_01.bmp",
  13. "python/images/QCIF_02.bmp",
  14. "python/images/QCIF_03.bmp",
  15. "python/images/QCIF_04.bmp",
  16. "python/images/QCIF_05.bmp"
  17. };
  18. PERF_TEST_P(VideoWriter_Writing, WriteFrame,
  19. testing::Combine(
  20. testing::ValuesIn(image_files),
  21. testing::Bool()))
  22. {
  23. const string filename = getDataPath(get<0>(GetParam()));
  24. const bool isColor = get<1>(GetParam());
  25. Mat image = imread(filename, isColor ? IMREAD_COLOR : IMREAD_GRAYSCALE );
  26. #if defined(HAVE_MSMF) && !defined(HAVE_FFMPEG)
  27. const string outfile = cv::tempfile(".wmv");
  28. const int fourcc = VideoWriter::fourcc('W', 'M', 'V', '3');
  29. #else
  30. const string outfile = cv::tempfile(".avi");
  31. const int fourcc = VideoWriter::fourcc('X', 'V', 'I', 'D');
  32. #endif
  33. VideoWriter writer(outfile, fourcc, 25, cv::Size(image.cols, image.rows), isColor);
  34. if (!writer.isOpened())
  35. throw SkipTestException("Video file can not be opened");
  36. TEST_CYCLE_N(100) { writer << image; }
  37. SANITY_CHECK_NOTHING();
  38. remove(outfile.c_str());
  39. }
  40. } // namespace