forked from Smorodov/Multitarget-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYolo3Detector.cpp
More file actions
63 lines (49 loc) · 1.42 KB
/
Yolo3Detector.cpp
File metadata and controls
63 lines (49 loc) · 1.42 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "Yolo3Detector.h"
Yolo3Detector::Yolo3Detector(
bool collectPoints,
cv::UMat& colorFrame
)
:
BaseDetector(collectPoints, colorFrame),
m_WHRatio(m_inWidth / (float)m_inHeight)
{
}
Yolo3Detector::~Yolo3Detector(void)
{
}
bool Yolo3Detector::Init(const config_t& config)
{
auto modelConfiguration = config.find("modelConfiguration");
auto modelBinary = config.find("modelBinary");
if (modelConfiguration != config.end() && modelBinary != config.end())
{
m_detector = std::make_unique<Detector>(modelConfiguration->second, modelBinary->second);
}
auto classNames = config.find("classNames");
if (classNames != config.end())
{
std::ifstream classNamesFile(classNames->second);
if (classNamesFile.is_open())
{
m_classNames.clear();
std::string className;
for (; std::getline(classNamesFile, className); )
{
m_classNames.push_back(className);
}
}
}
auto confidenceThreshold = config.find("confidenceThreshold");
if (confidenceThreshold != config.end())
{
m_confidenceThreshold = std::stof(confidenceThreshold->second);
}
//TODO need crop ?
return m_detector.get() != nullptr;
}
void Yolo3Detector::Detect(cv::UMat& colorFrame)
{
m_regions.clear();
cv::Mat colorMat = colorFrame.getMat(cv::ACCESS_READ);
m_detector
}