kodokan#

kodokan — study Kodokan Judo throws from video via body-pose analysis.

A pipeline over the official Kodokan 100 Techniques YouTube playlist: acquire clips + metadata, estimate per-frame two-person skeletons, segment each clip into its repeated demonstrations, visualize skeletons (overlay-on-video and on a blank canvas), and — later — recognize, compare, and score throws.

Quick start:

from kodokan.acquire import download_techniques
from kodokan.pose import estimate_poses
from kodokan.viz import render_skeleton_video

res = download_techniques(playlist_items="2")          # Seoi-nage
seq = estimate_poses(res[0].path, source_url=res[0].info["webpage_url"])
render_skeleton_video(seq, out_path="overlay.mp4", source_video=res[0].path)
render_skeleton_video(seq, out_path="skeleton.mp4", blank_canvas=True)

See misc/docs/research-architecture.md for the tool/architecture rationale.

Functions

estimate_poses(video_path, *[, backend, ...])

Estimate per-frame, per-person COCO-17 keypoints for a video clip.

estimate_poses_tracked(video_path, *[, ...])

Estimate per-frame keypoints with persistent tori/uke identity.

render_skeleton_video(pose_seq, *, out_path)

Render skeletons to an MP4.

log_to_rerun(pose_seq, *[, source_video, ...])

Log frames + 2D skeletons to Rerun (overlay-on-video and skeleton-only views).

segment_demonstrations(pose_seq, *[, ...])

Find demonstrations, annotate each with its two-person coverage, and gate.

compare(features_a, features_b)

DTW-align two angle-feature sequences.

angle_features(pose_seq, *[, person, ...])

Per-frame joint-angle features (F, n_angles) for one person.

distance_matrix(feature_seqs)

Pairwise normalized-DTW distance matrix over a list of feature sequences.

pose_store([directory])

A dict-like {video_id: PoseSequence} store backed by per-clip Parquet.

segments_store([directory])

A dict-like {video_id: <json>} store for demo segments (and metadata).

load_all_tidy([store])

Concatenate every clip's tidy table (with a video_id column) into one DataFrame.

build_reference(feature_list)

Pick the medoid demo as reference and record the baseline distance spread.

score(query_features, reference)

Score a query against a reference, calibrated to the genuine-demo spread.

feedback(query_features, reference, *[, ...])

Interpretable difference: per joint-angle and per phase (degrees).

demo_features(pose_seq, start_s, end_s, *[, ...])

Cleaned joint-angle features for one demo window (primary person by default).

recognize_segments(pose_seq, recognizer, *)

Offline video mode: every detected throw in pose_seq, recognized.

coach(query_features, reference, *[, ...])

Score query_features against reference and advise on the worst dimensions.

make_problem(catalog, target_key, *[, mode, ...])

Build a multiple-choice problem for target_key from a technique catalog.

build_catalog(*[, min_two_person_frac, ...])

Build {technique_key: {"name", "clips":[...]}} from the pose/segments stores.

clip_filename(video_id, start_s, dur_s)

The web-app clip file for one demo segment, named by the segment's IDENTITY.

build_confusability([catalog, feature])

Technique×technique similarity (0..1) from mean pooled pose descriptors.

score_response(correct_key, chosen_key, *[, ...])

Confusion-weighted credit in [0, 1].

next_target(keys, history, *[, focus, rng])

Pick the next technique to quiz: unseen and often-missed (within focus) first.

log_response(problem, chosen_index, *[, ...])

Record a response (datetime + exact problem + choice + correctness + score).

Classes

PoseSequence(keypoints, frame_indices, fps, ...)

A per-frame, per-person sequence of COCO-17 keypoints for one clip.

Segment(index, start_s, end_s, start_frame, ...)

One detected demonstration interval.

TechniqueRecognizer(*[, method, temperature])

Fit on pooled descriptors; recognize with top-k guesses and the full score vector.

Recognition(guesses[, scores])

The top-k guesses, best first, and every technique's score.

Guess(technique, score)

One candidate technique and its score (higher is more likely).

LiveRecognizer(recognizer, *, fps[, k, ...])

Live mode: each throw a ThrowDetector reports, recognized once.

ThrowDetector(*, fps[, width, height, ...])

A rolling pose buffer that reports each throw once, after its segment closes.

Coaching(technique, lang, score, closer_than_pct)

A scored performance and the advice drawn from its worst dimensions.

