Skip to content

Home / TangoPosture Community Edition / Technical Docs / Package Structure & API Reference

Package Structure & API Reference

Provenance Value
Source repository TangoMovementLabs/TangoPostureOpenCommunity
Application version 0.5.3
Source commit SHA 09038960daee
Generated / updated (UTC) 2026-11-27T19:38:11Z

tango_posture

Source: src/tango_posture/__init__.py

tango_posture.app

Source: src/tango_posture/app.py

Desktop controller. Headless and GUI use the same observation/session pipeline.

Classes: - class Application (line 108) Functions: - def runtime_versions(model_hash: str) -> dict (line 76)

tango_posture.archive

Source: src/tango_posture/archive.py

Portable practice archives and temporary, validated replay extraction.

Classes: - class PracticeArchive (line 837) Functions: - def movement_member_name(index: int) -> str (line 79)- def analytics_member_name(index: int) -> str (line 85)- def rename_archive(path: Path, name: str) -> None (line 109)- def read_analytics(path: Path, index: int) -> dict[str, Any] | None (line 119)- def store_analytics(path: Path, index: int, payload: dict[str, Any], *, expected_video_sha256: str | None = None, report_section: str | None = None, report_text: str | None = None, overlay_path: Path | None = None, lines_path: Path | None = None, metadata_updates: dict[str, Any] | None = None, frame_log: list[dict[str, Any]] | None = None, dancer_analysis_run: dict[str, Any] | None = None) -> None (line 236)- def update_couple_annotations(path: Path, index: int, *, run_id: str, annotations: dict[str, Any], cfg: Any, expected_video_sha256: str | None = None) -> dict[str, Any] (line 386) — Atomically rebuild and store edited Couple annotations for a matching run_id.- def set_active_dancer_run(path: Path, index: int, mode: str) -> dict[str, Any] (line 448) — Switch the active saved run mode ('single' or 'couple') for an archived segment.- def practice_directory(data_dir: str) -> Path (line 482)- def calibration_directory(data_dir: str) -> Path (line 486)- def calibration_path(folder: Path, name: str) -> Path (line 490)- def practice_path(folder: Path, name: str) -> Path (line 494)- def read_manifest(path: Path) -> dict (line 501)- def write_review_companions(output, overlay, name, *, include_lines = True) (line 545)- def append_segment(path: Path, report: Path, video: Path | None, overlay: Path | None, timestamps: list[float], *, analytics: dict[str, Any] | None = None, lines: Path | None = None, metadata_extra: dict[str, Any] | None = None) -> int (line 554)- def file_sha256(path: Path) -> str (line 564)- def extract_segment_video(path: Path, index: int, destination: Path) -> str (line 587)- def store_movement_analysis(path: Path, index: int, expected_video_sha256: str, payload: dict[str, Any]) -> str (line 604)- def read_movement_analysis(path: Path, index: int) -> dict[str, Any] | None (line 644)- def save_calibration_archive(path: Path, reference: Calibration, video: Path, overlay: Path, timestamps: list[float]) -> None (line 755)- def read_calibration_archive(path: Path) -> Calibration (line 800)- def store_analysis(path: Path, analysis: Path) -> None (line 815)

tango_posture.beat

Source: src/tango_posture/beat.py

Argentine Tango 8-beat phrase tracker with 30s phrase-start analysis and WAV recording.

Classes: - class BeatTracker (line 260) — Records microphone audio, analyzes the first analysis_seconds (default 30s) of active music Functions: - def mux_audio_into_video(video_path: Path, wav_path: Path) -> bool (line 74) — Embed wav_path audio track into video_path (.mp4) in-place using macOS AVFoundation.

tango_posture.calibration

Source: src/tango_posture/calibration/__init__.py

Baseline and approved-range calibration independent of the desktop UI.

tango_posture.calibration.archives

Source: src/tango_posture/calibration/archives.py

Atomic video-independent range profile archives.

Functions: - def save_range_profile(path: Path, profile: RangeProfile, *, overwrite: bool = False, embedded_evidence: Path | None = None) -> None (line 16)- def has_embedded_evidence(path: Path) -> bool (line 54) — Return True if a .tpc calibration archive embeds a raw evidence.tpr archive.- def extract_embedded_evidence(path: Path, dest_dir: Path) -> Path | None (line 65) — Extract embedded evidence.tpr from a .tpc archive into dest_dir if present.- def read_range_profile(path: Path) -> RangeProfile (line 79)

