SurfaceLayerDetectionAlgorithm.hpp 1.08 KB
#pragma once

#include <opencv2/core/mat.hpp>

#include "algorithm/Algorithm.hpp"

namespace Cpu {

class SurfaceLayerDetectionAlgorithm : public Algorithm {
  public:
	/* Configurable parameters */
	cv::Scalar derivativeThreshold{7};
	cv::Mat hostMinTemperature;

	cv::Mat setMinimumTemperature(ushort temperature);
	/* Configurable parameters */

	SurfaceLayerDetectionAlgorithm() = default;

	void setup(const cv::Size &frameSize, const CVMatLoader &loader) override;
	void handleFrame(const cv::Mat &sourceFrame,
	                 unsigned long timestamp) override;

	cv::Mat hostSurfaceLayers; /* Surface layers mask */

  private:
	/* ns to s and invert to multiply instead of divide */
	static constexpr double NS_TO_S{1e-5};

	cv::Mat hostRegionMask;

	cv::Mat hostPreviousPreviousFrame, hostPreviousFrame;
	unsigned long previousPreviousTimestamp{}, previousTimestamp{},
	    currentTimestamp{};

	void normalizedDerivative();

	/* Buffors */
	cv::Mat hostFrame, hostFiltered, hostInput, hostFloatInput, hostDifference,
	    hostDifferenceAbs, hostResult;
	/* Buffors */
};

} // namespace Cpu