SurfaceLayerDetectionAlgorithm.hpp
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
#pragma once
#include <opencv2/cudaarithm.hpp>
#include <opencv2/cudafilters.hpp>
#include "algorithm/Algorithm.hpp"
#include "algorithm/gpu/common/ContinuousGpuMat.hpp"
class SurfaceLayerDetectionAlgorithm : public Algorithm {
public:
/* Configurable parameters */
std::unique_ptr<cv::cuda::Filter> medianFilter;
cv::Scalar derivativeThreshold{7};
cv::cuda::GpuMat deviceMinTemperature;
std::unique_ptr<cv::cuda::Filter> createMedianFilter(int kernel) const;
cv::cuda::GpuMat setMinimumTemperature(ushort temperature);
/* Configurable parameters */
SurfaceLayerDetectionAlgorithm() = default;
void setup(const cv::Size &frameSize, const CVMatLoader &loader) override;
void handleFrame(const cv::Mat &hostFrame,
unsigned long timestamp) override;
cv::cuda::GpuMat deviceSurfaceLayers; /* Surface layers mask */
private:
/* ns to s and invert to multiply instead of divide */
static constexpr double NS_TO_S{1e-5};
cv::Size currentFrameSize;
cv::cuda::GpuMat deviceRegionMask;
cv::cuda::GpuMat devicePreviousPreviousFrame, devicePreviousFrame;
unsigned long previousPreviousTimestamp{}, previousTimestamp{},
currentTimestamp{};
void normalizedDerivative();
/* Buffors */
std::unique_ptr<ContinuousGpuMat> medianFilterInput, medianFilterOutput;
cv::cuda::GpuMat deviceFrame, deviceFiltered, deviceInput, deviceFloatInput,
deviceDifference, deviceDifferenceAbs, deviceResult;
/* Buffors */
};