Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/video/perf/perf_bgfg_utils.hpp
16356 views
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
5
namespace opencv_test {
6
7
//#define DEBUG_BGFG
8
9
using namespace testing;
10
using namespace cvtest;
11
using namespace perf;
12
13
namespace {
14
15
using namespace cv;
16
17
static void cvtFrameFmt(std::vector<Mat>& input, std::vector<Mat>& output)
18
{
19
for(int i = 0; i< (int)(input.size()); i++)
20
{
21
cvtColor(input[i], output[i], COLOR_RGB2GRAY);
22
}
23
}
24
25
static void prepareData(VideoCapture& cap, int cn, std::vector<Mat>& frame_buffer, int skipFrames = 0)
26
{
27
std::vector<Mat> frame_buffer_init;
28
int nFrame = (int)frame_buffer.size();
29
for (int i = 0; i < skipFrames; i++)
30
{
31
cv::Mat frame;
32
cap >> frame;
33
}
34
for (int i = 0; i < nFrame; i++)
35
{
36
cv::Mat frame;
37
cap >> frame;
38
ASSERT_FALSE(frame.empty());
39
frame_buffer_init.push_back(frame);
40
}
41
42
if (cn == 1)
43
cvtFrameFmt(frame_buffer_init, frame_buffer);
44
else
45
frame_buffer.swap(frame_buffer_init);
46
}
47
48
}}
49
50