tango_posture.calibration.baseline

Source: src/tango_posture/calibration/baseline.py

Functions: - def utc_now() -> str (line 15)- def profile(cfg: Config, width: int, height: int, source: str) -> dict (line 19)- def compatible(ref: Calibration, current: dict, model_hash: str) -> None (line 31)- def calibrate(samples: list[MetricObservation], start: float, cfg: Config, capture_profile: dict, model_hash: str, name: str, review: dict | None = None) -> Calibration (line 45)- def save_calibration_file(cal: Calibration, folder: Path = Path('calibrations')) -> Path (line 108) — Save accepted calibration to calibrations/calibration_<timestamp>.json and latest_calibration.json.- def load_calibration_file(identifier: str, folder: Path = Path('calibrations')) -> Calibration | None (line 122) — Load a Calibration from a JSON file path, filename in calibrations/, 'latest', or UUID.

tango_posture.calibration.camera_session

Source: src/tango_posture/calibration/camera_session.py

Qt-independent state machine, readiness gates, and guided plans for solo camera calibration.

Classes: - class GuidePhaseSpec (line 41) — Definition of a single capture phase in a guided calibration plan.- class CheckSpec (line 59) — Definition of a guided individual measurement check.- class AcceptedPassageRecord (line 282) — Ledger entry for a single accepted capture phase.- class GateEvaluation (line 300) — Per-frame evaluation of dancer tracking, view, framing, and metric eligibility.- class SoloCameraSession (line 872) — Qt-independent state machine managing solo camera calibration capture and gating. Functions: - def build_quick_setup_phases() -> list[GuidePhaseSpec] (line 138) — Return the default four-hold Quick Setup plan.- def build_check_phases(check_ids: list[str] | tuple[str, ...]) -> list[GuidePhaseSpec] (line 197) — Build 4-phase neutral A -> changed A -> neutral B -> changed B sequences for selected checks.- def build_walking_phases() -> list[GuidePhaseSpec] (line 252) — Build the two-pass Solo Walking plan.- def prepare_side_measurement_frame(frame: FrameObservation, cfg: Config) -> FrameObservation (line 445) — Repair occluded far-side torso joints in side view so near-side measurements stay valid.- def resolve_side_frame_config(frame: FrameObservation, base_cfg: Config, ledger: Sequence[Mapping[str, Any]] | None = None) -> tuple[FrameObservation, Config] (line 578) — Resolve per-frame orientation and repair occluded far-side joints for side frames only.- def ledger_metric_samples(frames: Sequence[FrameObservation], base_cfg: Config, ledger: Sequence[Mapping[str, Any]], *, view: Literal['side', 'front', 'all']) -> dict[str, list[tuple[float, float | None]]] (line 627) — Compute metric time series honoring per-phase side/facing ledger entries.- def classify_guide_view(frame: FrameObservation, cfg: Config, requested_view: Literal['front', 'side'] | None = None, *, strict_facing: bool = True, turn_direction: Literal['camera', 'left', 'right'] | None = None) -> tuple[GuideView, str] (line 673) — Classify the single-dancer view for guided capture using strict facial and torso cues.- def check_full_body_framing(frame: FrameObservation, cfg: Config) -> tuple[bool, str] (line 779) — Require one tracked dancer, sufficient torso size, and reliable head + ankle/shoe landmarks.- def accumulate_usable_duration(samples: list[tuple[float, float | None]], max_gap: float) -> float (line 804) — Accumulate duration only between adjacent eligible observations within max_gap.- def check_neutral_pair_comparable(samples: list[tuple[float, float | None]], hold_a: Passage, hold_b: Passage, max_gap: float, *, is_wrapped: bool = False) -> tuple[bool, str] (line 823) — Check whether two independent neutral holds agree within 2x max spread.- def evaluate_metric_repeat_check(samples: list[tuple[float, float | None]], holds_4: list[Passage], max_gap: float, *, expected_sign: int | None = None) -> tuple[bool, str] (line 851) — Run repeat_check() on neutral A, changed A, neutral B, changed B plus optional sign check.

tango_posture.calibration.couple

Source: src/tango_posture/calibration/couple.py

Temporal comparison of identity-tracked couple measurements and approved ranges.

