Blame view

3rdparty/opencv-4.5.4/modules/video/perf/perf_bgfg_utils.hpp 1.11 KB
f4334277   Hu Chunming   提交3rdparty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  // This file is part of OpenCV project.
  // It is subject to the license terms in the LICENSE file found in the top-level directory
  // of this distribution and at http://opencv.org/license.html.
  
  namespace opencv_test {
  
  //#define DEBUG_BGFG
  
  using namespace testing;
  using namespace cvtest;
  using namespace perf;
  
  namespace {
  
  using namespace cv;
  
  static void cvtFrameFmt(std::vector<Mat>& input, std::vector<Mat>& output)
  {
      for(int i = 0; i< (int)(input.size()); i++)
      {
          cvtColor(input[i], output[i], COLOR_RGB2GRAY);
      }
  }
  
  static void prepareData(VideoCapture& cap, int cn, std::vector<Mat>& frame_buffer, int skipFrames = 0)
  {
      std::vector<Mat> frame_buffer_init;
      int nFrame = (int)frame_buffer.size();
      for (int i = 0; i < skipFrames; i++)
      {
          cv::Mat frame;
          cap >> frame;
      }
      for (int i = 0; i < nFrame; i++)
      {
          cv::Mat frame;
          cap >> frame;
          ASSERT_FALSE(frame.empty());
          frame_buffer_init.push_back(frame);
      }
  
      if (cn == 1)
          cvtFrameFmt(frame_buffer_init, frame_buffer);
      else
          frame_buffer.swap(frame_buffer_init);
  }
  
  }}