JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
PoseSkeleton.H
Go to the documentation of this file.
1// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2//
3// JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2024 by Laurent Itti, the University of Southern
4// California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5//
6// This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7// redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8// Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10// License for more details. You should have received a copy of the GNU General Public License along with this program;
11// if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12//
13// Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14// Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16/*! \file */
17
18#pragma once
19
20#include <jevois/Types/Enum.H>
21#include <memory>
22
23namespace jevois
24{
25 //! An enum for different kinds of skeletons
26 /*! See PoseSkeleton.C for their definition in terms of nodes and links */
27 JEVOIS_DEFINE_ENUM_CLASS(PoseSkeletonType, (Coco17))
28
29 //! Class to hold a pose skeleton definition
30 /*! \ingroup types */
32 {
33 //! Create from a YAML file
34 PoseSkeletonDefinition(std::string const & filename);
35
36 std::vector<std::string> nodeNames; //!< names of nodes (size nn)
37 std::vector<unsigned int> nodeColors; //!< colors of nodes (size nn)
38 std::vector<std::pair<unsigned int, unsigned int>> links; //!< link definitions, each is pair of node IDs (size nl)
39 std::vector<unsigned int> linkColors; //!< link colors (size nl)
40 };
41
42 //! A simple skeleton class for pose detection deep neural networks
43 /*! This class simply represents a set of nodes and links with associated confidences and colors. In this class, you
44 should only store nodes and links that have actually been detected. \ingroup types */
46 {
47 //! A pose skeleton node
48 struct Node
49 {
50 unsigned int id; //!< Node ID (number) within the skeleton's definition of nodes
51 float x, y; //!< Node location, in image coords (b2i() already applied)
52 float confidence; //!< Node confidence [0.0 .. 100.0]
53 };
54
55 //! A pose skeleton link between two nodes
56 /*! In principle, from the link id we could recover the two node ids and then find those in our list of nodes to
57 get their coordinates. But this is costly, so here instead we store again the coordinates of the two nodes, to
58 make drawing of links fast. */
59 struct Link
60 {
61 unsigned int id; //!< Link id within the skeleton's definition of links
62 float x1, y1; //!< Coordinates of first joint, in image coords (b2i() already applied)
63 float x2, y2; //!< Coordinates of second joint, in image coords (b2i() already applied)
64 float confidence; //!< Confidence in that link (e.g., product of the 2 node confidences), [0.0 .. 100.0]
65 };
66
67 std::vector<Node> nodes; //!< The nodes we found in this detection
68 std::vector<Link> links; //!< The links we found in this detection
69
70 //! Constructor from a previously loaded definition
71 PoseSkeleton(std::shared_ptr<PoseSkeletonDefinition> def);
72
73 //! Get the total number of nodes in the skeleton. Node ID is from 0 to that total - 1
74 /*! This is not the number of detected nodes for a particular detection, which is simply nodes.size() */
75 unsigned int numSkeletonNodes() const;
76
77 //! Get the total number of links in the skeleton. Link ID is from 0 to that total - 1
78 /*! This is not the number of detected links for a particular detection, which is simply links.size() */
79 unsigned int numSkeletonLinks() const;
80
81 //! Get the name of a node from its ID
82 char const * nodeName(unsigned int id) const;
83
84 //! Get draw color of a node from its ID, as 0xAABBGGRR (note: returned unsigned int is the same as ImU32)
85 unsigned int nodeColor(unsigned int id) const;
86
87 //! Get draw color of a node from its ID, as 0xAABBGGRR (note: returned unsigned int is the same as ImU32)
88 unsigned int linkColor(unsigned int id) const;
89
90 //! Get a const ref to our link definitions, useful to iterate over. Each link is <node_id_1, node_id_2>
91 std::vector<std::pair<unsigned int, unsigned int>> const & linkDefinitions() const;
92
93 private:
94 PoseSkeleton() = delete; // Disable default constructor, we always need a skeleton definition
95 std::shared_ptr<PoseSkeletonDefinition> psd;
96 };
97
98}
JEVOIS_DEFINE_ENUM_CLASS(CameraSensor,(any)(imx290)(os08a10)(ar0234))
Enum for different sensor models.
Main namespace for all JeVois classes and functions.
Definition Concepts.dox:2
An enum for different kinds of skeletons.
std::vector< unsigned int > nodeColors
colors of nodes (size nn)
std::vector< std::pair< unsigned int, unsigned int > > links
link definitions, each is pair of node IDs (size nl)
std::vector< std::string > nodeNames
names of nodes (size nn)
std::vector< unsigned int > linkColors
link colors (size nl)
A pose skeleton node.
float y
Node location, in image coords (b2i() already applied)
unsigned int id
Node ID (number) within the skeleton's definition of nodes.
float confidence
Node confidence [0.0 .. 100.0].
A simple skeleton class for pose detection deep neural networks.
std::vector< Node > nodes
The nodes we found in this detection.
unsigned int linkColor(unsigned int id) const
Get draw color of a node from its ID, as 0xAABBGGRR (note: returned unsigned int is the same as ImU32...
unsigned int numSkeletonNodes() const
Get the total number of nodes in the skeleton. Node ID is from 0 to that total - 1.
std::vector< Link > links
The links we found in this detection.
std::vector< std::pair< unsigned int, unsigned int > > const & linkDefinitions() const
Get a const ref to our link definitions, useful to iterate over. Each link is <node_id_1,...
unsigned int numSkeletonLinks() const
Get the total number of links in the skeleton. Link ID is from 0 to that total - 1.
unsigned int nodeColor(unsigned int id) const
Get draw color of a node from its ID, as 0xAABBGGRR (note: returned unsigned int is the same as ImU32...
char const * nodeName(unsigned int id) const
Get the name of a node from its ID.