Hotspot.hpp 1.31 KB
#pragma once

#include <vector>

#include <opencv2/core/mat.hpp>
#include <opencv2/imgproc.hpp>

namespace Cpu {

class Hotspot {
  public:
	using Contour = std::vector<cv::Point>;
	using Surface = std::vector<cv::Point3f>;

	const unsigned long timestamp;
	const int component;
	const Contour contour;

	const cv::Mat mask;

	const double meanTemperature, maxTemperature;
	const int size;

	Hotspot(const cv::Mat &temperature, unsigned long timestamp, int component,
	        const Contour &contour, const Surface &surface);

	double perimeter() const;

  private:
	const Surface surface;

	Hotspot(const cv::Mat &temperature, unsigned long timestamp, int component,
	        const Contour &contour, const Surface &surface,
	        const cv::Mat &mask);

	int calculateSize() const;
	double calculateMean(const cv::Mat &temperature) const;
	double calculateMax(const cv::Mat &temperature) const;

	static cv::Mat createMask(const cv::Size &size, const Contour &contour);
};

class PersistentHotspot {
  public:
	explicit PersistentHotspot(const Hotspot &initial);

	void merge(const Hotspot &other);
	int area() const;

	cv::Mat mask;
	int component;
	std::vector<unsigned long> timestamps;
	std::vector<double> meanTemperatures;
	std::vector<double> maxTemperatures;

  private:
	void append(const Hotspot &other);
};

} // namespace Cpu