LiveCoach(target, reference, *, fps[, lang, ...])

Coach a target technique on a live pose stream, one throw at a time.

TechniqueTest(recognizer, *[, pool, ...])

Prompt a random technique from a focus pool; grade the performance.

LiveTechniqueTest(test, *, fps[, featurize, ...])

The test loop on a live stream: prompt, detect the throw, grade, prompt again.

TestResult(target, recognition, ...)

The grade of one performance of the prompted technique.

class kodokan.Coaching(technique, lang, score, closer_than_pct, per_joint_deg=dict(), per_phase_deg=dict(), worst_joint=None, worst_phase=None, tips=(), reason=None)[source]#

Bases: object

A scored performance and the advice drawn from its worst dimensions.

reason: str | None = None#

"too_short" when the throw window had fewer than two usable frames to compare.

Type:

Why there is no score or tip

property text: str#

The advice as one paragraph.

class kodokan.Guess(technique, score)[source]#

Bases: object

One candidate technique and its score (higher is more likely).

class kodokan.LiveCoach(target, reference, *, fps, lang='en', n_tips=2, advice={'en': {'close': 'Close to the reference: keep it up.', 'elbow': "Your {side} elbow is {deg:.0f}° off the reference: keep that arm's pull firm and close to your body.", 'headline': '{technique}: {score}/100.', 'hip': 'Your {side} hip is {deg:.0f}° off: bring your hips lower and closer to your partner.', 'kake': 'Most of the difference is in kake: commit through the finish.', 'knee': 'Your {side} knee is {deg:.0f}° off: bend your knees more as you enter, then drive up.', 'kuzushi': "Most of the difference is in kuzushi: break your partner's balance before you turn in.", 'shoulder': "Your {side} shoulder is {deg:.0f}° off: lift and turn that arm with the reference timing to take your partner's balance.", 'tsukuri': 'Most of the difference is in tsukuri: step in faster and closer.'}, 'fr': {'close': 'Proche de la référence : continuez ainsi.', 'elbow': "Votre coude {side} s'écarte de {deg:.0f}° de la référence : gardez la traction de ce bras ferme et près du corps.", 'headline': '{technique} : {score}/100.', 'hip': "Votre hanche {side_f} s'écarte de {deg:.0f}° : placez vos hanches plus bas et plus près de votre partenaire.", 'kake': "L'essentiel de l'écart est dans le kake : allez au bout de la projection.", 'knee': "Votre genou {side} s'écarte de {deg:.0f}° : fléchissez davantage les genoux en entrant, puis poussez vers le haut.", 'kuzushi': "L'essentiel de l'écart est dans le kuzushi : déséquilibrez votre partenaire avant d'entrer.", 'shoulder': "Votre épaule {side_f} s'écarte de {deg:.0f}° : levez et tournez ce bras au rythme de la référence pour déséquilibrer votre partenaire.", 'tsukuri': "L'essentiel de l'écart est dans le tsukuri : entrez plus vite et plus près."}}, featurize=<function demo_features>, **detector_kwargs)[source]#

Bases: object

Coach a target technique on a live pose stream, one throw at a time.

push() takes one frame ((P, 17, 3) keypoints) and returns (segment, coaching) for each throw that closed with it. The target can be changed between throws (target, reference). Detector options (buffer_s, close_after_s, segmenter, …) pass through.

push(keypoints, frame_index=None)[source]#

Add one frame; return each throw it closed, coached against the target.

Return type:

list[tuple[Segment, Coaching]]

class kodokan.LiveRecognizer(recognizer, *, fps, k=3, featurize=<function pooled_demo_descriptor>, **detector_kwargs)[source]#

Bases: object

Live mode: each throw a ThrowDetector reports, recognized once.

push() takes one frame ((P, 17, 3) keypoints) and returns (segment, recognition) for the throws that closed with it. Detector options (buffer_s, close_after_s, segmenter, width, height) pass through.

push(keypoints, frame_index=None)[source]#

Add one frame; return the throws that closed with it, recognized.

Return type:

list[tuple[Segment, Recognition]]

class kodokan.LiveTechniqueTest(test, *, fps, featurize=<function pooled_demo_descriptor>, angle_featurize=<function demo_features>, on_prompt=None, **detector_kwargs)[source]#

Bases: object

The test loop on a live stream: prompt, detect the throw, grade, prompt again.

push() takes one frame and returns (segment, result) for each throw that closed with it; after each graded throw the next technique is drawn (prompt). Detector options pass through.

