File size: 784 Bytes
95db528
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class Hand:
    def __init__(self, bbox, hand_id=None, gesture=None):
        """
        Hand class

        Parameters
        ----------
        bbox : np.ndarray
            Bounding box of hand

        hand_id : int
            Id of hand

        gesture : int
            Current gesture of hand
        """
        self.bbox = bbox
        self.hand_id = hand_id
        if self.bbox is not None:
            self.center = self._get_center()
            self.size = self.bbox[2] - self.bbox[0]
        self.position = None
        self.gesture = gesture

    def _get_center(self):
        return (self.bbox[0] + self.bbox[2]) / 2, (self.bbox[1] + self.bbox[3]) / 2

    def __repr__(self):
        return f"Hand({self.center}, {self.size}, {self.position}, {self.gesture})"