#pragma once #include #include #include #include #include "camera.hpp" // ================================================================================================= using RaggedPoses2D = std::vector>>>; using NestedPoses3D = std::vector>>; // ================================================================================================= struct PoseBatch2DView { const float *data = nullptr; const uint32_t *person_counts = nullptr; size_t num_views = 0; size_t max_persons = 0; size_t num_joints = 0; const float &at(size_t view, size_t person, size_t joint, size_t coord) const; }; struct PoseBatch2D { std::vector data; std::vector person_counts; size_t num_views = 0; size_t max_persons = 0; size_t num_joints = 0; float &at(size_t view, size_t person, size_t joint, size_t coord); const float &at(size_t view, size_t person, size_t joint, size_t coord) const; PoseBatch2DView view() const; static PoseBatch2D from_nested(const RaggedPoses2D &poses_2d); }; struct PoseBatch3D { std::vector data; size_t num_persons = 0; size_t num_joints = 0; float &at(size_t person, size_t joint, size_t coord); const float &at(size_t person, size_t joint, size_t coord) const; NestedPoses3D to_nested() const; static PoseBatch3D from_nested(const NestedPoses3D &poses_3d); }; // ================================================================================================= /** * Calculate a triangulation using a padded pose tensor. * * @param poses_2d Padded poses of shape [views, max_persons, joints, 3]. * @param cameras List of cameras. * @param roomparams Room parameters (room size, room center). * @param joint_names List of 2D joint names. * @param min_match_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. * * @return Pose tensor of shape [persons, joints, 4]. */ PoseBatch3D triangulate_poses( const PoseBatch2DView &poses_2d, const std::vector &cameras, const std::array, 2> &roomparams, const std::vector &joint_names, float min_match_score = 0.95f, size_t min_group_size = 1); inline PoseBatch3D triangulate_poses( const PoseBatch2D &poses_2d, const std::vector &cameras, const std::array, 2> &roomparams, const std::vector &joint_names, float min_match_score = 0.95f, size_t min_group_size = 1) { return triangulate_poses( poses_2d.view(), cameras, roomparams, joint_names, min_match_score, min_group_size); }