#pragma once

#include "../../../../include/dv-processing/camera/calibrations/stereo_calibration.hpp"

#include <pybind11/pybind11.h>

namespace py = pybind11;

/**
 * @brief Bind camera::calibrations::StereoCalibration to python
 * @param m pybind The module to bind to
 */
void bind_calibration_stereo_calibration(py::module &m) {
	using pybind11::operator""_a;

	py::class_<dv::camera::calibrations::StereoCalibration> stereoCalibration(m, "StereoCalibration");

	py::class_<dv::camera::calibrations::StereoCalibration::Metadata>(
		stereoCalibration, "Metadata", "Metadata for the stereo calibration.")
		.def(py::init<const std::optional<float> &, const std::string &>(), py::arg("epipolarError") = std::nullopt,
			py::arg("comment") = "")
		.def_readonly("epipolarError", &dv::camera::calibrations::StereoCalibration::Metadata::epipolarError,
			"Average epipolar error (can be None if unknown)")
		.def_readonly(
			"comment", &dv::camera::calibrations::StereoCalibration::Metadata::comment, "Any additional information");

	stereoCalibration.def(py::init<>())
		.def(py::init<const std::string &, const std::string &, const std::vector<float> &, const std::vector<float> &,
			const std::optional<dv::camera::calibrations::StereoCalibration::Metadata> &>())
		.def_readonly(
			"leftCameraName", &dv::camera::calibrations::StereoCalibration::leftCameraName, "Name of the left camera")
		.def_readonly("rightCameraName", &dv::camera::calibrations::StereoCalibration::rightCameraName,
			"Name of the right camera")
		.def_readonly("fundamentalMatrix", &dv::camera::calibrations::StereoCalibration::fundamentalMatrix,
			"Stereo calibration Fundamental Matrix")
		.def_readonly("essentialMatrix", &dv::camera::calibrations::StereoCalibration::essentialMatrix,
			"Stereo calibration Essential Matrix")
		.def_readonly("metadata", &dv::camera::calibrations::StereoCalibration::metadata, "Metadata")
		.def("getFundamentalMatrix", &dv::camera::calibrations::StereoCalibration::getFundamentalMatrix)
		.def("getEssentialMatrix", &dv::camera::calibrations::StereoCalibration::getEssentialMatrix);
}
