#pragma once

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

#include <pybind11/pybind11.h>

namespace py = pybind11;

/**
 * @brief Binds noise::BackgroundActivityNoiseFilter to python.
 * @param m The module to bind to.
 */
void bind_k_noise_filter(py::module &m) {
	py::class_<dv::noise::KNoiseFilter<>, std::shared_ptr<dv::noise::KNoiseFilter<>>>(m, "KNoiseFilter",
		"A memory-efficient, spatiotemporal event filter as proposed by Khodamoradi's algorithm. The filter discards "
		"an event if the number of spatiotemporal neighbors is less than the given number of supporting pixels. The "
		"spatial window size is defined by the window half size, while the temporal window size is defined by the "
		"given time delta. Note that while this filter is is more memory efficient than other provided filters due to "
		"only storing values per row/column, it is more computationally expensive than other filters as twice as many "
		"lookup operations are required.")
		.def(py::init<const cv::Size &, const dv::Duration>(), py::arg("resolution"),
			py::arg("timeDelta") = dv::Duration(1'000))
		.def("accept", &dv::noise::KNoiseFilter<>::accept, py::arg("events"), "Accepts incoming events.")
		.def("generateEvents", &dv::noise::KNoiseFilter<>::generateEvents,
			"Apply the filter algorithm and return only the filtered events from the ones that were accepted as input.")
		.def("retain", &dv::noise::KNoiseFilter<>::retain, "Test whether event should be kept or discarded.")
		.def("getNumberOfIncomingEvents", &dv::noise::KNoiseFilter<>::getNumberOfIncomingEvents,
			"Get number of total events that were accepted by the noise filter.")
		.def("getNumberOfOutgoingEvents", &dv::noise::KNoiseFilter<>::getNumberOfOutgoingEvents,
			"Total number of outgoing events from this filter instance.")
		.def("getReductionFactor", &dv::noise::KNoiseFilter<>::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("getTemporalWindowDuration", &dv::noise::KNoiseFilter<>::getTemporalWindowDuration,
			"Get the duration of the temporal window used to check for neighboring events.")
		.def("setTemporalWindowDuration", &dv::noise::KNoiseFilter<>::setTemporalWindowDuration, py::arg("timeDelta"),
			"Set the duration of the temporal window used to check for neighboring events.");
}