A throw is graded once it has closed (close_after_s after it ends), so the performer should wait for the next prompt before the next throw; any motion the detector takes for a throw also uses up a prompt.

push(keypoints, frame_index=None)[source]#

Add one frame; grade each throw it closed and draw the next prompt.

Return type:

list[tuple[Segment, TestResult]]

class kodokan.PoseSequence(keypoints, frame_indices, fps, width, height, backend, video_path, source_url=None, keypoint_names=('nose', 'left_eye', 'right_eye', 'left_ear', 'right_ear', 'left_shoulder', 'right_shoulder', 'left_elbow', 'right_elbow', 'left_wrist', 'right_wrist', 'left_hip', 'right_hip', 'left_knee', 'right_knee', 'left_ankle', 'right_ankle'), skeleton=((5, 7), (7, 9), (6, 8), (8, 10), (5, 6), (5, 11), (6, 12), (11, 12), (11, 13), (13, 15), (12, 14), (14, 16), (0, 1), (0, 2), (1, 3), (2, 4), (0, 5), (0, 6)))[source]#

Bases: object

A per-frame, per-person sequence of COCO-17 keypoints for one clip.

keypoints#

(F, P, 17, 3) float array of (x_px, y_px, confidence); NaN for empty person slots.

Type:

ndarray

frame_indices#

(F,) int array of source frame indices analyzed.

Type:

ndarray

fps#

Source frames-per-second.

Type:

float

width, height

Source frame dimensions in pixels.

backend#

The estimator backend used.

Type:

str

video_path#

Source clip path (provenance).

Type:

str

source_url#

Canonical YouTube URL, if known (provenance; required by project).

Type:

str | None

save_npz(path)[source]#

Persist as a compressed .npz (the dense numeric cache).

Return type:

Path

times()[source]#

Timestamp (seconds) of each analyzed frame.

Return type:

ndarray

class kodokan.Recognition(guesses, scores=dict())[source]#

Bases: object

The top-k guesses, best first, and every technique’s score.

score_of(technique)[source]#

The score of technique (0 for a technique the recognizer never saw).

Return type:

float

class kodokan.Segment(index, start_s, end_s, start_frame, end_frame, peak_activity, two_person_frac=None)[source]#

Bases: object

One detected demonstration interval.

class kodokan.TechniqueRecognizer(*, method='lda', temperature=1.0)[source]#

Bases: object

Fit on pooled descriptors; recognize with top-k guesses and the full score vector.

Parameters:
  • method (str) – "lda" (LDA projection when scikit-learn is installed, else plain standardized space) or "centroid" (standardized space only).

  • temperature (float) – softmax temperature; higher spreads the scores out.

fit(X, y)[source]#

Fit on pooled descriptors X (one row per demo) and technique labels y.

Return type:

TechniqueRecognizer

fit_demos(feature_seqs, labels, *, levels=(1, 2, 4))[source]#

Fit on per-frame feature sequences (e.g. kodokan.recognize.demo_feature()).

Return type:

TechniqueRecognizer

recognize(x, *, k=3)[source]#

Top-k guesses (best first) and the full score vector for one descriptor.

Return type:

Recognition

recognize_clip(pose_seq, start_s, end_s, *, k=3, featurize=<function pooled_demo_descriptor>)[source]#

Recognize the throw in pose_seq between start_s and end_s.

Return type:

Recognition

scores(x)[source]#

Every technique’s score for one pooled descriptor (they sum to 1).

Return type:

dict[str, float]

