#pragma once

#include "../../../include/dv-processing/noise/fast_decay_noise_filter.hpp"

#include <pybind11/pybind11.h>

namespace py = pybind11;

/**
 * @brief Binds noise::FastDecayNoiseFilter to python.
 * @param m The module to bind to.
 */
void bind_fast_decay_noise_filter(py::module &m) {
	py::class_<dv::noise::FastDecayNoiseFilter<>, std::shared_ptr<dv::noise::FastDecayNoiseFilter<>>>(m,
		"FastDecayNoiseFilter",
		"Fast decay noise filter uses a concept that performs a fast decay on a low resolution representation of the "
		"image and checks whether corresponding neighbourhood of the event has recent activity.")
		.def(py::init<const cv::Size &, const dv::Duration, const int, const float>(), py::arg("resolution"),
			py::arg("halfLife") = dv::Duration(10'000), py::arg("subdivisionFactor") = 4, py::arg("noiseThreshold") = 6)
		.def("accept", &dv::noise::FastDecayNoiseFilter<>::accept, py::arg("events"), "Accepts incoming events.")
		.def("generateEvents", &dv::noise::FastDecayNoiseFilter<>::generateEvents,
			"Apply the filter algorithm and return only the filtered events from the ones that were accepted as input.")
		.def("retain", &dv::noise::FastDecayNoiseFilter<>::retain, "Test whether event is of configured polarity.")
		.def("getNumberOfIncomingEvents", &dv::noise::FastDecayNoiseFilter<>::getNumberOfIncomingEvents,
			"Get number of total events that were accepted by the noise filter.")
		.def("getNumberOfOutgoingEvents", &dv::noise::FastDecayNoiseFilter<>::getNumberOfOutgoingEvents,
			"Total number of outgoing events from this filter instance.")
		.def("getReductionFactor", &dv::noise::FastDecayNoiseFilter<>::getReductionFactor,
			"Get the reduction factor of this filter. It's a fraction representation of events that were discard by "
			"this filter compared to the amount of incoming events.")
		.def("getNoiseThreshold", &dv::noise::FastDecayNoiseFilter<>::getNoiseThreshold,
			"Get the currently configured noise threshold.")
		.def("setNoiseThreshold", &dv::noise::FastDecayNoiseFilter<>::setNoiseThreshold, py::arg("noiseThreshold"),
			"Set a new noise threshold value.")
		.def("getHalfLife", &dv::noise::FastDecayNoiseFilter<>::getHalfLife,
			"Get the current configured half-life value. Half-life is the amount of time it takes for the internal "
			"event counter to halve. Decreasing this will increase the strength of the noise filter (cause it to "
			"reject more events).")
		.def("setHalfLife", &dv::noise::FastDecayNoiseFilter<>::setHalfLife, py::arg("halfLife"),
			"Set a new counter half-life value. Half-life is the amount of time it takes for the internal event "
			"counter to halve. Decreasing this will increase the strength of the noise filter (cause it to reject more "
			"events).");
}
