class

MJ::Pose

Inherits JSON::Serializable < Reference < Object

Constants

KEYPOINT_COLORS = [{255, 0, 0}, {255, 85, 0}, {255, 170, 0}, {255, 255, 0}, {170, 255, 0}, {85, 255, 0}, {0, 255, 0}, {0, 255, 85}, {0, 255, 170}, {0, 255, 255}, {0, 170, 255}, {0, 85, 255}, {0, 0, 255}, {85, 0, 255}, {170, 0, 255}, {255, 0, 255}, {255, 0, 170}, {255, 0, 85}]

Rainbow gradient colors for keypoints (R, G, B)

KEYPOINT_INDEX = KEYPOINT_NAMES.each_with_index.to_h
KEYPOINT_NAMES = ["nose", "neck", "right_shoulder", "right_elbow", "right_wrist", "left_shoulder", "left_elbow", "left_wrist", "right_hip", "right_knee", "right_ankle", "left_hip", "left_knee", "left_ankle", "right_eye", "left_eye", "right_ear", "left_ear"]

COCO 18-keypoint names

LIMB_COLORS = [{0, 0, 153}, {153, 0, 0}, {153, 51, 0}, {153, 102, 0}, {153, 153, 0}, {102, 153, 0}, {51, 153, 0}, {0, 153, 0}, {0, 153, 51}, {0, 153, 102}, {0, 153, 153}, {0, 102, 153}, {0, 51, 153}, {51, 0, 153}, {102, 0, 153}, {153, 0, 153}, {153, 0, 102}]

Colors for each limb connection

LIMB_PAIRS = [{1, 0}, {1, 2}, {1, 5}, {2, 3}, {3, 4}, {5, 6}, {6, 7}, {1, 8}, {8, 9}, {9, 10}, {1, 11}, {11, 12}, {12, 13}, {0, 14}, {14, 16}, {0, 15}, {15, 17}]

17 limb connections [from, to]

Constructors

from_flat_array(data : Array(Float64), width : Int32, height : Int32) : Pose

Create from Runware preprocess response (flat array: [x0,y0,c0, x1,y1,c1, ...])

Source
interpolate(a : Pose, b : Pose, t : Float64) : Pose

Linear interpolation between two poses

Source
new(keypoints : Array(MJ::Keypoint) = Array(Keypoint).new(18) do Keypoint.new end)
Source
new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source

Instance methods

[](index : Int32) : Keypoint
Source
[](name : String) : Keypoint
Source
[]=(name : String, value : Keypoint)
Source
[]=(index : Int32, value : Keypoint)
Source
keypoints
Source
keypoints=(keypoints : Array(Keypoint))
Source
with_overrides(joints : Hash(String, Array(Float64))) : Pose

Apply joint overrides from a hash like {"right_wrist": [0.6, 0.5]}

Source