OverloadHotspotDetectionAlgorithm.hpp 1.39 KB
#pragma once

#include <opencv2/core/mat.hpp>

#include "algorithm/Algorithm.hpp"

#include "algorithm/cpu/common/ClusterCorrespondence.hpp"
#include "algorithm/cpu/hotspot/Hotspot.hpp"

#include "algorithm/common/PfcSegmenter.hpp"
#include "algorithm/common/SurfaceMap.hpp"

namespace Cpu {

class OverloadHotspotDetectionAlgorithm : public Algorithm {
  public:
	/* Configurable parameters */
	std::size_t blobsLimit{5};
	std::size_t pixelsThreshold{3};
	/* Configurable parameters */

	OverloadHotspotDetectionAlgorithm() = default;

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

	std::vector<Cpu::PersistentHotspot> uniqueHotspots; /* Set of persistent hotspots */

  private:
	using Contours = std::vector<std::vector<cv::Point>>;

	static constexpr int KELVINS{273};
	static constexpr int MAX_TEMPERATURE{(1L << 15) - 1};

	cv::Size currentFrameSize;

	Cpu::ClusterCorrespondence clusterCorrespondence{.8, 2.};
	std::unique_ptr<const SurfaceMap> surfaceMap;

	cv::Mat hostFov, hostModel, hostPfc;
	cv::Mat hostPfcMask;

	std::vector<Cpu::Hotspot> currentHotspots;

	void identifyHotspots(unsigned long timestamp);
	void matchHotspot(const Cpu::Hotspot &hotspot);

	/* Buffors */
	cv::Mat overheating;
	cv::Mat hostFrame, hostInput, hostTemperature;
	/* Buffors */
};

} // namespace Cpu