Functions: - def compare_couple_series(key: str, points: list[tuple[float, float | None]], target: ApprovedRange, cfg: Config) -> tuple[list[tuple[float, float | None]], dict[float, str]] (line 8)

tango_posture.calibration.evidence

Source: src/tango_posture/calibration/evidence.py

Cached landmark evidence and conservative explicit dancer association.

Classes: - class Evidence (line 22) Functions: - def cached_evidence(path: Path, index: int = 0, *, couple: bool = False) -> Evidence (line 30)- def has_linkable_pose(frame: FrameObservation, confidence: float) -> bool (line 150) — Return True when the frame has a pose with a reliable hip center for tracking.- def contiguous_pose_run_end(frames: list[FrameObservation], start_index: int) -> int (line 157) — Return the exclusive end index of the contiguous pose run starting at start_index.- def is_static_pose_run(frames: list[FrameObservation], start_index: int, *, min_frames: int = 10, max_median_step: float = 0.001) -> bool (line 165) — Detect frozen title/poster slides where consecutive poses barely move.- def single_dancer_anchors(evidence: Evidence, confidence: float, *, skip_static: bool = True, allow_multi_pose_gaps: bool = False) -> dict[int, int] (line 191) — Compute anchor frames to link a solo dancer across brief dropouts or cuts.- def dancer_frames(evidence: Evidence, dancer: int, confidence: float) -> list[FrameObservation] (line 234) — Conservative spatial association; ambiguity/gaps end a track, never silently reseed it.- def cached_couple_result(data: dict[str, Any]) -> dict[str, Any] (line 271) — Read couple evidence from a saved run or the couple engine's coach cache.

tango_posture.calibration.measurements

Source: src/tango_posture/calibration/measurements.py

Confidence-qualified range measurements shared by editing and scoring.

Functions: - def measure_ranges(frame: FrameObservation, cfg: Config) -> MetricObservation (line 30) — Use only confidence-qualified landmarks and existing measurement definitions.- def view_eligible(view: Literal['side', 'front', 'all'], view_width: float | None, max_view_width: float) -> bool (line 76) — Return whether a frame's measured view_width satisfies the target view policy.- def measure_profile(frame: FrameObservation, cfg: Config, profile: RangeProfile) -> MetricObservation (line 93) — Use the same per-view measurement path in approval and subsequent scoring.- def measure_targets(frame: FrameObservation, cfg: Config, targets: Mapping[str, RangeDefault | ApprovedRange]) -> MetricObservation (line 98)- def metric_samples(frames: Sequence[FrameObservation], cfg: Config, *, view: Literal['side', 'front', 'all'] | None = None) -> dict[str, list[tuple[float, float | None]]] (line 120)

tango_posture.calibration.models

Source: src/tango_posture/calibration/models.py

Versioned approved-range models and supported measurement identities.

Classes: - class Passage(BaseModel) (line 48)- class ApprovedRange(BaseModel) (line 60)- class RangeProfile(BaseModel) (line 86) Functions: - def profile_from_calibration(reference: Calibration) -> RangeProfile | None (line 131)

tango_posture.calibration.normalization

Source: src/tango_posture/calibration/normalization.py

Per-metric measurement normalization models, hold verification, and applicability checks.

