MCPcopy Create free account
hub / github.com/Smorodov/Multitarget-tracker / Init

Method Init

src/Detector/BackgroundSubtract.cpp:19–205  ·  view source on GitHub ↗

---------------------------------------------------------------------- ----------------------------------------------------------------------

Source from the content-addressed store, hash-verified

17//
18//----------------------------------------------------------------------
19bool BackgroundSubtract::Init(const config_t& config)
20{
21 bool failed = true;
22 for (; failed;)
23 {
24 failed = false;
25
26 switch (m_algType)
27 {
28 case ALG_VIBE:
29 {
30 std::array<int, 5> params = { 20, 1, 20, 3, 16 };
31 std::array<std::string, params.size()> paramsConf = { "samples", "pixelNeighbor", "distanceThreshold", "matchingThreshold", "updateFactor" };
32
33 for (size_t i = 0; i < paramsConf.size(); ++i)
34 {
35 auto conf = config.find(paramsConf[i]);
36 if (conf != config.end())
37 {
38 params[i] = std::stoi(conf->second);
39 }
40 }
41 m_modelVibe = std::make_unique<vibe::VIBE>(m_channels, params[0], params[1], params[2], params[3], params[4]);
42 break;
43 }
44
45#ifdef USE_OCV_BGFG
46 case ALG_MOG:
47 {
48 auto params = std::make_tuple(100, 3, 0.7, 0);
49 std::array<std::string, std::tuple_size<decltype(params)>::value> paramsConf = { "history", "nmixtures", "backgroundRatio", "noiseSigma" };
50
51 for (size_t i = 0; i < paramsConf.size(); ++i)
52 {
53 auto conf = config.find(paramsConf[i]);
54 if (conf != config.end())
55 {
56 std::stringstream ss(conf->second);
57
58 switch (i)
59 {
60 case 0:
61 ss >> std::get<0>(params);
62 break;
63 case 1:
64 ss >> std::get<1>(params);
65 break;
66 case 2:
67 ss >> std::get<2>(params);
68 break;
69 case 3:
70 ss >> std::get<3>(params);
71 break;
72 }
73 }
74 }
75 m_modelOCV = cv::bgsegm::createBackgroundSubtractorMOG(std::get<0>(params), std::get<1>(params), std::get<2>(params), std::get<3>(params));
76 break;

Callers

nothing calls this directly

Calls 2

endMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected