scripts.hand_module

Author: Carmen Meinson

class HandGesture(name: str, position_checker: Callable[[scripts.core.position.Position], bool], tracker: scripts.core.position_tracker.PositionTracker)

Bases: scripts.core.gesture.Gesture

Author: Carmen Meinson Partially based on the Hand class in the MotionInput v2 code

class HandLandmarkDetector

Bases: scripts.core.module.LandmarkDetector

get_raw_data(raw_data: scripts.core.raw_data.RawData, image: numpy.ndarray) None

Adds the xyz coordinates of all the hand landmarks detected on the image into the RawData instance.

Parameters
  • raw_data (RawData) – RawData instance to add the landmarks to

  • image (ndarray) – Image to process with mediapipe and read the landmarks locations from

Author: Carmen Meinson Partially based on the Hand class in the MotionInput v2 code

dist(x, y)
class HandPosition(raw_hand_data: Dict[str, numpy.ndarray], used_primitives: Optional[Set[str]] = None)

Bases: scripts.core.position.Position

get_primitives_names() Set[str]
Returns

Names of all primitives that are calculated by the specific modules Position class on initialization

Return type

List[str]

get_primitive(name: str) Optional[bool]

Returns the state of the given primitive in the Position if it has been calculated. Returns None If the primitive has not been calculated, hence if it either is not defined for current module or the land marks needed to calculate it were not provided

Parameters

name (str) – name of the primitive (e.g. “palm_facing_camera” or “index_pinched”)

Returns

state of the primitive

Return type

Optional[bool]

get_landmark(name: str) Optional[numpy.ndarray]

Returns the coordinates of the landmark. Returns None if the landmarks was not provided to the Position on initialization

Parameters

name (str) – name of the landmark (e.g. “index_tip” or “wrist”)

Returns

coordinates of the landmark

Return type

Optional[np.ndarray]

get_landmarks_distance(name1: str, name2: str) float
get_palm_height() Optional[float]

Returns the distance between the wrist and the base of the middle finger

get_palm_scalar() float

Returns the perimeter of the triangle formed from the wrist, index_base and pinky_base

get_finger_tilted_left(finger_name: str) Optional[bool]

Returns weather the given finger is tilted to the left from the users perspective. Tilted left is defined as the tip of the finger being further left than the wrist.

get_finger_tilted_right(finger_name: str) Optional[bool]

Returns weather the given finger is tilted to the right from the users perspective. Tilted right is defined as the tip of the finger being further right than the wrist.

Module contents

Author: Carmen Meinson

class HandModule

Bases: scripts.core.module.Module