Classes: - class PairApplicability (line 75) — Applicability status of a normalization pair against current data.- class MatchedHoldResult (line 85) — Outcome of computing and checking a matched-hold offset for one metric.- class NormalizedMetricValue (line 94) — Single-frame normalization outcome for one metric. Functions: - def make_pair_rule_id(calibration_id: str, raw_media_sha256: str | None, fallback_seed: str = '') -> str (line 105) — Build a deterministic short identifier for a calibration + practice recording pair.- def capture_identity_dict(capture: Mapping[str, Any] | None) -> dict[str, Any] (line 119) — Return canonical non-null capture orientation/size fields for identity comparisons.- def profile_content_digest(profile: RangeProfile) -> str (line 128) — Hash approved ranges and measurement contract without archive filenames or names.- def settings_fingerprint(cfg: Config) -> str (line 151) — Hash config fields that affect raw pose/metric computation.- def frames_fingerprint(observations: Sequence[FrameObservation]) -> str (line 165) — Hash raw frame dimensions, timestamps, and pose coordinates in order.- def extract_coach_observations(data: Mapping[str, Any]) -> list[FrameObservation] (line 225) — Extract ordered raw FrameObservations from cached coach_data, ignoring display poses.- def resolve_raw_media_sha256(archive_path: Path, segment_index: int = 0, analytics: Mapping[str, Any] | None = None) -> str | None (line 310) — Hash raw segment video media inside .tp/.tpr, or recover from provenance metadata.- def resolve_profile_reference_source(profile: RangeProfile, profile_path: Path, cfg: Config, *, override_path: Path | None = None) -> Path (line 348) — Find the source .tpr archive for profile, honoring explicit user override when valid.- def select_archive_frames(archive_path: Path, segment_index: int, cfg: Config, *, prefer_coach_frames: bool = False) -> tuple[list[FrameObservation], dict[str, Any]] (line 398) — Load real, non-interpolated FrameObservations and capture/analytics metadata for a segment.- def build_source_identity(*, archive_path: Path | None, segment_index: int, cfg: Config, observations: Sequence[FrameObservation], capture_profile: Mapping[str, Any] | None, raw_media_sha256: str | None, source_label: str | None = None) -> HoldSourceIdentity (line 436) — Construct a complete content-bound HoldSourceIdentity for persistence and applicability checks.- def windows_disjoint(a: HoldWindow | Passage, b: HoldWindow | Passage) -> bool (line 460) — Return True when hold windows a and b do not overlap ([start, end)).- def measure_hold_window(frames: Sequence[FrameObservation], cfg: Config, metric: str, target: ApprovedRange | RangeDefault, window: HoldWindow | Passage, *, min_samples: int = 8, min_coverage: float = 0.6) -> tuple[HoldWindowStats | None, str] (line 480) — Measure one hold window on real frames without interpolation.- def metric_offset_between(metric: str, reference_value: float, practice_value: float) -> float (line 538) — Compute signed offset b mapping practice_value + b -> reference_value.- def metric_error(metric: str, a: float, b: float) -> float (line 544) — Distance between two metric values on metric's domain.- def in_physical_domain(metric: str, value: float) -> bool (line 550) — Return True if value obeys physical domain bounds for metric.- def apply_metric_offset(metric: str, observed_raw: float, offset: float) -> float (line 563) — Apply additive adjustment offset cleanly for linear or cyclic metrics.- def evaluate_matched_holds(*, metric: str, target: ApprovedRange | RangeDefault, rule: MetricNormalizationRule, reference_frames: Sequence[FrameObservation], practice_frames: Sequence[FrameObservation], cfg: Config) -> MatchedHoldResult (line 572) — Fit additive offset on Fit holds and verify on separate Check holds.- def find_matching_pair(cfg: Config, calibration_id: str, practice_identity: HoldSourceIdentity) -> NormalizationPairRule | None (line 721) — Locate the stored pair rule targeting (calibration_id, practice_identity).- def evaluate_pair_applicability(cfg: Config, profile: RangeProfile, practice_identity: HoldSourceIdentity) -> PairApplicability (line 739) — Check whether any stored normalization pair safely applies to this comparison.- def normalize_metric_observation(*, metric: str, observed_raw: float | None, quality_valid: bool, rule: MetricNormalizationRule | None, applicability: PairApplicability, norm_cfg: MeasurementNormalizationConfig) -> NormalizedMetricValue (line 847) — Resolve one frame's raw value, applied adjustment, and Evaluator input.- def utc_timestamp_now() -> str (line 918) — Public helper returning an ISO-8601 UTC timestamp with Z suffix.

tango_posture.calibration.readiness

Source: src/tango_posture/calibration/readiness.py

Compatibility and clip-interval readiness for baseline analysis.

Classes: - class CalibrationReadiness (line 18) — Pre-check or outcome for reference-relative posture review. Functions: - def check_calibration_readiness(*, analysis_mode: str, cfg: Config, probe: VideoProbeInfo, selected_in: float, selected_out: float, reference: Calibration | None = None, calibration_interval: tuple[float, float] | None = None, model_hash: str | None = None) -> CalibrationReadiness (line 41) — Check whether reference-relative posture review can run with the chosen inputs.

tango_posture.calibration.statistics

Source: src/tango_posture/calibration/statistics.py

Passage distributions, reliable duration and guided repeatability checks.