class kodokan.TechniqueTest(recognizer, *, pool=None, references=None, lang='en', confidence_weight=0.5, seed=None, rng=None, advice={'en': {'close': 'Close to the reference: keep it up.', 'elbow': "Your {side} elbow is {deg:.0f}° off the reference: keep that arm's pull firm and close to your body.", 'headline': '{technique}: {score}/100.', 'hip': 'Your {side} hip is {deg:.0f}° off: bring your hips lower and closer to your partner.', 'kake': 'Most of the difference is in kake: commit through the finish.', 'knee': 'Your {side} knee is {deg:.0f}° off: bend your knees more as you enter, then drive up.', 'kuzushi': "Most of the difference is in kuzushi: break your partner's balance before you turn in.", 'shoulder': "Your {side} shoulder is {deg:.0f}° off: lift and turn that arm with the reference timing to take your partner's balance.", 'tsukuri': 'Most of the difference is in tsukuri: step in faster and closer.'}, 'fr': {'close': 'Proche de la référence : continuez ainsi.', 'elbow': "Votre coude {side} s'écarte de {deg:.0f}° de la référence : gardez la traction de ce bras ferme et près du corps.", 'headline': '{technique} : {score}/100.', 'hip': "Votre hanche {side_f} s'écarte de {deg:.0f}° : placez vos hanches plus bas et plus près de votre partenaire.", 'kake': "L'essentiel de l'écart est dans le kake : allez au bout de la projection.", 'knee': "Votre genou {side} s'écarte de {deg:.0f}° : fléchissez davantage les genoux en entrant, puis poussez vers le haut.", 'kuzushi': "L'essentiel de l'écart est dans le kuzushi : déséquilibrez votre partenaire avant d'entrer.", 'shoulder': "Votre épaule {side_f} s'écarte de {deg:.0f}° : levez et tournez ce bras au rythme de la référence pour déséquilibrer votre partenaire.", 'tsukuri': "L'essentiel de l'écart est dans le tsukuri : entrez plus vite et plus près."}})[source]#

Bases: object

Prompt a random technique from a focus pool; grade the performance.

Parameters:
  • recognizer (TechniqueRecognizer) – a fitted TechniqueRecognizer.

  • pool (Iterable[str] | None) – the techniques to draw from (default: all the recognizer knows).

  • references (Mapping[str, dict] | None) – {technique: build_reference(...)}; techniques with one are also graded on closeness, with advice.

  • confidence_weight (float) – share of the score from the target’s confidence (the rest from closeness to the reference, when there is one).

  • seed (int | None) – or rng, for a reproducible sequence of prompts.

grade(descriptor, angle_features=None)[source]#

Grade one performance: its pooled descriptor and, for closeness, its per-frame angle_features (kodokan.score.demo_features()).

Return type:

TestResult

grade_clip(pose_seq, start_s, end_s, *, featurize=<function pooled_demo_descriptor>, angle_featurize=<function demo_features>)[source]#

Grade the performance in pose_seq between start_s and end_s.

Return type:

TestResult

next_prompt()[source]#

Draw the next technique to perform (never the same one twice in a row).

Return type:

str

class kodokan.TestResult(target, recognition, target_confidence, coaching, score)[source]#

Bases: object

The grade of one performance of the prompted technique.

property passed: bool#

Whether the recognizer’s best guess is the target.

class kodokan.ThrowDetector(*, fps, width=0, height=0, buffer_s=20.0, close_after_s=1.0, segmenter=<function motion_segments>)[source]#

Bases: object

A rolling pose buffer that reports each throw once, after its segment closes.

Push one frame at a time ((P, 17, 3) keypoints, as in PoseSequence). push() returns (buffer, segment) for the throws that closed with that frame. A segment counts as closed when it ends at least close_after_s before the newest frame; the buffer keeps the last buffer_s seconds of pushed frames (at fps frames a second: push every analysed frame, or pass the analysed rate as fps). A segment that mostly overlaps a throw already reported is that throw.

buffer()[source]#

The buffered frames as a PoseSequence (people padded with NaN).

Return type:

PoseSequence

push(keypoints, frame_index=None)[source]#

Add one frame; return (buffer, segment) for each throw it closed.

Return type:

list[tuple[PoseSequence, Segment]]

kodokan.angle_features(pose_seq, *, person=0, frame_range=None)[source]#

Per-frame joint-angle features (F, n_angles) for one person.

Return type:

ndarray

kodokan.build_catalog(*, min_two_person_frac=None, min_demo_s=1.0, max_demos=None, segments=None)[source]#

Build {technique_key: {"name", "clips":[...]}} from the pose/segments stores.

Aggregates all sources: each clip contributes its demo intervals (for looping media), so a technique present in several sources offers varied multiple-choice media.

