v2 compositional engine
@treefour/haath/v2 layers richer recognition on the same 25-joint buffers as the core engine. It adds named static poses with confidence scores (a core pack and an ASL alphabet pack), motion states, 3D trajectory shapes, micro-gestures, and two-hand compound gestures.
Setup #
import { Haath } from '@treefour/haath';
import { CompositionalGestureEngine, CoreStaticPosePack, ASLStaticPosePack } from '@treefour/haath/v2';
const haath = new Haath();
const v2 = new CompositionalGestureEngine({ pose: { poses: [...CoreStaticPosePack, ...ASLStaticPosePack] } });
// per frame, after haath.update(...): reuse haath's joint buffers
const L = haath.leftRecognizer, R = haath.rightRecognizer;
const res = v2.update(
haath.state.left.tracked ? L.getHistoryBuffer() : null, L.getFrameOffset(0),
haath.state.right.tracked ? R.getHistoryBuffer() : null, R.getFrameOffset(0),
dt,
);What it returns #
res.right.pose?.name; // 'peace', 'asl_v', ... with res.right.pose.confidence
res.right.motion.state; // 'STATIONARY' | 'MICRO_MOVING' | 'TRANSLATING' | 'BALLISTIC'
res.right.trajectory.gesture; // 'circle_cw', 'line_swipe', 'infinity', 'star', ... or null
res.right.micro.active; // 'money_rub', 'thumb_index_tap', 'finger_snap', ...
res.bimanual.kamehameha.triggered; // also: bow, portal, timeout (T sign), dialCustom poses #
Describe each finger as extended or curled, with an optional match() scorer and a priority:
v2.pose.right.registerPose({
name: 'spidey',
category: 'custom',
fingers: { thumb: 'extended', index: 'extended', middle: 'curled', ring: 'curled', pinky: 'extended' },
priority: 1.1,
});