Functions: - def summarize_examples(samples: list[tuple[float, float | None]], passages: list[Passage], max_gap: float, lower: float | None = None, upper: float | None = None, *, suggest_lower_pct: float = 10.0, suggest_upper_pct: float = 90.0, min_usable_samples: int = 2) -> dict[str, Any] (line 14)- def repeat_check(samples: list[tuple[float, float | None]], holds: list[Passage], max_gap: float) -> tuple[bool, str] (line 62)

tango_posture.capture

Source: src/tango_posture/capture.py

Sequential file decode and a latest-frame-only webcam producer.

Classes: - class Captured (line 54)- class Capture (line 60)

tango_posture.cli

Source: src/tango_posture/cli.py

Functions: - def parser() -> argparse.ArgumentParser (line 40)- def main(argv: list[str] | None = None, *, display: PracticeDisplay | None = None) -> int (line 130)

tango_posture.config

Source: src/tango_posture/config.py

Classes: - class Threshold(BaseModel) (line 12)- class RangeDefault(BaseModel) (line 24)- class AnalysisRegion(BaseModel) (line 38) — Normalized [0, 1] image region restricting candidate dancer detection.- class DancerAnalysisConfig(BaseModel) (line 56) — Configurable controls for Single, Couple, and Auto opening-window analysis.- class SoloCameraCalibrationConfig(BaseModel) (line 117)- class Config(BaseModel) (line 141) Functions: - def parse_bool(value: str) -> bool (line 280)- def set_setting(data: dict, key: str, value: str) -> None (line 733)- def setting_value(cfg: Config, field: str) (line 746)- def export_toml(cfg: Config) -> str (line 753)- def startup_config_path(explicit: Path | None) -> Path | None (line 830)- def load(path: Path | None, overrides: dict, env_path: Path | None = None) -> Config (line 841)

tango_posture.contracts

Source: src/tango_posture/contracts/__init__.py

Typed contracts (commands, events, models) between desktop UI and services.

tango_posture.contracts.commands

Source: src/tango_posture/contracts/commands.py

Typed in-process commands sent from Qt UI/ViewModels to application services.

Classes: - class PreparePractice (line 13)- class StartPreview (line 28)- class SetRecording (line 33)- class SetScoring (line 39)- class PauseScoring (line 46)- class StopAndSave (line 52)- class AbortUnsaved (line 57)- class CutVideoSegment (line 62)- class ExportOverlayVideo (line 70)

tango_posture.contracts.events

Source: src/tango_posture/contracts/events.py

Typed domain events emitted by application services to Qt ViewModels.

Classes: - class DomainEvent (line 15)- class SessionStateChanged(DomainEvent) (line 22)- class MetricSnapshotEmitted(DomainEvent) (line 28)- class BeatTracked(DomainEvent) (line 35)- class SegmentSaved(DomainEvent) (line 44)- class PracticeCompleted(DomainEvent) (line 52)- class ServiceErrorOccurred(DomainEvent) (line 60)- class AIAnalysisProgress(DomainEvent) (line 67)

tango_posture.contracts.models

Source: src/tango_posture/contracts/models.py

Pydantic request and response models for queries, library views, and diagnostics.

Classes: - class PracticeFilterQuery(BaseModel) (line 12)- class PracticeItemSummary(BaseModel) (line 20)- class LibraryPage(BaseModel) (line 31)- class ReadinessCheck(BaseModel) (line 39)- class ReadinessReport(BaseModel) (line 46)

tango_posture.core

Source: src/tango_posture/core/__init__.py

Framework-free domain types, errors and state machines (no Qt, Tk, cv2 or SQLite).

tango_posture.core.entities

Source: src/tango_posture/core/entities.py

Core domain entities for TangoPosture (pure Python, framework-independent).

Classes: - class CaptureSetup (line 15)- class MetricSample (line 27)- class IssueEvent (line 41)- class MovementRecord (line 53)- class Recording (line 62)- class Practice (line 77)- class ReferenceSummary (line 89)

tango_posture.core.errors

Source: src/tango_posture/core/errors.py

Stable domain errors. UI layers map code to user-facing copy.

Classes: - class TangoError(Exception) (line 6)- class InvalidTransition(TangoError) (line 15)- class ModelUnavailable(TangoError) (line 19)- class ReferenceInvalid(TangoError) (line 23)- class ArchiveDamaged(TangoError) (line 27)- class SettingsInvalid(TangoError) (line 31)- class Cancelled(TangoError) (line 35)

Source References


← Previous: Processing Pipelines & Coordinate Systems · Next: Metrics Technical Specification →