#pragma once

#include <string>
#include <vector>

#include "camera.hpp"

// =================================================================================================

// Forward declaration of the class, that swig does not try to parse all its dependencies.
class TriangulatorInternal;

// =================================================================================================

class Triangulator
{
public:
    /**
     * Triangulator to predict poses from multiple views.
     *
     *
     * @param min_score Minimum score to consider a triangulated joint as valid.
     * @param min_group_size Minimum number of camera pairs that need to see a person.
     */
    Triangulator(
        float min_score = 0.95,
        size_t min_group_size = 1);

    /**
     * Calculate a triangulation.
     *
     *
     * @param poses_2d List of shape [views, persons, joints, 3], containing the 2D poses.
     * @param cameras List of cameras.
     * @param roomparams Room parameters (room size, room center).
     * @param joint_names List of 2D joint names.
     *
     * @return List of shape [persons, joints, 4], containing the 3D poses.
     */
    std::vector<std::vector<std::array<float, 4>>> triangulate_poses(
        const std::vector<std::vector<std::vector<std::array<float, 3>>>> &poses_2d,
        const std::vector<Camera> &cameras,
        const std::array<std::array<float, 3>, 2> &roomparams,
        const std::vector<std::string> &joint_names);

    /** Reset the triangulator. */
    void reset();

    /** Print triangulation statistics. */
    void print_stats();

private:
    TriangulatorInternal *triangulator;
};