max_demos caps the demos kept per source video (None, the default, keeps every demo that passes the quality gate — #37: the store has 6–8 reps per video and all of them are worth showing). segments is the {video_id: record} mapping to read (default: kodokan.store.segments_store()).

kodokan.build_confusability(catalog=None, *, feature='tori_angles_pos')[source]#

Technique×technique similarity (0..1) from mean pooled pose descriptors.

similarity[a][b] high ⇒ techniques a, b look alike in pose-space (likely confusable for a learner). An honest, recognizer-free proxy; swap for the model’s confusion matrix once cross-source recognition works.

Return type:

dict

kodokan.build_reference(feature_list)[source]#

Pick the medoid demo as reference and record the baseline distance spread.

Returns {medoid, reference, baseline, distance_matrix} where baseline is the array of normalized-DTW distances from every other demo to the medoid.

Return type:

dict

kodokan.clip_filename(video_id, start_s, dur_s)[source]#

The web-app clip file for one demo segment, named by the segment’s IDENTITY.

{video_id}_{start_ms}_{dur_ms}.mp4: the name says which time span of which source it shows, so re-segmenting can never make an existing name show a different cut (#45) — a changed segment simply gets a new name. Positional names ({vid}_3.mp4) could.

Return type:

str

kodokan.coach(query_features, reference, *, technique=None, lang='en', n_tips=2, min_deviation_deg=10.0, advice={'en': {'close': 'Close to the reference: keep it up.', 'elbow': "Your {side} elbow is {deg:.0f}° off the reference: keep that arm's pull firm and close to your body.", 'headline': '{technique}: {score}/100.', 'hip': 'Your {side} hip is {deg:.0f}° off: bring your hips lower and closer to your partner.', 'kake': 'Most of the difference is in kake: commit through the finish.', 'knee': 'Your {side} knee is {deg:.0f}° off: bend your knees more as you enter, then drive up.', 'kuzushi': "Most of the difference is in kuzushi: break your partner's balance before you turn in.", 'shoulder': "Your {side} shoulder is {deg:.0f}° off: lift and turn that arm with the reference timing to take your partner's balance.", 'tsukuri': 'Most of the difference is in tsukuri: step in faster and closer.'}, 'fr': {'close': 'Proche de la référence : continuez ainsi.', 'elbow': "Votre coude {side} s'écarte de {deg:.0f}° de la référence : gardez la traction de ce bras ferme et près du corps.", 'headline': '{technique} : {score}/100.', 'hip': "Votre hanche {side_f} s'écarte de {deg:.0f}° : placez vos hanches plus bas et plus près de votre partenaire.", 'kake': "L'essentiel de l'écart est dans le kake : allez au bout de la projection.", 'knee': "Votre genou {side} s'écarte de {deg:.0f}° : fléchissez davantage les genoux en entrant, puis poussez vers le haut.", 'kuzushi': "L'essentiel de l'écart est dans le kuzushi : déséquilibrez votre partenaire avant d'entrer.", 'shoulder': "Votre épaule {side_f} s'écarte de {deg:.0f}° : levez et tournez ce bras au rythme de la référence pour déséquilibrer votre partenaire.", 'tsukuri': "L'essentiel de l'écart est dans le tsukuri : entrez plus vite et plus près."}})[source]#

Score query_features against reference and advise on the worst dimensions.

Parameters:
  • query_features (ndarray) – per-frame joint angles of the performance (kodokan.score.demo_features()).

  • reference (dict) – the target technique’s build_reference().

  • lang (str) – a key of advice ("en" or "fr" built in).

  • n_tips (int) – joint tips to give, worst first, after the phase tip.

  • min_deviation_deg (float) – a phase or joint closer than this gets no tip; with none left, the advice says the performance is close to the reference.

Return type:

Coaching

A window with fewer than two usable frames cannot be compared: it gets a Coaching with no score and reason="too_short" rather than an error, so a live loop goes on.

kodokan.compare(features_a, features_b)[source]#

DTW-align two angle-feature sequences.

Returns a dict with distance (total DTW cost), normalized (cost per aligned step — comparable across different-length demos), the warping path, and the cleaned input arrays a/b.

One DTW pass gives both the path and the distance, on dtaidistance’s C library when it is available (its pure-Python fallback is ~250x slower).

Return type:

dict

kodokan.demo_features(pose_seq, start_s, end_s, *, person=None)[source]#

Cleaned joint-angle features for one demo window (primary person by default).

Return type:

ndarray

kodokan.distance_matrix(feature_seqs)[source]#

Pairwise normalized-DTW distance matrix over a list of feature sequences.

The normalized distance is symmetric, so only the upper triangle is computed.

Return type:

ndarray

kodokan.estimate_poses(video_path, *, backend='rtmlib', n_persons=2, conf_thresh=0.3, frame_step=1, frame_range=None, device=None, source_url=None, progress=True, **backend_kwargs)[source]#

Estimate per-frame, per-person COCO-17 keypoints for a video clip.

Simplest use: estimate_poses("clip.mp4") → a PoseSequence with the two highest-confidence people per frame (left→right ordered) via RTMPose.

Parameters:
  • video_path (str | Path) – Path to the video clip.

  • backend (str) – "rtmlib" (RTMPose top-down, CPU/ONNX; default, and the only one installed by kodokan[pose]) or "ultralytics" (YOLO11-pose, MPS), which needs kodokan[track] — an AGPL-3.0-or-later dependency, see the README’s “Licensing of extras”.

  • n_persons (int) – Number of person slots to keep per frame (2 for tori+uke).

  • conf_thresh (float) – Minimum mean per-person confidence to keep a detection.

  • frame_step (int) – Analyze every frame_step-th frame (1 = every frame).

  • frame_range (tuple[int, int] | None) – Optional (start, stop) frame index window.

  • device (str | None) – Backend device ("cpu"/"mps"); backend default if None.

  • source_url (str | None) – Canonical source URL to record as provenance.

  • progress (bool) – Print a progress line periodically.

  • **backend_kwargs – Forwarded to the backend (e.g. mode="performance" for rtmlib, or model_name="yolo11m-pose.pt" for ultralytics).

Return type:

PoseSequence

Returns:

A PoseSequence of shape (F, n_persons, 17, 3).

kodokan.estimate_poses_tracked(video_path, *, n_persons=2, tracker='botsort.yaml', conf_thresh=0.3, max_gap_frac=0.15, stale_after=12, frame_step=1, frame_range=None, device='mps', model_name='yolo11n-pose.pt', source_url=None, progress=True)[source]#

Estimate per-frame keypoints with persistent tori/uke identity.

Returns a PoseSequence whose person slots are stable across the clip (slot 0 = the track that is, on average, further left).

Parameters:
  • video_path (str | Path) – Path to the clip.

  • n_persons (int) – Number of stable identity slots to keep (2 for tori+uke).

  • tracker (str) – Ultralytics tracker config ("botsort.yaml" or "bytetrack.yaml").

  • conf_thresh (float) – Minimum mean per-person confidence to count a detection.

  • frame_step (int) – Analyze every n-th frame.

  • frame_range (tuple[int, int] | None) – Optional (start, stop) frame window.

  • device (str | None) – Torch device ("mps"/"cpu").

  • model_name (str) – YOLO-pose weights (resolved under the data models dir).

  • source_url (str | None) – Provenance URL.

  • progress (bool) – Print progress.

Return type:

PoseSequence

kodokan.feedback(query_features, reference, *, n_phases=3)[source]#

Interpretable difference: per joint-angle and per phase (degrees).

Return type:

dict

kodokan.load_all_tidy(store=None)[source]#

Concatenate every clip’s tidy table (with a video_id column) into one DataFrame.

kodokan.log_response(problem, chosen_index, *, user='default', store=None, similarity=None, timestamp=None)[source]#

Record a response (datetime + exact problem + choice + correctness + score).

Return type:

dict

kodokan.log_to_rerun(pose_seq, *, source_video=None, save=None, spawn=False, blank_canvas=True, frame_scale=0.5, conf_thresh=0.3, entity_prefix='')[source]#

Log frames + 2D skeletons to Rerun (overlay-on-video and skeleton-only views).

Parameters:
  • pose_seq (PoseSequence) – The sequence to log.

  • source_video (str | Path | None) – If given, downscaled frames are logged under video/ as a backdrop.

  • save (str | Path | None) – Write a standalone .rrd recording to this path.

  • spawn (bool) – Launch the Rerun viewer.

  • blank_canvas (bool) – Also log a skeleton-only view under skeleton/.

  • frame_scale (float) – Downscale factor for logged video frames (keypoints scaled to match).

  • conf_thresh (float) – Hide keypoints below this confidence.

  • entity_prefix (str) – Prefix all entity paths (use distinct prefixes to compare two sequences side-by-side in one recording, e.g. "demoA/", "demoB/").

Return type:

None

kodokan.make_problem(catalog, target_key, *, mode='video_to_name', n_choices=4, similarity=None, rng=None, clip_for=None)[source]#

Build a multiple-choice problem for target_key from a technique catalog.

catalog maps technique_key -> {"name": str, "clips": [clip dicts]}. clip_for(key) returns a looping clip for a key (default: first clip); for name_to_video the choices are clips, for video_to_name they are names.

Return type:

Problem

kodokan.next_target(keys, history, *, focus=None, rng=None)[source]#

Pick the next technique to quiz: unseen and often-missed (within focus) first.

Spaced-repetition-ish weight = (wrongs + 1) / (seen + 1): unseen -> 1, frequently wrong -> high, mastered -> low. history is a list of response dicts.

Return type:

str

kodokan.pose_store(directory=None)[source]#

A dict-like {video_id: PoseSequence} store backed by per-clip Parquet.

kodokan.recognize_segments(pose_seq, recognizer, *, k=3, featurize=<function pooled_demo_descriptor>, segmenter=<function motion_segments>)[source]#

Offline video mode: every detected throw in pose_seq, recognized.

Return type:

list[tuple[Segment, Recognition]]

kodokan.render_skeleton_video(pose_seq, *, out_path, source_video=None, blank_canvas=False, conf_thresh=0.3, fps=None, person_colors=((0, 255, 0), (255, 0, 255), (255, 255, 0), (0, 165, 255)), background=(0, 0, 0), thickness=2, radius=4)[source]#

Render skeletons to an MP4.

Parameters:
  • pose_seq (PoseSequence) – The pose sequence to draw.

  • out_path (str | Path) – Output .mp4 path.

  • source_video (str | Path | None) – Source clip; required (and used as backdrop) unless blank_canvas=True.

  • blank_canvas (bool) – If True, draw on a solid background instead of the video.

  • conf_thresh (float) – Hide keypoints/edges below this confidence.

  • fps (float | None) – Output fps (defaults to the sequence’s source fps).

  • person_colors – BGR colors per person slot.

  • background – BGR background color for the blank canvas.

  • thickness (int) – Edge thickness / joint radius in pixels.

  • radius (int) – Edge thickness / joint radius in pixels.

Return type:

Path

Returns:

The output path.

kodokan.score(query_features, reference)[source]#

Score a query against a reference, calibrated to the genuine-demo spread.

score is 0–100: 100 ≈ as close as the closest genuine demo, 0 ≈ as far as the 90th-percentile (or worse). closer_than_pct is the percent of genuine demos the query is closer-to-reference than.

Return type:

dict

kodokan.score_response(correct_key, chosen_key, *, similarity=None, max_partial=0.5)[source]#

Confusion-weighted credit in [0, 1].

Correct = 1.0. A wrong answer earns partial credit proportional to how confusable the chosen technique is with the correct one (an honest mistake between look-alike throws is penalized less than confusing two obviously different throws).

Return type:

float

kodokan.segment_demonstrations(pose_seq, *, video_path=None, use_optical_flow=False, min_two_person_frac=0.0, **find_kwargs)[source]#

Find demonstrations, annotate each with its two-person coverage, and gate.

Uses pose motion energy by default (fuse optical flow with use_optical_flow). Segments whose two-person coverage is below min_two_person_frac are dropped (a throw demonstration needs both tori and uke), then re-indexed in time order.

Return type:

list[Segment]

kodokan.segments_store(directory=None)[source]#

A dict-like {video_id: <json>} store for demo segments (and metadata).

Modules

acquire

Acquire Kodokan technique clips from YouTube (thin wrapper over yb.download).

canon3d

Pelvis-frame (Procrustes) canonicalization of 3D world landmarks.

competitions

A calendar of upcoming judo competitions in one French département, and who may enter each.

config

Where kodokan keeps its data (downloaded clips + derived artifacts).

descriptors

Experimental per-demo feature descriptors (to test what makes throws separable).

flashcards

Technique-recognition learning game (app #6) — logic layer.

pose

Body-pose estimation: a video → a sequence of per-person skeletal keypoints.

recognize

Learned-vs-DTW technique recognition experiments (data-appropriate, no GPU).

recognizer

Technique recognition for applications: top-k guesses with inspectable scores (#3).

segment

Segment a clip into its repeated demonstrations of one throw.

store

dol-backed stores for the pipeline's artifacts (the analysis SSOT).

testmode

Technique test mode: perform the technique the system names, get scored (#5).

tori_labels

Hand-labelling of the tori heuristic (#49): sample demos, then score agreement.

track

Stable tori/uke identity tracking (BoT-SORT / ByteTrack).

viz

Visualize a PoseSequence.

vocab

Word parts of technique names: which techniques share which part, and how often.