-
Notifications
You must be signed in to change notification settings - Fork 7
/
AbstractCFAR.h
69 lines (49 loc) · 1.32 KB
/
AbstractCFAR.h
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
64
65
66
67
68
69
#pragma once
#include <omp.h>
#include <opencv2\opencv.hpp>
using namespace cv;
using namespace std;
class AbstractCFAR {
public:
AbstractCFAR()
{
threadCount = INT_MAX;
}
virtual ~AbstractCFAR()
{
}
virtual AbstractCFAR* clone() = 0;
virtual Mat execute(Mat image, double probabilityOfFalseAlarm, map<string, double>& parameters) = 0;
virtual int getClutterArea(map<string, double>& parameters) = 0;
virtual int getBandWidth(map<string, double>& parameters) = 0;
virtual bool isDeterministic() const { return true; }
virtual bool requiresGlobalHistogram() const { return false; }
double getParameterValue(map<string, double>& parameters, string key, double defaultValue)
{
if (parameters.find(key) == parameters.end())
return defaultValue;
else
return parameters[key];
}
int getThreadCount() const
{
return max(min(omp_get_max_threads(), threadCount), 1);
}
void setThreadCount(int threadCount)
{
this->threadCount = threadCount;
}
template<typename T>
static inline T sqr(T x)
{
return x * x;
}
protected:
int calculateBandSize(int windowRadius, int blockSize = 8)
{
const int overlapSize = ((2 * windowRadius + blockSize - 1) / blockSize) * blockSize;
return overlapSize;
}
private:
int threadCount;
};