Free Motion Capture for Everyone 💀✨
TypeScript
Add concept of 'Active Recording' plus many other changes (#788)
jonmatthis5433838557fc
diff --git a/.gitignore b/.gitignoreindex f8d2d4b3..ec3cda30 100644--- a/.gitignore+++ b/.gitignore@@ -161,5 +161,10 @@ pyapp.zip.vite*.zip+upx.exe+.docusaurus/*/.claude/*+/.claude/+/CLAUDE.md+.aider*diff --git a/freemocap-ui/electron-builder.json b/freemocap-ui/electron-builder.jsonindex bef24ea3..50fa05ff 100644--- a/freemocap-ui/electron-builder.json+++ b/freemocap-ui/electron-builder.json@@ -16,7 +16,7 @@"**/freemocap_server*","**/freemocap-logo.png"],- "compression": "maximum",+ "compression": "normal","win": {"icon": "../shared/freemocap-logo/freemocap-favicon.ico",diff --git a/freemocap-ui/electron/main/services/menu-builder.ts b/freemocap-ui/electron/main/services/menu-builder.tsindex cd78a118..1b151c9a 100644--- a/freemocap-ui/electron/main/services/menu-builder.ts+++ b/freemocap-ui/electron/main/services/menu-builder.ts@@ -18,6 +18,9 @@ export type MenuAction =| 'start-recording'| 'stop-recording'| 'open-recording-folder'+ | 'show-pipeline-progress'+ | 'load-test-data'+ | 'clear-active-recording'| 'toggle-fullscreen'| 'toggle-locale'| 'check-for-updates'@@ -34,6 +37,9 @@ export interface MenuLabels {menuView: string;menuCamera: string;menuRecording: string;+ menuData: string;+ menuLoadTestData: string;+ menuClearActiveRecording: string;menuHelp: string;menuDetectCameras: string;menuConnectCameras: string;@@ -51,6 +57,7 @@ export interface MenuLabels {menuAbout: string;menuCheckForUpdates: string;menuPlayback: string;+ menuShowPipelineProgress: string;// Keys reused from the existing i18nhome: string;cameras: string;@@ -66,6 +73,9 @@ const DEFAULT_LABELS: MenuLabels = {menuView: 'View',menuCamera: 'Camera',menuRecording: 'Recording',+ menuData: 'Data',+ menuLoadTestData: 'Load Test Data',+ menuClearActiveRecording: 'Clear Active Recording',menuHelp: 'Help',menuDetectCameras: 'Detect Cameras',menuConnectCameras: 'Connect Cameras',@@ -83,6 +93,7 @@ const DEFAULT_LABELS: MenuLabels = {menuAbout: 'About FreeMoCap',menuCheckForUpdates: 'Check for Updates…',menuPlayback: 'Playback',+ menuShowPipelineProgress: 'Show Pipeline Progress',home: 'Home',cameras: 'Cameras',settings: 'Settings',@@ -239,6 +250,28 @@ function buildRecordingMenu(t: MenuLabels): MenuItemConstructorOptions {label: t.menuOpenRecordingFolder,click: () => sendMenuAction('open-recording-folder'),},+ { type: 'separator' },+ {+ label: t.menuShowPipelineProgress,+ click: () => sendMenuAction('show-pipeline-progress'),+ },+ ],+ };+}++function buildDataMenu(t: MenuLabels): MenuItemConstructorOptions {+ return {+ label: t.menuData,+ submenu: [+ {+ label: t.menuLoadTestData,+ accelerator: 'CmdOrCtrl+T',+ click: () => sendMenuAction('load-test-data'),+ },+ {+ label: t.menuClearActiveRecording,+ click: () => sendMenuAction('clear-active-recording'),+ },],};}@@ -326,6 +359,7 @@ export function buildApplicationMenu(params: MenuBuildParams = {}): void {template.push(buildViewMenu(t));template.push(buildCameraMenu(t));template.push(buildRecordingMenu(t));+ template.push(buildDataMenu(t));// macOS window menuif (isMac) {diff --git a/freemocap-ui/index.html b/freemocap-ui/index.htmlindex 037bbe43..58a726ff 100644--- a/freemocap-ui/index.html+++ b/freemocap-ui/index.html@@ -4,7 +4,7 @@<meta charset="UTF-8"/><link href="/favicon.ico" rel="icon" type="image/x-icon"/><meta content="width=device-width, initial-scale=1.0" name="viewport"/>- <meta content="script-src 'self' 'unsafe-inline'; worker-src blob:;" http-equiv="Content-Security-Policy"/>+ <meta content="script-src 'self' 'unsafe-inline'; worker-src blob: 'self';" http-equiv="Content-Security-Policy"/><title>FreeMoCap💀✨</title></head><body>diff --git a/freemocap-ui/src/app/AppContent.tsx b/freemocap-ui/src/app/AppContent.tsxindex a90f713e..15f3d71a 100644--- a/freemocap-ui/src/app/AppContent.tsx+++ b/freemocap-ui/src/app/AppContent.tsx@@ -4,16 +4,19 @@ import { HashRouter } from 'react-router-dom';import { CssBaseline } from "@mui/material";import { BasePanelLayout } from "@/layout/BasePanelLayout";import { createExtendedTheme } from "@/layout/paperbase-theme";-import { useAppSelector } from "@/store";+import { useAppDispatch, useAppSelector } from "@/store";import { BaseContentRouter } from "@/layout/content/BaseContentRouter";import { UpdateBanner } from "@/components/ui-components/UpdateBanner";+import PipelineProgressSnackbar from "@/components/pipeline-progress/PipelineProgressSnackbar";import { AutoUpdateProvider } from "@/hooks/AutoUpdateContext";import { PlaybackProvider } from "@/components/playback/PlaybackContext";import { useTranslation } from "react-i18next";import { getLocaleDirection } from "@/i18n";+import { fetchAllRecordings } from "@/store/slices/recording-status/recording-status-thunks";export const AppContent = function () {const { i18n } = useTranslation();+ const dispatch = useAppDispatch();const themeMode = useAppSelector(state => state.theme.mode);const direction = getLocaleDirection(i18n.language);@@ -23,6 +26,11 @@ export const AppContent = function () {document.documentElement.lang = i18n.language;}, [direction, i18n.language]);+ // Prefetch recordings list on startup so data is ready when user opens the tab+ React.useEffect(() => {+ dispatch(fetchAllRecordings());+ }, [dispatch]);+const theme = React.useMemo(() => {const base = createExtendedTheme(themeMode);return { ...base, direction };@@ -39,6 +47,7 @@ export const AppContent = function () {</BasePanelLayout></PlaybackProvider><UpdateBanner />+ <PipelineProgressSnackbar /></AutoUpdateProvider></HashRouter></ThemeProvider>diff --git a/freemocap-ui/src/components/LogTerminal.tsx b/freemocap-ui/src/components/LogTerminal.tsxdeleted file mode 100644index 3546a64d..00000000--- a/freemocap-ui/src/components/LogTerminal.tsx+++ /dev/null@@ -1,702 +0,0 @@-// LogTerminal.tsx-import {alpha, Box, IconButton, TextField, ToggleButton, ToggleButtonGroup, Tooltip, useTheme,} from "@mui/material";-import React, {useCallback, useEffect, useMemo, useRef, useState} from "react";-import {useServer} from "@/services/server/ServerContextProvider";-import {LogRecord, LogSnapshot} from "@/services/server/server-helpers/log-store";-import {- ContentCopy as ContentCopyIcon,- DeleteSweep as DeleteSweepIcon,- Pause as PauseIcon,- PlayArrow as PlayArrowIcon,- Save as SaveIcon,- SaveAlt as ScrollToBottomIcon,- Search as SearchIcon,- Warning as WarningIcon,-} from "@mui/icons-material";-import {useTranslation} from "react-i18next";--const LOG_POLL_INTERVAL_MS = 500;--/** Height of a single line of monospace text in the log view. */-const LINE_HEIGHT = 20;--/** Vertical padding added to each log entry. */-const ROW_PADDING = 8;--/** Extra rows rendered above/below the visible viewport. */-const OVERSCAN = 10;--const LOG_COLORS: Record<string, string> = {- TRACE: "#ccc",- DEBUG: "#88ccFF",- INFO: "#00E5FF",- SUCCESS: "#FF66FF",- API: "#66FF66",- WARNING: "#FFFF66",- ERROR: "#FF6666",- CRITICAL: "#FF0000",-};--// ----------------------------------------------------------------------------// URL linkification — splits text on http/https URLs and renders them as-// clickable <a> tags. When split() is called with a capture group, matched-// segments land at odd indices, so i % 2 === 1 identifies URLs.-// -----------------------------------------------------------------------------const URL_REGEX = /(https?:\/\/[^\s)"'>\]]+)/g;--const Linkify = ({ text }: { text: string }) => {- const parts = text.split(URL_REGEX);- if (parts.length === 1) return <>{text}</>;-- return (- <>- {parts.map((part, i) =>- i % 2 === 1 ? (- <a- key={i}- href={part}- target="_blank"- rel="noopener noreferrer"- style={{ color: "#58a6ff", textDecoration: "underline" }}- onClick={(e) => e.stopPropagation()}- >- {part}- </a>- ) : (- <span key={i}>{part}</span>- )- )}- </>- );-};--// ----------------------------------------------------------------------------// Variable-height virtualization helpers.-// Each log entry's height depends on the number of lines in its message.-// Single-line messages get a compact row; multi-line messages expand to-// show every line, rendered with preserved whitespace like a real terminal.-// -----------------------------------------------------------------------------/** Count lines in a message. A message with no newlines has 1 line. */-const countLines = (text: string): number => {- if (!text) return 1;- let count = 1;- for (let i = 0; i < text.length; i++) {- if (text[i] === "\n") count++;- }- return count;-};--/** Compute the pixel height of a log entry based on its line count. */-const getRowHeight = (log: LogRecord): number => {- const lines = countLines(log.message);- if (lines === 1) {- // Single-line: one line of text + padding- return LINE_HEIGHT + ROW_PADDING;- }- // Multi-line: header line + all message lines + padding- return LINE_HEIGHT + lines * LINE_HEIGHT + ROW_PADDING;-};--/**- * Build a prefix-sum array of cumulative heights for variable-height virtualization.- * prefixHeights[i] = total height of rows 0..i-1 (the Y offset of row i).- * prefixHeights[n] = total height of all rows.- */-const buildPrefixHeights = (logs: LogRecord[]): number[] => {- const prefixes = new Array<number>(logs.length + 1);- prefixes[0] = 0;- for (let i = 0; i < logs.length; i++) {- prefixes[i + 1] = prefixes[i] + getRowHeight(logs[i]);- }- return prefixes;-};--/** Binary search for the first row whose bottom edge is past the given Y offset. */-const findStartIndex = (prefixHeights: number[], y: number): number => {- let lo = 0;- let hi = prefixHeights.length - 2;- while (lo < hi) {- const mid = (lo + hi) >>> 1;- if (prefixHeights[mid + 1] <= y) {- lo = mid + 1;- } else {- hi = mid;- }- }- return lo;-};--// ----------------------------------------------------------------------------// Lightweight log entry — renders multi-line messages with preserved whitespace-// -----------------------------------------------------------------------------const LogEntryRow = React.memo(({ log, style }: { log: LogRecord; style: React.CSSProperties }) => {- const [expanded, setExpanded] = useState(false);- const color = LOG_COLORS[log.levelname.toUpperCase()] || "#ccc";- const multiLine = log.message.includes("\n");-- return (- <div- style={{- ...style,- borderLeft: `2px solid ${color}`,- paddingLeft: 8,- paddingTop: ROW_PADDING / 2,- paddingBottom: ROW_PADDING / 2,- backgroundColor: expanded ? `${color}1a` : "rgba(0,0,0,0.2)",- cursor: "pointer",- fontFamily: "monospace",- fontSize: "0.85em",- lineHeight: `${LINE_HEIGHT}px`,- overflow: expanded ? "visible" : "hidden",- position: "relative",- }}- onClick={() => setExpanded((prev) => !prev)}- >- {/* Header line: timestamp + level badge + first line (or entire message if single-line) */}- <div style={{ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>- <span style={{ color: "#888", marginRight: 8, fontSize: "0.9em" }}>- {log.asctime}- </span>- <span- style={{- backgroundColor: color,- color: "#000",- padding: "1px 5px",- borderRadius: 2,- fontSize: "0.75em",- fontWeight: 600,- marginRight: 8,- display: "inline-block",- lineHeight: "normal",- verticalAlign: "middle",- }}- >- {log.levelname}- </span>- <span style={{ color: "#fff" }}>- <Linkify text={multiLine ? log.message.split("\n")[0] : log.message} />- </span>- </div>-- {/* Multi-line message body: remaining lines rendered with preserved whitespace */}- {multiLine && (- <div- style={{- whiteSpace: "pre",- color: "#fff",- paddingLeft: 4,- }}- >- <Linkify text={log.message.split("\n").slice(1).join("\n")} />- </div>- )}-- {/* Expanded overlay for log metadata (click to toggle) */}- {expanded && (- <div- style={{- position: "absolute",- top: "100%",- left: 0,- right: 0,- zIndex: 10,- backgroundColor: "#1a1a1a",- borderLeft: `2px solid ${color}`,- borderBottom: `1px solid ${color}`,- boxShadow: "0 4px 12px rgba(0,0,0,0.5)",- overflow: "auto",- maxHeight: 400,- }}- onClick={(e) => e.stopPropagation()}- >- <LogEntryDetail log={log} color={color} />- </div>- )}- </div>- );-});-LogEntryRow.displayName = "LogEntryRow";--const LogEntryDetail = ({ log, color }: { log: LogRecord; color: string }) => {- const { t } = useTranslation();-- return (- <div- style={{- paddingLeft: 16,- paddingTop: 6,- paddingBottom: 6,- fontSize: "0.8em",- color: "#888",- borderTop: "1px solid rgba(255,255,255,0.1)",- whiteSpace: "pre-wrap",- lineHeight: "1.4",- overflow: "visible",- }}- onClick={(e) => e.stopPropagation()}- >- <div>Location: {log.module}:{log.funcName}:Line#{log.lineno}</div>- <div>{t("fileLabel")}: {log.filename}</div>- <div>{t("timeDelta")}: {log.delta_t}</div>- <div>{t("pathLabel")}: <Linkify text={log.pathname} /></div>- {log.formatted_message && (- <div>{t("rawMessage")}: <Linkify text={log.formatted_message} /></div>- )}- <div>Thread: {log.threadName} (ID: {log.thread})</div>- <div>Process: {log.processName} (ID: {log.process})</div>- {(log.exc_info || log.exc_text) && (- <div>- <div>{t("exceptionDetails")}:</div>- {log.exc_info && <div><Linkify text={log.exc_info} /></div>}- {log.exc_text && <div><Linkify text={log.exc_text} /></div>}- </div>- )}- {log.stack_info && (- <div>- <div>{t("stackTrace")}:</div>- <pre- style={{- whiteSpace: "pre-wrap",- background: "#111",- padding: 8,- borderRadius: 4,- margin: "8px 0",- }}- >- <Linkify text={log.stack_info} />- </pre>- </div>- )}- </div>- );-};--// ----------------------------------------------------------------------------// Filtering-// -----------------------------------------------------------------------------function applyFilters(- entries: LogRecord[],- selectedLevels: string[],- searchText: string,-): LogRecord[] {- let filtered = entries;-- if (selectedLevels.length > 0) {- filtered = filtered.filter(log =>- selectedLevels.includes(log.levelname.toLowerCase())- );- }-- if (searchText) {- const searchLower = searchText.toLowerCase();- filtered = filtered.filter(log =>- log.message.toLowerCase().includes(searchLower) ||- log.module.toLowerCase().includes(searchLower) ||- log.funcName.toLowerCase().includes(searchLower) ||- log.formatted_message?.toLowerCase().includes(searchLower)- );- }-- return filtered;-}--// ----------------------------------------------------------------------------// LogTerminal-// -----------------------------------------------------------------------------export const LogTerminal = () => {- const theme = useTheme();- const { t } = useTranslation();- const { getLogStore } = useServer();-- const [snapshot, setSnapshot] = useState<LogSnapshot>({- entries: [],- hasErrors: false,- countsByLevel: {},- version: 0,- });-- const [isPaused, setIsPaused] = useState(false);- const [selectedLevels, setSelectedLevels] = useState<string[]>([]);- const [searchText, setSearchText] = useState<string>("");- const [showSearch, setShowSearch] = useState(false);- const [copyFeedback, setCopyFeedback] = useState(false);-- // Virtualization state- const scrollContainerRef = useRef<HTMLDivElement>(null);- const [scrollTop, setScrollTop] = useState(0);- const [containerHeight, setContainerHeight] = useState(0);- const shouldAutoScroll = useRef(true);-- /** Track last snapshot version so we skip no-op polls. */- const lastVersionRef = useRef(-1);-- // Poll the mutable LogStore on a fixed interval.- useEffect(() => {- if (isPaused) return;-- const poll = () => {- const snap = getLogStore().getSnapshot();- // Skip setState entirely if nothing changed — avoids React reconciliation- if (snap.version === lastVersionRef.current) return;- lastVersionRef.current = snap.version;- setSnapshot(snap);- };-- // Immediate snapshot when unpausing- poll();-- const interval = setInterval(poll, LOG_POLL_INTERVAL_MS);- return () => clearInterval(interval);- }, [getLogStore, isPaused]);-- const filteredLogs = applyFilters(snapshot.entries, selectedLevels, searchText);-- // Build prefix-sum height array for variable-height virtualization.- // Recomputed when filteredLogs changes (memoized to avoid recalc on scroll).- const prefixHeights = useMemo(() => buildPrefixHeights(filteredLogs), [filteredLogs]);- const totalHeight = prefixHeights[filteredLogs.length] || 0;-- // Track container height via ResizeObserver- useEffect(() => {- const container = scrollContainerRef.current;- if (!container) return;-- const observer = new ResizeObserver((entries) => {- for (const entry of entries) {- setContainerHeight(Math.round(entry.contentRect.height));- }- });- observer.observe(container);- return () => observer.disconnect();- }, []);-- // Auto-scroll to bottom when new logs arrive.- // Deferred via requestAnimationFrame so that the DOM has painted the- // updated totalHeight before we read scrollHeight — without this, the- // scroll position gets set against a stale (shorter) scrollHeight and- // then snaps back once layout catches up, causing a visible bounce.- useEffect(() => {- if (!isPaused && shouldAutoScroll.current && scrollContainerRef.current) {- requestAnimationFrame(() => {- const el = scrollContainerRef.current;- if (el) {- el.scrollTop = el.scrollHeight;- }- });- }- }, [filteredLogs, isPaused]);-- const handleScroll = useCallback(() => {- const el = scrollContainerRef.current;- if (!el) return;- setScrollTop(el.scrollTop);- // Tight tolerance (< 2px) accounts for sub-pixel rounding while- // ensuring the user must be truly at the bottom to re-engage- // auto-scroll. A large tolerance causes auto-scroll to stay active- // when the user is trying to read entries near the bottom.- const isAtBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 2;- shouldAutoScroll.current = isAtBottom;- }, []);-- const scrollToBottom = useCallback(() => {- const el = scrollContainerRef.current;- if (el) {- el.scrollTop = el.scrollHeight;- shouldAutoScroll.current = true;- }- }, []);-- // Compute visible row window using variable-height prefix sums- const startIdx = Math.max(0, findStartIndex(prefixHeights, scrollTop) - OVERSCAN);- const endScrollTop = scrollTop + containerHeight;- const endIdx = Math.min(filteredLogs.length, findStartIndex(prefixHeights, endScrollTop) + 1 + OVERSCAN);- const offsetY = prefixHeights[startIdx];-- const formatLogsForExport = useCallback((): string => {- return filteredLogs.map((log) =>- `[${log.asctime}] [${log.levelname}] ${log.module}:${log.funcName}:${log.lineno} - ${log.message}`- ).join('\n');- }, [filteredLogs]);-- const handleCopyToClipboard = useCallback(async () => {- const text = formatLogsForExport();- await navigator.clipboard.writeText(text);- setCopyFeedback(true);- setTimeout(() => setCopyFeedback(false), 2000);- }, [formatLogsForExport]);-- const handleSaveToDisk = useCallback(() => {- const text = formatLogsForExport();- const blob = new Blob([text], { type: 'text/plain' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = `freemocap-logs-${new Date().toISOString().replace(/[:.]/g, '-')}.txt`;- document.body.appendChild(a);- a.click();- document.body.removeChild(a);- URL.revokeObjectURL(url);- }, [formatLogsForExport]);-- const handleLevelToggle = (_: React.MouseEvent<HTMLElement>, newLevels: string[]): void => {- setSelectedLevels(newLevels);- };-- const handlePauseToggle = (): void => {- setIsPaused(prev => !prev);- };-- const handleClear = (): void => {- getLogStore().clear();- setSelectedLevels([]);- setSearchText("");- setShowSearch(false);- setIsPaused(false);- lastVersionRef.current = -1;- setSnapshot({ entries: [], hasErrors: false, countsByLevel: {}, version: 0 });- };-- return (- <Box- sx={{- height: "100%",- display: "flex",- flexDirection: "column",- backgroundColor:- theme.palette.mode === "dark" ? "#1a1a1a" : theme.palette.grey[100],- }}- >- {/* Toolbar */}- <Box- sx={{- p: 0.5,- borderBottom: "1px solid",- borderColor: theme.palette.divider,- display: "flex",- gap: 1,- alignItems: "center",- flexWrap: "wrap",- }}- >- <span- style={{- color: theme.palette.text.primary,- fontSize: "0.9em",- fontWeight: "bold",- }}- >- {t('serverLogs')}- </span>-- {snapshot.hasErrors && (- <Tooltip title={t("errorsDetected")}>- <WarningIcon- sx={{- color: LOG_COLORS.ERROR,- fontSize: "1.2em",- animation: "pulse 2s infinite",- "@keyframes pulse": {- "0%, 100%": { opacity: 1 },- "50%": { opacity: 0.5 },- },- }}- />- </Tooltip>- )}-- <ToggleButtonGroup- size="small"- value={selectedLevels}- onChange={handleLevelToggle}- sx={{- ".MuiToggleButtonGroup-grouped": {- border: `1px solid ${theme.palette.divider} !important`,- mx: "1px",- "&:not(:first-of-type)": {- borderRadius: "2px",- },- "&:first-of-type": {- borderRadius: "2px",- },- },- }}- >- {Object.entries(LOG_COLORS).map(([level, color]) => {- const count = snapshot.countsByLevel[level] || 0;- return (- <ToggleButton- key={level}- value={level.toLowerCase()}- sx={{- py: 0.25,- px: 1,- minWidth: 0,- fontSize: "0.75em",- position: "relative",- color: alpha(color, 0.7),- "&.Mui-selected": {- backgroundColor: alpha(color, 0.15),- color: color,- "&:hover": {- backgroundColor: alpha(color, 0.2),- },- },- "&:hover": {- backgroundColor: alpha(color, 0.1),- },- }}- >- {level}- {count > 0 && (- <span- style={{- marginLeft: "4px",- fontSize: "0.8em",- opacity: 0.7,- }}- >- ({count})- </span>- )}- </ToggleButton>- );- })}- </ToggleButtonGroup>-- <Box sx={{ ml: "auto", display: "flex", gap: 0.5 }}>- <Tooltip title={copyFeedback ? t("copied") : t("copyLogsToClipboard")}>- <IconButton- size="small"- onClick={handleCopyToClipboard}- sx={{ color: copyFeedback ? theme.palette.success.main : theme.palette.text.secondary }}- >- <ContentCopyIcon fontSize="small" />- </IconButton>- </Tooltip>-- <Tooltip title={t("saveLogsToFile")}>- <IconButton- size="small"- onClick={handleSaveToDisk}- sx={{ color: theme.palette.text.secondary }}- >- <SaveIcon fontSize="small" />- </IconButton>- </Tooltip>-- <Tooltip title="Scroll to bottom">- <IconButton- size="small"- onClick={scrollToBottom}- sx={{ color: theme.palette.text.secondary }}- >- <ScrollToBottomIcon fontSize="small" />- </IconButton>- </Tooltip>-- <IconButton- size="small"- onClick={() => setShowSearch(!showSearch)}- sx={{ color: theme.palette.text.secondary }}- >- <SearchIcon fontSize="small" />- </IconButton>-- <IconButton- size="small"- onClick={handlePauseToggle}- sx={{- color: isPaused ? theme.palette.warning.main : theme.palette.text.secondary- }}- >- {isPaused ? <PlayArrowIcon fontSize="small" /> : <PauseIcon fontSize="small" />}- </IconButton>-- <IconButton- size="small"- onClick={handleClear}- sx={{ color: theme.palette.text.secondary }}- >- <DeleteSweepIcon fontSize="small" />- </IconButton>- </Box>- </Box>-- {showSearch && (- <Box sx={{ p: 1, borderBottom: "1px solid", borderColor: theme.palette.divider }}>- <TextField- size="small"- fullWidth- placeholder={t("searchLogs")}- value={searchText}- onChange={(e) => setSearchText(e.target.value)}- InputProps={{- startAdornment: <SearchIcon sx={{ mr: 1, color: "text.secondary" }} />,- }}- />- </Box>- )}-- {/* Virtualized log list */}- <div- ref={scrollContainerRef}- onScroll={handleScroll}- style={{- flex: 1,- overflowY: "auto",- overflowX: "auto",- position: "relative",- scrollbarWidth: "thin" as any,- scrollbarColor:- theme.palette.mode === "dark"- ? "rgba(255, 255, 255, 0.2) transparent"- : "rgba(0, 0, 0, 0.2) transparent",- }}- >- {filteredLogs.length === 0 ? (- <div- style={{- display: "flex",- justifyContent: "center",- alignItems: "center",- height: "100%",- color: theme.palette.text.disabled,- }}- >- {isPaused ? t("loggingPaused") : t("noLogsToDisplay")}- </div>- ) : (- // Outer div creates the full scrollable height- <div style={{ height: totalHeight, position: "relative" }}>- {/* Inner div is offset to the first visible row */}- <div- style={{- position: "absolute",- top: offsetY,- left: 0,- right: 0,- }}- >- {filteredLogs.slice(startIdx, endIdx).map((log, i) => {- const rowIdx = startIdx + i;- const rowHeight = prefixHeights[rowIdx + 1] - prefixHeights[rowIdx];- return (- <LogEntryRow- key={`${log.created}-${log.thread}-${rowIdx}`}- log={log}- style={{ height: rowHeight }}- />- );- })}- </div>- </div>- )}- </div>- </Box>- );-};diff --git a/freemocap-ui/src/components/ServerConnectionStatus.tsx b/freemocap-ui/src/components/ServerConnectionStatus.tsxdeleted file mode 100644index 632f84d0..00000000--- a/freemocap-ui/src/components/ServerConnectionStatus.tsx+++ /dev/null@@ -1,767 +0,0 @@-import React, {useCallback, useEffect, useRef, useState} from 'react';-import {- Box,- Button,- Chip,- CircularProgress,- Collapse,- FormControl,- FormControlLabel,- IconButton,- InputLabel,- MenuItem,- Select,- Switch,- TextField,- Tooltip,- Typography,-} from '@mui/material';-import {useTheme} from '@mui/material/styles';-import WifiIcon from '@mui/icons-material/Wifi';-import WifiOffIcon from '@mui/icons-material/WifiOff';-import PlayArrowIcon from '@mui/icons-material/PlayArrow';-import StopIcon from '@mui/icons-material/Stop';-import RestartAltIcon from '@mui/icons-material/RestartAlt';-import ExpandMoreIcon from '@mui/icons-material/ExpandMore';-import ExpandLessIcon from '@mui/icons-material/ExpandLess';-import RefreshIcon from '@mui/icons-material/Refresh';-import FolderOpenIcon from '@mui/icons-material/FolderOpen';-import {useServer} from '@/services/server/ServerContextProvider';-import {useTranslation} from "react-i18next";-import {useElectronIPC} from '@/services';-import {DEFAULT_HOST, DEFAULT_PORT} from '@/constants/server-urls';--interface ExecutableCandidate {- name: string;- path: string;- description: string;- isValid?: boolean;- error?: string;- resolvedPath?: string;-}--const AUTO_CONNECT_DELAY_MS = 2000;-const WS_RECONNECT_INTERVAL_MS = 3000;--const STORAGE_KEYS = {- SELECTED_EXE_PATH: 'freemocap:selectedExePath',- PANEL_EXPANDED: 'freemocap:serverPanelExpanded',- AUTO_LAUNCH_SERVER: 'freemocap:autoLaunchServer',- AUTO_CONNECT_WS: 'freemocap:autoConnectWs',- SERVER_HOST: 'freemocap:serverHost',- SERVER_PORT: 'freemocap:serverPort',-} as const;--function loadFromStorage<T>(key: string, fallback: T): T {- try {- const raw = localStorage.getItem(key);- if (raw === null) return fallback;- return JSON.parse(raw) as T;- } catch {- return fallback;- }-}--function saveToStorage(key: string, value: unknown): void {- try {- localStorage.setItem(key, JSON.stringify(value));- } catch (err) {- console.error(`Failed to save ${key} to localStorage:`, err);- }-}--export const ServerConnectionStatus: React.FC = () => {- const theme = useTheme();- const { isConnected, connect, disconnect, connectedCameraIds, updateServerConnection } = useServer();- const { t } = useTranslation();- const { isElectron, api } = useElectronIPC();-- // Persisted UI state- const [expanded, setExpanded] = useState(() => loadFromStorage(STORAGE_KEYS.PANEL_EXPANDED, false));- const [selectedExePath, setSelectedExePath] = useState(() => loadFromStorage(STORAGE_KEYS.SELECTED_EXE_PATH, ''));- const [autoLaunchServer, setAutoLaunchServer] = useState(() => loadFromStorage(STORAGE_KEYS.AUTO_LAUNCH_SERVER, true));- const [autoConnectWs, setAutoConnectWs] = useState(() => loadFromStorage(STORAGE_KEYS.AUTO_CONNECT_WS, true));- const [serverHost, setServerHost] = useState(() => loadFromStorage(STORAGE_KEYS.SERVER_HOST, DEFAULT_HOST));- const [serverPort, setServerPort] = useState(() => loadFromStorage(STORAGE_KEYS.SERVER_PORT, DEFAULT_PORT));-- // Text field drafts (applied on blur/enter so we don't reconnect on every keystroke)- const [hostDraft, setHostDraft] = useState(serverHost);- const [portDraft, setPortDraft] = useState(String(serverPort));-- // Transient state- const [serverRunning, setServerRunning] = useState(false);- const [serverLoading, setServerLoading] = useState(false);- const [currentExePath, setCurrentExePath] = useState<string | null>(null);- const [candidates, setCandidates] = useState<ExecutableCandidate[]>([]);- const [candidatesLoading, setCandidatesLoading] = useState(false);- const [processInfo, setProcessInfo] = useState<{ pid: number | undefined; killed: boolean } | null>(null);- const [error, setError] = useState<string | null>(null);-- // Track whether the initial auto-launch has been attempted so we only fire once- const autoLaunchFiredRef = useRef(false);- // Guard against concurrent startServer calls from the auto-launch effect- const serverLaunchingRef = useRef(false);-- // ── Persistence effects ──-- useEffect(() => { saveToStorage(STORAGE_KEYS.PANEL_EXPANDED, expanded); }, [expanded]);- useEffect(() => { saveToStorage(STORAGE_KEYS.SELECTED_EXE_PATH, selectedExePath); }, [selectedExePath]);- useEffect(() => { saveToStorage(STORAGE_KEYS.AUTO_LAUNCH_SERVER, autoLaunchServer); }, [autoLaunchServer]);- useEffect(() => { saveToStorage(STORAGE_KEYS.AUTO_CONNECT_WS, autoConnectWs); }, [autoConnectWs]);- useEffect(() => { saveToStorage(STORAGE_KEYS.SERVER_HOST, serverHost); }, [serverHost]);- useEffect(() => { saveToStorage(STORAGE_KEYS.SERVER_PORT, serverPort); }, [serverPort]);-- // Apply persisted host/port to the server connection on mount- useEffect(() => {- updateServerConnection(serverHost, serverPort);- }, []); // eslint-disable-line react-hooks/exhaustive-deps-- // ── Server status polling ──-- const pollServerStatus = useCallback(async () => {- if (!isElectron || !api) return;- try {- const running = await api.pythonServer.isRunning.query();- setServerRunning(running);- const info = await api.pythonServer.getProcessInfo.query();- setProcessInfo(info);- const exePath = await api.pythonServer.getExecutablePath.query();- setCurrentExePath(exePath);- } catch (err) {- console.error('Failed to poll server status:', err);- }- }, [isElectron, api]);-- // ── Candidate management ──-- const loadCandidates = useCallback(async () => {- if (!isElectron || !api) return;- setCandidatesLoading(true);- try {- const result = await api.pythonServer.getExecutableCandidates.query();- const typed = result as ExecutableCandidate[];- setCandidates(typed);- if (!selectedExePath) {- const firstValid = typed.find((c) => c.isValid);- if (firstValid) {- setSelectedExePath(firstValid.path);- }- }- } catch (err) {- console.error('Failed to load executable candidates:', err);- setError(`Failed to load candidates: ${err instanceof Error ? err.message : String(err)}`);- } finally {- setCandidatesLoading(false);- }- }, [isElectron, api, selectedExePath]);-- const refreshCandidates = useCallback(async () => {- if (!isElectron || !api) return;- setCandidatesLoading(true);- setError(null);- try {- const result = await api.pythonServer.refreshCandidates.mutate();- const typed = result as ExecutableCandidate[];- setCandidates(typed);- const firstValid = typed.find((c) => c.isValid);- if (firstValid) {- setSelectedExePath(firstValid.path);- }- } catch (err) {- console.error('Failed to refresh candidates:', err);- setError(`Failed to refresh: ${err instanceof Error ? err.message : String(err)}`);- } finally {- setCandidatesLoading(false);- }- }, [isElectron, api]);-- const browseForExecutable = useCallback(async () => {- if (!isElectron || !api) return;- try {- const filePath = await api.fileSystem.selectExecutableFile.mutate();- if (filePath) {- setSelectedExePath(filePath);- }- } catch (err) {- console.error('Failed to browse for executable:', err);- setError(`Browse failed: ${err instanceof Error ? err.message : String(err)}`);- }- }, [isElectron, api]);-- // ── Server actions ──-- const startServer = useCallback(async () => {- if (!isElectron || !api) return;- if (serverLaunchingRef.current) return;- serverLaunchingRef.current = true;- setServerLoading(true);- setError(null);- try {- const exePath = selectedExePath || null;- await api.pythonServer.start.mutate({ exePath });- await pollServerStatus();- } catch (err) {- console.error('Failed to start server:', err);- setError(`Start failed: ${err instanceof Error ? err.message : String(err)}`);- } finally {- setServerLoading(false);- serverLaunchingRef.current = false;- }- }, [isElectron, api, selectedExePath, pollServerStatus]);-- const stopServer = useCallback(async () => {- if (!isElectron || !api) return;- setServerLoading(true);- setError(null);- try {- disconnect();- await api.pythonServer.stop.mutate();- await pollServerStatus();- } catch (err) {- console.error('Failed to stop server:', err);- setError(`Stop failed: ${err instanceof Error ? err.message : String(err)}`);- } finally {- setServerLoading(false);- }- }, [isElectron, api, pollServerStatus, disconnect]);-- const resetServer = useCallback(async () => {- if (!isElectron || !api) return;- setServerLoading(true);- setError(null);- try {- disconnect();- await api.pythonServer.stop.mutate();- await new Promise((resolve) => setTimeout(resolve, 500));- const exePath = selectedExePath || null;- await api.pythonServer.start.mutate({ exePath });- await pollServerStatus();- } catch (err) {- console.error('Failed to reset server:', err);- setError(`Reset failed: ${err instanceof Error ? err.message : String(err)}`);- } finally {- setServerLoading(false);- }- }, [isElectron, api, selectedExePath, pollServerStatus, disconnect]);-- // ── Initial load: poll status + load candidates ──-- useEffect(() => {- if (isElectron && api) {- pollServerStatus();- loadCandidates();- }- }, [isElectron, api, pollServerStatus, loadCandidates]);-- // ── Poll server status periodically ──-- useEffect(() => {- if (!isElectron || !api) return;- const interval = setInterval(pollServerStatus, 5000);- return () => clearInterval(interval);- }, [isElectron, api, pollServerStatus]);-- // ── Auto-launch server on mount (once) ──- // Waits for candidates to be loaded so selectedExePath is populated,- // then fires a single launch attempt if the server is not already running.-- useEffect(() => {- if (!isElectron || !api) return;- if (!autoLaunchServer) return;- if (autoLaunchFiredRef.current) return;- if (candidatesLoading) return; // wait for candidates to load- if (serverRunning || serverLoading) return;-- autoLaunchFiredRef.current = true;- console.log('Auto-launching server...');- startServer();- }, [isElectron, api, autoLaunchServer, candidatesLoading, serverRunning, serverLoading, startServer]);-- // ── WebSocket auto-reconnect loop ──- // When autoConnectWs is on and we're not connected, periodically call connect().- // The underlying WebSocketConnection handles deduplication of CONNECTING state.-- useEffect(() => {- if (!autoConnectWs) return;- if (isConnected) return;-- // Fire one immediate attempt- connect();-- const interval = setInterval(() => {- if (!isConnected) {- connect();- }- }, WS_RECONNECT_INTERVAL_MS);-- return () => clearInterval(interval);- }, [autoConnectWs, isConnected, connect]);-- // ── Toggle handlers ──-- const handleToggleAutoLaunch = useCallback((e: React.MouseEvent) => {- e.stopPropagation();- setAutoLaunchServer((prev) => !prev);- }, []);-- const handleToggleAutoConnectWs = useCallback((e: React.MouseEvent) => {- e.stopPropagation();- setAutoConnectWs((prev) => {- const next = !prev;- if (!next) {- // User is turning off auto-connect — disconnect now- disconnect();- }- return next;- });- }, [disconnect]);-- const handleToggleServerRunning = useCallback((e: React.MouseEvent) => {- e.stopPropagation();- if (serverRunning) {- stopServer();- } else {- startServer();- }- }, [serverRunning, startServer, stopServer]);-- const handleToggleWsConnected = useCallback((e: React.MouseEvent) => {- e.stopPropagation();- if (isConnected) {- // Turn off auto-connect so it doesn't immediately reconnect- setAutoConnectWs(false);- disconnect();- } else {- setAutoConnectWs(true);- connect();- }- }, [isConnected, connect, disconnect]);-- const applyHostPort = useCallback(() => {- const trimmedHost = hostDraft.trim();- const parsedPort = parseInt(portDraft, 10);- if (!trimmedHost) return;- if (isNaN(parsedPort) || parsedPort < 1 || parsedPort > 65535) return;-- setServerHost(trimmedHost);- setServerPort(parsedPort);- updateServerConnection(trimmedHost, parsedPort);- }, [hostDraft, portDraft, updateServerConnection]);-- const handleHostPortKeyDown = useCallback((e: React.KeyboardEvent) => {- if (e.key === 'Enter') {- applyHostPort();- }- }, [applyHostPort]);-- // ── Derived values ──-- const wsStatusColor = isConnected ? '#00ffff' : '#f44336';- const serverStatusColor = serverRunning ? theme.palette.success.main : theme.palette.text.disabled;-- const validCandidates = candidates.filter((c) => c.isValid);- const invalidCandidates = candidates.filter((c) => !c.isValid);-- // ── Render ──-- return (- <Box- sx={{- borderBottom: `1px solid ${theme.palette.divider}`,- backgroundColor: theme.palette.mode === 'dark'- ? 'rgba(0, 0, 0, 0.2)'- : 'rgba(0, 0, 0, 0.02)',- }}- >- {/* ── Collapsed summary row ── */}- <Box- onClick={() => setExpanded((prev) => !prev)}- sx={{- display: 'flex',- alignItems: 'center',- gap: 0.5,- px: 1.5,- py: 0.5,- cursor: 'pointer',- '&:hover': { backgroundColor: 'rgba(255,255,255,0.03)' },- }}- >- {/* Status labels */}- <Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, flex: 1, minWidth: 0 }}>- {/* WS toggle button */}- <Tooltip title={isConnected ? t('disconnectWebSocket') : t('connectWebSocket')}>- <IconButton- size="small"- onClick={handleToggleWsConnected}- sx={{ p: 0.25, color: wsStatusColor }}- >- {isConnected ? (- <WifiIcon sx={{ fontSize: 16 }} />- ) : (- <WifiOffIcon sx={{ fontSize: 16 }} />- )}- </IconButton>- </Tooltip>-- <Typography- variant="caption"- sx={{ fontWeight: 500, color: wsStatusColor, whiteSpace: 'nowrap', fontSize: '0.7rem' }}- >- {isConnected ? t('connected') : autoConnectWs ? t('connecting') : t('off')}- </Typography>-- {isElectron && (- <>- <Box sx={{ mx: 0.25, color: theme.palette.text.disabled, fontSize: '0.7rem' }}>|</Box>-- {/* Server toggle button */}- <Tooltip title={serverRunning ? t('stopServer') : t('launchServer')}>- <IconButton- size="small"- onClick={handleToggleServerRunning}- disabled={serverLoading}- sx={{ p: 0.25, color: serverStatusColor }}- >- {serverLoading ? (- <CircularProgress size={14} />- ) : serverRunning ? (- <StopIcon sx={{ fontSize: 16 }} />- ) : (- <PlayArrowIcon sx={{ fontSize: 16 }} />- )}- </IconButton>- </Tooltip>-- <Typography- variant="caption"- sx={{ fontWeight: 500, color: serverStatusColor, whiteSpace: 'nowrap', fontSize: '0.7rem' }}- >- {serverLoading ? t('working') : serverRunning ? t('running') : t('stopped')}- </Typography>- </>- )}-- {isConnected && connectedCameraIds.length > 0 && (- <Chip- label={`${connectedCameraIds.length} cam${connectedCameraIds.length !== 1 ? 's' : ''}`}- size="small"- sx={{- height: 18,- fontSize: '0.6rem',- ml: 0.5,- backgroundColor: 'rgba(0, 255, 255, 0.1)',- color: '#00ffff',- }}- />- )}- </Box>-- {expanded ? (- <ExpandLessIcon sx={{ fontSize: 16, color: theme.palette.text.secondary }} />- ) : (- <ExpandMoreIcon sx={{ fontSize: 16, color: theme.palette.text.secondary }} />- )}- </Box>-- {/* ── Expanded panel ── */}- <Collapse in={expanded}>- <Box sx={{ px: 1.5, pb: 1.5, display: 'flex', flexDirection: 'column', gap: 1.5 }}>- {/* ── Server Process Section (Electron only) ── */}- {isElectron && (- <Box sx={{ border: `1px solid ${theme.palette.divider}`, borderRadius: 1, p: 1 }}>- <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 0.5 }}>- <Typography- variant="caption"- sx={{ fontWeight: 600, color: theme.palette.text.secondary }}- >- SERVER PROCESS- </Typography>- <FormControlLabel- control={- <Switch- size="small"- checked={autoLaunchServer}- onClick={handleToggleAutoLaunch}- onChange={() => {}} // controlled via onClick with stopPropagation- />- }- label={- <Typography variant="caption" sx={{ fontSize: '0.65rem', color: theme.palette.text.secondary }}>- {t('autoLaunch')}- </Typography>- }- sx={{ mr: 0, ml: 0, height: 24 }}- labelPlacement="start"- />- </Box>-- {/* Status line */}- <Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, mb: 1 }}>- <Box- sx={{- width: 8,- height: 8,- borderRadius: '50%',- backgroundColor: serverRunning- ? theme.palette.success.main- : theme.palette.error.main,- }}- />- <Typography variant="caption" sx={{ color: theme.palette.text.primary }}>- {serverRunning ? t('running') : t('stopped')}- {processInfo?.pid && ` (PID: ${processInfo.pid})`}- </Typography>- </Box>-- {/* Executable selector */}- <FormControl fullWidth size="small" sx={{ mb: 1 }}>- <InputLabel sx={{ fontSize: '0.75rem' }}>{t('executable')}</InputLabel>- <Select- value={selectedExePath}- onChange={(e) => setSelectedExePath(e.target.value)}- label={t("executable")}- disabled={serverRunning || serverLoading}- sx={{ fontSize: '0.75rem' }}- >- {validCandidates.map((candidate) => (- <MenuItem key={candidate.path} value={candidate.path} sx={{ fontSize: '0.75rem' }}>- <Box>- <Typography variant="caption" sx={{ fontWeight: 600 }}>- {candidate.name}- </Typography>- <Typography- variant="caption"- sx={{- display: 'block',- color: theme.palette.text.secondary,- fontSize: '0.65rem',- overflow: 'hidden',- textOverflow: 'ellipsis',- whiteSpace: 'nowrap',- maxWidth: 250,- }}- >- {candidate.path}- </Typography>- </Box>- </MenuItem>- ))}- {invalidCandidates.length > 0 && validCandidates.length > 0 && (- <MenuItem disabled divider sx={{ fontSize: '0.65rem', opacity: 0.5 }}>- — invalid —- </MenuItem>- )}- {invalidCandidates.map((candidate) => (- <MenuItem- key={candidate.path}- value={candidate.path}- disabled- sx={{ fontSize: '0.75rem', opacity: 0.4 }}- >- <Tooltip title={candidate.error || t('invalid')} placement="right">- <Typography variant="caption">- {candidate.name} — {candidate.error || 'not found'}- </Typography>- </Tooltip>- </MenuItem>- ))}- </Select>- </FormControl>-- {/* Browse + Refresh row */}- <Box sx={{ display: 'flex', gap: 0.5, mb: 1 }}>- <Tooltip title={t('browseForExecutable')}>- <IconButton- size="small"- onClick={browseForExecutable}- disabled={serverRunning || serverLoading}- sx={{ border: `1px solid ${theme.palette.divider}`, borderRadius: 1 }}- >- <FolderOpenIcon sx={{ fontSize: 16 }} />- </IconButton>- </Tooltip>- <Tooltip title={t('refreshCandidates')}>- <IconButton- size="small"- onClick={refreshCandidates}- disabled={serverRunning || candidatesLoading}- sx={{ border: `1px solid ${theme.palette.divider}`, borderRadius: 1 }}- >- {candidatesLoading ? (- <CircularProgress size={14} />- ) : (- <RefreshIcon sx={{ fontSize: 16 }} />- )}- </IconButton>- </Tooltip>- </Box>-- {/* Action buttons */}- <Box sx={{ display: 'flex', gap: 0.5 }}>- <Button- variant="contained"- size="small"- color="success"- startIcon={serverLoading ? <CircularProgress size={14} color="inherit" /> : <PlayArrowIcon />}- onClick={() => startServer()}- disabled={serverRunning || serverLoading}- sx={{ flex: 1, fontSize: '0.7rem', textTransform: 'none' }}- >- Launch- </Button>- <Button- variant="contained"- size="small"- color="error"- startIcon={serverLoading ? <CircularProgress size={14} color="inherit" /> : <StopIcon />}- onClick={() => stopServer()}- disabled={!serverRunning || serverLoading}- sx={{ flex: 1, fontSize: '0.7rem', textTransform: 'none' }}- >- Stop- </Button>- <Button- variant="outlined"- size="small"- startIcon={serverLoading ? <CircularProgress size={14} /> : <RestartAltIcon />}- onClick={() => resetServer()}- disabled={!serverRunning || serverLoading}- sx={{ flex: 1, fontSize: '0.7rem', textTransform: 'none' }}- >- Reset- </Button>- </Box>-- {/* Running executable path */}- {currentExePath && (- <Tooltip title={currentExePath} placement="bottom">- <Typography- variant="caption"- sx={{- mt: 0.5,- display: 'block',- color: theme.palette.text.secondary,- fontSize: '0.6rem',- overflow: 'hidden',- textOverflow: 'ellipsis',- whiteSpace: 'nowrap',- }}- >- {t('runningPath', { path: currentExePath })}- </Typography>- </Tooltip>- )}-- {/* Error display */}- {error && (- <Typography- variant="caption"- sx={{- mt: 0.5,- display: 'block',- color: theme.palette.error.main,- fontSize: '0.65rem',- wordBreak: 'break-word',- }}- >- {error}- </Typography>- )}- </Box>- )}-- {/* ── WebSocket Section ── */}- <Box sx={{ border: `1px solid ${theme.palette.divider}`, borderRadius: 1, p: 1 }}>- <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 0.5 }}>- <Typography- variant="caption"- sx={{ fontWeight: 600, color: theme.palette.text.secondary }}- >- WEBSOCKET CONNECTION- </Typography>- <FormControlLabel- control={- <Switch- size="small"- checked={autoConnectWs}- onClick={handleToggleAutoConnectWs}- onChange={() => {}}- />- }- label={- <Typography variant="caption" sx={{ fontSize: '0.65rem', color: theme.palette.text.secondary }}>- {t('autoConnect')}- </Typography>- }- sx={{ mr: 0, ml: 0, height: 24 }}- labelPlacement="start"- />- </Box>-- {/* Host / Port inputs */}- <Box sx={{ display: 'flex', gap: 0.5, mb: 1 }}>- <TextField- size="small"- label={t("host")}- value={hostDraft}- onChange={(e) => setHostDraft(e.target.value)}- onBlur={applyHostPort}- onKeyDown={handleHostPortKeyDown}- disabled={isConnected}- slotProps={{ inputLabel: { sx: { fontSize: '0.7rem' } }, input: { sx: { fontSize: '0.75rem' } } }}- sx={{ flex: 3 }}- />- <TextField- size="small"- label={t("port")}- type="number"- value={portDraft}- onChange={(e) => setPortDraft(e.target.value)}- onBlur={applyHostPort}- onKeyDown={handleHostPortKeyDown}- disabled={isConnected}- slotProps={{- inputLabel: { sx: { fontSize: '0.7rem' } },- input: { sx: { fontSize: '0.75rem' } },- htmlInput: { min: 1, max: 65535 },- }}- sx={{ flex: 1 }}- />- </Box>-- <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>- <Box- sx={{- width: 8,- height: 8,- borderRadius: '50%',- backgroundColor: isConnected ? '#00ffff' : theme.palette.error.main,- }}- />- <Typography variant="caption" sx={{ color: theme.palette.text.primary, flex: 1 }}>- {isConnected ? t('connected') : autoConnectWs ? t('connecting') : t('disconnected')}- {isConnected && connectedCameraIds.length > 0- ? ` — ${connectedCameraIds.length} camera${connectedCameraIds.length !== 1 ? 's' : ''}`- : ''}- </Typography>-- <Button- variant={isConnected ? 'outlined' : 'contained'}- size="small"- color={isConnected ? 'error' : 'info'}- startIcon={isConnected ? <WifiOffIcon /> : <WifiIcon />}- onClick={(e) => {- e.stopPropagation();- handleToggleWsConnected(e);- }}- sx={{ fontSize: '0.7rem', textTransform: 'none' }}- >- {isConnected ? t('disconnect') : t('connect')}- </Button>- </Box>- </Box>- </Box>- </Collapse>- </Box>- );-};diff --git a/freemocap-ui/src/components/camera-views/CameraView.tsx b/freemocap-ui/src/components/camera-views/CameraView.tsxindex 73b3f7b1..76e3c5cf 100644--- a/freemocap-ui/src/components/camera-views/CameraView.tsx+++ b/freemocap-ui/src/components/camera-views/CameraView.tsx@@ -1,8 +1,10 @@import React, {memo, useEffect, useMemo, useRef} from 'react';import {useServer} from '@/services/server/ServerContextProvider';import {backendColor, frontendColor} from '@/components/framerate-viewer/FrameRateViewer';+import {useZoomTransform} from '@/hooks/useZoomTransform';interface CameraViewProps {+ cameraIndex: number;cameraId: string;scale?: number;maxWidth?: boolean;@@ -16,13 +18,18 @@ const FPS_UPDATE_INTERVAL_MS = 250;* Wrapped in memo to prevent re-renders when props haven't changed.* FPS display uses direct DOM manipulation via a low-frequency setInterval* instead of a per-component requestAnimationFrame loop.+ *+ * Zoom is provided by useZoomTransform (scroll-to-zoom, drag-to-pan, pinch-to-zoom).*/-export const CameraView: React.FC<CameraViewProps> = memo(({ cameraId, scale, maxWidth }) => {+export const CameraView: React.FC<CameraViewProps> = memo(({cameraIndex, cameraId, scale, maxWidth }) => {const canvasRef = useRef<HTMLCanvasElement>(null);const displayFpsRef = useRef<HTMLSpanElement>(null);const serverFpsRef = useRef<HTMLSpanElement>(null);+ const containerRef = useRef<HTMLDivElement>(null);const { setCanvasForCamera, getFps, getServerFps } = useServer();+ const { zoomWrapperStyle, cursor, containerHandlers } = useZoomTransform(containerRef);+useEffect(() => {const canvas = canvasRef.current;@@ -64,6 +71,7 @@ export const CameraView: React.FC<CameraViewProps> = memo(({ cameraId, scale, mareturn (<div+ ref={containerRef}style={{width: '100%',height: '100%',@@ -73,13 +81,17 @@ export const CameraView: React.FC<CameraViewProps> = memo(({ cameraId, scale, majustifyContent: 'center',backgroundColor: '#000',position: 'relative',- overflow: 'hidden'+ overflow: 'hidden',+ cursor,}}+ {...containerHandlers}>- <canvas- ref={canvasRef}- style={canvasStyle}- />+ <div style={zoomWrapperStyle}>+ <canvas+ ref={canvasRef}+ style={canvasStyle}+ />+ </div><divstyle={{position: 'absolute',@@ -94,8 +106,8 @@ export const CameraView: React.FC<CameraViewProps> = memo(({ cameraId, scale, malineHeight: 1.4,}}>- <div>{cameraId}</div><div style={{ fontSize: '10px', marginTop: '2px', display: 'flex', gap: '6px' }}>+ <span style={{color:'#aaa'}}>#{cameraIndex} - {cameraId}</span><span style={{ color: frontendColor }}>D:<span ref={displayFpsRef}>--</span></span>diff --git a/freemocap-ui/src/components/camera-views/CameraViewWithOverlay.tsx b/freemocap-ui/src/components/camera-views/CameraViewWithOverlay.tsxnew file mode 100644index 00000000..24222240--- /dev/null+++ b/freemocap-ui/src/components/camera-views/CameraViewWithOverlay.tsx@@ -0,0 +1,278 @@+import React, {useState} from 'react';+import {Box, CircularProgress, IconButton, Tooltip, Typography} from '@mui/material';+import RotateRightIcon from '@mui/icons-material/RotateRight';+import BrightnessHighIcon from '@mui/icons-material/BrightnessHigh';+import BrightnessLowIcon from '@mui/icons-material/BrightnessLow';+import WbIncandescentIcon from '@mui/icons-material/WbIncandescent';+import BrightnessAutoIcon from '@mui/icons-material/BrightnessAuto';+import SyncIcon from '@mui/icons-material/Sync';+import SyncDisabledIcon from '@mui/icons-material/SyncDisabled';+import CheckIcon from '@mui/icons-material/Check';+import {useAppDispatch, useAppSelector} from '@/store/hooks';+import {selectCameraById} from '@/store/slices/cameras/cameras-selectors';+import {cameraDesiredConfigUpdated, autoApplyToggled} from '@/store/slices/cameras/cameras-slice';+import {camerasConnectOrUpdate} from '@/store/slices/cameras/cameras-thunks';+import {ROTATION_DEGREE_LABELS, ROTATION_OPTIONS, RotationValue} from '@/store/slices/cameras/cameras-types';+import {CameraView} from './CameraView';++const EXPOSURE_MIN = -13;+const EXPOSURE_MAX = -4;++interface CameraViewWithOverlayProps {+ cameraIndex: number;+ cameraId: string;+ isLoading: boolean;+ isAutoApply: boolean;+}++export const CameraViewWithOverlay: React.FC<CameraViewWithOverlayProps> = ({cameraIndex, cameraId, isLoading, isAutoApply}) => {+ const dispatch = useAppDispatch();+ const [hovered, setHovered] = useState(false);+ const [isApplying, setIsApplying] = useState(false);+ const camera = useAppSelector(state => selectCameraById(state, cameraId));+ const desiredConfig = camera?.desiredConfig;++ const rotation = desiredConfig?.rotation as RotationValue ?? -1;+ const exposure = desiredConfig?.exposure ?? -7;+ const exposureMode = desiredConfig?.exposure_mode ?? 'MANUAL';++ const handleRotate = () => {+ if (!desiredConfig) return;+ const idx = ROTATION_OPTIONS.indexOf(rotation);+ const next = ROTATION_OPTIONS[(idx + 1) % ROTATION_OPTIONS.length];+ dispatch(cameraDesiredConfigUpdated({cameraId, config: {rotation: next}}));+ };++ const handleExposureUp = () => {+ if (!desiredConfig) return;+ dispatch(cameraDesiredConfigUpdated({+ cameraId,+ config: {exposure: Math.min(EXPOSURE_MAX, exposure + 1), exposure_mode: 'MANUAL'},+ }));+ };++ const handleExposureDown = () => {+ if (!desiredConfig) return;+ dispatch(cameraDesiredConfigUpdated({+ cameraId,+ config: {exposure: Math.max(EXPOSURE_MIN, exposure - 1), exposure_mode: 'MANUAL'},+ }));+ };++ const handleRecommendExposure = () => {+ // Server computes recommended exposure and returns MANUAL mode + value in the response.+ // The fulfilled handler in cameras-slice normalizes desiredConfig from the server response.+ dispatch(cameraDesiredConfigUpdated({cameraId, config: {exposure_mode: 'RECOMMEND'}}));+ };++ const handleAutoExposure = () => {+ if (exposureMode === 'AUTO') {+ dispatch(cameraDesiredConfigUpdated({cameraId, config: {exposure_mode: 'MANUAL'}}));+ } else {+ dispatch(cameraDesiredConfigUpdated({cameraId, config: {exposure_mode: 'AUTO'}}));+ }+ };++ const handleApply = async () => {+ setIsApplying(true);+ try {+ await dispatch(camerasConnectOrUpdate()).unwrap();+ } catch {+ // error stored in redux state+ } finally {+ setIsApplying(false);+ }+ };++ const exposureLabel =+ exposureMode === 'AUTO' ? 'auto' :+ exposureMode === 'RECOMMEND' ? '...' :+ String(exposure);++ return (+ <Box+ sx={{position: 'relative', width: '100%', height: '100%'}}+ onMouseEnter={() => setHovered(true)}+ onMouseLeave={() => setHovered(false)}+ >+ <CameraView cameraIndex={cameraIndex} cameraId={cameraId} maxWidth/>++ {hovered && (+ <Box+ sx={{+ position: 'absolute',+ top: 6,+ right: 6,+ display: 'flex',+ flexDirection: 'column',+ gap: '5px',+ zIndex: 10,+ backgroundColor: 'rgba(0,0,0,0.55)',+ backdropFilter: 'blur(3px)',+ border: '1px solid rgba(255,255,255,0.12)',+ borderRadius: '8px',+ padding: '6px',+ }}+ >+ {/* Rotation row */}+ <Box sx={{display: 'flex', alignItems: 'center', gap: '6px'}}>+ <Tooltip title="Rotate 90° clockwise" placement="left" disableInteractive enterDelay={600}>+ <IconButton+ size="small"+ onClick={handleRotate}+ disabled={isLoading}+ sx={btnSx}+ >+ <RotateRightIcon sx={{fontSize: 16}}/>+ </IconButton>+ </Tooltip>+ <Typography sx={valueSx}>{ROTATION_DEGREE_LABELS[rotation]}</Typography>+ </Box>++ <Box sx={dividerSx}/>++ {/* Exposure +/- row */}+ <Box sx={{display: 'flex', alignItems: 'center', gap: '4px'}}>+ <Tooltip title="Decrease exposure" placement="left" disableInteractive enterDelay={600}>+ <span>+ <IconButton+ size="small"+ onClick={handleExposureDown}+ disabled={isLoading || exposureMode !== 'MANUAL' || exposure <= EXPOSURE_MIN}+ sx={btnSx}+ >+ <BrightnessLowIcon sx={{fontSize: 16}}/>+ </IconButton>+ </span>+ </Tooltip>+ <Tooltip title="Increase exposure" placement="left" disableInteractive enterDelay={600}>+ <span>+ <IconButton+ size="small"+ onClick={handleExposureUp}+ disabled={isLoading || exposureMode !== 'MANUAL' || exposure >= EXPOSURE_MAX}+ sx={btnSx}+ >+ <BrightnessHighIcon sx={{fontSize: 16}}/>+ </IconButton>+ </span>+ </Tooltip>+ <Typography sx={valueSx}>{exposureLabel}</Typography>+ </Box>++ {/* Exposure mode row */}+ <Box sx={{display: 'flex', alignItems: 'center', gap: '4px'}}>+ <Tooltip+ title={exposureMode === 'AUTO' ? 'Switch to manual exposure' : 'Switch to auto exposure'}+ placement="left"+ disableInteractive+ enterDelay={600}+ >+ <IconButton+ size="small"+ onClick={handleAutoExposure}+ disabled={isLoading}+ sx={exposureMode === 'AUTO' ? btnActiveSx : btnSx}+ >+ <BrightnessAutoIcon sx={{fontSize: 16}}/>+ </IconButton>+ </Tooltip>+ <Tooltip+ title="Recommend exposure for this camera"+ placement="left"+ disableInteractive+ enterDelay={600}+ >+ <IconButton+ size="small"+ onClick={handleRecommendExposure}+ disabled={isLoading}+ sx={btnSx}+ >+ <WbIncandescentIcon sx={{fontSize: 16}}/>+ </IconButton>+ </Tooltip>+ </Box>++ <Box sx={dividerSx}/>++ {/* Auto-apply row */}+ <Box sx={{display: 'flex', alignItems: 'center', gap: '4px'}}>+ <Tooltip+ title={isAutoApply ? 'Auto-apply on — changes send automatically' : 'Auto-apply off — click apply to send'}+ placement="left"+ disableInteractive+ enterDelay={600}+ >+ <IconButton+ size="small"+ onClick={() => dispatch(autoApplyToggled())}+ sx={isAutoApply ? btnActiveSx : btnSx}+ >+ {isAutoApply ? <SyncIcon sx={{fontSize: 16}}/> : <SyncDisabledIcon sx={{fontSize: 16}}/>}+ </IconButton>+ </Tooltip>+ {!isAutoApply && (+ <Tooltip title="Apply changes to camera" placement="left" disableInteractive enterDelay={600}>+ <span>+ <IconButton+ size="small"+ onClick={handleApply}+ disabled={isApplying}+ sx={btnSx}+ >+ {isApplying+ ? <CircularProgress size={16} sx={{color: 'inherit'}}/>+ : <CheckIcon sx={{fontSize: 16}}/>}+ </IconButton>+ </span>+ </Tooltip>+ )}+ </Box>+ </Box>+ )}+ </Box>+ );+};++const btnSx = {+ width: 24,+ height: 24,+ padding: '3px',+ color: 'rgba(255,255,255,0.8)',+ borderRadius: '5px',+ outline: 'none',+ '&:hover': {+ backgroundColor: 'rgba(255,255,255,0.18)',+ color: '#fff',+ },+ '&:focus': {+ outline: 'none',+ },+ '&.Mui-disabled': {+ color: 'rgba(255,255,255,0.2)',+ },+} as const;++const btnActiveSx = {+ ...btnSx,+ color: '#fff',+ backgroundColor: 'rgba(255,255,255,0.2)',+ '&:focus': {+ outline: 'none',+ },+} as const;++const valueSx = {+ fontSize: 11,+ fontFamily: 'monospace',+ color: 'rgba(255,255,255,0.85)',+ minWidth: '28px',+ lineHeight: 1,+} as const;++const dividerSx = {+ height: '1px',+ backgroundColor: 'rgba(255,255,255,0.1)',+ mx: '-2px',+} as const;diff --git a/freemocap-ui/src/components/camera-views/CameraViewsGrid.tsx b/freemocap-ui/src/components/camera-views/CameraViewsGrid.tsxindex 4858f775..605a0994 100644--- a/freemocap-ui/src/components/camera-views/CameraViewsGrid.tsx+++ b/freemocap-ui/src/components/camera-views/CameraViewsGrid.tsx@@ -1,14 +1,14 @@-import React, {useCallback, useEffect, useMemo, useRef, useState} from "react";+import React, {useMemo} from "react";import {Box, keyframes} from "@mui/material";-import type {Layout, LayoutItem} from "react-grid-layout";import ReactGridLayout, {noCompactor} from "react-grid-layout";import "react-grid-layout/css/styles.css";import "react-resizable/css/styles.css";-import {CameraView} from "./CameraView";+import {CameraViewWithOverlay} from "./CameraViewWithOverlay";import {useServer} from "@/services/server/ServerContextProvider";import {useTranslation} from "react-i18next";import {useAppSelector} from "@/store/hooks";-import {selectConnectedCameras} from "@/store/slices/cameras/cameras-selectors";+import {selectAutoApply, selectCameras, selectIsLoading} from "@/store/slices/cameras/cameras-selectors";+import {useGridLayout} from "@/hooks/useGridLayout";const recordingBorderPulse = keyframes`0% { border-color: #ff2020; box-shadow: 0 0 4px rgba(255, 32, 32, 0.4); }@@ -16,123 +16,6 @@ const recordingBorderPulse = keyframes`100% { border-color: #ff2020; box-shadow: 0 0 4px rgba(255, 32, 32, 0.4); }`;-/** Number of abstract grid columns. More columns = finer positioning granularity. */-const GRID_COLS = 12;-const MARGIN: [number, number] = [4, 4];--interface Tiling {- cols: number;- rows: number;-}--/**- * Get the preferred number of columns based on camera count.- * This uses the "old version" heuristic for determining a good initial layout.- * - 1 camera → 1 column- * - 2-4 cameras → 2 columns- * - 5-9 cameras → 3 columns- * - 10+ cameras → 4 columns- */-function getPreferredColumns(n: number): number {- if (n <= 1) return 1;- if (n <= 4) return 2;- if (n <= 9) return 3;- return 4;-}--/**- * Compute optimal tiling combining the best of both approaches:- * 1. Uses the old heuristic to determine ideal column count bounds- * 2. Within those bounds, maximizes area and prefers square-ish cells- * 3. Respects container dimensions- */-function computeOptimalTiling(- n: number,- containerWidth: number,- containerHeight: number,-): Tiling {- if (n === 0) return { cols: 1, rows: 1 };- if (n === 1) return { cols: 1, rows: 1 };-- // Get the heuristic-preferred columns (from old version logic)- const preferredCols = getPreferredColumns(n);-- // Also compute the "ideal" square-ish layout- const sqrtN = Math.sqrt(n);- const idealCols = Math.round(sqrtN);-- // Allow some flexibility around the preferred columns- // We'll search within a range: minCols to maxCols- const minCols = Math.max(1, Math.floor(sqrtN) - 1);- const maxCols = Math.min(n, Math.ceil(sqrtN) + 2, preferredCols + 1);-- let bestCols = preferredCols;- let bestScore = -Infinity;-- for (let cols = minCols; cols <= maxCols; cols++) {- const rows = Math.ceil(n / cols);- const cellW = (containerWidth - MARGIN[0] * (cols - 1)) / cols;- const cellH = (containerHeight - MARGIN[1] * (rows - 1)) / rows;-- if (cellW < 80 || cellH < 60) continue;-- // Calculate area- const totalArea = n * cellW * cellH;-- // Calculate aspect ratio penalty (prefer cells closer to square)- const aspectRatio = cellW / cellH;- const aspectPenalty = Math.abs(Math.log(aspectRatio)) * 0.3;-- // Calculate balance penalty (prefer more even distribution across rows)- const itemsInLastRow = n % cols || cols;- const balancePenalty = (cols - itemsInLastRow) / cols * 0.5;-- // Combined score: maximize area, minimize penalties- const score = totalArea * (1 - aspectPenalty - balancePenalty);-- // Bonus for matching the preferred column count- const preferredBonus = cols === preferredCols ? totalArea * 0.1 : 0;-- const finalScore = score + preferredBonus;-- if (finalScore > bestScore) {- bestScore = finalScore;- bestCols = cols;- }- }-- return { cols: bestCols, rows: Math.ceil(n / bestCols) };-}--/**- * Build a tiling from a manual column count.- */-function tilingFromColumns(n: number, cols: number): Tiling {- if (n === 0) return { cols: 1, rows: 1 };- const clamped = Math.max(1, Math.min(cols, n));- return { cols: clamped, rows: Math.ceil(n / clamped) };-}--/**- * Build a react-grid-layout layout from a tiling.- */-function buildLayout(cameraIds: string[], tiling: Tiling): LayoutItem[] {- const n = cameraIds.length;- if (n === 0) return [];-- const colSpan = Math.floor(GRID_COLS / tiling.cols);-- return cameraIds.map((id, i) => ({- i: id,- x: (i % tiling.cols) * colSpan,- y: Math.floor(i / tiling.cols),- w: colSpan,- h: 1,- minW: 1,- minH: 1,- }));-}-interface CameraViewsGridProps {/** null = auto-optimize, number = manual column count */manualColumns: number | null;@@ -144,124 +27,48 @@ export const CameraViewsGrid: React.FC<CameraViewsGridProps> = ({ manualColumns,const { connectedCameraIds } = useServer();const { t } = useTranslation();const isRecording = useAppSelector(state => state.recording.isRecording);- const containerRef = useRef<HTMLDivElement>(null);- const [containerWidth, setContainerWidth] = useState<number>(800);- const [containerHeight, setContainerHeight] = useState<number>(600);-- // Measure the container's parent to avoid feedback loops- useEffect(() => {- const el = containerRef.current?.parentElement;- if (!el) return;-- const measure = () => {- const rect = el.getBoundingClientRect();- setContainerWidth(rect.width);- setContainerHeight(rect.height);- };+ const isLoading = useAppSelector(selectIsLoading);+ const isAutoApply = useAppSelector(selectAutoApply);+ // Watch camera configs for rotation/resolution changes+ const cameras = useAppSelector(selectCameras);- measure();- const observer = new ResizeObserver(() => measure());- observer.observe(el);- return () => observer.disconnect();- }, []);+ const sortedCameraIds = useMemo(() => {+ const indexByCameraId = new Map<string, number>();+ for (const cam of cameras) {+ indexByCameraId.set(cam.id, cam.index);+ }+ return [...connectedCameraIds].sort((a, b) => {+ const idxA = indexByCameraId.get(a) ?? Infinity;+ const idxB = indexByCameraId.get(b) ?? Infinity;+ return idxA - idxB;+ });+ }, [connectedCameraIds, cameras]);- // Watch camera configs for rotation/resolution changes- const connectedCameras = useAppSelector(selectConnectedCameras);const configFingerprint = useMemo(() => {- return connectedCameras+ return cameras.map((cam) => {const cfg = cam.actualConfig;return `${cam.id}:${cfg.rotation}:${cfg.resolution.width}x${cfg.resolution.height}`;}).join("|");- }, [connectedCameras]);-- // Compute tiling: manual column count overrides auto-optimal.- // Stabilized with a ref to prevent flip-flop.- const prevTilingRef = useRef<Tiling>({ cols: 1, rows: 1 });- const tiling = useMemo(() => {- const candidate = manualColumns !== null- ? tilingFromColumns(connectedCameraIds.length, manualColumns)- : computeOptimalTiling(connectedCameraIds.length, containerWidth, containerHeight);- const prev = prevTilingRef.current;- if (candidate.cols === prev.cols && candidate.rows === prev.rows) {- return prev;- }- prevTilingRef.current = candidate;- return candidate;- }, [connectedCameraIds.length, containerWidth, containerHeight, manualColumns]);-- const [layout, setLayout] = useState<LayoutItem[]>(() =>- buildLayout(connectedCameraIds, tiling),- );-- // Re-tile when cameras, tiling, config, or reset changes- useEffect(() => {- setLayout(buildLayout(connectedCameraIds, tiling));- }, [connectedCameraIds, tiling, resetKey, configFingerprint]);-- // Snapshot layout before drag for swap detection- const layoutBeforeDragRef = useRef<LayoutItem[]>(layout);-- const handleDragStart = useCallback(() => {- layoutBeforeDragRef.current = layout;- }, [layout]);-- const handleDragStop = useCallback((_newLayout: Layout, _oldItem: LayoutItem | null, newItem: LayoutItem | null) => {- if (!newItem) return;- const preDrag = layoutBeforeDragRef.current;- const draggedBefore = preDrag.find((l) => l.i === newItem.i);- if (!draggedBefore) return;-- // Check if we landed on another item- const swapTarget = preDrag.find((l) => {- if (l.i === newItem.i) return false;- const overlapX = newItem.x < l.x + l.w && newItem.x + newItem.w > l.x;- const overlapY = newItem.y < l.y + l.h && newItem.y + newItem.h > l.y;- return overlapX && overlapY;- });-- if (swapTarget) {- const swapped = preDrag.map((l) => {- if (l.i === newItem.i) {- return { ...l, x: swapTarget.x, y: swapTarget.y };- }- if (l.i === swapTarget.i) {- return { ...l, x: draggedBefore.x, y: draggedBefore.y };- }- return l;- });- setLayout(swapped);- } else {- // Dropped in empty space — clamp to grid bounds- const maxX = GRID_COLS - newItem.w;- const maxY = tiling.rows - newItem.h;- const updated = preDrag.map((l) => {- if (l.i === newItem.i) {- return {- ...l,- x: Math.max(0, Math.min(newItem.x, maxX)),- y: Math.max(0, Math.min(newItem.y, maxY)),- };- }- return l;- });- setLayout(updated);- }- }, [tiling.rows]);-- const handleLayoutChange = useCallback((_newLayout: Layout) => {}, []);-- const handleResizeStop = useCallback((newLayout: Layout) => {- setLayout([...newLayout]);- }, []);-- const rowHeight = useMemo(() => {- const totalMargin = (tiling.rows - 1) * MARGIN[1];- return Math.max(30, (containerHeight - totalMargin) / tiling.rows);- }, [containerHeight, tiling.rows]);-- if (connectedCameraIds.length === 0) {+ }, [cameras]);++ const {+ containerRef,+ width,+ layout,+ gridHandlers,+ gridConfig,+ } = useGridLayout({+ itemIds: sortedCameraIds,+ margin: [4, 4],+ manualColumns,+ resetKey,+ measureParent: true,+ extraResetDeps: [configFingerprint],+ });++ if (sortedCameraIds.length === 0) {return (<Boxref={containerRef}@@ -320,40 +127,35 @@ export const CameraViewsGrid: React.FC<CameraViewsGridProps> = ({ manualColumns,}}><ReactGridLayout- width={containerWidth}+ width={width}layout={layout}- gridConfig={{- cols: GRID_COLS,- rowHeight,- margin: MARGIN,- containerPadding: [0, 0] as [number, number],- }}+ gridConfig={gridConfig}dragConfig={{ enabled: true }}resizeConfig={{ enabled: true }}compactor={noCompactor}- onLayoutChange={handleLayoutChange}- onDragStart={handleDragStart}- onDragStop={handleDragStop}- onResizeStop={handleResizeStop}+ {...gridHandlers}>- {connectedCameraIds.map((cameraId) => (- <Box- key={cameraId}- sx={{- overflow: "hidden",- borderRadius: "4px",- border: isRecording- ? "2px solid #ff2020"- : "1px solid rgba(255,255,255,0.15)",- transition: "border 0.3s ease, box-shadow 0.3s ease",- ...(isRecording && {- animation: `${recordingBorderPulse} 3s infinite ease-in-out`,- }),- }}- >- <CameraView cameraId={cameraId} />- </Box>- ))}+ {sortedCameraIds.map((cameraId) => {+ const cam = cameras.find(c => c.id === cameraId);+ return (+ <Box+ key={cameraId}+ sx={{+ overflow: "hidden",+ borderRadius: "4px",+ border: isRecording+ ? "2px solid #ff2020"+ : "1px solid rgba(255,255,255,0.15)",+ transition: "border 0.3s ease, box-shadow 0.3s ease",+ ...(isRecording && {+ animation: `${recordingBorderPulse} 3s infinite ease-in-out`,+ }),+ }}+ >+ <CameraViewWithOverlay cameraIndex={cam?.index ?? -1} cameraId={cameraId} isLoading={isLoading} isAutoApply={isAutoApply} />+ </Box>+ );+ })}</ReactGridLayout></Box>);diff --git a/freemocap-ui/src/components/camera-views/ResizableCameraView.tsx b/freemocap-ui/src/components/camera-views/ResizableCameraView.tsxindex e4f57859..22f4909c 100644--- a/freemocap-ui/src/components/camera-views/ResizableCameraView.tsx+++ b/freemocap-ui/src/components/camera-views/ResizableCameraView.tsx@@ -3,6 +3,7 @@ import {Box} from '@mui/material';import {CameraView} from './CameraView';interface ResizableCameraViewProps {+ cameraIndex: number;cameraId: string;/** Initial position/size from the auto-layout */initialX: number;@@ -28,6 +29,7 @@ type DragMode = 'none' | 'move' | 'resize';* and resized (by a bottom-right handle) within an absolute-positioned container.*/export const ResizableCameraView: React.FC<ResizableCameraViewProps> = ({+ cameraIndex,cameraId,initialX,initialY,@@ -169,7 +171,7 @@ export const ResizableCameraView: React.FC<ResizableCameraViewProps> = ({cursor: dragMode === 'move' ? 'grabbing' : 'grab',}}>- <CameraView cameraId={cameraId} />+ <CameraView cameraIndex={cameraIndex} cameraId={cameraId} /></Box>{/* Resize handle in the bottom-right corner */}diff --git a/freemocap-ui/src/components/common/PresetPicker.tsx b/freemocap-ui/src/components/common/PresetPicker.tsxindex ef8794fb..f0bf37ed 100644--- a/freemocap-ui/src/components/common/PresetPicker.tsx+++ b/freemocap-ui/src/components/common/PresetPicker.tsx@@ -1,5 +1,5 @@import React from "react";-import {FormControl, InputLabel, MenuItem, Select, SxProps, Theme} from "@mui/material";+import {Box, FormControl, InputLabel, MenuItem, Select, SxProps, Theme} from "@mui/material";interface PresetOption<T extends string> {value: T;@@ -30,6 +30,7 @@ export function PresetPicker<T extends string>({const labelId = label ? `preset-picker-${label.toLowerCase().replace(/\s+/g, "-")}-label` : undefined;return (+ <Box ><FormControl size={size} sx={{minWidth, ...sx}}>{label && <InputLabel id={labelId}>{label}</InputLabel>}<Select@@ -46,5 +47,6 @@ export function PresetPicker<T extends string>({))}</Select></FormControl>+ </Box>);}diff --git a/freemocap-ui/src/components/common/RecordingStatusPanel.tsx b/freemocap-ui/src/components/common/RecordingStatusPanel.tsxindex 36aec702..6c1aece6 100644--- a/freemocap-ui/src/components/common/RecordingStatusPanel.tsx+++ b/freemocap-ui/src/components/common/RecordingStatusPanel.tsx@@ -182,6 +182,7 @@ export const RecordingStatusPanel: React.FC<RecordingStatusPanelProps> = ({<Tooltip title="Re-check folder"><span><IconButton+ component="span"size="small"onClick={(e) => {e.stopPropagation();diff --git a/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationControlPanel.tsx b/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationControlPanel.tsxdeleted file mode 100644index 0b9ead97..00000000--- a/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationControlPanel.tsx+++ /dev/null@@ -1,453 +0,0 @@-import React, {useCallback, useEffect, useMemo, useState} from "react";-import {- Alert,- Box,- Button,- Chip,- CircularProgress,- IconButton,- InputAdornment,- Stack,- TextField,- Tooltip,- Typography,- useTheme,-} from "@mui/material";-import SquareFootIcon from "@mui/icons-material/SquareFoot";-import PlayArrowIcon from "@mui/icons-material/PlayArrow";-import StopIcon from "@mui/icons-material/Stop";-import FolderOpenIcon from "@mui/icons-material/FolderOpen";-import ClearIcon from "@mui/icons-material/Clear";-import CheckCircleIcon from "@mui/icons-material/CheckCircle";-import FiberManualRecordIcon from "@mui/icons-material/FiberManualRecord";-import RefreshIcon from "@mui/icons-material/Refresh";-import WarningAmberIcon from "@mui/icons-material/WarningAmber";-import CancelIcon from "@mui/icons-material/Cancel";-import {CollapsibleSidebarSection} from "@/components/common/CollapsibleSidebarSection";-import {DirectoryStatusPanel} from "@/components/common/DirectoryStatusPanel";-import {useCalibration} from "@/hooks/useCalibration";-import {useElectronIPC} from "@/services";-import {CalibrationSolverSection} from "@/components/control-panels/calibration-control-panel/CalibrationSolverSection";-import {CharucoBoardConfigSection} from "@/components/control-panels/calibration-control-panel/CharucoBoardConfigSection";---export const CalibrationControlPanel: React.FC = () => {- const theme = useTheme();- const [localError, setLocalError] = useState<string | null>(null);- const [isRefreshing, setIsRefreshing] = useState(false);- const {api} = useElectronIPC();-- const {- error,- isLoading,- isRecording,- recordingProgress,- canStartRecording,- canCalibrate,- calibrationRecordingPath,- directoryInfo,- isUsingManualPath,- dispatchStopCalibrationRecording,- dispatchStartCalibrationRecording,- setManualRecordingPath,- clearManualRecordingPath,- validateDirectory,- calibrateSelectedRecording,- clearError,- } = useCalibration();-- useEffect(() => {- if (calibrationRecordingPath) {- validateDirectory(calibrationRecordingPath);- }- }, [calibrationRecordingPath, validateDirectory]);-- const handleClearError = useCallback((): void => {- clearError();- setLocalError(null);- }, [clearError]);-- const handleSelectDirectory = async (): Promise<void> => {- if (!api) {- console.warn("Electron API not available");- return;- }- try {- const result: string | null = await api.fileSystem.selectDirectory.mutate();- if (result) {- await setManualRecordingPath(result);- }- } catch (err) {- console.error("Failed to select directory:", err);- setLocalError("Failed to select directory");- }- };-- const handlePathInputChange = async (- e: React.ChangeEvent<HTMLInputElement>- ): Promise<void> => {- const newPath: string = e.target.value;- if (newPath.includes("~") && api) {- try {- const home: string = await api.fileSystem.getHomeDirectory.query();- const expanded: string = newPath.replace(- /^~([/\\])?/,- home ? `${home}$1` : ""- );- await setManualRecordingPath(expanded);- } catch (err) {- console.error("Failed to expand home directory:", err);- await setManualRecordingPath(newPath);- }- } else {- await setManualRecordingPath(newPath);- }- };-- const handleClearManualPath = useCallback((): void => {- clearManualRecordingPath();- }, [clearManualRecordingPath]);-- /** Re-scan the calibration folder on demand */- const handleRefresh = useCallback(async (): Promise<void> => {- if (!calibrationRecordingPath) return;- setIsRefreshing(true);- try {- await validateDirectory(calibrationRecordingPath);- } finally {- // Give a brief visual pulse so it feels snappy even if validate is instant- setTimeout(() => setIsRefreshing(false), 400);- }- }, [calibrationRecordingPath, validateDirectory]);-- const displayError = error || localError || directoryInfo?.errorMessage;-- const pathHelperText = useMemo(() => {- if (isUsingManualPath) return "Using custom path";- return "Using default recording directory";- }, [isUsingManualPath]);-- // ─── Header status icon logic ──────────────────────────────────────────────- // cyan ✓ → TOML found / calibration loaded- // yellow ⚠ → no path set, or directoryInfo not yet available- // red ✗ → path is set but no valid calibration TOML found there- const calibStatus: "ok" | "none" | "bad" = useMemo(() => {- if (directoryInfo?.cameraCalibrationTomlPath) return "ok";- if (!calibrationRecordingPath || !directoryInfo) return "none";- return "bad";- }, [directoryInfo, calibrationRecordingPath]);-- const calibStatusIcon = useMemo(() => {- if (calibStatus === "ok") {- return (- <Tooltip title="Calibration file found ✓">- <CheckCircleIcon- fontSize="small"- sx={{color: "#00e5ff" /* cyan */}}- />- </Tooltip>- );- }- if (calibStatus === "bad") {- return (- <Tooltip title="No valid calibration file at this path">- <CancelIcon- fontSize="small"- sx={{color: theme.palette.error.main}}- />- </Tooltip>- );- }- return (- <Tooltip title="No calibration selected">- <WarningAmberIcon- fontSize="small"- sx={{color: theme.palette.warning.main}}- />- </Tooltip>- );- }, [calibStatus, theme]);-- /** Refresh button — lives in the header row */- const refreshButton = (- <Tooltip title={calibrationRecordingPath ? "Re-check calibration folder" : "No path set"}>- <span>- <IconButton- size="small"- onClick={(e: React.MouseEvent) => {- e.stopPropagation();- handleRefresh();- }}- disabled={!calibrationRecordingPath || isLoading || isRefreshing}- sx={{- p: 0.5,- color: "inherit",- border: "1.5px solid rgba(255,255,255,0.25)",- borderRadius: 1,- "&:hover": {backgroundColor: "rgba(255,255,255,0.1)"},- "&.Mui-disabled": {- color: "rgba(255,255,255,0.3)",- borderColor: "rgba(255,255,255,0.1)",- },- }}- >- {isRefreshing ? (- <CircularProgress size={16} color="inherit" />- ) : (- <RefreshIcon fontSize="small" />- )}- </IconButton>- </span>- </Tooltip>- );-- // Derive status for collapsed summary chip- const statusLabel = isRecording- ? `Recording ${recordingProgress.toFixed(0)}%`- : isLoading- ? "Processing..."- : directoryInfo?.cameraCalibrationTomlPath- ? "Calibrated"- : "Idle";-- const statusColor = isRecording- ? theme.palette.error.main- : isLoading- ? theme.palette.warning.main- : directoryInfo?.cameraCalibrationTomlPath- ? theme.palette.success.main- : theme.palette.grey[600];-- // Primary control: compact start/stop recording toggle + refresh in the header- const headerControls = (- <Box sx={{display: "flex", alignItems: "center", gap: 0.75}}>- {/* calibration status icon — always visible */}- {calibStatusIcon}-- {/* refresh */}- {refreshButton}-- {/* record start/stop */}- {isRecording ? (- <Tooltip title="Stop calibration recording">- <IconButton- size="small"- onClick={(e: React.MouseEvent) => {- e.stopPropagation();- dispatchStopCalibrationRecording();- }}- disabled={isLoading}- sx={{- color: theme.palette.error.light,- border: `1.5px solid ${theme.palette.error.light}`,- borderRadius: 1,- p: 0.5,- "&:hover": {backgroundColor: "rgba(244,67,54,0.15)"},- }}- >- <StopIcon fontSize="small" />- </IconButton>- </Tooltip>- ) : (- <Tooltip title={canStartRecording ? "Start calibration recording" : "Cannot record yet"}>- <span>- <IconButton- size="small"- onClick={(e: React.MouseEvent) => {- e.stopPropagation();- dispatchStartCalibrationRecording();- }}- disabled={!canStartRecording || isLoading}- sx={{- color: "inherit",- border: "1.5px solid rgba(255,255,255,0.25)",- borderRadius: 1,- p: 0.5,- "&:hover": {backgroundColor: "rgba(255,255,255,0.1)"},- "&.Mui-disabled": {- color: "rgba(255,255,255,0.3)",- borderColor: "rgba(255,255,255,0.1)",- },- }}- >- <FiberManualRecordIcon fontSize="small" />- </IconButton>- </span>- </Tooltip>- )}- </Box>- );-- return (- <CollapsibleSidebarSection- icon={<SquareFootIcon sx={{color: "inherit"}} />}- title="Calibration"- summaryContent={- <Chip- label={statusLabel}- size="small"- sx={{- height: 20,- fontSize: 11,- fontWeight: 600,- backgroundColor: statusColor,- color: theme.palette.getContrastText(statusColor),- }}- />- }- primaryControl={headerControls}- defaultExpanded={false}- >- <Box sx={{p: 2, bgcolor: "background.paper"}}>- <Stack spacing={2}>- {/* Error Display */}- {displayError && (- <Alert severity="error" onClose={handleClearError}>- {displayError}- </Alert>- )}---- {/* Recording Controls */}- <Stack direction="row" spacing={2}>- <Button- variant="contained"- color="primary"- startIcon={<PlayArrowIcon />}- onClick={dispatchStartCalibrationRecording}- disabled={!canStartRecording || isLoading}- fullWidth- >- Start Calibration Recording- </Button>- {isRecording && (- <Button- variant="contained"- color="error"- startIcon={<StopIcon />}- onClick={dispatchStopCalibrationRecording}- disabled={isLoading}- fullWidth- >- Stop Recording- </Button>- )}- </Stack>-- {/* Recording Path Input */}- <TextField- label="Calibration Recording Path"- value={calibrationRecordingPath}- onChange={handlePathInputChange}- fullWidth- size="small"- helperText={pathHelperText}- InputProps={{- endAdornment: (- <InputAdornment position="end">- {isUsingManualPath && (- <Tooltip title="Clear manual path (revert to default)">- <IconButton- onClick={handleClearManualPath}- edge="end"- size="small"- >- <ClearIcon fontSize="small" />- </IconButton>- </Tooltip>- )}- <Tooltip title="Re-check calibration folder">- <span>- <IconButton- onClick={handleRefresh}- edge="end"- size="small"- disabled={!calibrationRecordingPath || isLoading || isRefreshing}- >- {isRefreshing- ? <CircularProgress size={18} color="inherit" />- : <RefreshIcon fontSize="small" />- }- </IconButton>- </span>- </Tooltip>- <Tooltip title="Select directory">- <IconButton- onClick={handleSelectDirectory}- edge="end"- >- <FolderOpenIcon />- </IconButton>- </Tooltip>- </InputAdornment>- ),- }}- />-- {/* Directory Status Info */}- <DirectoryStatusPanel- title="Calibration Folder Status"- tomlLabel="Has calibration TOML"- directoryInfo={directoryInfo ? {- ...directoryInfo,- tomlPath: directoryInfo.cameraCalibrationTomlPath,- } : null}- status={calibStatus}- onRefresh={handleRefresh}- refreshDisabled={!calibrationRecordingPath || isLoading || isRefreshing}- isRefreshing={isRefreshing}- />-- {/* Charuco Board Configuration */}- <CharucoBoardConfigSection />-- {/* Solver Method & Groundplane */}- <CalibrationSolverSection />-- {/* Recording Progress */}- {isRecording && (- <Box sx={{width: "100%"}}>- <Typography- variant="caption"- color="text.secondary"- gutterBottom- >- Recording in Progress: {recordingProgress.toFixed(0)}%- </Typography>- <Box- sx={{- width: "100%",- height: 8,- bgcolor: "grey.300",- borderRadius: 1,- overflow: "hidden",- }}- >- <Box- sx={{- width: `${recordingProgress}%`,- height: "100%",- bgcolor: theme.palette.primary.main,- transition: "width 0.3s",- }}- />- </Box>- </Box>- )}-- {/* Calibrate Button */}- <Button- variant="contained"- color="secondary"- onClick={calibrateSelectedRecording}- disabled={!canCalibrate || isLoading}- fullWidth- >- Calibrate Selected Recording- </Button>- </Stack>- </Box>- </CollapsibleSidebarSection>- );-};diff --git a/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationPanel.tsx b/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationPanel.tsxindex 75ea10df..e839a5dd 100644--- a/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationPanel.tsx+++ b/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationPanel.tsx@@ -3,10 +3,10 @@ import {Alert,Box,Button,- Chip,+ Chip, FormControlLabel,IconButton,InputAdornment,- Stack,+ Stack, Switch,TextField,Tooltip,Typography,@@ -26,18 +26,21 @@ import {useElectronIPC} from "@/services";import {CalibrationSolverSection} from "@/components/control-panels/calibration-control-panel/CalibrationSolverSection";import {CharucoBoardConfigSection} from "@/components/control-panels/calibration-control-panel/CharucoBoardConfigSection";import {CollapsibleSidebarSection} from "@/components/common/CollapsibleSidebarSection";+import {selectEffectiveRecordingPath} from "@/store/slices/active-recording/active-recording-slice";+import {useAppSelector} from "@/store";export const CalibrationPanel: React.FC = () => {const theme = useTheme();const [localError, setLocalError] = useState<string | null>(null);- const {api} = useElectronIPC();+ const {api, isElectron} = useElectronIPC();const {error,+ config,isLoading,isRecording,recordingProgress,- canStartRecording,+ updateCalibrationConfig,canCalibrate,calibrationRecordingPath,directoryInfo,@@ -51,6 +54,9 @@ export const CalibrationPanel: React.FC = () => {clearError,} = useCalibration();+ // Effective path: actual activeRecording if any, otherwise the planned path+ const effectiveCalibrationPath = useAppSelector(selectEffectiveRecordingPath);+// Auto-poll directory status instead of requiring manual refreshconst {triggerRefresh, isWatching} = useDirectoryWatcher(calibrationRecordingPath,@@ -64,7 +70,7 @@ export const CalibrationPanel: React.FC = () => {}, [clearError]);const handleSelectDirectory = async (): Promise<void> => {- if (!api) return;+ if (!isElectron || !api) return;try {const result: string | null = await api.fileSystem.selectDirectory.mutate();if (result) {@@ -77,9 +83,9 @@ export const CalibrationPanel: React.FC = () => {};const handleOpenFolder = async (): Promise<void> => {- if (!api || !calibrationRecordingPath) return;+ if (!isElectron || !api || !effectiveCalibrationPath) return;try {- await api.fileSystem.openFolder.mutate({path: calibrationRecordingPath});+ await api.fileSystem.openFolder.mutate({path: effectiveCalibrationPath});} catch (err) {console.error("Failed to open folder:", err);setLocalError("Failed to open folder in file explorer");@@ -93,7 +99,7 @@ export const CalibrationPanel: React.FC = () => {if (newPath.includes("~") && api) {try {const home: string = await api.fileSystem.getHomeDirectory.query();- const expanded: string = newPath.replace(/^~([/\\])?/, home ? `${home}$1` : "");+ const expanded: string = newPath.replace(/^~([\/])?/, home ? home + '$1' : "");await setManualRecordingPath(expanded);} catch {await setManualRecordingPath(newPath);@@ -112,9 +118,9 @@ export const CalibrationPanel: React.FC = () => {const displayError = error || localError || directoryInfo?.errorMessage;const statusLabel = isRecording- ? `Recording ${recordingProgress.toFixed(0)}%`+ ? "Recording " + recordingProgress.toFixed(0) + "%": isLoading- ? "Processing..."+ ? "Running": directoryInfo?.cameraCalibrationTomlPath? "Calibrated": "Idle";@@ -154,49 +160,38 @@ export const CalibrationPanel: React.FC = () => {</Alert>)}- {/*<FormControlLabel*/}- {/* control={*/}- {/* <Checkbox*/}- {/* checked={config.liveTrackCharuco}*/}- {/* onChange={(e) =>*/}- {/* updateCalibrationConfig({liveTrackCharuco: e.target.checked})*/}- {/* }*/}- {/* disabled={isLoading}*/}- {/* />*/}- {/* }*/}- {/* label="Live Track Charuco Board"*/}- {/*/>*/}-{/* Recording Controls */}- <Stack direction="row" spacing={2}>- <Button- variant="contained"- color="primary"- startIcon={<PlayArrowIcon/>}- onClick={dispatchStartCalibrationRecording}- disabled={!canStartRecording || isLoading}- fullWidth- >- Start Calibration Recording- </Button>- {isRecording && (- <Button- variant="contained"- color="error"- startIcon={<StopIcon/>}- onClick={dispatchStopCalibrationRecording}- disabled={isLoading}- fullWidth- >- Stop Recording- </Button>- )}- </Stack>+ {/* TODO - Wire up these recording buttons to the EXACT same workflow as the recording panel - current wiring has slop*/}+ {/*<Stack direction="row" spacing={2}>*/}+ {/* <Button*/}+ {/* variant="contained"*/}+ {/* color="primary"*/}+ {/* startIcon={<PlayArrowIcon/>}*/}+ {/* onClick={dispatchStartCalibrationRecording}*/}+ {/* // disabled={!canStartRecording || isLoading}*/}+ {/* disabled={ isLoading}*/}+ {/* fullWidth*/}+ {/* >*/}+ {/* Start Calibration Recording*/}+ {/* </Button>*/}+ {/* {isRecording && (*/}+ {/* <Button*/}+ {/* variant="contained"*/}+ {/* color="error"*/}+ {/* startIcon={<StopIcon/>}*/}+ {/* onClick={dispatchStopCalibrationRecording}*/}+ {/* disabled={isLoading}*/}+ {/* fullWidth*/}+ {/* >*/}+ {/* Stop Recording*/}+ {/* </Button>*/}+ {/* )}*/}+ {/*</Stack>*/}{/* Recording Path Input */}<TextFieldlabel="Calibration Recording Path"- value={calibrationRecordingPath}+ value={effectiveCalibrationPath || ''}onChange={handlePathInputChange}fullWidthsize="small"@@ -229,14 +224,14 @@ export const CalibrationPanel: React.FC = () => {onClick={handleOpenFolder}edge="end"size="small"- disabled={!calibrationRecordingPath}+ disabled={!isElectron || !effectiveCalibrationPath}><LaunchIcon fontSize="small"/></IconButton></span></Tooltip><Tooltip title="Select directory">- <IconButton onClick={handleSelectDirectory} edge="end">+ <IconButton onClick={handleSelectDirectory} edge="end" disabled={!isElectron}><FolderOpenIcon/></IconButton></Tooltip>@@ -244,6 +239,7 @@ export const CalibrationPanel: React.FC = () => {),}}/>+<Buttonvariant="contained"color="secondary"@@ -267,6 +263,24 @@ export const CalibrationPanel: React.FC = () => {isRefreshing={false}/>+ {/* Groundplane */}+ <FormControlLabel+ control={+ <Switch+ size="small"+ checked={config.useGroundplane}+ onChange={(_, checked) =>+ updateCalibrationConfig({useGroundplane: checked})+ }+ disabled={isLoading}+ />+ }+ label={+ <Typography variant="body2">+ Align to ground plane to initial charuco position+ </Typography>+ }+ /><CharucoBoardConfigSection /><CalibrationSolverSection/>@@ -287,7 +301,7 @@ export const CalibrationPanel: React.FC = () => {><Boxsx={{- width: `${recordingProgress}%`,+ width: recordingProgress + "%",height: "100%",bgcolor: theme.palette.primary.main,transition: "width 0.3s",diff --git a/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationSolverSection.tsx b/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationSolverSection.tsxindex 4e2dee23..463ddf78 100644--- a/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationSolverSection.tsx+++ b/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationSolverSection.tsx@@ -52,24 +52,7 @@ export const CalibrationSolverSection: React.FC = () => {</Select></FormControl>- {/* Groundplane */}- <FormControlLabel- control={- <Switch- size="small"- checked={config.useGroundplane}- onChange={(_, checked) =>- updateCalibrationConfig({useGroundplane: checked})- }- disabled={isLoading}- />- }- label={- <Typography variant="body2">- Align to ground plane- </Typography>- }- />+</Stack>);};diff --git a/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraConfigTreeViewHeader.tsx b/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraConfigTreeViewHeader.tsxindex d5c5d639..a0774046 100644--- a/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraConfigTreeViewHeader.tsx+++ b/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraConfigTreeViewHeader.tsx@@ -7,15 +7,18 @@ import PauseIcon from "@mui/icons-material/Pause";import PlayArrowIcon from "@mui/icons-material/PlayArrow";import YoutubeSearchedForIcon from "@mui/icons-material/YoutubeSearchedFor";import DeleteSweepIcon from "@mui/icons-material/DeleteSweep";+import SyncIcon from "@mui/icons-material/Sync";+import SyncDisabledIcon from "@mui/icons-material/SyncDisabled";-import {useAppDispatch} from "@/store";+import {useAppDispatch, useAppSelector} from "@/store";import {camerasConnectOrUpdate,closeCameras,detectCameras,pauseUnpauseCameras,} from "@/store/slices/cameras/cameras-thunks";-import {savedSettingsCleared} from "@/store/slices/cameras/cameras-slice";+import {autoApplyToggled, savedSettingsCleared} from "@/store/slices/cameras/cameras-slice";+import {selectAutoApply} from "@/store/slices/cameras/cameras-selectors";import {useTranslation} from 'react-i18next';interface CameraConfigTreeViewHeaderProps {@@ -32,6 +35,7 @@ export const CameraConfigTreeViewHeader: React.FC<CameraConfigTreeViewHeaderPropconst theme = useTheme();const dispatch = useAppDispatch();const {t} = useTranslation();+ const isAutoApply = useAppSelector(selectAutoApply);const [isActionInProgress, setIsActionInProgress] = React.useState(false);const handleRefreshCameras = async (e: React.MouseEvent): Promise<void> => {@@ -113,6 +117,20 @@ export const CameraConfigTreeViewHeader: React.FC<CameraConfigTreeViewHeaderProp</Typography><Stack direction="row" spacing={1} sx={{mr: 2}}>+ {/* Auto-apply toggle */}+ <Tooltip title={isAutoApply ? 'Auto-apply on — changes send automatically' : 'Auto-apply off — use apply button to send'}>+ <IconButton+ size="small"+ onClick={() => dispatch(autoApplyToggled())}+ sx={{+ color: isAutoApply ? theme.palette.secondary.light : 'inherit',+ opacity: isAutoApply ? 1 : 0.5,+ }}+ >+ {isAutoApply ? <SyncIcon/> : <SyncDisabledIcon/>}+ </IconButton>+ </Tooltip>+{/* Connect/Apply Button - Always visible, changes icon and behavior */}<Tooltip title={t("connectCameras")}><span>diff --git a/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraHeaderActions.tsx b/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraHeaderActions.tsxindex 31a308fa..23b1e66a 100644--- a/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraHeaderActions.tsx+++ b/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraHeaderActions.tsx@@ -7,6 +7,7 @@ import PlayArrowIcon from "@mui/icons-material/PlayArrow";import YoutubeSearchedForIcon from "@mui/icons-material/YoutubeSearchedFor";import DeleteSweepIcon from "@mui/icons-material/DeleteSweep";import ArrowDownwardIcon from "@mui/icons-material/ArrowDownward";+import WbIncandescentIcon from "@mui/icons-material/WbIncandescent";import {useAppDispatch} from "@/store";import {@@ -15,7 +16,7 @@ import {detectCameras,pauseUnpauseCameras,} from "@/store/slices/cameras/cameras-thunks";-import {savedSettingsCleared} from "@/store/slices/cameras/cameras-slice";+import {recommendExposureForAll, savedSettingsCleared} from "@/store/slices/cameras/cameras-slice";import {useTranslation} from 'react-i18next';interface CameraHeaderActionsProps {@@ -81,6 +82,11 @@ export const CameraHeaderActions: React.FC<CameraHeaderActionsProps> = ({}};+ const handleRecommendExposureAll = (e: React.MouseEvent): void => {+ e.stopPropagation();+ dispatch(recommendExposureForAll());+ };+const handleClearSavedSettings = (e: React.MouseEvent): void => {e.stopPropagation();dispatch(savedSettingsCleared());@@ -134,6 +140,19 @@ export const CameraHeaderActions: React.FC<CameraHeaderActionsProps> = ({</span></Tooltip>+ {/* Recommend Exposure for All Button */}+ <Tooltip title="Auto-recommend exposure for all cameras">+ <span>+ <IconButton+ size="small"+ onClick={handleRecommendExposureAll}+ sx={{color: "inherit", padding: "4px"}}+ >+ <WbIncandescentIcon sx={{fontSize: 24}}/>+ </IconButton>+ </span>+ </Tooltip>+{/* Pause/Play Button */}<Tooltip title={isPaused ? t("resumeStreaming") : t("pauseStreaming")}><span>diff --git a/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraTreeItem.tsx b/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraTreeItem.tsxindex 2cd2c7a5..61600478 100644--- a/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraTreeItem.tsx+++ b/freemocap-ui/src/components/control-panels/camera-config-panel/camera-config-tree-view/CameraTreeItem.tsx@@ -1,15 +1,16 @@import React from "react";-import {Box, Chip, IconButton, Typography, useTheme} from "@mui/material";+import {Box, Chip, IconButton, Tooltip, Typography, useTheme} from "@mui/material";import {TreeItem} from "@mui/x-tree-view/TreeItem";import CheckCircleIcon from "@mui/icons-material/CheckCircle";import RadioButtonUncheckedIcon from "@mui/icons-material/RadioButtonUnchecked";-import VideocamIcon from "@mui/icons-material/Videocam";import SettingsIcon from "@mui/icons-material/Settings";+import VideoCameraFrontIcon from "@mui/icons-material/VideoCameraFront";+import VideoCameraFrontOutlinedIcon from "@mui/icons-material/VideoCameraFrontOutlined";import {useTranslation} from "react-i18next";import {CameraConfigTreeSection} from "./CameraConfigTreeSection";import {ROTATION_DEGREE_LABELS, RotationValue, useAppDispatch} from "@/store";-import {cameraSelectionToggled} from "@/store/slices/cameras/cameras-slice";+import {cameraRealtimeToggled, cameraSelectionToggled} from "@/store/slices/cameras/cameras-slice";import {Camera} from "@/store/slices/cameras/cameras-types";interface CameraTreeItemProps {@@ -69,6 +70,11 @@ export const CameraTreeItem: React.FC<CameraTreeItemProps> = ({camera, isExpandedispatch(cameraSelectionToggled(camera.id));};+ const handleToggleRealtime = (e: React.MouseEvent): void => {+ e.stopPropagation();+ dispatch(cameraRealtimeToggled(camera.id));+ };+const getStatusColor = (): string => {switch (camera.connectionStatus) {case "connected":@@ -98,21 +104,38 @@ export const CameraTreeItem: React.FC<CameraTreeItemProps> = ({camera, isExpandeminHeight: 32,}}>- {/* Selection checkbox */}- <IconButton- size="small"- onClick={handleToggleSelection}- sx={{mr: 1, flexShrink: 0}}- >- {camera.selected ? (- <CheckCircleIcon color="info"/>- ) : (- <RadioButtonUncheckedIcon color="info"/>- )}- </IconButton>-- {/* Camera icon */}- <VideocamIcon sx={{mr: 1, color: getStatusColor(), flexShrink: 0}}/>+ {/* Camera group selection */}+ <Tooltip title={camera.selected ? "In camera group" : "Not in camera group"} enterDelay={600} disableInteractive>+ <IconButton+ size="small"+ onClick={handleToggleSelection}+ sx={{mr: 0.5, flexShrink: 0}}+ >+ {camera.selected ? (+ <CheckCircleIcon color="primary"/>+ ) : (+ <RadioButtonUncheckedIcon color="disabled"/>+ )}+ </IconButton>+ </Tooltip>++ {/* Realtime pipeline toggle */}+ <Tooltip title={camera.realtimeEnabled ? "In realtime pipeline" : "Not in realtime pipeline"} enterDelay={600} disableInteractive>+ <span>+ <IconButton+ size="small"+ onClick={handleToggleRealtime}+ disabled={!camera.selected}+ sx={{mr: 1, flexShrink: 0}}+ >+ {camera.realtimeEnabled ? (+ <VideoCameraFrontIcon color="primary"/>+ ) : (+ <VideoCameraFrontOutlinedIcon color="disabled"/>+ )}+ </IconButton>+ </span>+ </Tooltip>{/* Camera name and config summary container */}<Box sx={{diff --git a/freemocap-ui/src/components/control-panels/mocap-control-panel/MocapPanel.tsx b/freemocap-ui/src/components/control-panels/mocap-control-panel/MocapPanel.tsxindex badde5c8..2cf2442e 100644--- a/freemocap-ui/src/components/control-panels/mocap-control-panel/MocapPanel.tsx+++ b/freemocap-ui/src/components/control-panels/mocap-control-panel/MocapPanel.tsx@@ -35,6 +35,8 @@ import {CollapsibleSidebarSection} from "@/components/common/CollapsibleSidebarSimport {BlenderSection} from "@/components/control-panels/mocap-control-panel/BlenderSection";import {RecordingStatusPanel} from "@/components/common/RecordingStatusPanel";import {useRecordingStatus} from "@/hooks/useRecordingStatus";+import {selectEffectiveRecordingPath} from "@/store/slices/active-recording/active-recording-slice";+import {useAppSelector} from "@/store";export const MocapPanel: React.FC = () => {const theme = useTheme();@@ -47,8 +49,6 @@ export const MocapPanel: React.FC = () => {isLoading,isRecording,recordingProgress,- processingProgress,- processingPhase,canStartRecording,canProcessMocapRecording,mocapRecordingPath,@@ -70,6 +70,24 @@ export const MocapPanel: React.FC = () => {directoryInfo: calibrationDirectoryInfo,} = useCalibration();+ // Effective path: actual activeRecording if any, otherwise the planned path+ const effectiveMocapPath = useAppSelector(selectEffectiveRecordingPath);++ // Derive recording ID from path (last folder name)+ const recordingId = useMemo(() => {+ if (!mocapRecordingPath) return null;+ const parts = mocapRecordingPath.replace(/[/\\]+$/, "").split(/[/\\]/);+ return parts[parts.length - 1] || null;+ }, [mocapRecordingPath]);++ // Derive parent directory so the backend can resolve non-default recording roots+ const recordingParentDirectory = useMemo(() => {+ if (!mocapRecordingPath) return null;+ const trimmed = mocapRecordingPath.replace(/[/\\]+$/, "");+ const idx = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));+ return idx > 0 ? trimmed.slice(0, idx) : null;+ }, [mocapRecordingPath]);+// Blender export is driven by the backend aggregator via config flags// (state.blender.*), which mocap-thunks.ts folds into the process request.// The standalone "Process Recording with Blender" button inside@@ -113,9 +131,9 @@ export const MocapPanel: React.FC = () => {};const handleOpenFolder = async (): Promise<void> => {- if (!isElectron || !api || !mocapRecordingPath) return;+ if (!isElectron || !api || !effectiveMocapPath) return;try {- await api.fileSystem.openFolder.mutate({path: mocapRecordingPath});+ await api.fileSystem.openFolder.mutate({path: effectiveMocapPath});} catch (err) {console.error("Failed to open folder:", err);setLocalError("Failed to open folder in file explorer");@@ -129,7 +147,7 @@ export const MocapPanel: React.FC = () => {if (newPath.includes("~") && isElectron && api) {try {const home: string = await api.fileSystem.getHomeDirectory.query();- const expanded: string = newPath.replace(/^~([/\\])?/, home ? `${home}$1` : "");+ const expanded: string = newPath.replace(/^~([/\\])?/, home ? home + '$1' : "");await setManualRecordingPath(expanded);} catch {await setManualRecordingPath(newPath);@@ -176,25 +194,6 @@ export const MocapPanel: React.FC = () => {const displayError = error || localError || directoryInfo?.errorMessage;- // Derive recording ID from path (last folder name)- const recordingId = useMemo(() => {- if (!mocapRecordingPath) return null;- const parts = mocapRecordingPath.replace(/[/\\]+$/, "").split(/[/\\]/);- return parts[parts.length - 1] || null;- }, [mocapRecordingPath]);-- // Derive parent directory so the backend can resolve non-default recording roots- const recordingParentDirectory = useMemo(() => {- if (!mocapRecordingPath) return null;- const trimmed = mocapRecordingPath.replace(/[/\\]+$/, "");- const idx = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));- return idx > 0 ? trimmed.slice(0, idx) : null;- }, [mocapRecordingPath]);-- // Only auto-fetch if the folder exists on disk — otherwise recordingId- // may tick every second (default path embeds a timestamp) and we'd spam- // the backend with 404s for folders that don't exist yet.- const directoryExists = directoryInfo?.exists ?? false;const {status: recordingStatus,isLoading: recordingStatusLoading,@@ -202,25 +201,12 @@ export const MocapPanel: React.FC = () => {refresh: refreshRecordingStatus,} = useRecordingStatus(recordingId, {recordingParentDirectory,- autoFetch: directoryExists,});- const formatPhase = (phase: string): string => {- const labels: Record<string, string> = {- detecting_frames: "Detecting",- collecting_frames: "Collecting",- all_frames_collected: "Collected",- running_task: "Processing",- complete: "Done",- failed: "Failed",- };- return labels[phase] ?? "Processing";- };-const statusLabel = isRecording- ? `Recording ${recordingProgress.toFixed(0)}%`+ ? "Recording " + recordingProgress.toFixed(0) + "%": isLoading- ? `${formatPhase(processingPhase)} ${processingProgress}%`+ ? "Running": effectiveCalibrationTomlPath? "Ready": "Idle";@@ -278,45 +264,49 @@ export const MocapPanel: React.FC = () => {borderRadius: 1,bgcolor: theme.palette.action.hover,}}>- <Typography variant="caption" color="text.secondary">- Recording ID- </Typography>+ <Stack direction="row" spacing={1} alignItems="center">+ <Typography variant="caption" color="text.secondary">+ Recording ID+ </Typography>+ </Stack><Typography variant="body2" sx={{fontFamily: "monospace", fontWeight: 600}}>{recordingId}</Typography></Box>)}- {/* Recording Controls */}- <Stack direction="row" spacing={2}>- <Button- variant="contained"- color="primary"- startIcon={<PlayArrowIcon />}- onClick={dispatchStartMocapRecording}- disabled={!canStartRecording || isLoading}- fullWidth- >- Start Mocap Recording- </Button>- {isRecording && (- <Button- variant="contained"- color="error"- startIcon={<StopIcon />}- onClick={dispatchStopMocapRecording}- disabled={isLoading}- fullWidth- >- Stop Recording- </Button>- )}- </Stack>+ {/*/!* Recording Controls *!/*/}+ {/* TODO - Wire up these recording buttons to the EXACT same workflow as the recording panel - current wiring has slop*/}+ {/*<Stack direction="row" spacing={2}>*/}+ {/* <Button*/}+ {/* variant="contained"*/}+ {/* color="primary"*/}+ {/* startIcon={<PlayArrowIcon />}*/}+ {/* onClick={dispatchStartMocapRecording}*/}+ {/* // disabled={!canStartRecording || isLoading}*/}+ {/* disabled={isLoading}*/}+ {/* fullWidth*/}+ {/* >*/}+ {/* Start Mocap Recording*/}+ {/* </Button>*/}+ {/* {isRecording && (*/}+ {/* <Button*/}+ {/* variant="contained"*/}+ {/* color="error"*/}+ {/* startIcon={<StopIcon />}*/}+ {/* onClick={dispatchStopMocapRecording}*/}+ {/* disabled={isLoading}*/}+ {/* fullWidth*/}+ {/* >*/}+ {/* Stop Recording*/}+ {/* </Button>*/}+ {/* )}*/}+ {/*</Stack>*/}{/* Recording Path Input */}<TextFieldlabel="Mocap Recording Path"- value={mocapRecordingPath}+ value={effectiveMocapPath || ''}onChange={handlePathInputChange}fullWidthsize="small"@@ -352,7 +342,7 @@ export const MocapPanel: React.FC = () => {onClick={handleOpenFolder}edge="end"size="small"- disabled={!isElectron || !mocapRecordingPath}+ disabled={!isElectron || !effectiveMocapPath}><LaunchIcon fontSize="small" /></IconButton>@@ -379,7 +369,7 @@ export const MocapPanel: React.FC = () => {refreshRecordingStatus();}}activeCalibrationTomlPath={effectiveCalibrationTomlPath}- folderExists={directoryExists}+ // folderExists={directoryExists}recordingFolderPath={mocapRecordingPath}/>)}@@ -410,7 +400,7 @@ export const MocapPanel: React.FC = () => {><Boxsx={{- width: `${recordingProgress}%`,+ width: recordingProgress + "%",height: "100%",bgcolor: theme.palette.primary.main,transition: "width 0.3s",@@ -420,33 +410,6 @@ export const MocapPanel: React.FC = () => {</Box>)}- {/* Processing Progress */}- {isLoading && !isRecording && processingProgress > 0 && (- <Box sx={{width: "100%"}}>- <Typography variant="caption" color="text.secondary" gutterBottom>- {formatPhase(processingPhase)}: {processingProgress}%- </Typography>- <Box- sx={{- width: "100%",- height: 8,- bgcolor: "grey.300",- borderRadius: 1,- overflow: "hidden",- }}- >- <Box- sx={{- width: `${processingProgress}%`,- height: "100%",- bgcolor: theme.palette.warning.main,- transition: "width 0.4s",- }}- />- </Box>- </Box>- )}-{/* Hierarchical pipeline config (replaces flat MediapipeConfigPanel + SkeletonFilterConfigPanel) */}<RealtimePipelineConfigTreecontext="posthoc"diff --git a/freemocap-ui/src/components/control-panels/realtime-panel/RealtimePipelineConfigTree.tsx b/freemocap-ui/src/components/control-panels/realtime-panel/RealtimePipelineConfigTree.tsxindex 078e93f2..264eda6d 100644--- a/freemocap-ui/src/components/control-panels/realtime-panel/RealtimePipelineConfigTree.tsx+++ b/freemocap-ui/src/components/control-panels/realtime-panel/RealtimePipelineConfigTree.tsx@@ -240,6 +240,9 @@ export const RealtimePipelineConfigTree: React.FC<PipelineConfigTreeProps> = ({</Box></RealtimePipelineStageTreeItem></RealtimePipelineStageTreeItem>+</SimpleTreeView>- );++)+ ;};diff --git a/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingInfoPanel.tsx b/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingInfoPanel.tsxindex 94df9bcf..bcea8566 100644--- a/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingInfoPanel.tsx+++ b/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingInfoPanel.tsx@@ -1,17 +1,32 @@-import React, {useEffect, useState} from "react";-import {Box, useTheme} from "@mui/material";+import React, {useEffect} from "react";+import {Box, Checkbox, FormControlLabel, useTheme} from "@mui/material";import {SimpleTreeView} from "@mui/x-tree-view/SimpleTreeView";import ExpandMoreIcon from "@mui/icons-material/ExpandMore";import ChevronRightIcon from "@mui/icons-material/ChevronRight";import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord';import {recordingInfoUpdated, startRecording, stopRecording, useAppDispatch, useAppSelector} from "@/store";-import {pathRecomputed} from "@/store/slices/recording/recording-slice";-import {manualCalibrationRecordingPathChanged} from "@/store/slices/calibration/calibration-slice";+import {+ autoProcessToggled,+ baseNameChanged,+ countdownSet,+ createSubfolderToggled,+ currentIncrementChanged,+ currentIncrementIncremented,+ customSubfolderNameChanged,+ delaySecondsChanged,+ micDeviceIndexChanged,+ pendingOperationSet,+ recordingTagChanged,+ recordingTypePresetChanged,+ useDelayStartToggled,+ useIncrementToggled,+ useTimestampToggled,+} from "@/store/slices/recording/recording-slice";+import type {RecordingTypePreset} from "@/store/slices/recording/recording-types";import {calibrateRecording} from "@/store/slices/calibration/calibration-thunks";-import {manualMocapRecordingPathChanged} from "@/store/slices/mocap/mocap-slice";import {processMocapRecording} from "@/store/slices/mocap/mocap-thunks";import {PresetPicker} from "@/components/common/PresetPicker";-import {RecordingTypePreset, RECORDING_TYPE_OPTIONS} from "./recording-type-preset";+import {MicrophoneSelector} from "@/components/control-panels/recording-info-panel/recording-subcomponents/MicrophoneSelector";@@ -23,115 +38,52 @@ import {CollapsibleSidebarSection} from "@/components/common/CollapsibleSidebarSimport {RecordingSummary} from "./RecordingSummary";import {RecordingHeaderButton} from "./RecordingHeaderButton";-interface RecordingOperation {- type: 'start' | 'stop';- timestamp: number;-}+export type {RecordingTypePreset};++export const RECORDING_TYPE_OPTIONS: { value: RecordingTypePreset; label: string }[] = [+ {value: "none", label: "None"},+ {value: "calibration", label: "Calibration"},+ {value: "mocap", label: "Mocap"},+];export const RecordingInfoPanel: React.FC = () => {const theme = useTheme();const dispatch = useAppDispatch();- const recordingInfo = useAppSelector(- (state) => state.recording- );-- // Local UI state- const [createSubfolder, setCreateSubfolder] = useState<boolean>(false);- const [useDelayStart, setUseDelayStart] = useState<boolean>(false);- const [delaySeconds, setDelaySeconds] = useState<number>(3);- const [countdown, setCountdown] = useState<number | null>(null);-- // Track pending operation and recording start time- const [pendingOperation, setPendingOperation] = useState<RecordingOperation | null>(null);- const [recordingStartTime, setRecordingStartTime] = useState<number | null>(null);+ const recordingInfo = useAppSelector((state) => state.recording);+ const {config, pendingOperation, countdown} = recordingInfo;+ const {+ createSubfolder,+ useDelayStart,+ delaySeconds,+ useTimestamp,+ useIncrement,+ currentIncrement,+ baseName,+ customSubfolderName,+ recordingTag,+ micDeviceIndex,+ recordingTypePreset,+ autoProcess,+ } = config;- // Local recording naming- const [useTimestamp, setUseTimestamp] = useState<boolean>(true);- const [useIncrement, setUseIncrement] = useState<boolean>(false);- const [currentIncrement, setCurrentIncrement] = useState<number>(1);- const [baseName, setBaseName] = useState<string>("recording");- const [customSubfolderName, setCustomSubfolderName] = useState<string>("");- const [recordingTag, setRecordingTag] = useState<string>("");- const [micDeviceIndex, setMicDeviceIndex] = useState<number>(-1);- const [recordingTypePreset, setRecordingTypePreset] = useState<RecordingTypePreset>("none");const {isElectron, api} = useElectronIPC();const {connectedCameraIds} = useServer();const noCamerasConnected = connectedCameraIds.length === 0;- // Recording duration for summary- const [recordingDuration, setRecordingDuration] = useState<string>("");-- // Keep the computed recording path timestamp ticking with the wall clock- useEffect(() => {- if (recordingInfo.isRecording) return;- const id = setInterval(() => dispatch(pathRecomputed()), 1000);- return () => clearInterval(id);- }, [dispatch, recordingInfo.isRecording]);-- // Track when recording state changes to clear pending state- useEffect(() => {- if (pendingOperation) {- const isNowRecording = recordingInfo.isRecording;- const wasStarting = pendingOperation.type === 'start';- const wasStopping = pendingOperation.type === 'stop';-- // Clear pending if state changed as expected- if ((wasStarting && isNowRecording) || (wasStopping && !isNowRecording)) {- setPendingOperation(null);- // Set or clear recording start time- if (wasStarting && isNowRecording) {- setRecordingStartTime(Date.now());- } else if (wasStopping && !isNowRecording) {- setRecordingStartTime(null);- setRecordingDuration("");- }- }-- // Timeout fallback - clear pending after 5 seconds if thunk hasn't responded- const timeoutMs = 5000;- const elapsed = Date.now() - pendingOperation.timestamp;- if (elapsed > timeoutMs) {- console.error(`Recording ${pendingOperation.type} operation timed out after ${timeoutMs}ms`);- setPendingOperation(null);- }- }- }, [recordingInfo.isRecording, pendingOperation]);-- // Set initial recording start time if already recording on mount+ // Timeout fallback - clear pending after 5 seconds if thunk hasn't respondeduseEffect(() => {- if (recordingInfo.isRecording && !recordingStartTime) {- setRecordingStartTime(Date.now());- }- }, []);-- // Update recording duration display- useEffect(() => {- if (!recordingInfo.isRecording || !recordingStartTime) {- setRecordingDuration("");- return;- }+ if (!pendingOperation) return;+ const timeoutMs = 5000;+ const elapsed = Date.now() - pendingOperation.timestamp;+ const remaining = Math.max(0, timeoutMs - elapsed);+ const timer = setTimeout(() => {+ console.error("Recording " + pendingOperation.type + " operation timed out after " + timeoutMs + "ms");+ dispatch(pendingOperationSet(null));+ }, remaining);+ return () => clearTimeout(timer);+ }, [dispatch, pendingOperation]);- const updateDuration = (): void => {- const now = Date.now();- const seconds = Math.floor((now - recordingStartTime) / 1000);- const hours = Math.floor(seconds / 3600);- const minutes = Math.floor((seconds % 3600) / 60);- const secs = seconds % 60;-- const parts: string[] = [];- if (hours > 0) {- parts.push(hours.toString().padStart(2, '0'));- }- parts.push(minutes.toString().padStart(2, '0'));- parts.push(secs.toString().padStart(2, '0'));- setRecordingDuration(parts.join(':'));- };-- updateDuration();- const interval = setInterval(updateDuration, 1000);- return () => clearInterval(interval);- }, [recordingInfo.isRecording, recordingStartTime]);// replace ~ with user's home directoryuseEffect(() => {@@ -153,59 +105,40 @@ export const RecordingInfoPanel: React.FC = () => {// Handle countdown timeruseEffect(() => {- if (countdown !== null && countdown > 0) {- const timer = setTimeout(() => setCountdown(countdown - 1), 1000);+ if (countdown === null) return;+ if (countdown > 0) {+ const timer = setTimeout(() => dispatch(countdownSet(countdown - 1)), 1000);return () => clearTimeout(timer);- } else if (countdown === 0) {- handleStartRecording();- setCountdown(null);}+ // countdown === 0+ dispatch(countdownSet(null));+ handleStartRecording();}, [countdown]);- const handleRecordingTagChange = (tag: string): void => {- setRecordingTag(tag);- };-- const buildRecordingName = (): string => {- const parts: string[] = [];-- if (useTimestamp) {- parts.push(getTimestampString());- } else {- parts.push(baseName);- }-- if (recordingTypePreset !== "none") {- parts.push(recordingTypePreset);- }-- if (recordingTag) {- parts.push(recordingTag);- }-- return parts.join("_");- };const handleStartRecording = async (): Promise<void> => {console.log("Starting recording...");- const recordingName = buildRecordingName();+ const ts = getTimestampString();+ const nameParts = useTimestamp ? [ts] : [baseName];+ if (recordingTypePreset !== "none") nameParts.push(recordingTypePreset);+ if (recordingTag) nameParts.push(recordingTag);+ const recordingName = nameParts.join("_");const subfolderName = createSubfolder? customSubfolderName || getTimestampString(): "";const recordingPath = createSubfolder- ? `${recordingInfo.recordingDirectory}/${subfolderName}`+ ? recordingInfo.recordingDirectory + "/" + subfolderName: recordingInfo.recordingDirectory;console.log("Recording path:", recordingPath);console.log("Recording name:", recordingName);if (useIncrement) {- setCurrentIncrement((prev) => prev + 1);+ dispatch(currentIncrementIncremented());}- // Set pending state before dispatching- setPendingOperation({type: 'start', timestamp: Date.now()});+ dispatch(pendingOperationSet({type: 'start', timestamp: Date.now()}));try {await dispatch(@@ -217,72 +150,48 @@ export const RecordingInfoPanel: React.FC = () => {).unwrap();} catch (error) {console.error("Failed to start recording:", error);- setPendingOperation(null);+ dispatch(pendingOperationSet(null));throw error; // Fail loudly as per preferences}};const handleRecordButtonClick = async (): Promise<void> => {- // Don't allow clicking while pendingif (pendingOperation) {return;}if (recordingInfo.isRecording) {console.log("Stopping recording...");- setPendingOperation({type: 'stop', timestamp: Date.now()});+ dispatch(pendingOperationSet({type: 'stop', timestamp: Date.now()}));try {const result = await dispatch(stopRecording()).unwrap();- // Auto-launch pipeline based on recording type preset- if (result && recordingTypePreset === "calibration") {- dispatch(manualCalibrationRecordingPathChanged(result.recording_path));+ if (result && autoProcess && recordingTypePreset === "calibration") {dispatch(calibrateRecording());- } else if (result && recordingTypePreset === "mocap") {- dispatch(manualMocapRecordingPathChanged(result.recording_path));+ } else if (result && autoProcess && recordingTypePreset === "mocap") {dispatch(processMocapRecording());}} catch (error) {console.error("Failed to stop recording:", error);- setPendingOperation(null);+ dispatch(pendingOperationSet(null));throw error; // Fail loudly as per preferences}} else if (useDelayStart) {- console.log(`Starting countdown from ${delaySeconds} seconds`);- setCountdown(delaySeconds);+ console.log("Starting countdown from " + delaySeconds + " seconds");+ dispatch(countdownSet(delaySeconds));} else {await handleStartRecording();}};- const recordingName = buildRecordingName();- const subfolderName = createSubfolder- ? customSubfolderName || getTimestampString()- : undefined;-return (<CollapsibleSidebarSectionicon={<FiberManualRecordIcon sx={{color: "inherit"}}/>}title={"Recording"}- secondaryControls={- <PresetPicker- value={recordingTypePreset}- options={RECORDING_TYPE_OPTIONS}- onChange={setRecordingTypePreset}- disabled={recordingInfo.isRecording}- size="small"- minWidth={80}- sx={{- '& .MuiSelect-select': {py: 0.25, fontSize: 12, color: 'inherit'},- '& .MuiOutlinedInput-notchedOutline': {borderColor: 'rgba(255,255,255,0.3)'},- '& .MuiSvgIcon-root': {color: 'inherit'},- }}- />- }summaryContent={<RecordingSummaryisRecording={recordingInfo.isRecording}- recordingDuration={recordingDuration}+ startedAt={recordingInfo.startedAt}/>}primaryControl={@@ -293,6 +202,43 @@ export const RecordingInfoPanel: React.FC = () => {onClick={handleRecordButtonClick}/>}+ secondaryControls={+ <Box sx={{display: 'flex', alignItems: 'center', gap: 0.5}}>+ <PresetPicker+ value={recordingTypePreset}+ options={RECORDING_TYPE_OPTIONS}+ onChange={(v) => dispatch(recordingTypePresetChanged(v))}+ disabled={recordingInfo.isRecording}+ size="small"+ minWidth={70}+ sx={{+ '& .MuiSelect-select': {py: 0.25, fontSize: 11, color: 'inherit'},+ '& .MuiOutlinedInput-notchedOutline': {borderColor: 'rgba(255,255,255,0.3)'},+ '& .MuiSvgIcon-root': {color: 'inherit', fontSize: 14},+ }}+ />+ <FormControlLabel+ control={+ <Checkbox+ checked={autoProcess}+ onChange={(e) => dispatch(autoProcessToggled(e.target.checked))}+ disabled={recordingTypePreset === "none" || recordingInfo.isRecording}+ size="small"+ sx={{py: 0, '& .MuiSvgIcon-root': {fontSize: 14}}}+ />+ }+ label="Auto Process"+ sx={{+ ml: 0,+ mr: 0,+ '& .MuiFormControlLabel-label': {+ fontSize: 10,+ opacity: recordingTypePreset === "none" ? 0.5 : 1,+ },+ }}+ />+ </Box>+ }defaultExpanded={false}><Box@@ -322,40 +268,37 @@ export const RecordingInfoPanel: React.FC = () => {},}}>- {/* Full recording button in expanded content */}- <Box sx={{ px: 1, py: 1 }}>- {/* Microphone selector */}+ <Box sx={{px: 1, py: 1}}><MicrophoneSelectorselectedMicIndex={micDeviceIndex}- onMicSelected={setMicDeviceIndex}+ onMicSelected={(idx) => dispatch(micDeviceIndexChanged(idx))}disabled={recordingInfo.isRecording}/></Box>-+<RecordingPathTreeItemrecordingDirectory={recordingInfo.recordingDirectory}- recordingName={recordingName}- subfolder={subfolderName}countdown={countdown}recordingTag={recordingTag}useDelayStart={useDelayStart}delaySeconds={delaySeconds}useTimestamp={useTimestamp}baseName={baseName}+ recordingTypePreset={recordingTypePreset}useIncrement={useIncrement}currentIncrement={currentIncrement}createSubfolder={createSubfolder}customSubfolderName={customSubfolderName}isRecording={recordingInfo.isRecording}- onDelayToggle={setUseDelayStart}- onDelayChange={setDelaySeconds}- onTagChange={handleRecordingTagChange}- onUseTimestampChange={setUseTimestamp}- onBaseNameChange={setBaseName}- onUseIncrementChange={setUseIncrement}- onIncrementChange={setCurrentIncrement}- onCreateSubfolderChange={setCreateSubfolder}- onCustomSubfolderNameChange={setCustomSubfolderName}+ onDelayToggle={(v) => dispatch(useDelayStartToggled(v))}+ onDelayChange={(v) => dispatch(delaySecondsChanged(v))}+ onTagChange={(v) => dispatch(recordingTagChanged(v))}+ onUseTimestampChange={(v) => dispatch(useTimestampToggled(v))}+ onBaseNameChange={(v) => dispatch(baseNameChanged(v))}+ onUseIncrementChange={(v) => dispatch(useIncrementToggled(v))}+ onIncrementChange={(v) => dispatch(currentIncrementChanged(v))}+ onCreateSubfolderChange={(v) => dispatch(createSubfolderToggled(v))}+ onCustomSubfolderNameChange={(v) => dispatch(customSubfolderNameChanged(v))}/></SimpleTreeView></Box>diff --git a/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingPathTreeItem.tsx b/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingPathTreeItem.tsxindex cb54e422..fb597dbf 100644--- a/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingPathTreeItem.tsx+++ b/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingPathTreeItem.tsx@@ -1,22 +1,21 @@-import React from 'react';+import React, {useEffect, useState} from 'react';import {Box, Typography} from '@mui/material';import {TreeItem} from '@mui/x-tree-view/TreeItem';import {FullRecordingPathPreview} from "@/components/control-panels/recording-info-panel/recording-subcomponents/FullRecordingPathPreview";import {RecordingControlsSection} from "@/components/control-panels/recording-info-panel/RecordingControlsTreeSection";+import {getTimestampString} from "@/components/control-panels/recording-info-panel/getTimestampString";interface RecordingPathTreeItemProps {recordingDirectory: string;- recordingName: string;- subfolder?: string;countdown: number | null;- // Add all the control propsrecordingTag: string;useDelayStart: boolean;delaySeconds: number;useTimestamp: boolean;baseName: string;+ recordingTypePreset: string;useIncrement: boolean;currentIncrement: number;createSubfolder: boolean;@@ -35,15 +34,13 @@ interface RecordingPathTreeItemProps {export const RecordingPathTreeItem: React.FC<RecordingPathTreeItemProps> = ({recordingDirectory,- recordingName,- subfolder,countdown,- // Control propsrecordingTag,useDelayStart,delaySeconds,useTimestamp,baseName,+ recordingTypePreset,useIncrement,currentIncrement,createSubfolder,@@ -59,6 +56,26 @@ export const RecordingPathTreeItem: React.FC<RecordingPathTreeItemProps> = ({onCreateSubfolderChange,onCustomSubfolderNameChange}) => {+ // Tick once per second while not recording so the name preview stays current.+ // Isolated here so only this subtree re-renders, not the entire panel.+ const [previewTimestamp, setPreviewTimestamp] = useState<string>(() => getTimestampString());+ useEffect(() => {+ if (isRecording) return;+ const id = setInterval(() => setPreviewTimestamp(getTimestampString()), 1000);+ return () => clearInterval(id);+ }, [isRecording]);++ const nameParts: string[] = [];+ if (useTimestamp) {+ nameParts.push(previewTimestamp);+ } else {+ nameParts.push(baseName);+ }+ if (recordingTypePreset !== "none") nameParts.push(recordingTypePreset);+ if (recordingTag) nameParts.push(recordingTag);+ const recordingName = nameParts.join("_");+ const subfolder = createSubfolder ? customSubfolderName || previewTimestamp : undefined;+return (<TreeItemitemId="recording-path"diff --git a/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingSummary.tsx b/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingSummary.tsxindex 11b20c15..47c50a2c 100644--- a/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingSummary.tsx+++ b/freemocap-ui/src/components/control-panels/recording-info-panel/RecordingSummary.tsx@@ -1,16 +1,39 @@-import React from "react";+import React, {useEffect, useState} from "react";import {Chip, Typography, useTheme} from "@mui/material";import FiberManualRecordIcon from "@mui/icons-material/FiberManualRecord";+function formatDuration(startedAt: string): string {+ const seconds = Math.floor((Date.now() - new Date(startedAt).getTime()) / 1000);+ const hours = Math.floor(seconds / 3600);+ const minutes = Math.floor((seconds % 3600) / 60);+ const secs = seconds % 60;+ const parts: string[] = [];+ if (hours > 0) parts.push(hours.toString().padStart(2, '0'));+ parts.push(minutes.toString().padStart(2, '0'));+ parts.push(secs.toString().padStart(2, '0'));+ return parts.join(':');+}+interface RecordingSummaryProps {isRecording: boolean;- recordingDuration?: string;+ startedAt: string | null;}export const RecordingSummary: React.FC<RecordingSummaryProps> = ({isRecording,- recordingDuration,+ startedAt,}) => {+ const [recordingDuration, setRecordingDuration] = useState<string>("");++ useEffect(() => {+ if (!isRecording || !startedAt) {+ setRecordingDuration("");+ return;+ }+ setRecordingDuration(formatDuration(startedAt));+ const id = setInterval(() => setRecordingDuration(formatDuration(startedAt)), 1000);+ return () => clearInterval(id);+ }, [isRecording, startedAt]);const theme = useTheme();if (!isRecording) {diff --git a/freemocap-ui/src/components/control-panels/recording-info-panel/recording-type-preset.ts b/freemocap-ui/src/components/control-panels/recording-info-panel/recording-type-preset.tsdeleted file mode 100644index e5520d42..00000000--- a/freemocap-ui/src/components/control-panels/recording-info-panel/recording-type-preset.ts+++ /dev/null@@ -1,7 +0,0 @@-export type RecordingTypePreset = "none" | "calibration" | "mocap";--export const RECORDING_TYPE_OPTIONS: { value: RecordingTypePreset; label: string }[] = [- {value: "none", label: "None"},- {value: "calibration", label: "Cal"},- {value: "mocap", label: "Mocap"},-];diff --git a/freemocap-ui/src/components/control-panels/server-connection/ServerConnectionStatus.tsx b/freemocap-ui/src/components/control-panels/server-connection/ServerConnectionStatus.tsxnew file mode 100644index 00000000..5cecfbab--- /dev/null+++ b/freemocap-ui/src/components/control-panels/server-connection/ServerConnectionStatus.tsx@@ -0,0 +1,31 @@+import React from 'react';+import {Box, Collapse} from '@mui/material';+import {useServerPanel} from './useServerPanel';+import {ServerStatusBar} from './ServerStatusBar';+import {ServerProcessSection} from './ServerProcessSection';+import {WebSocketSection} from './WebSocketSection';++export const ServerConnectionStatus: React.FC = () => {+ const panel = useServerPanel();+ const {theme, expanded, setExpanded, isElectron} = panel;++ return (+ <Box+ sx={{+ borderBottom: `1px solid ${theme.palette.divider}`,+ backgroundColor: theme.palette.mode === 'dark'+ ? 'rgba(0, 0, 0, 0.2)'+ : 'rgba(0, 0, 0, 0.02)',+ }}+ >+ <ServerStatusBar {...panel} setExpanded={setExpanded} expanded={expanded}/>++ <Collapse in={expanded}>+ <Box sx={{px: 1.5, pb: 1.5, display: 'flex', flexDirection: 'column', gap: 1.5}}>+ {isElectron && <ServerProcessSection {...panel}/>}+ <WebSocketSection {...panel}/>+ </Box>+ </Collapse>+ </Box>+ );+};diff --git a/freemocap-ui/src/components/control-panels/server-connection/ServerProcessSection.tsx b/freemocap-ui/src/components/control-panels/server-connection/ServerProcessSection.tsxnew file mode 100644index 00000000..7ca920db--- /dev/null+++ b/freemocap-ui/src/components/control-panels/server-connection/ServerProcessSection.tsx@@ -0,0 +1,285 @@+import React from 'react';+import {+ Box,+ Button,+ CircularProgress,+ FormControl,+ FormControlLabel,+ IconButton,+ InputLabel,+ MenuItem,+ Select,+ Switch,+ Tooltip,+ Typography,+} from '@mui/material';+import PlayArrowIcon from '@mui/icons-material/PlayArrow';+import StopIcon from '@mui/icons-material/Stop';+import RestartAltIcon from '@mui/icons-material/RestartAlt';+import RefreshIcon from '@mui/icons-material/Refresh';+import FolderOpenIcon from '@mui/icons-material/FolderOpen';+import {useTranslation} from 'react-i18next';+import {ServerPanelState} from './useServerPanel';++type Props = Pick<+ ServerPanelState,+ | 'theme'+ | 'serverRunning'+ | 'serverLoading'+ | 'processInfo'+ | 'currentExePath'+ | 'autoLaunchServer'+ | 'selectedExePath'+ | 'setSelectedExePath'+ | 'candidates'+ | 'candidatesLoading'+ | 'validCandidates'+ | 'invalidCandidates'+ | 'error'+ | 'startServer'+ | 'stopServer'+ | 'resetServer'+ | 'refreshCandidates'+ | 'browseForExecutable'+ | 'handleToggleAutoLaunch'+>;++export const ServerProcessSection: React.FC<Props> = ({+ theme,+ serverRunning,+ serverLoading,+ processInfo,+ currentExePath,+ autoLaunchServer,+ selectedExePath,+ setSelectedExePath,+ candidatesLoading,+ validCandidates,+ invalidCandidates,+ error,+ startServer,+ stopServer,+ resetServer,+ refreshCandidates,+ browseForExecutable,+ handleToggleAutoLaunch,+}) => {+ const {t} = useTranslation();++ return (+ <Box sx={{border: `1px solid ${theme.palette.divider}`, borderRadius: 1, p: 1}}>+ {/* Header */}+ <Box sx={{display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 0.5}}>+ <Typography variant="caption" sx={{fontWeight: 600, color: theme.palette.text.secondary}}>+ SERVER PROCESS+ </Typography>+ <FormControlLabel+ control={+ <Switch+ size="small"+ checked={autoLaunchServer}+ onClick={handleToggleAutoLaunch}+ onChange={() => {}}+ />+ }+ label={+ <Typography variant="caption" sx={{fontSize: '0.65rem', color: theme.palette.text.secondary}}>+ {t('autoLaunch')}+ </Typography>+ }+ sx={{mr: 0, ml: 0, height: 24}}+ labelPlacement="start"+ />+ </Box>++ {/* Status dot */}+ <Box sx={{display: 'flex', alignItems: 'center', gap: 0.5, mb: 1}}>+ <Box+ sx={{+ width: 8,+ height: 8,+ borderRadius: '50%',+ backgroundColor: serverRunning+ ? theme.palette.success.main+ : theme.palette.error.main,+ }}+ />+ <Typography variant="caption" sx={{color: theme.palette.text.primary}}>+ {serverRunning ? t('running') : t('stopped')}+ {processInfo?.pid && ` (PID: ${processInfo.pid})`}+ </Typography>+ </Box>++ {/* Executable selector */}+ <FormControl fullWidth size="small" sx={{mb: 1}}>+ <InputLabel sx={{fontSize: '0.75rem'}}>{t('executable')}</InputLabel>+ <Select+ value={selectedExePath}+ onChange={(e) => setSelectedExePath(e.target.value)}+ label={t('executable')}+ disabled={serverRunning || serverLoading}+ sx={{fontSize: '0.75rem'}}+ renderValue={(value) => (+ <Tooltip title={value as string} placement="bottom-start">+ <Box+ sx={{+ overflow: 'auto',+ whiteSpace: 'nowrap',+ '&::-webkit-scrollbar': {height: 4},+ '&::-webkit-scrollbar-track': {background: 'transparent'},+ '&::-webkit-scrollbar-thumb': {background: theme.palette.divider, borderRadius: 2},+ }}+ >+ <Typography variant="caption" sx={{fontSize: '0.75rem'}}>+ {value as string}+ </Typography>+ </Box>+ </Tooltip>+ )}+ >+ {validCandidates.map((candidate) => (+ <MenuItem key={candidate.path} value={candidate.path} sx={{fontSize: '0.75rem'}}>+ <Tooltip title={candidate.path} placement="right">+ <Box sx={{minWidth: 0, maxWidth: 400}}>+ <Typography variant="caption" sx={{fontWeight: 600}}>+ {candidate.name}+ </Typography>+ <Typography+ variant="caption"+ sx={{+ display: 'block',+ color: theme.palette.text.secondary,+ fontSize: '0.65rem',+ whiteSpace: 'nowrap',+ }}+ >+ {candidate.path}+ </Typography>+ </Box>+ </Tooltip>+ </MenuItem>+ ))}+ {invalidCandidates.length > 0 && validCandidates.length > 0 && (+ <MenuItem disabled divider sx={{fontSize: '0.65rem', opacity: 0.5}}>+ — invalid —+ </MenuItem>+ )}+ {invalidCandidates.map((candidate) => (+ <MenuItem+ key={candidate.path}+ value={candidate.path}+ disabled+ sx={{fontSize: '0.75rem', opacity: 0.4}}+ >+ <Tooltip title={candidate.error || t('invalid')} placement="right">+ <Typography variant="caption">+ {candidate.name} — {candidate.error || 'not found'}+ </Typography>+ </Tooltip>+ </MenuItem>+ ))}+ </Select>+ </FormControl>++ {/* Browse + Refresh */}+ <Box sx={{display: 'flex', gap: 0.5, mb: 1}}>+ <Tooltip title={t('browseForExecutable')}>+ <IconButton+ size="small"+ onClick={browseForExecutable}+ disabled={serverRunning || serverLoading}+ sx={{border: `1px solid ${theme.palette.divider}`, borderRadius: 1}}+ >+ <FolderOpenIcon sx={{fontSize: 16}}/>+ </IconButton>+ </Tooltip>+ <Tooltip title={t('refreshCandidates')}>+ <IconButton+ size="small"+ onClick={refreshCandidates}+ disabled={serverRunning || candidatesLoading}+ sx={{border: `1px solid ${theme.palette.divider}`, borderRadius: 1}}+ >+ {candidatesLoading ? (+ <CircularProgress size={14}/>+ ) : (+ <RefreshIcon sx={{fontSize: 16}}/>+ )}+ </IconButton>+ </Tooltip>+ </Box>++ {/* Action buttons */}+ <Box sx={{display: 'flex', gap: 0.5}}>+ <Button+ variant="contained"+ size="small"+ color="success"+ startIcon={serverLoading ? <CircularProgress size={14} color="inherit"/> : <PlayArrowIcon/>}+ onClick={() => startServer()}+ disabled={serverRunning || serverLoading}+ sx={{flex: 1, fontSize: '0.7rem', textTransform: 'none'}}+ >+ Launch+ </Button>+ <Button+ variant="contained"+ size="small"+ color="error"+ startIcon={serverLoading ? <CircularProgress size={14} color="inherit"/> : <StopIcon/>}+ onClick={() => stopServer()}+ disabled={!serverRunning || serverLoading}+ sx={{flex: 1, fontSize: '0.7rem', textTransform: 'none'}}+ >+ Stop+ </Button>+ <Button+ variant="outlined"+ size="small"+ startIcon={serverLoading ? <CircularProgress size={14}/> : <RestartAltIcon/>}+ onClick={() => resetServer()}+ disabled={!serverRunning || serverLoading}+ sx={{flex: 1, fontSize: '0.7rem', textTransform: 'none'}}+ >+ Reset+ </Button>+ </Box>++ {/* Running executable path */}+ {currentExePath && (+ <Tooltip title={currentExePath} placement="bottom">+ <Typography+ variant="caption"+ sx={{+ mt: 0.5,+ display: 'block',+ color: theme.palette.text.secondary,+ fontSize: '0.6rem',+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap',+ }}+ >+ {t('runningPath', {path: currentExePath})}+ </Typography>+ </Tooltip>+ )}++ {/* Error */}+ {error && (+ <Typography+ variant="caption"+ sx={{+ mt: 0.5,+ display: 'block',+ color: theme.palette.error.main,+ fontSize: '0.65rem',+ wordBreak: 'break-word',+ }}+ >+ {error}+ </Typography>+ )}+ </Box>+ );+};diff --git a/freemocap-ui/src/components/control-panels/server-connection/ServerStatusBar.tsx b/freemocap-ui/src/components/control-panels/server-connection/ServerStatusBar.tsxnew file mode 100644index 00000000..cf30c467--- /dev/null+++ b/freemocap-ui/src/components/control-panels/server-connection/ServerStatusBar.tsx@@ -0,0 +1,134 @@+import React from 'react';+import {Box, Chip, IconButton, Tooltip, Typography} from '@mui/material';+import {CircularProgress} from '@mui/material';+import WifiIcon from '@mui/icons-material/Wifi';+import WifiOffIcon from '@mui/icons-material/WifiOff';+import PlayArrowIcon from '@mui/icons-material/PlayArrow';+import StopIcon from '@mui/icons-material/Stop';+import ExpandMoreIcon from '@mui/icons-material/ExpandMore';+import ExpandLessIcon from '@mui/icons-material/ExpandLess';+import {useTranslation} from 'react-i18next';+import {ServerPanelState} from './useServerPanel';++type Props = Pick<+ ServerPanelState,+ | 'theme'+ | 'isConnected'+ | 'connectedCameraIds'+ | 'isElectron'+ | 'expanded'+ | 'setExpanded'+ | 'serverRunning'+ | 'serverLoading'+ | 'autoConnectWs'+ | 'wsStatusColor'+ | 'serverStatusColor'+ | 'handleToggleWsConnected'+ | 'handleToggleServerRunning'+>;++export const ServerStatusBar: React.FC<Props> = ({+ theme,+ isConnected,+ connectedCameraIds,+ isElectron,+ expanded,+ setExpanded,+ serverRunning,+ serverLoading,+ autoConnectWs,+ wsStatusColor,+ serverStatusColor,+ handleToggleWsConnected,+ handleToggleServerRunning,+}) => {+ const {t} = useTranslation();++ return (+ <Box+ onClick={() => setExpanded((prev) => !prev)}+ sx={{+ display: 'flex',+ alignItems: 'center',+ gap: 0.5,+ px: 1.5,+ py: 0.5,+ cursor: 'pointer',+ '&:hover': {backgroundColor: 'rgba(255,255,255,0.03)'},+ }}+ >+ <Box sx={{display: 'flex', alignItems: 'center', gap: 0.5, flex: 1, minWidth: 0}}>+ <Tooltip title={isConnected ? t('disconnectWebSocket') : t('connectWebSocket')}>+ <IconButton+ size="small"+ onClick={handleToggleWsConnected}+ sx={{p: 0.25, color: wsStatusColor}}+ >+ {isConnected ? (+ <WifiIcon sx={{fontSize: 16}}/>+ ) : (+ <WifiOffIcon sx={{fontSize: 16}}/>+ )}+ </IconButton>+ </Tooltip>++ <Typography+ variant="caption"+ sx={{fontWeight: 500, color: wsStatusColor, whiteSpace: 'nowrap', fontSize: '0.7rem'}}+ >+ {isConnected ? t('connected') : autoConnectWs ? t('connecting') : t('off')}+ </Typography>++ {isElectron && (+ <>+ <Box sx={{mx: 0.25, color: theme.palette.text.disabled, fontSize: '0.7rem'}}>|</Box>++ <Tooltip title={serverRunning ? t('stopServer') : t('launchServer')}>+ <IconButton+ size="small"+ onClick={handleToggleServerRunning}+ disabled={serverLoading}+ sx={{p: 0.25, color: serverStatusColor}}+ >+ {serverLoading ? (+ <CircularProgress size={14}/>+ ) : serverRunning ? (+ <StopIcon sx={{fontSize: 16}}/>+ ) : (+ <PlayArrowIcon sx={{fontSize: 16}}/>+ )}+ </IconButton>+ </Tooltip>++ <Typography+ variant="caption"+ sx={{fontWeight: 500, color: serverStatusColor, whiteSpace: 'nowrap', fontSize: '0.7rem'}}+ >+ {serverLoading ? t('working') : serverRunning ? t('running') : t('stopped')}+ </Typography>+ </>+ )}++ {isConnected && connectedCameraIds.length > 0 && (+ <Chip+ label={`${connectedCameraIds.length} cam${connectedCameraIds.length !== 1 ? 's' : ''}`}+ size="small"+ sx={{+ height: 18,+ fontSize: '0.6rem',+ ml: 0.5,+ backgroundColor: 'rgba(0, 255, 255, 0.1)',+ color: '#00ffff',+ }}+ />+ )}+ </Box>++ {expanded ? (+ <ExpandLessIcon sx={{fontSize: 16, color: theme.palette.text.secondary}}/>+ ) : (+ <ExpandMoreIcon sx={{fontSize: 16, color: theme.palette.text.secondary}}/>+ )}+ </Box>+ );+};diff --git a/freemocap-ui/src/components/control-panels/server-connection/WebSocketSection.tsx b/freemocap-ui/src/components/control-panels/server-connection/WebSocketSection.tsxnew file mode 100644index 00000000..d767bd7e--- /dev/null+++ b/freemocap-ui/src/components/control-panels/server-connection/WebSocketSection.tsx@@ -0,0 +1,133 @@+import React from 'react';+import {Box, Button, FormControlLabel, Switch, TextField, Typography} from '@mui/material';+import WifiIcon from '@mui/icons-material/Wifi';+import WifiOffIcon from '@mui/icons-material/WifiOff';+import {useTranslation} from 'react-i18next';+import {ServerPanelState} from './useServerPanel';++type Props = Pick<+ ServerPanelState,+ | 'theme'+ | 'isConnected'+ | 'connectedCameraIds'+ | 'autoConnectWs'+ | 'hostDraft'+ | 'setHostDraft'+ | 'portDraft'+ | 'setPortDraft'+ | 'applyHostPort'+ | 'handleHostPortKeyDown'+ | 'handleToggleAutoConnectWs'+ | 'handleToggleWsConnected'+>;++export const WebSocketSection: React.FC<Props> = ({+ theme,+ isConnected,+ connectedCameraIds,+ autoConnectWs,+ hostDraft,+ setHostDraft,+ portDraft,+ setPortDraft,+ applyHostPort,+ handleHostPortKeyDown,+ handleToggleAutoConnectWs,+ handleToggleWsConnected,+}) => {+ const {t} = useTranslation();++ return (+ <Box sx={{border: `1px solid ${theme.palette.divider}`, borderRadius: 1, p: 1}}>+ {/* Header */}+ <Box sx={{display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 0.5}}>+ <Typography variant="caption" sx={{fontWeight: 600, color: theme.palette.text.secondary}}>+ WEBSOCKET CONNECTION+ </Typography>+ <FormControlLabel+ control={+ <Switch+ size="small"+ checked={autoConnectWs}+ onClick={handleToggleAutoConnectWs}+ onChange={() => {}}+ />+ }+ label={+ <Typography variant="caption" sx={{fontSize: '0.65rem', color: theme.palette.text.secondary}}>+ {t('autoConnect')}+ </Typography>+ }+ sx={{mr: 0, ml: 0, height: 24}}+ labelPlacement="start"+ />+ </Box>++ {/* Host / Port inputs */}+ <Box sx={{display: 'flex', gap: 0.5, mb: 1}}>+ <TextField+ size="small"+ label={t('host')}+ value={hostDraft}+ onChange={(e) => setHostDraft(e.target.value)}+ onBlur={applyHostPort}+ onKeyDown={handleHostPortKeyDown}+ disabled={isConnected}+ slotProps={{+ inputLabel: {sx: {fontSize: '0.7rem'}},+ input: {sx: {fontSize: '0.75rem'}},+ }}+ sx={{flex: 3}}+ />+ <TextField+ size="small"+ label={t('port')}+ type="number"+ value={portDraft}+ onChange={(e) => setPortDraft(e.target.value)}+ onBlur={applyHostPort}+ onKeyDown={handleHostPortKeyDown}+ disabled={isConnected}+ slotProps={{+ inputLabel: {sx: {fontSize: '0.7rem'}},+ input: {sx: {fontSize: '0.75rem'}},+ htmlInput: {min: 1, max: 65535},+ }}+ sx={{flex: 1}}+ />+ </Box>++ {/* Status + connect button */}+ <Box sx={{display: 'flex', alignItems: 'center', gap: 1}}>+ <Box+ sx={{+ width: 8,+ height: 8,+ borderRadius: '50%',+ backgroundColor: isConnected ? '#00ffff' : theme.palette.error.main,+ }}+ />+ <Typography variant="caption" sx={{color: theme.palette.text.primary, flex: 1}}>+ {isConnected ? t('connected') : autoConnectWs ? t('connecting') : t('disconnected')}+ {isConnected && connectedCameraIds.length > 0+ ? ` — ${connectedCameraIds.length} camera${connectedCameraIds.length !== 1 ? 's' : ''}`+ : ''}+ </Typography>++ <Button+ variant={isConnected ? 'outlined' : 'contained'}+ size="small"+ color={isConnected ? 'error' : 'info'}+ startIcon={isConnected ? <WifiOffIcon/> : <WifiIcon/>}+ onClick={(e) => {+ e.stopPropagation();+ handleToggleWsConnected(e);+ }}+ sx={{fontSize: '0.7rem', textTransform: 'none'}}+ >+ {isConnected ? t('disconnect') : t('connect')}+ </Button>+ </Box>+ </Box>+ );+};diff --git a/freemocap-ui/src/components/control-panels/server-connection/index.ts b/freemocap-ui/src/components/control-panels/server-connection/index.tsnew file mode 100644index 00000000..c117aff8--- /dev/null+++ b/freemocap-ui/src/components/control-panels/server-connection/index.ts@@ -0,0 +1 @@+export {ServerConnectionStatus} from './ServerConnectionStatus';diff --git a/freemocap-ui/src/components/control-panels/server-connection/storage.ts b/freemocap-ui/src/components/control-panels/server-connection/storage.tsnew file mode 100644index 00000000..ccdccf42--- /dev/null+++ b/freemocap-ui/src/components/control-panels/server-connection/storage.ts@@ -0,0 +1,26 @@+export const STORAGE_KEYS = {+ SELECTED_EXE_PATH: 'freemocap:selectedExePath',+ PANEL_EXPANDED: 'freemocap:serverPanelExpanded',+ AUTO_LAUNCH_SERVER: 'freemocap:autoLaunchServer',+ AUTO_CONNECT_WS: 'freemocap:autoConnectWs',+ SERVER_HOST: 'freemocap:serverHost',+ SERVER_PORT: 'freemocap:serverPort',+} as const;++export function loadFromStorage<T>(key: string, fallback: T): T {+ try {+ const raw = localStorage.getItem(key);+ if (raw === null) return fallback;+ return JSON.parse(raw) as T;+ } catch {+ return fallback;+ }+}++export function saveToStorage(key: string, value: unknown): void {+ try {+ localStorage.setItem(key, JSON.stringify(value));+ } catch (err) {+ console.error(`Failed to save ${key} to localStorage:`, err);+ }+}diff --git a/freemocap-ui/src/components/control-panels/server-connection/types.ts b/freemocap-ui/src/components/control-panels/server-connection/types.tsnew file mode 100644index 00000000..ac094cf8--- /dev/null+++ b/freemocap-ui/src/components/control-panels/server-connection/types.ts@@ -0,0 +1,11 @@+export interface ExecutableCandidate {+ name: string;+ path: string;+ description: string;+ isValid?: boolean;+ error?: string;+ resolvedPath?: string;+}++export const AUTO_CONNECT_DELAY_MS = 2000;+export const WS_RECONNECT_INTERVAL_MS = 3000;diff --git a/freemocap-ui/src/components/control-panels/server-connection/useServerPanel.ts b/freemocap-ui/src/components/control-panels/server-connection/useServerPanel.tsnew file mode 100644index 00000000..2d328e6a--- /dev/null+++ b/freemocap-ui/src/components/control-panels/server-connection/useServerPanel.ts@@ -0,0 +1,369 @@+import React, {useCallback, useEffect, useRef, useState} from 'react';+import {Theme, useTheme} from '@mui/material/styles';+import {useServer} from '@/services/server/ServerContextProvider';+import {useTranslation} from 'react-i18next';+import {useElectronIPC} from '@/services';+import {DEFAULT_HOST, DEFAULT_PORT} from '@/constants/server-urls';+import {ExecutableCandidate, WS_RECONNECT_INTERVAL_MS} from './types';+import {STORAGE_KEYS, loadFromStorage, saveToStorage} from './storage';++export interface ServerPanelState {+ // theme+ theme: Theme;+ // server context+ isConnected: boolean;+ connectedCameraIds: string[];+ // electron+ isElectron: boolean;+ // persisted UI+ expanded: boolean;+ setExpanded: React.Dispatch<React.SetStateAction<boolean>>;+ selectedExePath: string;+ setSelectedExePath: React.Dispatch<React.SetStateAction<string>>;+ autoLaunchServer: boolean;+ autoConnectWs: boolean;+ serverHost: string;+ serverPort: number;+ // drafts+ hostDraft: string;+ setHostDraft: React.Dispatch<React.SetStateAction<string>>;+ portDraft: string;+ setPortDraft: React.Dispatch<React.SetStateAction<string>>;+ // transient+ serverRunning: boolean;+ serverLoading: boolean;+ currentExePath: string | null;+ candidates: ExecutableCandidate[];+ candidatesLoading: boolean;+ processInfo: { pid: number | undefined; killed: boolean } | null;+ error: string | null;+ // actions+ startServer: () => Promise<void>;+ stopServer: () => Promise<void>;+ resetServer: () => Promise<void>;+ refreshCandidates: () => Promise<void>;+ browseForExecutable: () => Promise<void>;+ // toggle handlers+ handleToggleAutoLaunch: (e: React.MouseEvent) => void;+ handleToggleAutoConnectWs: (e: React.MouseEvent) => void;+ handleToggleServerRunning: (e: React.MouseEvent) => void;+ handleToggleWsConnected: (e: React.MouseEvent) => void;+ // host/port+ applyHostPort: () => void;+ handleHostPortKeyDown: (e: React.KeyboardEvent) => void;+ // derived+ wsStatusColor: string;+ serverStatusColor: string;+ validCandidates: ExecutableCandidate[];+ invalidCandidates: ExecutableCandidate[];+}++export function useServerPanel(): ServerPanelState {+ const theme = useTheme();+ const {isConnected, connect, disconnect, connectedCameraIds, updateServerConnection} = useServer();+ const {t} = useTranslation();+ const {isElectron, api} = useElectronIPC();++ // Persisted UI state+ const [expanded, setExpanded] = useState(() => loadFromStorage(STORAGE_KEYS.PANEL_EXPANDED, false));+ const [selectedExePath, setSelectedExePath] = useState(() => loadFromStorage(STORAGE_KEYS.SELECTED_EXE_PATH, ''));+ const [autoLaunchServer, setAutoLaunchServer] = useState(() => loadFromStorage(STORAGE_KEYS.AUTO_LAUNCH_SERVER, true));+ const [autoConnectWs, setAutoConnectWs] = useState(() => loadFromStorage(STORAGE_KEYS.AUTO_CONNECT_WS, true));+ const [serverHost, setServerHost] = useState(() => loadFromStorage(STORAGE_KEYS.SERVER_HOST, DEFAULT_HOST));+ const [serverPort, setServerPort] = useState(() => loadFromStorage(STORAGE_KEYS.SERVER_PORT, DEFAULT_PORT));++ // Text field drafts (applied on blur/enter so we don't reconnect on every keystroke)+ const [hostDraft, setHostDraft] = useState(serverHost);+ const [portDraft, setPortDraft] = useState(String(serverPort));++ // Transient state+ const [serverRunning, setServerRunning] = useState(false);+ const [serverLoading, setServerLoading] = useState(false);+ const [currentExePath, setCurrentExePath] = useState<string | null>(null);+ const [candidates, setCandidates] = useState<ExecutableCandidate[]>([]);+ const [candidatesLoading, setCandidatesLoading] = useState(false);+ const [processInfo, setProcessInfo] = useState<{ pid: number | undefined; killed: boolean } | null>(null);+ const [error, setError] = useState<string | null>(null);++ const autoLaunchFiredRef = useRef(false);+ const serverLaunchingRef = useRef(false);++ // ── Persistence effects ──++ useEffect(() => { saveToStorage(STORAGE_KEYS.PANEL_EXPANDED, expanded); }, [expanded]);+ useEffect(() => { saveToStorage(STORAGE_KEYS.SELECTED_EXE_PATH, selectedExePath); }, [selectedExePath]);+ useEffect(() => { saveToStorage(STORAGE_KEYS.AUTO_LAUNCH_SERVER, autoLaunchServer); }, [autoLaunchServer]);+ useEffect(() => { saveToStorage(STORAGE_KEYS.AUTO_CONNECT_WS, autoConnectWs); }, [autoConnectWs]);+ useEffect(() => { saveToStorage(STORAGE_KEYS.SERVER_HOST, serverHost); }, [serverHost]);+ useEffect(() => { saveToStorage(STORAGE_KEYS.SERVER_PORT, serverPort); }, [serverPort]);++ // Apply persisted host/port to the server connection once on mount.+ // Intentionally runs only once — serverHost/serverPort here are the values+ // loaded from localStorage at initialisation. Subsequent reconnections when+ // the user changes these values are handled by applyHostPort().+ // eslint-disable-next-line react-hooks/exhaustive-deps+ useEffect(() => {+ updateServerConnection(serverHost, serverPort);+ }, []);++ // ── Server status polling ──++ const pollServerStatus = useCallback(async () => {+ if (!isElectron || !api) return;+ try {+ const running = await api.pythonServer.isRunning.query();+ setServerRunning(running);+ const info = await api.pythonServer.getProcessInfo.query();+ setProcessInfo(info);+ const exePath = await api.pythonServer.getExecutablePath.query();+ setCurrentExePath(exePath);+ } catch (err) {+ console.error('Failed to poll server status:', err);+ }+ }, [isElectron, api]);++ // ── Candidate management ──++ const loadCandidates = useCallback(async () => {+ if (!isElectron || !api) return;+ setCandidatesLoading(true);+ try {+ const result = await api.pythonServer.getExecutableCandidates.query();+ const typed = result as ExecutableCandidate[];+ setCandidates(typed);+ if (!selectedExePath) {+ const firstValid = typed.find((c) => c.isValid);+ if (firstValid) setSelectedExePath(firstValid.path);+ }+ } catch (err) {+ console.error('Failed to load executable candidates:', err);+ setError(`Failed to load candidates: ${err instanceof Error ? err.message : String(err)}`);+ } finally {+ setCandidatesLoading(false);+ }+ }, [isElectron, api, selectedExePath]);++ const refreshCandidates = useCallback(async () => {+ if (!isElectron || !api) return;+ setCandidatesLoading(true);+ setError(null);+ try {+ const result = await api.pythonServer.refreshCandidates.mutate();+ const typed = result as ExecutableCandidate[];+ setCandidates(typed);+ const firstValid = typed.find((c) => c.isValid);+ if (firstValid) setSelectedExePath(firstValid.path);+ } catch (err) {+ console.error('Failed to refresh candidates:', err);+ setError(`Failed to refresh: ${err instanceof Error ? err.message : String(err)}`);+ } finally {+ setCandidatesLoading(false);+ }+ }, [isElectron, api]);++ const browseForExecutable = useCallback(async () => {+ if (!isElectron || !api) return;+ try {+ const filePath = await api.fileSystem.selectExecutableFile.mutate();+ if (filePath) setSelectedExePath(filePath);+ } catch (err) {+ console.error('Failed to browse for executable:', err);+ setError(`Browse failed: ${err instanceof Error ? err.message : String(err)}`);+ }+ }, [isElectron, api]);++ // ── Server actions ──++ const startServer = useCallback(async () => {+ if (!isElectron || !api) return;+ if (serverLaunchingRef.current) return;+ serverLaunchingRef.current = true;+ setServerLoading(true);+ setError(null);+ try {+ await api.pythonServer.start.mutate({ exePath: selectedExePath || null });+ await pollServerStatus();+ } catch (err) {+ console.error('Failed to start server:', err);+ setError(`Start failed: ${err instanceof Error ? err.message : String(err)}`);+ } finally {+ setServerLoading(false);+ serverLaunchingRef.current = false;+ }+ }, [isElectron, api, selectedExePath, pollServerStatus]);++ const stopServer = useCallback(async () => {+ if (!isElectron || !api) return;+ setServerLoading(true);+ setError(null);+ try {+ disconnect();+ await api.pythonServer.stop.mutate();+ await pollServerStatus();+ } catch (err) {+ console.error('Failed to stop server:', err);+ setError(`Stop failed: ${err instanceof Error ? err.message : String(err)}`);+ } finally {+ setServerLoading(false);+ }+ }, [isElectron, api, pollServerStatus, disconnect]);++ const resetServer = useCallback(async () => {+ if (!isElectron || !api) return;+ setServerLoading(true);+ setError(null);+ try {+ disconnect();+ await api.pythonServer.stop.mutate();+ await new Promise((resolve) => setTimeout(resolve, 500));+ await api.pythonServer.start.mutate({ exePath: selectedExePath || null });+ await pollServerStatus();+ } catch (err) {+ console.error('Failed to reset server:', err);+ setError(`Reset failed: ${err instanceof Error ? err.message : String(err)}`);+ } finally {+ setServerLoading(false);+ }+ }, [isElectron, api, selectedExePath, pollServerStatus, disconnect]);++ // ── Initial load + polling ──++ useEffect(() => {+ if (isElectron && api) {+ pollServerStatus();+ loadCandidates();+ }+ }, [isElectron, api, pollServerStatus, loadCandidates]);++ useEffect(() => {+ if (!isElectron || !api) return;+ const interval = setInterval(pollServerStatus, 5000);+ return () => clearInterval(interval);+ }, [isElectron, api, pollServerStatus]);++ // ── Auto-launch server (once) ──++ useEffect(() => {+ if (!isElectron || !api) return;+ if (!autoLaunchServer) return;+ if (autoLaunchFiredRef.current) return;+ if (candidatesLoading) return;+ if (serverRunning || serverLoading) return;++ autoLaunchFiredRef.current = true;+ console.log('Auto-launching server...');+ startServer();+ }, [isElectron, api, autoLaunchServer, candidatesLoading, serverRunning, serverLoading, startServer]);++ // ── WebSocket auto-reconnect ──++ useEffect(() => {+ if (!autoConnectWs) return;+ if (isConnected) return;++ connect();++ const interval = setInterval(() => {+ if (!isConnected) connect();+ }, WS_RECONNECT_INTERVAL_MS);++ return () => clearInterval(interval);+ }, [autoConnectWs, isConnected, connect]);++ // ── Toggle handlers ──++ const handleToggleAutoLaunch = useCallback((e: React.MouseEvent) => {+ e.stopPropagation();+ setAutoLaunchServer((prev) => !prev);+ }, []);++ const handleToggleAutoConnectWs = useCallback((e: React.MouseEvent) => {+ e.stopPropagation();+ setAutoConnectWs((prev) => {+ const next = !prev;+ if (!next) disconnect();+ return next;+ });+ }, [disconnect]);++ const handleToggleServerRunning = useCallback((e: React.MouseEvent) => {+ e.stopPropagation();+ if (serverRunning) stopServer();+ else startServer();+ }, [serverRunning, startServer, stopServer]);++ const handleToggleWsConnected = useCallback((e: React.MouseEvent) => {+ e.stopPropagation();+ if (isConnected) {+ setAutoConnectWs(false);+ disconnect();+ } else {+ setAutoConnectWs(true);+ connect();+ }+ }, [isConnected, connect, disconnect]);++ // ── Host / port ──++ const applyHostPort = useCallback(() => {+ const trimmedHost = hostDraft.trim();+ const parsedPort = parseInt(portDraft, 10);+ if (!trimmedHost) return;+ if (isNaN(parsedPort) || parsedPort < 1 || parsedPort > 65535) return;+ setServerHost(trimmedHost);+ setServerPort(parsedPort);+ updateServerConnection(trimmedHost, parsedPort);+ }, [hostDraft, portDraft, updateServerConnection]);++ const handleHostPortKeyDown = useCallback((e: React.KeyboardEvent) => {+ if (e.key === 'Enter') applyHostPort();+ }, [applyHostPort]);++ // ── Derived values ──++ const wsStatusColor = isConnected ? '#00ffff' : '#f44336';+ const serverStatusColor = serverRunning ? theme.palette.success.main : theme.palette.text.disabled;+ const validCandidates = candidates.filter((c) => c.isValid);+ const invalidCandidates = candidates.filter((c) => !c.isValid);++ return {+ theme,+ isConnected,+ connectedCameraIds,+ isElectron,+ expanded,+ setExpanded,+ selectedExePath,+ setSelectedExePath,+ autoLaunchServer,+ autoConnectWs,+ serverHost,+ serverPort,+ hostDraft,+ setHostDraft,+ portDraft,+ setPortDraft,+ serverRunning,+ serverLoading,+ currentExePath,+ candidates,+ candidatesLoading,+ processInfo,+ error,+ startServer,+ stopServer,+ resetServer,+ refreshCandidates,+ browseForExecutable,+ handleToggleAutoLaunch,+ handleToggleAutoConnectWs,+ handleToggleServerRunning,+ handleToggleWsConnected,+ applyHostPort,+ handleHostPortKeyDown,+ wsStatusColor,+ serverStatusColor,+ validCandidates,+ invalidCandidates,+ };+}diff --git a/freemocap-ui/src/components/framerate-viewer/BaseD3ChartView.tsx b/freemocap-ui/src/components/framerate-viewer/BaseD3ChartView.tsxindex 95d41bfd..ec3ab776 100644--- a/freemocap-ui/src/components/framerate-viewer/BaseD3ChartView.tsx+++ b/freemocap-ui/src/components/framerate-viewer/BaseD3ChartView.tsx@@ -41,7 +41,7 @@ type BaseChartViewProps = {let nextClipId = 0/** How often (ms) to run the imperative D3 data-update. */-const CHART_UPDATE_INTERVAL_MS = 500+const CHART_UPDATE_INTERVAL_MS = 1000export default memo(function BaseD3ChartView({title,diff --git a/freemocap-ui/src/components/framerate-viewer/FrameRateViewer.tsx b/freemocap-ui/src/components/framerate-viewer/FrameRateViewer.tsxindex 8222e947..7f076700 100644--- a/freemocap-ui/src/components/framerate-viewer/FrameRateViewer.tsx+++ b/freemocap-ui/src/components/framerate-viewer/FrameRateViewer.tsx@@ -1,5 +1,5 @@// src/components/framerate-viewer/FrameRateViewer.tsx-import {useState} from "react"+import {useEffect, useRef, useState} from "react"import {Box, IconButton, Paper, Stack, Tooltip, Typography} from "@mui/material"import {BarChart, ShowChart, TableChart} from "@mui/icons-material"import {alpha, useTheme} from "@mui/material/styles"@@ -7,11 +7,54 @@ import FramerateTimeseriesView from "./FramerateTimeseriesView"import FramerateHistogramView from "./FramerateHistogramView"import FramerateStatisticsView from "./FramerateStatisticsView"import {useTranslation} from "react-i18next";+import {useServer} from "@/services/server/ServerContextProvider";+import {DetailedFramerate} from "@/services/server/server-helpers/framerate-store";export const frontendColor: string = "#1976D2"export const backendColor: string = "#ff4d00"-export const FramerateViewerPanel = () => {+const fmtFps = (fr: DetailedFramerate | null): string => {+ if (!fr || !fr.frame_duration_mean || fr.frame_duration_mean <= 0) return "-- fps";+ return `${(1000 / fr.frame_duration_mean).toFixed(1)} fps ±${fr.frame_duration_stddev.toFixed(1)}ms`;+};++const FramerateCollapsedView = () => {+ const {getFramerateStore} = useServer();+ const backendRef = useRef<HTMLSpanElement>(null);+ const frontendRef = useRef<HTMLSpanElement>(null);++ useEffect(() => {+ const tick = () => {+ const snap = getFramerateStore().getSnapshot();+ if (backendRef.current) backendRef.current.textContent = fmtFps(snap.aggregateBackendFramerate);+ if (frontendRef.current) frontendRef.current.textContent = fmtFps(snap.aggregateFrontendFramerate);+ };+ tick();+ const id = setInterval(tick, 500);+ return () => clearInterval(id);+ }, [getFramerateStore]);++ return (+ <Box sx={{height: '100%', display: 'flex', alignItems: 'center', gap: 1.5, px: 1, overflow: 'hidden'}}>+ <Typography noWrap sx={{fontSize: '0.75rem', fontWeight: 'bold', color: 'text.secondary', flexShrink: 0}}>+ Camera Performance+ </Typography>+ <Typography noWrap sx={{fontSize: '0.75rem', color: backendColor, flexShrink: 0}}>+ Server: <span ref={backendRef}>-- fps</span>+ </Typography>+ <Typography noWrap sx={{fontSize: '0.75rem', color: frontendColor, flexShrink: 0}}>+ Display: <span ref={frontendRef}>-- fps</span>+ </Typography>+ </Box>+ );+};++export const FramerateViewerPanel = ({isCollapsed = false}: { isCollapsed?: boolean }) => {+ if (isCollapsed) return <FramerateCollapsedView/>;+ return <FramerateViewerPanelExpanded/>;+};++const FramerateViewerPanelExpanded = () => {const theme = useTheme()const { t } = useTranslation();const [showStats, setShowStats] = useState(true)diff --git a/freemocap-ui/src/components/log-terminal/Linkify.tsx b/freemocap-ui/src/components/log-terminal/Linkify.tsxnew file mode 100644index 00000000..961f14ad--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/Linkify.tsx@@ -0,0 +1,31 @@+import React from 'react';++// Splits text on http/https URLs. When split() is called with a capture group,+// matched segments land at odd indices, so i % 2 === 1 identifies URLs.+const URL_REGEX = /(https?:\/\/[^\s)"'>\]]+)/g;++export const Linkify = ({text}: {text: string}) => {+ const parts = text.split(URL_REGEX);+ if (parts.length === 1) return <>{text}</>;++ return (+ <>+ {parts.map((part, i) =>+ i % 2 === 1 ? (+ <a+ key={i}+ href={part}+ target="_blank"+ rel="noopener noreferrer"+ style={{color: "#58a6ff", textDecoration: "underline"}}+ onClick={(e) => e.stopPropagation()}+ >+ {part}+ </a>+ ) : (+ <span key={i}>{part}</span>+ )+ )}+ </>+ );+};diff --git a/freemocap-ui/src/components/log-terminal/LogEntryDetail.tsx b/freemocap-ui/src/components/log-terminal/LogEntryDetail.tsxnew file mode 100644index 00000000..721f37a1--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/LogEntryDetail.tsx@@ -0,0 +1,63 @@+import React from 'react';+import {useTranslation} from 'react-i18next';+import {LogRecord} from '@/services/server/server-helpers/log-store';+import {Linkify} from './Linkify';++interface Props {+ log: LogRecord;+ color: string;+}++export const LogEntryDetail: React.FC<Props> = ({log, color}) => {+ const {t} = useTranslation();++ return (+ <div+ style={{+ paddingLeft: 16,+ paddingTop: 6,+ paddingBottom: 6,+ fontSize: '0.8em',+ color: '#888',+ borderTop: '1px solid rgba(255,255,255,0.1)',+ whiteSpace: 'pre-wrap',+ lineHeight: '1.4',+ overflow: 'visible',+ }}+ onClick={(e) => e.stopPropagation()}+ >+ <div>Location: {log.module}:{log.funcName}:Line#{log.lineno}</div>+ <div>{t('fileLabel')}: {log.filename}</div>+ <div>{t('timeDelta')}: {log.delta_t}</div>+ <div>{t('pathLabel')}: <Linkify text={log.pathname}/></div>+ {log.formatted_message && (+ <div>{t('rawMessage')}: <Linkify text={log.formatted_message}/></div>+ )}+ <div>Thread: {log.threadName} (ID: {log.thread})</div>+ <div>Process: {log.processName} (ID: {log.process})</div>+ {(log.exc_info || log.exc_text) && (+ <div>+ <div>{t('exceptionDetails')}:</div>+ {log.exc_info && <div><Linkify text={log.exc_info}/></div>}+ {log.exc_text && <div><Linkify text={log.exc_text}/></div>}+ </div>+ )}+ {log.stack_info && (+ <div>+ <div>{t('stackTrace')}:</div>+ <pre+ style={{+ whiteSpace: 'pre-wrap',+ background: '#111',+ padding: 8,+ borderRadius: 4,+ margin: '8px 0',+ }}+ >+ <Linkify text={log.stack_info}/>+ </pre>+ </div>+ )}+ </div>+ );+};diff --git a/freemocap-ui/src/components/log-terminal/LogEntryRow.tsx b/freemocap-ui/src/components/log-terminal/LogEntryRow.tsxnew file mode 100644index 00000000..ef25f1f6--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/LogEntryRow.tsx@@ -0,0 +1,166 @@+import React, {useRef, useState, useEffect} from 'react';+import {LogRecord} from '@/services/server/server-helpers/log-store';+import {LOG_COLORS, LINE_HEIGHT, ROW_PADDING} from './constants';+import {Linkify} from './Linkify';+import {LogEntryDetail} from './LogEntryDetail';++interface Props {+ log: LogRecord;+ style: React.CSSProperties;+}++export const LogEntryRow = React.memo(({log, style}: Props) => {+ // ── Divider entry: session boundary marker ───────────────────────────+ if (log.type === 'divider') {+ return (+ <div+ style={{+ ...style,+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ paddingLeft: 16,+ paddingRight: 16,+ }}+ >+ <div+ style={{+ flex: 1,+ height: 1,+ backgroundColor: 'rgba(255,255,255,0.12)',+ }}+ />+ <span+ style={{+ flexShrink: 0,+ padding: '0 12px',+ fontSize: '0.7em',+ fontFamily: 'monospace',+ color: 'rgba(255,255,255,0.25)',+ whiteSpace: 'nowrap',+ }}+ >+ {log.message}+ </span>+ <div+ style={{+ flex: 1,+ height: 1,+ backgroundColor: 'rgba(255,255,255,0.12)',+ }}+ />+ </div>+ );+ }++ // ── Normal log entry ─────────────────────────────────────────────────+ const [expanded, setExpanded] = useState(false);+ const rowRef = useRef<HTMLDivElement>(null);+ const color = LOG_COLORS[log.levelname.toUpperCase()] || '#ccc';+ const multiLine = log.message.includes('\n');++ useEffect(() => {+ if (!expanded) return;+ const handleClickOutside = (e: MouseEvent) => {+ if (rowRef.current && !rowRef.current.contains(e.target as Node)) {+ setExpanded(false);+ }+ };+ document.addEventListener('mousedown', handleClickOutside);+ return () => document.removeEventListener('mousedown', handleClickOutside);+ }, [expanded]);++ return (+ <div+ ref={rowRef}+ style={{+ ...style,+ borderLeft: `2px solid ${color}`,+ paddingLeft: 8,+ paddingTop: ROW_PADDING / 2,+ paddingBottom: ROW_PADDING / 2,+ backgroundColor: expanded ? `${color}1a` : 'rgba(0,0,0,0.2)',+ cursor: 'pointer',+ fontFamily: 'monospace',+ fontSize: '0.85em',+ lineHeight: `${LINE_HEIGHT}px`,+ overflow: expanded ? 'visible' : 'hidden',+ position: 'relative',+ }}+ onClick={() => setExpanded((prev) => !prev)}+ >+ {/* Header line: timestamp + level badge + first (or only) message line */}+ <div style={{whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>+ <span style={{color: '#888', marginRight: 8, fontSize: '0.7em'}}>+ {log.asctime}+ </span>+ <span+ style={{+ backgroundColor: color,+ color: '#000',+ padding: '1px 5px',+ borderRadius: 2,+ fontSize: '0.5em',+ fontWeight: 600,+ marginRight: 4,+ display: 'inline-block',+ lineHeight: 'normal',+ verticalAlign: 'middle',+ }}+ >+ {log.levelname}+ </span>+ {/*Show UI vs Server tag*/}+ {/*<span*/}+ {/* style={{*/}+ {/* backgroundColor: log.source === 'ui' ? '#FF9944' : '#4488aa',*/}+ {/* color: '#000',*/}+ {/* padding: '1px 5px',*/}+ {/* borderRadius: 2,*/}+ {/* fontSize: '0.75em',*/}+ {/* fontWeight: 600,*/}+ {/* marginRight: 8,*/}+ {/* display: 'inline-block',*/}+ {/* lineHeight: 'normal',*/}+ {/* verticalAlign: 'middle',*/}+ {/* }}*/}+ {/*>*/}+ {/* {log.source === 'ui' ? 'UI' : 'SERVER'}*/}+ {/*</span>*/}+ <span style={{color: color, fontSize: '0.75em'}}>+ <Linkify text={multiLine ? log.message.split('\n')[0] : log.message}/>+ </span>+ </div>++ {/* Remaining lines for multi-line messages */}+ {multiLine && (+ <div style={{whiteSpace: 'pre', fontSize: '0.75em', color: color, paddingLeft: 4}}>+ <Linkify text={log.message.split('\n').slice(1).join('\n')}/>+ </div>+ )}++ {/* Expanded metadata overlay */}+ {expanded && (+ <div+ style={{+ position: 'absolute',+ top: '100%',+ left: 0,+ right: 0,+ zIndex: 10,+ backgroundColor: '#1a1a1a',+ borderLeft: `2px solid ${color}`,+ borderBottom: `1px solid ${color}`,+ boxShadow: '0 4px 12px rgba(0,0,0,0.5)',+ overflow: 'auto',+ maxHeight: 400,+ }}+ onClick={(e) => e.stopPropagation()}+ >+ <LogEntryDetail log={log} color={color}/>+ </div>+ )}+ </div>+ );+});+LogEntryRow.displayName = 'LogEntryRow';diff --git a/freemocap-ui/src/components/log-terminal/LogSearchBar.tsx b/freemocap-ui/src/components/log-terminal/LogSearchBar.tsxnew file mode 100644index 00000000..c4d19092--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/LogSearchBar.tsx@@ -0,0 +1,29 @@+import React from 'react';+import {Box, TextField, useTheme} from '@mui/material';+import {Search as SearchIcon} from '@mui/icons-material';+import {useTranslation} from 'react-i18next';++interface Props {+ searchText: string;+ onSearchChange: (text: string) => void;+}++export const LogSearchBar: React.FC<Props> = ({searchText, onSearchChange}) => {+ const theme = useTheme();+ const {t} = useTranslation();++ return (+ <Box sx={{p: 1, borderBottom: '1px solid', borderColor: theme.palette.divider}}>+ <TextField+ size="small"+ fullWidth+ placeholder={t('searchLogs')}+ value={searchText}+ onChange={(e) => onSearchChange(e.target.value)}+ InputProps={{+ startAdornment: <SearchIcon sx={{mr: 1, color: 'text.secondary'}}/>,+ }}+ />+ </Box>+ );+};diff --git a/freemocap-ui/src/components/log-terminal/LogTerminal.tsx b/freemocap-ui/src/components/log-terminal/LogTerminal.tsxnew file mode 100644index 00000000..979f4f55--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/LogTerminal.tsx@@ -0,0 +1,95 @@+import React from 'react';+import {Box, useTheme} from '@mui/material';+import {Warning as WarningIcon} from '@mui/icons-material';+import {useLogTerminal} from './useLogTerminal';+import {LogToolbar} from './LogToolbar';+import {LogSearchBar} from './LogSearchBar';+import {VirtualLogList} from './VirtualLogList';+import {LogSnapshot, LogRecord} from '@/services/server/server-helpers/log-store';+import {LOG_COLORS} from './constants';++const LogCollapsedView: React.FC<{snapshot: LogSnapshot; filteredLogs: LogRecord[]}> = ({snapshot, filteredLogs}) => {+ const theme = useTheme();+ const mostRecent = filteredLogs[filteredLogs.length - 1] ?? snapshot.entries[snapshot.entries.length - 1];+ const color = mostRecent+ ? (LOG_COLORS[mostRecent.levelname.toUpperCase()] ?? theme.palette.text.primary)+ : theme.palette.text.secondary;++ return (+ <Box sx={{+ height: '100%',+ display: 'flex',+ alignItems: 'center',+ gap: 1,+ px: 1,+ overflow: 'hidden',+ backgroundColor: theme.palette.mode === 'dark' ? '#1a1a1a' : theme.palette.grey[100],+ }}>+ <span style={{fontSize: '0.8em', fontWeight: 'bold', color: theme.palette.text.primary as string, flexShrink: 0}}>+ Server Logs+ </span>+ {snapshot.hasErrors && (+ <WarningIcon sx={{color: LOG_COLORS.ERROR, fontSize: '1em', flexShrink: 0}}/>+ )}+ <span style={{fontSize: '0.75em', color, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap'}}>+ {mostRecent ? `[${mostRecent.levelname}] ${mostRecent.message}` : 'No logs yet'}+ </span>+ </Box>+ );+};++export const LogTerminal: React.FC<{isCollapsed?: boolean}> = ({isCollapsed = false}) => {+ const theme = useTheme();+ const terminal = useLogTerminal();++ if (isCollapsed) {+ return <LogCollapsedView snapshot={terminal.snapshot} filteredLogs={terminal.filteredLogs}/>;+ }++ return (+ <Box+ sx={{+ height: '100%',+ display: 'flex',+ flexDirection: 'column',+ backgroundColor: theme.palette.mode === 'dark' ? '#1a1a1a' : theme.palette.grey[100],+ }}+ >+ <LogToolbar+ snapshot={terminal.snapshot}+ isPaused={terminal.isPaused}+ copyFeedback={terminal.copyFeedback}+ showSearch={terminal.showSearch}+ showLevelFilters={terminal.showLevelFilters}+ selectedLevels={terminal.selectedLevels}+ onLevelToggle={terminal.handleLevelToggle}+ onPauseToggle={terminal.handlePauseToggle}+ onClear={terminal.handleClear}+ onCopyToClipboard={terminal.handleCopyToClipboard}+ onSaveToDisk={terminal.handleSaveToDisk}+ onScrollToBottom={terminal.scrollToBottom}+ onToggleSearch={() => terminal.setShowSearch((prev) => !prev)}+ onToggleLevelFilters={() => terminal.setShowLevelFilters((prev) => !prev)}+ />++ {terminal.showSearch && (+ <LogSearchBar+ searchText={terminal.searchText}+ onSearchChange={terminal.setSearchText}+ />+ )}++ <VirtualLogList+ filteredLogs={terminal.filteredLogs}+ prefixHeights={terminal.prefixHeights}+ totalHeight={terminal.totalHeight}+ startIdx={terminal.startIdx}+ endIdx={terminal.endIdx}+ offsetY={terminal.offsetY}+ isPaused={terminal.isPaused}+ scrollContainerRef={terminal.scrollContainerRef}+ onScroll={terminal.handleScroll}+ />+ </Box>+ );+};diff --git a/freemocap-ui/src/components/log-terminal/LogToolbar.tsx b/freemocap-ui/src/components/log-terminal/LogToolbar.tsxnew file mode 100644index 00000000..2af854eb--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/LogToolbar.tsx@@ -0,0 +1,193 @@+import React, {memo} from 'react';+import {alpha, Box, IconButton, ToggleButton, ToggleButtonGroup, Tooltip, useTheme} from '@mui/material';+import {+ ContentCopy as ContentCopyIcon,+ DeleteSweep as DeleteSweepIcon,+ Pause as PauseIcon,+ PlayArrow as PlayArrowIcon,+ Save as SaveIcon,+ SaveAlt as ScrollToBottomIcon,+ FilterList as FilterListIcon,+ Search as SearchIcon,+ Warning as WarningIcon,+} from '@mui/icons-material';+import {useTranslation} from 'react-i18next';+import {LogSnapshot} from '@/services/server/server-helpers/log-store';+import {LOG_COLORS} from './constants';++interface Props {+ snapshot: LogSnapshot;+ isPaused: boolean;+ copyFeedback: boolean;+ showSearch: boolean;+ showLevelFilters: boolean;+ selectedLevels: string[];+ onLevelToggle: (e: React.MouseEvent<HTMLElement>, newLevels: string[]) => void;+ onPauseToggle: () => void;+ onClear: () => void;+ onCopyToClipboard: () => Promise<void>;+ onSaveToDisk: () => void;+ onScrollToBottom: () => void;+ onToggleSearch: () => void;+ onToggleLevelFilters: () => void;+}++export const LogToolbar = memo(function LogToolbar({+ snapshot,+ isPaused,+ copyFeedback,+ showSearch,+ showLevelFilters,+ selectedLevels,+ onLevelToggle,+ onPauseToggle,+ onClear,+ onCopyToClipboard,+ onSaveToDisk,+ onScrollToBottom,+ onToggleSearch,+ onToggleLevelFilters,+}: Props) {+ const theme = useTheme();+ const {t} = useTranslation();++ return (+ <Box+ sx={{+ p: 0.5,+ borderBottom: '1px solid',+ borderColor: theme.palette.divider,+ display: 'flex',+ gap: 1,+ alignItems: 'center',+ flexWrap: 'wrap',+ }}+ >+ <span style={{color: theme.palette.text.primary, fontSize: '0.9em', fontWeight: 'bold'}}>+ {t('serverLogs')}+ </span>++ {snapshot.hasErrors && (+ <Tooltip title={t('errorsDetected')}>+ <WarningIcon+ sx={{+ color: LOG_COLORS.ERROR,+ fontSize: '1.2em',+ animation: 'pulse 2s infinite',+ '@keyframes pulse': {+ '0%, 100%': {opacity: 1},+ '50%': {opacity: 0.5},+ },+ }}+ />+ </Tooltip>+ )}++ {showLevelFilters && (+ <ToggleButtonGroup+ size="small"+ value={selectedLevels}+ onChange={onLevelToggle}+ sx={{+ '.MuiToggleButtonGroup-grouped': {+ border: `1px solid ${theme.palette.divider} !important`,+ mx: '1px',+ '&:not(:first-of-type)': {borderRadius: '2px'},+ '&:first-of-type': {borderRadius: '2px'},+ },+ }}+ >+ {Object.entries(LOG_COLORS).map(([level, color]) => {+ const count = snapshot.countsByLevel[level] || 0;+ return (+ <ToggleButton+ key={level}+ value={level.toLowerCase()}+ sx={{+ py: 0.25,+ px: 1,+ minWidth: 0,+ fontSize: '0.75em',+ position: 'relative',+ color: alpha(color, 0.7),+ '&.Mui-selected': {+ backgroundColor: alpha(color, 0.15),+ color: color,+ '&:hover': {backgroundColor: alpha(color, 0.2)},+ },+ '&:hover': {backgroundColor: alpha(color, 0.1)},+ }}+ >+ {level}+ {count > 0 && (+ <span style={{marginLeft: '4px', fontSize: '0.8em', opacity: 0.7}}>+ ({count})+ </span>+ )}+ </ToggleButton>+ );+ })}+ </ToggleButtonGroup>+ )}++ <Box sx={{ml: 'auto', display: 'flex', gap: 0.5}}>+ <Tooltip title={copyFeedback ? t('copied') : t('copyLogsToClipboard')}>+ <IconButton+ size="small"+ onClick={onCopyToClipboard}+ sx={{color: copyFeedback ? theme.palette.success.main : theme.palette.text.secondary}}+ >+ <ContentCopyIcon fontSize="small"/>+ </IconButton>+ </Tooltip>++ <Tooltip title={t('saveLogsToFile')}>+ <IconButton size="small" onClick={onSaveToDisk} sx={{color: theme.palette.text.secondary}}>+ <SaveIcon fontSize="small"/>+ </IconButton>+ </Tooltip>++ <Tooltip title="Scroll to bottom">+ <IconButton size="small" onClick={onScrollToBottom} sx={{color: theme.palette.text.secondary}}>+ <ScrollToBottomIcon fontSize="small"/>+ </IconButton>+ </Tooltip>++ <IconButton+ size="small"+ onClick={onToggleLevelFilters}+ sx={{color: showLevelFilters ? theme.palette.primary.main : theme.palette.text.secondary}}+ >+ <FilterListIcon fontSize="small"/>+ </IconButton>++ <IconButton+ size="small"+ onClick={onToggleSearch}+ sx={{color: showSearch ? theme.palette.primary.main : theme.palette.text.secondary}}+ >+ <SearchIcon fontSize="small"/>+ </IconButton>++ <IconButton+ size="small"+ onClick={onPauseToggle}+ sx={{color: isPaused ? theme.palette.warning.main : theme.palette.text.secondary}}+ >+ {isPaused ? <PlayArrowIcon fontSize="small"/> : <PauseIcon fontSize="small"/>}+ </IconButton>++ <IconButton size="small" onClick={onClear} sx={{color: theme.palette.text.secondary}}>+ <DeleteSweepIcon fontSize="small"/>+ </IconButton>+ </Box>+ </Box>+ );+}, (prev, next) =>+ prev.snapshot.version === next.snapshot.version &&+ prev.isPaused === next.isPaused &&+ prev.copyFeedback === next.copyFeedback &&+ prev.showSearch === next.showSearch &&+ prev.showLevelFilters === next.showLevelFilters &&+ prev.selectedLevels === next.selectedLevels,+);diff --git a/freemocap-ui/src/components/log-terminal/VirtualLogList.tsx b/freemocap-ui/src/components/log-terminal/VirtualLogList.tsxnew file mode 100644index 00000000..dfa02b46--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/VirtualLogList.tsx@@ -0,0 +1,79 @@+import React from 'react';+import {useTheme} from '@mui/material';+import {useTranslation} from 'react-i18next';+import {LogRecord} from '@/services/server/server-helpers/log-store';+import {LogEntryRow} from './LogEntryRow';++interface Props {+ filteredLogs: LogRecord[];+ prefixHeights: number[];+ totalHeight: number;+ startIdx: number;+ endIdx: number;+ offsetY: number;+ isPaused: boolean;+ scrollContainerRef: React.RefObject<HTMLDivElement | null>;+ onScroll: () => void;+}++export const VirtualLogList: React.FC<Props> = ({+ filteredLogs,+ prefixHeights,+ totalHeight,+ startIdx,+ endIdx,+ offsetY,+ isPaused,+ scrollContainerRef,+ onScroll,+}) => {+ const theme = useTheme();+ const {t} = useTranslation();++ return (+ <div+ ref={scrollContainerRef}+ onScroll={onScroll}+ style={{+ flex: 1,+ overflowY: 'auto',+ overflowX: 'auto',+ position: 'relative',+ scrollbarWidth: 'thin' as React.CSSProperties['scrollbarWidth'],+ scrollbarColor: theme.palette.mode === 'dark'+ ? 'rgba(255, 255, 255, 0.2) transparent'+ : 'rgba(0, 0, 0, 0.2) transparent',+ }}+ >+ {filteredLogs.length === 0 ? (+ <div+ style={{+ display: 'flex',+ justifyContent: 'center',+ alignItems: 'center',+ height: '100%',+ color: theme.palette.text.disabled,+ }}+ >+ {isPaused ? t('loggingPaused') : t('noLogsToDisplay')}+ </div>+ ) : (+ <div style={{height: totalHeight, position: 'relative'}}>+ <div style={{position: 'absolute', top: offsetY, left: 0, right: 0}}>+ {filteredLogs.slice(startIdx, endIdx).map((log, i) => {+ const rowIdx = startIdx + i;+ const rowHeight = prefixHeights[rowIdx + 1] - prefixHeights[rowIdx];+ return (+ <LogEntryRow+ key={`${log.created}-${log.thread}-${rowIdx}`}+ log={log}+ style={{height: rowHeight}}+ />+ );+ })}+ </div>+ </div>+ )}+ </div>+ );+};diff --git a/freemocap-ui/src/components/log-terminal/constants.ts b/freemocap-ui/src/components/log-terminal/constants.tsnew file mode 100644index 00000000..1a5f9591--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/constants.ts@@ -0,0 +1,21 @@+export const LOG_POLL_INTERVAL_MS = 500;++/** Height of a single line of monospace text in the log view. */+export const LINE_HEIGHT = 15;++/** Vertical padding added to each log entry. */+export const ROW_PADDING = 1;++/** Extra rows rendered above/below the visible viewport. */+export const OVERSCAN = 10;++export const LOG_COLORS: Record<string, string> = {+ TRACE: "#ccc",+ DEBUG: "#88ccFF",+ INFO: "#00E5FF",+ SUCCESS: "#FF66FF",+ API: "#66FF66",+ WARNING: "#FFFF66",+ ERROR: "#FF6666",+ CRITICAL: "#FF0000",+};diff --git a/freemocap-ui/src/components/log-terminal/filtering.ts b/freemocap-ui/src/components/log-terminal/filtering.tsnew file mode 100644index 00000000..010116b0--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/filtering.ts@@ -0,0 +1,27 @@+import {LogRecord} from '@/services/server/server-helpers/log-store';++export function applyFilters(+ entries: LogRecord[],+ selectedLevels: string[],+ searchText: string,+): LogRecord[] {+ let filtered = entries;++ if (selectedLevels.length > 0) {+ filtered = filtered.filter((log) =>+ selectedLevels.includes(log.levelname.toLowerCase())+ );+ }++ if (searchText) {+ const searchLower = searchText.toLowerCase();+ filtered = filtered.filter((log) =>+ log.message.toLowerCase().includes(searchLower) ||+ log.module.toLowerCase().includes(searchLower) ||+ log.funcName.toLowerCase().includes(searchLower) ||+ log.formatted_message?.toLowerCase().includes(searchLower)+ );+ }++ return filtered;+}diff --git a/freemocap-ui/src/components/log-terminal/index.ts b/freemocap-ui/src/components/log-terminal/index.tsnew file mode 100644index 00000000..79601da3--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/index.ts@@ -0,0 +1 @@+export {LogTerminal} from './LogTerminal';diff --git a/freemocap-ui/src/components/log-terminal/useLogTerminal.ts b/freemocap-ui/src/components/log-terminal/useLogTerminal.tsnew file mode 100644index 00000000..14a1af2c--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/useLogTerminal.ts@@ -0,0 +1,207 @@+import {useCallback, useEffect, useMemo, useRef, useState} from 'react';+import {useServer} from '@/services/server/ServerContextProvider';+import {LogSnapshot} from '@/services/server/server-helpers/log-store';+import {applyFilters} from './filtering';+import {buildPrefixHeights, findStartIndex} from './virtualization';+import {LOG_POLL_INTERVAL_MS, OVERSCAN} from './constants';++export interface LogTerminalState {+ // data+ snapshot: LogSnapshot;+ filteredLogs: ReturnType<typeof applyFilters>;+ prefixHeights: number[];+ totalHeight: number;+ // virtualization+ scrollContainerRef: React.RefObject<HTMLDivElement | null>;+ startIdx: number;+ endIdx: number;+ offsetY: number;+ // ui state+ isPaused: boolean;+ selectedLevels: string[];+ searchText: string;+ showSearch: boolean;+ showLevelFilters: boolean;+ copyFeedback: boolean;+ // actions+ handleScroll: () => void;+ scrollToBottom: () => void;+ handleCopyToClipboard: () => Promise<void>;+ handleSaveToDisk: () => void;+ handleLevelToggle: (e: React.MouseEvent<HTMLElement>, newLevels: string[]) => void;+ handlePauseToggle: () => void;+ handleClear: () => void;+ setSearchText: React.Dispatch<React.SetStateAction<string>>;+ setShowSearch: React.Dispatch<React.SetStateAction<boolean>>;+ setShowLevelFilters: React.Dispatch<React.SetStateAction<boolean>>;+}++export function useLogTerminal(): LogTerminalState {+ const {getLogStore} = useServer();++ const [snapshot, setSnapshot] = useState<LogSnapshot>({+ entries: [],+ hasErrors: false,+ countsByLevel: {},+ version: 0,+ });+ const [isPaused, setIsPaused] = useState(false);+ const [selectedLevels, setSelectedLevels] = useState<string[]>([]);+ const [searchText, setSearchText] = useState('');+ const [showSearch, setShowSearch] = useState(false);+ const [showLevelFilters, setShowLevelFilters] = useState(false);+ const [copyFeedback, setCopyFeedback] = useState(false);++ // Virtualization state+ const scrollContainerRef = useRef<HTMLDivElement>(null);+ const [scrollTop, setScrollTop] = useState(0);+ const [containerHeight, setContainerHeight] = useState(0);+ const shouldAutoScroll = useRef(true);+ const lastVersionRef = useRef(-1);++ // Poll the mutable LogStore on a fixed interval.+ useEffect(() => {+ if (isPaused) return;++ const poll = () => {+ const snap = getLogStore().getSnapshot();+ if (snap.version === lastVersionRef.current) return;+ lastVersionRef.current = snap.version;+ setSnapshot(snap);+ };++ poll();++ const interval = setInterval(poll, LOG_POLL_INTERVAL_MS);+ return () => clearInterval(interval);+ }, [getLogStore, isPaused]);++ const filteredLogs = useMemo(+ () => applyFilters(snapshot.entries, selectedLevels, searchText),+ [snapshot.entries, selectedLevels, searchText]+ );++ const prefixHeights = useMemo(() => buildPrefixHeights(filteredLogs), [filteredLogs]);+ const totalHeight = prefixHeights[filteredLogs.length] || 0;++ // Track container height via ResizeObserver+ useEffect(() => {+ const container = scrollContainerRef.current;+ if (!container) return;++ const observer = new ResizeObserver((entries) => {+ for (const entry of entries) {+ setContainerHeight(Math.round(entry.contentRect.height));+ }+ });+ observer.observe(container);+ return () => observer.disconnect();+ }, []);++ // Auto-scroll to bottom when new logs arrive.+ // Deferred via requestAnimationFrame so the DOM has painted the updated+ // totalHeight before we read scrollHeight, preventing a visible bounce.+ useEffect(() => {+ if (!isPaused && shouldAutoScroll.current && scrollContainerRef.current) {+ requestAnimationFrame(() => {+ const el = scrollContainerRef.current;+ if (el) el.scrollTop = el.scrollHeight;+ });+ }+ }, [filteredLogs, isPaused]);++ const handleScroll = useCallback(() => {+ const el = scrollContainerRef.current;+ if (!el) return;+ setScrollTop(el.scrollTop);+ // Tight tolerance accounts for sub-pixel rounding while ensuring the+ // user must be truly at the bottom to re-engage auto-scroll.+ const isAtBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 2;+ shouldAutoScroll.current = isAtBottom;+ }, []);++ const scrollToBottom = useCallback(() => {+ const el = scrollContainerRef.current;+ if (el) {+ el.scrollTop = el.scrollHeight;+ shouldAutoScroll.current = true;+ }+ }, []);++ const formatLogsForExport = useCallback((): string => {+ return filteredLogs+ .map((log) => `[${log.asctime}] [${log.levelname}] ${log.module}:${log.funcName}:${log.lineno} - ${log.message}`)+ .join('\n');+ }, [filteredLogs]);++ const handleCopyToClipboard = useCallback(async () => {+ await navigator.clipboard.writeText(formatLogsForExport());+ setCopyFeedback(true);+ setTimeout(() => setCopyFeedback(false), 2000);+ }, [formatLogsForExport]);++ const handleSaveToDisk = useCallback(() => {+ const text = formatLogsForExport();+ const blob = new Blob([text], {type: 'text/plain'});+ const url = URL.createObjectURL(blob);+ const a = document.createElement('a');+ a.href = url;+ a.download = `freemocap-logs-${new Date().toISOString().replace(/[:.]/g, '-')}.txt`;+ document.body.appendChild(a);+ a.click();+ document.body.removeChild(a);+ URL.revokeObjectURL(url);+ }, [formatLogsForExport]);++ const handleLevelToggle = useCallback((_: React.MouseEvent<HTMLElement>, newLevels: string[]) => {+ setSelectedLevels(newLevels);+ }, []);++ const handlePauseToggle = useCallback(() => {+ setIsPaused((prev) => !prev);+ }, []);++ const handleClear = useCallback(() => {+ getLogStore().clear();+ setSelectedLevels([]);+ setSearchText('');+ setShowSearch(false);+ setShowLevelFilters(false);+ setIsPaused(false);+ lastVersionRef.current = -1;+ setSnapshot({entries: [], hasErrors: false, countsByLevel: {}, version: 0});+ }, [getLogStore]);++ // Compute visible row window+ const startIdx = Math.max(0, findStartIndex(prefixHeights, scrollTop) - OVERSCAN);+ const endScrollTop = scrollTop + containerHeight;+ const endIdx = Math.min(filteredLogs.length, findStartIndex(prefixHeights, endScrollTop) + 1 + OVERSCAN);+ const offsetY = prefixHeights[startIdx];++ return {+ snapshot,+ filteredLogs,+ prefixHeights,+ totalHeight,+ scrollContainerRef,+ startIdx,+ endIdx,+ offsetY,+ isPaused,+ selectedLevels,+ searchText,+ showSearch,+ showLevelFilters,+ copyFeedback,+ handleScroll,+ scrollToBottom,+ handleCopyToClipboard,+ handleSaveToDisk,+ handleLevelToggle,+ handlePauseToggle,+ handleClear,+ setSearchText,+ setShowSearch,+ setShowLevelFilters,+ };+}diff --git a/freemocap-ui/src/components/log-terminal/virtualization.ts b/freemocap-ui/src/components/log-terminal/virtualization.tsnew file mode 100644index 00000000..1651dda4--- /dev/null+++ b/freemocap-ui/src/components/log-terminal/virtualization.ts@@ -0,0 +1,55 @@+import {LogRecord} from '@/services/server/server-helpers/log-store';+import {LINE_HEIGHT, ROW_PADDING} from './constants';++/** Count lines in a message. A message with no newlines has 1 line. */+export const countLines = (text: string): number => {+ if (!text) return 1;+ let count = 1;+ for (let i = 0; i < text.length; i++) {+ if (text[i] === '\n') count++;+ }+ return count;+};++/** Compute the pixel height of a log entry based on its line count. */+export const getRowHeight = (log: LogRecord): number => {+ // Divider entries get a compact fixed height (short horizontal rule).+ if (log.type === 'divider') {+ return LINE_HEIGHT + 8;+ }+ const lines = countLines(log.message);+ if (lines === 1) {+ return LINE_HEIGHT + ROW_PADDING;+ }+ // Multi-line: header line + all message lines + padding+ return LINE_HEIGHT + lines * LINE_HEIGHT + ROW_PADDING;+};++/**+ * Build a prefix-sum array of cumulative heights for variable-height virtualization.+ * prefixHeights[i] = total height of rows 0..i-1 (the Y offset of row i).+ * prefixHeights[n] = total height of all rows.+ */+export const buildPrefixHeights = (logs: LogRecord[]): number[] => {+ const prefixes = new Array<number>(logs.length + 1);+ prefixes[0] = 0;+ for (let i = 0; i < logs.length; i++) {+ prefixes[i + 1] = prefixes[i] + getRowHeight(logs[i]);+ }+ return prefixes;+};++/** Binary search for the first row whose bottom edge is past the given Y offset. */+export const findStartIndex = (prefixHeights: number[], y: number): number => {+ let lo = 0;+ let hi = prefixHeights.length - 2;+ while (lo < hi) {+ const mid = (lo + hi) >>> 1;+ if (prefixHeights[mid + 1] <= y) {+ lo = mid + 1;+ } else {+ hi = mid;+ }+ }+ return lo;+};diff --git a/freemocap-ui/src/components/pipeline-progress/PipelineGroupCard.tsx b/freemocap-ui/src/components/pipeline-progress/PipelineGroupCard.tsxnew file mode 100644index 00000000..7a35cc41--- /dev/null+++ b/freemocap-ui/src/components/pipeline-progress/PipelineGroupCard.tsx@@ -0,0 +1,213 @@+import Box from '@mui/material/Box';+import IconButton from '@mui/material/IconButton';+import LinearProgress from '@mui/material/LinearProgress';+import Tooltip from '@mui/material/Tooltip';+import Typography from '@mui/material/Typography';+import CloseIcon from '@mui/icons-material/Close';+import FolderOpenIcon from '@mui/icons-material/FolderOpen';+import PlayArrowIcon from '@mui/icons-material/PlayArrow';+import StopIcon from '@mui/icons-material/Stop';+import {useNavigate} from 'react-router-dom';+import {useAppDispatch} from '@/store/hooks';+import {activeRecordingSet} from '@/store/slices/active-recording/active-recording-slice';+import {useElectronIPC} from '@/services';+import {PipelineGroup, PipelinePhase, PipelineProgress, PHASE_LABELS, PIPELINE_TYPE_CONFIG} from '@/store/slices/pipelines';+import {stopPipeline} from '@/store/slices/pipelines/pipelines-thunks';++function formatTimeAgo(timestamp: number): string {+ const seconds = Math.floor((Date.now() - timestamp) / 1000);+ if (seconds < 60) return `${seconds}s ago`;+ const minutes = Math.floor(seconds / 60);+ if (minutes < 60) return `${minutes}m ago`;+ const hours = Math.floor(minutes / 60);+ return `${hours}h ago`;+}++function SubProgressBar({pipeline, label, isAggregator = false}: {+ pipeline: PipelineProgress;+ label: string;+ isAggregator?: boolean;+}) {+ const isFailed = pipeline.phase === PipelinePhase.FAILED;+ const isComplete = pipeline.phase === PipelinePhase.COMPLETE;+ const isTerminal = isComplete || isFailed;+ // Aggregator uses indeterminate except when collecting real frame data (SETTING_UP) or at terminal state+ const isIndeterminate = isAggregator && !isTerminal && pipeline.phase !== PipelinePhase.SETTING_UP;++ const rightText = isTerminal && pipeline.completedAt+ ? formatTimeAgo(pipeline.completedAt)+ : isIndeterminate+ ? (pipeline.detail || PHASE_LABELS[pipeline.phase])+ : `${pipeline.progress}%`;++ return (+ <Box sx={{mb: 0.5, opacity: isTerminal ? 0.6 : 1}}>+ <Box sx={{display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', mb: 0.125}}>+ <Typography variant="caption" noWrap+ sx={{flex: 1, mr: 1, color: 'text.secondary', fontSize: '0.68rem'}}>+ {label}+ </Typography>+ <Typography variant="caption" color="text.secondary"+ sx={{fontSize: '0.65rem', flexShrink: 0, maxWidth: 160}} noWrap>+ {rightText}+ </Typography>+ </Box>+ <LinearProgress+ variant={isIndeterminate ? 'indeterminate' : 'determinate'}+ value={isIndeterminate ? undefined : pipeline.progress}+ color={isFailed ? 'error' : isComplete ? 'success' : 'primary'}+ sx={{height: 4, borderRadius: 1}}+ />+ {isFailed && pipeline.detail && (+ <Tooltip title={pipeline.detail} placement="bottom" arrow>+ <Typography+ variant="caption"+ color="error"+ noWrap+ sx={{display: 'block', fontSize: '0.62rem', mt: 0.25, cursor: 'default'}}+ >+ {pipeline.detail}+ </Typography>+ </Tooltip>+ )}+ </Box>+ );+}++export default function PipelineGroupCard({group, onDismiss}: {+ group: PipelineGroup;+ onDismiss?: () => void;+}) {+ const dispatch = useAppDispatch();+ const navigate = useNavigate();+ const {api} = useElectronIPC();++ const overallProgress =+ group.aggregator?.progress ??+ (group.videoNodes.length > 0+ ? Math.round(group.videoNodes.reduce((sum, n) => sum + n.progress, 0) / group.videoNodes.length)+ : 0);++ const borderColor = group.isFailed ? 'error.main' : group.isComplete ? 'success.main' : 'divider';+ const typeConfig = group.pipelineType ? PIPELINE_TYPE_CONFIG[group.pipelineType] : null;+ const fullPath = group.recordingPath || undefined;+ const recordingName = group.recordingName+ const pipelineId = group.basePipelineId;++ const handleOpenFolder = async () => {+ if (!fullPath) return;+ try {+ await api?.fileSystem.openFolder.mutate({path: fullPath});+ } catch (err) {+ console.error('Failed to open recording folder:', err);+ }+ };++ const handleLoadPlayback = () => {+ if (!group.recordingName) return;+ dispatch(activeRecordingSet({+ recordingName: group.recordingName,+ origin: 'browsed',+ }));+ navigate('/playback');+ };++ return (+ <Box+ sx={{+ mx: 1,+ my: 0.75,+ p: 1,+ border: 1,+ borderColor,+ borderRadius: 1,+ opacity: group.isActive ? 1 : 0.6,+ }}+ >+ <Box sx={{display: 'flex', alignItems: 'center', mb: 0.5}}>+ {typeConfig && (+ <Box sx={{+ px: 0.75, py: 0.125, mr: 0.75, borderRadius: 1, flexShrink: 0,+ bgcolor: typeConfig.color + '22',+ border: `1px solid ${typeConfig.color}66`,+ }}>+ <Typography variant="caption" sx={{fontSize: '0.62rem', fontWeight: 600, color: typeConfig.color, lineHeight: 1.4}}>+ {typeConfig.label}+ </Typography>+ </Box>+ )}+ <Typography variant="caption" noWrap sx={{flex: 1, minWidth: 0}}>+ <Typography component="span" variant="caption" color="text.secondary">Pipeline: </Typography>+ <Typography component="span" variant="caption" fontWeight="bold">{pipelineId}</Typography>+ </Typography>+++ <Typography variant="caption" color="text.secondary" sx={{flexShrink: 0, fontSize: '0.7rem'}}>+ {overallProgress}%+ </Typography>+ <Tooltip title="Open folder" placement="top">+ <span>+ <IconButton size="small" onClick={handleOpenFolder} disabled={!fullPath} sx={{p: 0.25}}>+ <FolderOpenIcon sx={{fontSize: '0.85rem'}}/>+ </IconButton>+ </span>+ </Tooltip>+ <Tooltip title="Load in playback" placement="top">+ <IconButton size="small" onClick={handleLoadPlayback} sx={{p: 0.25}}>+ <PlayArrowIcon sx={{fontSize: '0.85rem'}}/>+ </IconButton>+ </Tooltip>+ {group.isActive && (+ <Tooltip title="Stop pipeline" placement="top">+ <IconButton+ size="small"+ onClick={() => dispatch(stopPipeline(group.basePipelineId))}+ sx={{p: 0.25, color: 'error.main'}}+ >+ <StopIcon sx={{fontSize: '0.85rem'}}/>+ </IconButton>+ </Tooltip>+ )}+ {onDismiss && (+ <IconButton size="small" onClick={onDismiss} sx={{p: 0.25}}>+ <CloseIcon sx={{fontSize: '0.75rem'}}/>+ </IconButton>+ )}+ </Box>+ <Tooltip title={fullPath} placement="top" arrow>+ <Typography variant="caption" noWrap sx={{flex: 1, minWidth: 0}}>+ <Typography component="span" variant="caption" color="text.secondary">Recording: </Typography>+ <Typography component="span" variant="caption" fontWeight="bold">{recordingName}</Typography>+ </Typography>+ </Tooltip>+ {group.videoNodes.length > 0 && (+ <Box sx={{pl: 1, borderLeft: 2, borderColor: 'divider', mb: group.aggregator ? 0.75 : 0}}>+ {group.videoNodes.map((node) => {+ const cameraId = node.pipelineId.includes(':')+ ? node.pipelineId.split(':').slice(1).join(':')+ : node.pipelineId;+ return <SubProgressBar key={node.pipelineId} pipeline={node} label={`Camera: ${cameraId}`}/>;+ })}+ </Box>+ )}++ {group.aggregator && (+ <Box sx={{mt: 0.5}}>+ <SubProgressBar+ pipeline={group.aggregator}+ isAggregator={true}+ label={+ group.aggregator.phase === PipelinePhase.COMPLETE+ ? 'Aggregation complete'+ : group.aggregator.phase === PipelinePhase.FAILED+ ? 'Aggregation failed'+ : group.videoNodes.length > 0+ ? `Aggregating ${group.videoNodes.length} camera${group.videoNodes.length !== 1 ? 's' : ''}`+ : PHASE_LABELS[group.aggregator.phase]+ }+ />+ </Box>+ )}+ </Box>+ );+}diff --git a/freemocap-ui/src/components/pipeline-progress/PipelineProgressPanel.tsx b/freemocap-ui/src/components/pipeline-progress/PipelineProgressPanel.tsxindex 15e54fdb..58687914 100644--- a/freemocap-ui/src/components/pipeline-progress/PipelineProgressPanel.tsx+++ b/freemocap-ui/src/components/pipeline-progress/PipelineProgressPanel.tsx@@ -5,17 +5,17 @@ import FormControlLabel from '@mui/material/FormControlLabel';import Checkbox from '@mui/material/Checkbox';import {useAppDispatch, useAppSelector} from '@/store/hooks';import {- selectFilteredPipelines,+ selectGroupedPipelines,selectHasCompletedPipelines,selectShowCompleted,selectFilterText,toggleShowCompleted,filterTextChanged,} from '@/store/slices/pipelines';-import PipelineProgressBar from './PipelineProgressBar';+import PipelineGroupCard from './PipelineGroupCard';export default function PipelineProgressPanel() {- const pipelines = useAppSelector(selectFilteredPipelines);+ const groups = useAppSelector(selectGroupedPipelines);const hasCompleted = useAppSelector(selectHasCompletedPipelines);const showCompleted = useAppSelector(selectShowCompleted);const filterText = useAppSelector(selectFilterText);@@ -51,15 +51,15 @@ export default function PipelineProgressPanel() {</Box><Box sx={{flex: 1, overflow: 'auto'}}>- {pipelines.length === 0 ? (+ {groups.length === 0 ? (<Box sx={{height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center'}}><Typography variant="caption" color="text.secondary">No active pipelines</Typography></Box>) : (- pipelines.map((p) => (- <PipelineProgressBar key={p.pipelineId} pipeline={p}/>+ groups.map((group) => (+ <PipelineGroupCard key={group.basePipelineId} group={group}/>)))}</Box>diff --git a/freemocap-ui/src/components/pipeline-progress/PipelineProgressSnackbar.tsx b/freemocap-ui/src/components/pipeline-progress/PipelineProgressSnackbar.tsxnew file mode 100644index 00000000..5472d9d2--- /dev/null+++ b/freemocap-ui/src/components/pipeline-progress/PipelineProgressSnackbar.tsx@@ -0,0 +1,321 @@+import * as React from 'react';+import Box from '@mui/material/Box';+import IconButton from '@mui/material/IconButton';+import LinearProgress from '@mui/material/LinearProgress';+import Paper from '@mui/material/Paper';+import Typography from '@mui/material/Typography';+import CloseIcon from '@mui/icons-material/Close';+import DeleteSweepIcon from '@mui/icons-material/DeleteSweep';+import DragIndicatorIcon from '@mui/icons-material/DragIndicator';+import ExpandLessIcon from '@mui/icons-material/ExpandLess';+import ExpandMoreIcon from '@mui/icons-material/ExpandMore';+import StopCircleIcon from '@mui/icons-material/StopCircle';+import {useAppDispatch, useAppSelector} from '@/store/hooks';+import {+ allPipelinesCleared,+ pipelineDismissed,+ pipelineSnackbarHidden,+ pipelineSnackbarShown,+ selectActiveBasePipelineCount,+ selectDismissedBasePipelineIds,+ selectGroupedPipelinesAll,+ selectSnackbarVisible,+} from '@/store/slices/pipelines';+import {stopAllPipelines} from '@/store/slices/pipelines/pipelines-thunks';+import PipelineGroupCard from './PipelineGroupCard';+import {useTheme} from "@mui/material";++const DEFAULT_WIDTH = 360;+const DEFAULT_HEIGHT = 420;+const MIN_WIDTH = 240;+const MIN_HEIGHT = 100;++type ResizeHandle = 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw';++const CURSOR: Record<ResizeHandle, string> = {+ n: 'ns-resize', s: 'ns-resize',+ e: 'ew-resize', w: 'ew-resize',+ ne: 'nesw-resize', sw: 'nesw-resize',+ nw: 'nwse-resize', se: 'nwse-resize',+};++const EDGE = 6;+const CORN = 14;++function handleSx(h: ResizeHandle) {+ const base = {position: 'absolute', zIndex: 10} as const;+ switch (h) {+ case 'n': return {...base, top: -EDGE/2, left: CORN, right: CORN, height: EDGE, cursor: CURSOR.n};+ case 's': return {...base, bottom: -EDGE/2, left: CORN, right: CORN, height: EDGE, cursor: CURSOR.s};+ case 'e': return {...base, right: -EDGE/2, top: CORN, bottom: CORN, width: EDGE, cursor: CURSOR.e};+ case 'w': return {...base, left: -EDGE/2, top: CORN, bottom: CORN, width: EDGE, cursor: CURSOR.w};+ case 'nw': return {...base, top: -EDGE/2, left: -EDGE/2, width: CORN, height: CORN, cursor: CURSOR.nw};+ case 'ne': return {...base, top: -EDGE/2, right: -EDGE/2, width: CORN, height: CORN, cursor: CURSOR.ne};+ case 'sw': return {...base, bottom: -EDGE/2, left: -EDGE/2, width: CORN, height: CORN, cursor: CURSOR.sw};+ case 'se': return {...base, bottom: -EDGE/2, right: -EDGE/2, width: CORN, height: CORN, cursor: CURSOR.se};+ }+}++const HANDLES: ResizeHandle[] = ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw'];++export default function PipelineProgressSnackbar() {+ const dispatch = useAppDispatch();+ const theme = useTheme()+ const groups = useAppSelector(selectGroupedPipelinesAll);+ const activeCount = useAppSelector(selectActiveBasePipelineCount);+ const open = useAppSelector(selectSnackbarVisible);+ const dismissedIds = useAppSelector(selectDismissedBasePipelineIds);+ const [collapsed, setCollapsed] = React.useState(false);++ const [dragPos, setDragPos] = React.useState<{left: number; top: number} | null>(null);+ const [size, setSize] = React.useState({width: DEFAULT_WIDTH, height: DEFAULT_HEIGHT});++ const containerRef = React.useRef<HTMLDivElement>(null);+ const dragRef = React.useRef<{+ startMx: number; startMy: number; startLeft: number; startTop: number;+ } | null>(null);+ const resizeRef = React.useRef<{+ handle: ResizeHandle;+ startMx: number; startMy: number;+ startW: number; startH: number;+ startLeft: number; startTop: number;+ } | null>(null);++ const handleHeaderMouseDown = React.useCallback((e: React.MouseEvent) => {+ if (e.button !== 0) return;+ const rect = containerRef.current?.getBoundingClientRect();+ if (!rect) return;+ dragRef.current = {startMx: e.clientX, startMy: e.clientY, startLeft: rect.left, startTop: rect.top};+ e.preventDefault();+ }, []);++ const startResize = React.useCallback((handle: ResizeHandle, e: React.MouseEvent) => {+ if (e.button !== 0) return;+ e.preventDefault();+ e.stopPropagation();+ const rect = containerRef.current?.getBoundingClientRect();+ if (!rect) return;+ resizeRef.current = {+ handle,+ startMx: e.clientX, startMy: e.clientY,+ startW: rect.width, startH: rect.height,+ startLeft: rect.left, startTop: rect.top,+ };+ }, []);++ React.useEffect(() => {+ const onMove = (e: MouseEvent) => {+ if (dragRef.current) {+ const dx = e.clientX - dragRef.current.startMx;+ const dy = e.clientY - dragRef.current.startMy;+ setDragPos({+ left: Math.max(0, dragRef.current.startLeft + dx),+ top: Math.max(0, dragRef.current.startTop + dy),+ });+ }+ if (resizeRef.current) {+ const {handle, startMx, startMy, startW, startH, startLeft, startTop} = resizeRef.current;+ const dx = e.clientX - startMx;+ const dy = e.clientY - startMy;++ let newW = startW, newH = startH;+ let newLeft = startLeft, newTop = startTop;+ let posChanged = false;++ if (handle.includes('e')) newW = Math.max(MIN_WIDTH, startW + dx);+ if (handle.includes('s')) newH = Math.max(MIN_HEIGHT, startH + dy);+ if (handle.includes('w')) {+ newW = Math.max(MIN_WIDTH, startW - dx);+ newLeft = startLeft + startW - newW;+ posChanged = true;+ }+ if (handle.includes('n')) {+ newH = Math.max(MIN_HEIGHT, startH - dy);+ newTop = startTop + startH - newH;+ posChanged = true;+ }++ setSize({width: newW, height: newH});+ if (posChanged) setDragPos({left: newLeft, top: newTop});+ }+ };+ const onUp = () => { dragRef.current = null; resizeRef.current = null; };+ document.addEventListener('mousemove', onMove);+ document.addEventListener('mouseup', onUp);+ return () => {+ document.removeEventListener('mousemove', onMove);+ document.removeEventListener('mouseup', onUp);+ };+ }, []);+++ const visibleGroups = groups.filter(g => !dismissedIds.includes(g.basePipelineId));+ const hasRunningVisible = visibleGroups.some(g => !g.isComplete && !g.isFailed);++ // Summary info for collapsed view — prefer active, fall back to most recent+ const summaryGroup = visibleGroups.find(g => g.isActive) ?? visibleGroups[0] ?? null;+ const summaryProgress = summaryGroup+ ? (summaryGroup.aggregator?.progress+ ?? (summaryGroup.videoNodes.length > 0+ ? Math.round(summaryGroup.videoNodes.reduce((s, n) => s + n.progress, 0) / summaryGroup.videoNodes.length)+ : 0))+ : 0;+ const summaryLabel = summaryGroup+ ? `${summaryGroup.recordingName || summaryGroup.basePipelineId}${visibleGroups.length > 1 ? ` +${visibleGroups.length - 1}` : ''}`+ : 'No active pipelines';++ if (!open) return null;++ const positionSx: React.CSSProperties = dragPos+ ? {position: 'fixed', left: dragPos.left, top: dragPos.top, zIndex: 1400}+ : {position: 'fixed', bottom: 8, right: 8, zIndex: 1400};++ return (+ <Box+ ref={containerRef}+ sx={{+ ...positionSx,+ width: size.width,+ // collapsed: auto-height (just the header); expanded: full tracked height+ ...(collapsed ? {} : {height: size.height}),+ }}+ >+ {/* Width handles always available; height/corner handles only when expanded */}+ {HANDLES.filter(h => !collapsed || h === 'e' || h === 'w').map(h => (+ <Box key={h} sx={handleSx(h)} onMouseDown={(e) => startResize(h, e)}/>+ ))}++ <Paper+ elevation={6}+ sx={{+ width: '100%',+ height: collapsed ? 'auto' : '100%',+ display: 'flex',+ flexDirection: 'column',+ borderRadius: 2,+ overflow: 'hidden',+ border: 1,+ borderColor: hasRunningVisible ? '#FF00FF' : 'transparent',+ }}+ >+ {/* Header — always visible */}+ <Box+ onMouseDown={handleHeaderMouseDown}+ sx={{+ display: 'flex',+ alignItems: 'center',+ px: 1,+ py: 0.75,+ borderBottom: collapsed ? 0 : 1,+ borderColor: 'divider',+ flexShrink: 0,+ cursor: 'grab',+ userSelect: 'none',+ '&:active': {cursor: 'grabbing'},+ }}+ >+ {collapsed ? (+ // Collapsed summary: name + progress bar + %+ <Box sx={{flex: 1, minWidth: 0, mr: 1}}>+ <Box sx={{display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', mb: 0.25}}>+ <Typography variant="caption" noWrap sx={{fontSize: '0.72rem', flex: 1, mr: 0.5}}>+ {summaryLabel}+ </Typography>+ <Typography variant="caption" color="text.secondary" sx={{fontSize: '0.68rem', flexShrink: 0}}>+ {summaryProgress}%+ </Typography>+ </Box>+ {summaryGroup?.isActive && (+ <LinearProgress+ variant="determinate"+ value={summaryProgress}+ sx={{height: 3, borderRadius: 1}}+ />+ )}+ </Box>+ ) : (+ // Expanded title+ <Typography variant="subtitle2" sx={{flex: 1}}>+ Pipeline Progress+ </Typography>+ )}++ {hasRunningVisible && (+ <Box sx={{+ width: 7, height: 7, borderRadius: '50%', bgcolor: 'primary.main', mr: 1, flexShrink: 0,+ animation: 'fmcPulse 1.4s ease-in-out infinite',+ '@keyframes fmcPulse': {+ '0%, 100%': {opacity: 1, transform: 'scale(1)'},+ '50%': {opacity: 0.3, transform: 'scale(0.7)'},+ },+ }}/>+ )}++ <IconButton+ size="small"+ onMouseDown={e => e.stopPropagation()}+ onClick={() => setCollapsed(c => !c)}+ sx={{p: 0.25}}+ >+ {collapsed ? <ExpandLessIcon fontSize="small"/> : <ExpandMoreIcon fontSize="small"/>}+ </IconButton>++ {hasRunningVisible && (+ <IconButton+ size="small"+ onMouseDown={e => e.stopPropagation()}+ onClick={() => dispatch(stopAllPipelines())}+ title="Stop all pipelines"+ sx={{p: 0.25, color: 'error.main'}}+ >+ <StopCircleIcon fontSize="small"/>+ </IconButton>+ )}++ <IconButton+ size="small"+ onMouseDown={e => e.stopPropagation()}+ onClick={() => dispatch(allPipelinesCleared())}+ disabled={visibleGroups.length === 0}+ title="Clear all pipelines"+ sx={{p: 0.25}}+ >+ <DeleteSweepIcon fontSize="small"/>+ </IconButton>++ <IconButton+ size="small"+ onMouseDown={e => e.stopPropagation()}+ onClick={() => dispatch(pipelineSnackbarHidden())}+ sx={{p: 0.25}}+ >+ <CloseIcon fontSize="small"/>+ </IconButton>++ <DragIndicatorIcon sx={{fontSize: '0.9rem', color: 'text.disabled', ml: 0.25, flexShrink: 0, cursor: 'grab'}}/>+ </Box>++ {/* Scrollable content — hidden when collapsed */}+ {!collapsed && (+ <Box sx={{overflow: 'auto', flex: 1, minHeight: 0}}>+ {visibleGroups.length === 0 ? (+ <Box sx={{py: 2, display: 'flex', justifyContent: 'center'}}>+ <Typography variant="caption" color="text.secondary">+ No active pipelines+ </Typography>+ </Box>+ ) : (+ visibleGroups.map((group) => (+ <PipelineGroupCard+ key={group.basePipelineId}+ group={group}+ onDismiss={() => dispatch(pipelineDismissed(group.basePipelineId))}+ />+ ))+ )}+ </Box>+ )}+ </Paper>+ </Box>+ );+}diff --git a/freemocap-ui/src/components/playback/PlaybackContext.tsx b/freemocap-ui/src/components/playback/PlaybackContext.tsxindex 1b32e759..44aa2c35 100644--- a/freemocap-ui/src/components/playback/PlaybackContext.tsx+++ b/freemocap-ui/src/components/playback/PlaybackContext.tsx@@ -1,132 +1,147 @@-import React, {createContext, useCallback, useContext, useEffect, useState} from 'react';+import React, {createContext, useCallback, useContext, useEffect, useRef, useState} from 'react';import type {LoadedVideo} from './RecordingBrowser';-import {serverUrls} from '@/constants/server-urls';--// Module-level cache so playback state survives tab switches-let cachedPlaybackState = {- loadedVideos: [] as LoadedVideo[],- recordingPath: null as string | null,- recordingFps: undefined as number | undefined,- frameTimestamps: null as Record<string, number[]> | null,- currentFrame: 0,-};+import {useAppDispatch, useAppSelector} from '@/store';+import {+ activeRecordingSet,+ selectActiveRecordingBaseDirectory,+ selectActiveRecordingName,+ selectActiveRecordingOrigin,+ splitParentAndName,+} from '@/store/slices/active-recording/active-recording-slice';+import {selectRecordingsList} from '@/store/slices/recording-status/recording-status-slice';+import {selectPlaybackBundle} from '@/store/slices/playback-data/playback-data-slice';++export interface SourceInfo {+ available: boolean;+ valid: boolean;+ video_count: number;+ videos: LoadedVideo[];+}interface PlaybackContextValue {loadedVideos: LoadedVideo[];- recordingPath: string | null;recordingFps: number | undefined;frameTimestamps: Record<string, number[]> | null;- initialLoadPath: string | null;cachedCurrentFrame: number;- onRecordingLoaded: (videos: LoadedVideo[], recordingPath: string, recordingFps?: number) => void;+ availableSources: Record<string, SourceInfo> | null;+ selectedSource: string | null;+ setSelectedSource: (source: string) => void;+ onRecordingLoaded: (+ videos: LoadedVideo[],+ recordingPath: string,+ recordingFps?: number,+ sources?: Record<string, SourceInfo>,+ preferred?: string,+ ) => void;onFrameChange: (frame: number) => void;- setInitialLoadPath: (path: string | null) => void;}const PlaybackContext = createContext<PlaybackContextValue | null>(null);export const PlaybackProvider: React.FC<{ children: React.ReactNode }> = ({children}) => {- const [initialLoadPath, setInitialLoadPath] = useState<string | null>(null);-- const initState = (initialLoadPath && initialLoadPath !== cachedPlaybackState.recordingPath)- ? {- loadedVideos: [] as LoadedVideo[],- recordingPath: null,- recordingFps: undefined,- frameTimestamps: null,- currentFrame: 0,- }- : cachedPlaybackState;+ const dispatch = useAppDispatch();+ const activeRecordingOrigin = useAppSelector(selectActiveRecordingOrigin);+ const activeRecordingName = useAppSelector(selectActiveRecordingName);+ const activeRecordingBaseDirectory = useAppSelector(selectActiveRecordingBaseDirectory);- const [loadedVideos, setLoadedVideos] = useState<LoadedVideo[]>(initState.loadedVideos);- const [recordingPath, setRecordingPath] = useState<string | null>(initState.recordingPath);- const [recordingFps, setRecordingFps] = useState<number | undefined>(initState.recordingFps);- const [frameTimestamps, setFrameTimestamps] = useState<Record<string, number[]> | null>(initState.frameTimestamps);+ const [loadedVideos, setLoadedVideos] = useState<LoadedVideo[]>([]);+ const [loadedRecordingName, setLoadedRecordingName] = useState<string | null>(null);+ const [recordingFps, setRecordingFps] = useState<number | undefined>(undefined);+ const [frameTimestamps, setFrameTimestamps] = useState<Record<string, number[]> | null>(null);+ const [availableSources, setAvailableSources] = useState<Record<string, SourceInfo> | null>(null);+ const [selectedSource, setSelectedSource] = useState<string | null>(null);+ const currentFrameRef = useRef<number>(0);- const onRecordingLoaded = useCallback((videos: LoadedVideo[], path: string, fps?: number) => {+ const onRecordingLoaded = useCallback((+ videos: LoadedVideo[],+ path: string,+ fps?: number,+ sources?: Record<string, SourceInfo>,+ preferred?: string,+ ) => {setLoadedVideos(videos);- setRecordingPath(path);+ setLoadedRecordingName(path);setRecordingFps(fps);setFrameTimestamps(null);- cachedPlaybackState = {- loadedVideos: videos,- recordingPath: path,- recordingFps: fps,- frameTimestamps: null,- currentFrame: 0,- };+ setAvailableSources(sources ?? null);+ setSelectedSource(preferred ?? (sources ? Object.keys(sources)[0] ?? null : null));+ currentFrameRef.current = 0;}, []);const onFrameChange = useCallback((frame: number) => {- cachedPlaybackState.currentFrame = frame;+ currentFrameRef.current = frame;}, []);- // After a recording is loaded, fetch real timestamps from the server+ // Watch the Redux-cached bundle for the active recording. When it arrives,+ // populate local state (videos, fps, timestamps, sources). The bundle is+ // dispatched once by FileKeypointsSourceProvider — the Redux `condition`+ // guard prevents duplicate requests.+ const bundle = useAppSelector(selectPlaybackBundle(activeRecordingName));++ useEffect(() => {+ if (!bundle || activeRecordingOrigin === 'pending-capture') return;+ if (bundle.recordingId === loadedRecordingName) return;++ const sources: Record<string, SourceInfo> = {};+ for (const [key, source] of Object.entries(bundle.videos.sources)) {+ sources[key] = {+ available: source.available,+ valid: source.valid,+ video_count: source.videoCount,+ videos: source.videos,+ };+ }+ const preferred = bundle.videos.preferredSource;+ const preferredVids = sources[preferred]?.videos ?? [];++ setLoadedVideos(preferredVids);+ setLoadedRecordingName(bundle.recordingId);+ setRecordingFps(bundle.recordingFps ?? undefined);+ setFrameTimestamps(bundle.timestamps?.timestamps ?? null);+ setAvailableSources(sources);+ setSelectedSource(preferred);+ currentFrameRef.current = 0;+ }, [bundle, loadedRecordingName, activeRecordingOrigin]);++ // When selectedSource changes, swap loadedVideos to the new source's pre-fetched list.useEffect(() => {- if (loadedVideos.length === 0) return;- const fetchTimestamps = async () => {- try {- if (recordingPath) {- const response = await fetch(serverUrls.endpoints.playbackAllTimestamps(recordingPath));- if (!response.ok) return;- const data = await response.json();- if (data.timestamps && Object.keys(data.timestamps).length > 0) {- setFrameTimestamps(data.timestamps);- cachedPlaybackState.frameTimestamps = data.timestamps;- }- }- } catch {- // Timestamps not available- }- };- fetchTimestamps();- }, [loadedVideos, recordingPath]);-- // Auto-load latest recording on mount if nothing is loaded+ if (!selectedSource || !availableSources) return;+ const source = availableSources[selectedSource];+ if (!source?.videos.length) return;+ setLoadedVideos(source.videos);+ setFrameTimestamps(null);+ currentFrameRef.current = 0;+ }, [selectedSource, availableSources]);++ // Bootstrap: if no active recording on mount, auto-pick the most recent from cache.+ const recordingsList = useAppSelector(selectRecordingsList);+useEffect(() => {- if (initialLoadPath || initState.loadedVideos.length > 0) return;-- let isMounted = true;- const fetchLatest = async () => {- try {- const response = await fetch(serverUrls.endpoints.playbackRecordings);- if (response.ok && isMounted) {- const data = await response.json();- if (data && data.length > 0) {- const latest = data[0];- const vidResp = await fetch(serverUrls.endpoints.playbackVideos(latest.name));- if (vidResp.ok && isMounted) {- const vidsData = await vidResp.json();- const baseUrl = serverUrls.getHttpUrl();- const vids = vidsData.map((v: any) => ({- videoId: v.video_id,- filename: v.filename,- streamUrl: `${baseUrl}${v.stream_url}`,- sizeBytes: v.size_bytes,- }));- onRecordingLoaded(vids, latest.name, latest.fps);- }- }- }- } catch {- // Ignore errors- }- };- fetchLatest();- return () => { isMounted = false; };- }, [initialLoadPath, initState.loadedVideos.length]);+ if (activeRecordingName) return;+ if (activeRecordingOrigin === 'pending-capture') return;+ if (recordingsList.length === 0) return;++ const latest = recordingsList[0];+ const parsed = splitParentAndName(latest.path);+ setRecordingFps(latest.fps ?? undefined);+ dispatch(activeRecordingSet({+ recordingName: latest.name,+ origin: 'auto-latest',+ baseDirectory: parsed?.baseDirectory,+ }));+ }, [activeRecordingName, activeRecordingOrigin, recordingsList, dispatch]);return (<PlaybackContext.Provider value={{loadedVideos,- recordingPath,recordingFps,frameTimestamps,- initialLoadPath,- cachedCurrentFrame: initState.currentFrame,+ cachedCurrentFrame: currentFrameRef.current,+ availableSources,+ selectedSource,+ setSelectedSource,onRecordingLoaded,onFrameChange,- setInitialLoadPath,}}>{children}</PlaybackContext.Provider>diff --git a/freemocap-ui/src/components/playback/PlaybackControls.tsx b/freemocap-ui/src/components/playback/PlaybackControls.tsxindex 11688397..2a5d48d8 100644--- a/freemocap-ui/src/components/playback/PlaybackControls.tsx+++ b/freemocap-ui/src/components/playback/PlaybackControls.tsx@@ -48,6 +48,9 @@ interface PlaybackControlsProps {onSeekToEnd: () => void;isLooping: boolean;onToggleLoop: () => void;+ availableSources?: Record<string, { available: boolean; valid: boolean }> | null;+ selectedSource?: string | null;+ onSourceChange?: (source: string) => void;}const PLAYBACK_RATES = [0.1, 0.25, 0.5, 1, 1.5, 2, 4, 8];@@ -79,6 +82,9 @@ export const PlaybackControls: React.FC<PlaybackControlsProps> = ({onSeekToEnd,isLooping,onToggleLoop,+ availableSources,+ selectedSource,+ onSourceChange,}) => {const theme = useTheme();const { t } = useTranslation();@@ -273,6 +279,45 @@ export const PlaybackControls: React.FC<PlaybackControlsProps> = ({</IconButton></Tooltip>+ {/* Video source toggle — only when 2+ valid sources available */}+ {availableSources && selectedSource && onSourceChange && (() => {+ const validSources = Object.entries(availableSources)+ .filter(([, s]) => s.available && s.valid)+ .map(([key]) => key);+ if (validSources.length < 2) return null;+ return (+ <ToggleButtonGroup+ value={selectedSource}+ exclusive+ onChange={(_, val) => { if (val) onSourceChange(val); }}+ size="small"+ sx={{+ ml: 2,+ '& .MuiToggleButton-root': {+ fontSize: '0.7rem',+ fontFamily: monoFont,+ py: 0.3,+ px: 1,+ textTransform: 'capitalize',+ color: isDark ? '#b3b9c6' : theme.palette.text.secondary,+ borderColor: isDark ? 'rgba(255,255,255,0.2)' : theme.palette.divider,+ '&.Mui-selected': {+ color: '#fff',+ backgroundColor: isDark ? 'rgba(41,182,246,0.25)' : theme.palette.primary.main,+ borderColor: accentBlue,+ '&:hover': {+ backgroundColor: isDark ? 'rgba(41,182,246,0.35)' : theme.palette.primary.dark,+ },+ },+ },+ }}+ >+ <ToggleButton value="annotated">Annotated</ToggleButton>+ <ToggleButton value="synchronized">Synchronized</ToggleButton>+ </ToggleButtonGroup>+ );+ })()}+{/* Right: speed selector + settings */}<Box sx={{ display: 'flex', alignItems: 'center', ml: 2, gap: 1 }}><Tooltip title={t("playbackSpeed")}>diff --git a/freemocap-ui/src/components/playback/RecordingBrowser.tsx b/freemocap-ui/src/components/playback/RecordingBrowser.tsxindex 8c6906a7..5b3251c2 100644--- a/freemocap-ui/src/components/playback/RecordingBrowser.tsx+++ b/freemocap-ui/src/components/playback/RecordingBrowser.tsx@@ -2,7 +2,9 @@* RecordingBrowser — lists available recording sessions from the server,* with search filtering, multi-field sorting, and rich per-recording metadata.*- * Standalone component: only depends on MUI + server URL helper.+ * Uses a Redux-cached batch response (fetchAllRecordings) so expanding a row+ * doesn't trigger individual HTTP requests. The cache is populated on app+ * startup and refreshed when the user navigates to the recordings tab.*/import React, {useCallback, useEffect, useMemo, useState} from 'react';import {@@ -38,26 +40,29 @@ import SearchIcon from '@mui/icons-material/Search';import SortIcon from '@mui/icons-material/Sort';import {serverUrls} from '@/constants/server-urls';import {useTranslation} from 'react-i18next';-import {RecordingStatusSummary} from '@/types/recording-status';import {RecordingStatusPanel} from '@/components/common/RecordingStatusPanel';import {useRecordingStatus} from '@/hooks/useRecordingStatus';+import {useAppDispatch, useAppSelector} from '@/store';+import {+ activeRecordingSet,+ splitParentAndName,+} from '@/store/slices/active-recording/active-recording-slice';+import {+ detectLayoutPreset,+ listDetectedLegacyMarkers,+} from '@/store/slices/active-recording/recording-structure';+import {+ fetchAllRecordings,+ type RecordingListEntry,+} from '@/store/slices/recording-status/recording-status-thunks';+import {+ selectRecordingsList,+ selectRecordingsFetchedAt,+ selectRecordingsIsLoading,+} from '@/store/slices/recording-status/recording-status-slice';-// ----------------------------------------------------------------------------// Types-// -----------------------------------------------------------------------------/** Shape returned by GET /freemocap/playback/recordings */-interface RecordingEntry {- name: string;- path: string;- video_count: number;- total_size_bytes?: number;- created_timestamp?: string;- total_frames?: number;- duration_seconds?: number;- fps?: number;- status_summary?: RecordingStatusSummary;-}+/** Re-exported for PlaybackContext / PlaybackPage consumers. */+export type RecordingEntry = RecordingListEntry;/** Shape passed up to the parent when a recording is loaded */export interface LoadedVideo {@@ -68,9 +73,13 @@ export interface LoadedVideo {}interface RecordingBrowserProps {- onRecordingLoaded: (videos: LoadedVideo[], recordingPath: string, recordingFps?: number) => void;- /** If set, automatically load this recording path on mount. */- initialLoadPath?: string | null;+ onRecordingLoaded: (+ videos: LoadedVideo[],+ recordingPath: string,+ recordingFps?: number,+ sources?: Record<string, { available: boolean; valid: boolean; video_count: number; videos: LoadedVideo[] }>,+ preferred?: string,+ ) => void;/** Name/path of the recording currently loaded into the Playback view — highlighted in the list. */activeRecordingPath?: string | null;}@@ -206,14 +215,17 @@ const SORT_OPTIONS: { value: SortField; labelKey: string }[] = [// Component// ----------------------------------------------------------------------------export const RecordingBrowser: React.FC<RecordingBrowserProps> = ({ onRecordingLoaded, initialLoadPath, activeRecordingPath }) => {+export const RecordingBrowser: React.FC<RecordingBrowserProps> = ({ onRecordingLoaded, activeRecordingPath }) => {const theme = useTheme();const { t } = useTranslation();const isDark = theme.palette.mode === 'dark';+ const dispatch = useAppDispatch();++ // Data from Redux cache (prefetched on app startup)+ const recordings = useAppSelector(selectRecordingsList);+ const recordingsFetchedAt = useAppSelector(selectRecordingsFetchedAt);+ const isLoadingList = useAppSelector(selectRecordingsIsLoading);- // Data state- const [recordings, setRecordings] = useState<RecordingEntry[]>([]);- const [isLoadingList, setIsLoadingList] = useState(false);const [isLoadingRecording, setIsLoadingRecording] = useState(false);const [error, setError] = useState<string | null>(null);const [loadingPath, setLoadingPath] = useState<string | null>(null);@@ -227,28 +239,26 @@ export const RecordingBrowser: React.FC<RecordingBrowserProps> = ({ onRecordingLconst [sortDir, setSortDir] = useState<SortDirection>('desc');// ------------------------------------------------------------------------ // Fetch the list of recordings from the server+ // Fetch the list of recordings from the server (cache-aware)// ------------------------------------------------------------------------ const fetchRecordings = useCallback(async () => {- setIsLoadingList(true);- setError(null);+ const fetchRecordings = useCallback(async (force = false) => {+ const MAX_CACHE_AGE_MS = 30_000;+ if (!force && recordingsFetchedAt && Date.now() - recordingsFetchedAt < MAX_CACHE_AGE_MS) {+ return;+ }try {- const response = await fetch(serverUrls.endpoints.playbackRecordings);- if (!response.ok) {- throw new Error(`Failed to fetch recordings: ${response.statusText}`);- }- const data: RecordingEntry[] = await response.json();- setRecordings(data);+ await dispatch(fetchAllRecordings()).unwrap();} catch (e) {setError(e instanceof Error ? e.message : t('failedToFetch'));- } finally {- setIsLoadingList(false);}- }, []);+ }, [dispatch, recordingsFetchedAt]);useEffect(() => {- fetchRecordings();- }, [fetchRecordings]);+ // Fetch on mount if cache is empty (belt-and-suspenders with AppContent prefetch)+ if (recordings.length === 0) {+ fetchRecordings();+ }+ }, []); // eslint-disable-line react-hooks/exhaustive-deps// -----------------------------------------------------------------------// Apply filter + sort@@ -276,11 +286,18 @@ export const RecordingBrowser: React.FC<RecordingBrowserProps> = ({ onRecordingLsetError(null);try {- // Determine recording ID (name)+ // Determine recording ID (name) and parent directoryconst rec = recordings.find((r) => r.path === recordingPath);const recName = rec ? rec.name : recordingPath.split(/[\\/]/).pop() || recordingPath;+ const parsed = rec?.path ? splitParentAndName(rec.path) : null;+ const parentDir = parsed?.baseDirectory;++ const videosUrl = serverUrls.endpoints.playbackVideos(recName);+ const url = parentDir+ ? `${videosUrl}?recording_parent_directory=${encodeURIComponent(parentDir)}`+ : videosUrl;- const response = await fetch(serverUrls.endpoints.playbackVideos(recName));+ const response = await fetch(url);if (!response.ok) {const detail = await response@@ -292,24 +309,61 @@ export const RecordingBrowser: React.FC<RecordingBrowserProps> = ({ onRecordingLconst data = await response.json();const baseUrl = serverUrls.getHttpUrl();- const videos: LoadedVideo[] = data.map(- (v: {- video_id: string;- filename: string;- stream_url: string;- size_bytes: number;- }) => ({- videoId: v.video_id,- filename: v.filename,- streamUrl: `${baseUrl}${v.stream_url}`,- sizeBytes: v.size_bytes,- }),- );+ let videos: LoadedVideo[];+ let sources: Record<string, {available: boolean; valid: boolean; video_count: number; videos: LoadedVideo[]}> | undefined;+ let preferred: string | undefined;++ // New structured response: { preferred_source, sources: { annotated, synchronized } }+ if (data.sources) {+ sources = {};+ for (const [key, src] of Object.entries(data.sources) as [string, any][]) {+ sources[key] = {+ available: src.available,+ valid: src.valid,+ video_count: src.video_count,+ videos: (src.videos || []).map((v: any) => ({+ videoId: v.video_id,+ filename: v.filename,+ streamUrl: `${baseUrl}${v.stream_url}`,+ sizeBytes: v.size_bytes,+ })),+ };+ }+ const resolvedPreferred: string = data.preferred_source || 'synchronized';+ preferred = resolvedPreferred;+ videos = sources[resolvedPreferred]?.videos ?? [];+ } else {+ // Fallback: old flat-array response+ videos = data.map(+ (v: {+ video_id: string;+ filename: string;+ stream_url: string;+ size_bytes: number;+ }) => ({+ videoId: v.video_id,+ filename: v.filename,+ streamUrl: `${baseUrl}${v.stream_url}`,+ sizeBytes: v.size_bytes,+ }),+ );+ }const recFps = rec?.fps ?? undefined;- // Send recName as the recording path to identify it successfully in playbackpage- onRecordingLoaded(videos, recName, recFps);+ // Promote this recording to the app-wide active recording.+ const layoutPreset = rec?.layout_validation+ ? detectLayoutPreset(rec.layout_validation)+ : undefined;+ dispatch(activeRecordingSet({+ recordingName: parsed?.recordingName ?? recName,+ baseDirectory: parsed?.baseDirectory,+ origin: 'browsed',+ layoutPreset,+ }));++ // Context callback is view-model only (loadedVideos/fps/sources).+ onRecordingLoaded(videos, recName, recFps, sources, preferred);} catch (e) {setError(e instanceof Error ? e.message : 'Failed to load recording');} finally {@@ -317,18 +371,9 @@ export const RecordingBrowser: React.FC<RecordingBrowserProps> = ({ onRecordingLsetLoadingPath(null);}},- [onRecordingLoaded, recordings],+ [onRecordingLoaded, recordings, dispatch],);- // Auto-load a recording if initialLoadPath is provided- const [didAutoLoad, setDidAutoLoad] = useState(false);- useEffect(() => {- if (initialLoadPath && !didAutoLoad) {- setDidAutoLoad(true);- loadRecording(initialLoadPath);- }- }, [initialLoadPath, didAutoLoad, loadRecording]);-const handleLoadManualPath = useCallback(() => {const trimmed = manualPath.trim();if (trimmed) loadRecording(trimmed);@@ -528,7 +573,7 @@ export const RecordingBrowser: React.FC<RecordingBrowserProps> = ({ onRecordingL<Buttonsize="small"startIcon={<RefreshIcon />}- onClick={fetchRecordings}+ onClick={() => fetchRecordings(true)}disabled={isLoadingList}sx={{ color: isDark ? '#b3b9c6' : undefined }}>@@ -619,6 +664,14 @@ const RecordingRow: React.FC<RecordingRowProps> = React.memo(const stagesComplete = summary?.stages_complete ?? 0;const stagesTotal = summary?.stages_total ?? 0;+ const layoutPreset = rec.layout_validation+ ? detectLayoutPreset(rec.layout_validation)+ : 'canonical';+ const isLegacyLayout = layoutPreset === 'legacy_v1';+ const legacyMarkers = rec.layout_validation+ ? listDetectedLegacyMarkers(rec.layout_validation)+ : [];+const toggleExpand = (e: React.MouseEvent): void => {e.stopPropagation();setExpanded((v) => !v);@@ -697,6 +750,37 @@ const RecordingRow: React.FC<RecordingRowProps> = React.memo(}}/>)}+ {isLegacyLayout && (+ <Tooltip+ title={+ <Box sx={{fontFamily: MONO_FONT, fontSize: '0.7rem'}}>+ <div>Legacy folder layout (legacy_v1)</div>+ {legacyMarkers.length > 0 && (+ <ul style={{margin: '4px 0 0 16px', padding: 0}}>+ {legacyMarkers.map((marker) => (+ <li key={marker}>{marker}</li>+ ))}+ </ul>+ )}+ </Box>+ }+ arrow+ >+ <Chip+ size="small"+ label="Legacy"+ sx={{+ height: 18,+ fontSize: '0.65rem',+ fontFamily: MONO_FONT,+ backgroundColor: isDark ? 'rgba(255,167,38,0.18)' : 'rgba(255,167,38,0.15)',+ color: isDark ? '#ffb74d' : '#e65100',+ border: `1px solid ${isDark ? 'rgba(255,167,38,0.5)' : 'rgba(230,81,0,0.4)'}`,+ '& .MuiChip-label': {px: 0.75},+ }}+ />+ </Tooltip>+ )}</Box>}secondary={diff --git a/freemocap-ui/src/components/playback/RecordingBrowserSection.tsx b/freemocap-ui/src/components/playback/RecordingBrowserSection.tsxindex 404eaad9..fbad6d5d 100644--- a/freemocap-ui/src/components/playback/RecordingBrowserSection.tsx+++ b/freemocap-ui/src/components/playback/RecordingBrowserSection.tsx@@ -19,7 +19,6 @@ export const RecordingBrowserSection: React.FC = () => {><RecordingBrowseronRecordingLoaded={ctx.onRecordingLoaded}- initialLoadPath={ctx.initialLoadPath}/></CollapsibleSidebarSection>);diff --git a/freemocap-ui/src/components/playback/SyncedVideoPlayer.tsx b/freemocap-ui/src/components/playback/SyncedVideoPlayer.tsxindex 200827a1..9069fcbe 100644--- a/freemocap-ui/src/components/playback/SyncedVideoPlayer.tsx+++ b/freemocap-ui/src/components/playback/SyncedVideoPlayer.tsx@@ -1,11 +1,12 @@-import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';-import {Box, Tooltip, Typography, useTheme} from '@mui/material';-import type {Layout, LayoutItem} from 'react-grid-layout';+import React, {useMemo} from 'react';+import {Box, Typography, useTheme} from '@mui/material';import ReactGridLayout, {noCompactor} from 'react-grid-layout';import 'react-grid-layout/css/styles.css';import 'react-resizable/css/styles.css';import {useTranslation} from 'react-i18next';import type {PlaybackController} from './usePlaybackController';+import {ZoomableVideoTile} from './ZoomableVideoTile';+import {useGridLayout} from '@/hooks/useGridLayout';interface VideoEntry {videoId: string;@@ -78,137 +79,37 @@ export const SyncedVideoPlayer: React.FC<SyncedVideoPlayerProps> = ({setFrameOverlayRef,setTimeOverlayRef,handleLoadedMetadata,- settingsRef,frameTimestampsRef,- fpsRef,} = controller;// -----------------------------------------------------------------------// Grid layout// ------------------------------------------------------------------------ const GRID_COLS = 12;- const GRID_MARGIN: [number, number] = [2, 2];+ const videoIds = useMemo(() => videos.map(v => v.videoId), [videos]);- const gridContainerRef = useRef<HTMLDivElement>(null);- const [gridWidth, setGridWidth] = useState<number>(800);- const [gridHeight, setGridHeight] = useState<number>(400);-- useEffect(() => {- const el = gridContainerRef.current;- if (!el) return;- const measure = () => {- const rect = el.getBoundingClientRect();- setGridWidth(rect.width);- setGridHeight(rect.height);- };- measure();- const observer = new ResizeObserver(() => measure());- observer.observe(el);- return () => observer.disconnect();- }, []);-- const computeTiling = (n: number, w: number, h: number) => {- if (n <= 1) return {cols: 1, rows: 1};- let bestCols = 1;- let bestArea = 0;- const TARGET_AR = 16 / 9; // Assume standard video aspect ratio- for (let cols = 1; cols <= n; cols++) {- const rows = Math.ceil(n / cols);- const cellW = (w - GRID_MARGIN[0] * (cols - 1)) / cols;- const cellH = (h - GRID_MARGIN[1] * (rows - 1)) / rows;- if (cellW < 80 || cellH < 60) continue;-- // Calculate actual media fitted area preserving aspect ratio- const fittedW = Math.min(cellW, cellH * TARGET_AR);- const fittedH = fittedW / TARGET_AR;- const area = n * fittedW * fittedH;-- if (area > bestArea) { bestArea = area; bestCols = cols; }- }- return {cols: bestCols, rows: Math.ceil(n / bestCols)};- };-- const prevTilingRef = useRef({cols: 1, rows: 1});- const tiling = useMemo(() => {- const candidate = manualColumns !== null- ? {cols: Math.max(1, Math.min(manualColumns, videos.length || 1)), rows: Math.ceil((videos.length || 1) / Math.max(1, Math.min(manualColumns, videos.length || 1)))}- : computeTiling(videos.length, gridWidth, gridHeight);- const prev = prevTilingRef.current;- if (candidate.cols === prev.cols && candidate.rows === prev.rows) return prev;- prevTilingRef.current = candidate;- return candidate;- }, [videos.length, gridWidth, gridHeight, manualColumns]);-- const buildVideoLayout = (vids: VideoEntry[]): LayoutItem[] => {- if (vids.length === 0) return [];- const colSpan = Math.floor(GRID_COLS / tiling.cols);- return vids.map((v, i) => ({- i: v.videoId,- x: (i % tiling.cols) * colSpan,- y: Math.floor(i / tiling.cols),- w: colSpan,- h: 1,- minW: 1,- minH: 1,- }));- };-- const [gridLayout, setGridLayout] = useState<LayoutItem[]>(() => buildVideoLayout(videos));-- useEffect(() => {- setGridLayout(buildVideoLayout(videos));- }, [videos, tiling, resetKey]);-- const gridLayoutBeforeDragRef = useRef<LayoutItem[]>(gridLayout);-- const handleGridDragStart = useCallback(() => {- gridLayoutBeforeDragRef.current = gridLayout;- }, [gridLayout]);-- const handleGridDragStop = useCallback((_newLayout: Layout, _oldItem: LayoutItem | null, newItem: LayoutItem | null) => {- if (!newItem) return;- const preDrag = gridLayoutBeforeDragRef.current;- const draggedBefore = preDrag.find((l) => l.i === newItem.i);- if (!draggedBefore) return;-- const swapTarget = preDrag.find((l) => {- if (l.i === newItem.i) return false;- return newItem.x < l.x + l.w && newItem.x + newItem.w > l.x- && newItem.y < l.y + l.h && newItem.y + newItem.h > l.y;- });-- if (swapTarget) {- setGridLayout(preDrag.map((l) => {- if (l.i === newItem.i) return {...l, x: swapTarget.x, y: swapTarget.y};- if (l.i === swapTarget.i) return {...l, x: draggedBefore.x, y: draggedBefore.y};- return l;- }));- } else {- const maxX = GRID_COLS - newItem.w;- const maxY = tiling.rows - newItem.h;- setGridLayout(preDrag.map((l) => {- if (l.i === newItem.i) {- return {...l, x: Math.max(0, Math.min(newItem.x, maxX)), y: Math.max(0, Math.min(newItem.y, maxY))};- }- return l;- }));- }- }, [tiling.rows]);-- const handleGridLayoutChange = useCallback((_: Layout) => {}, []);- const handleGridResizeStop = useCallback((newLayout: Layout) => { setGridLayout([...newLayout]); }, []);-- const gridRowHeight = useMemo(() => {- const totalMargin = (tiling.rows - 1) * GRID_MARGIN[1];- return Math.max(30, (gridHeight - totalMargin) / tiling.rows);- }, [gridHeight, tiling.rows]);+ const {+ containerRef,+ width,+ layout,+ gridHandlers,+ gridConfig,+ } = useGridLayout({+ itemIds: videoIds,+ margin: [2, 2],+ manualColumns,+ resetKey,+ measureParent: true,+ });// -----------------------------------------------------------------------// Render// -----------------------------------------------------------------------if (videos.length === 0) {return (- <Box sx={{display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100%', color: 'text.secondary'}}>+ <Box+ ref={containerRef}+ sx={{display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100%', color: 'text.secondary'}}+ ><Typography>{t("noVideosLoaded")}</Typography></Box>);@@ -217,7 +118,6 @@ export const SyncedVideoPlayer: React.FC<SyncedVideoPlayerProps> = ({const framePadLen = Math.max(String(totalFrames).length, 1);const initialFrameText = 'F' + String(currentFrame).padStart(framePadLen, '0');- // Compute initial time text for overlay SSRlet initialTimeText: string;let timestampsAreReal = false;const frameTimestamps = frameTimestampsRef.current;@@ -242,123 +142,72 @@ export const SyncedVideoPlayer: React.FC<SyncedVideoPlayerProps> = ({}return (- <Box sx={{display: 'flex', flexDirection: 'column', height: '100%', width: '100%'}}>- {/* Video grid */}- <Box- ref={gridContainerRef}- sx={{- flex: 1,- position: 'relative',- overflow: 'hidden',- backgroundColor: '#0a0a0a',- minHeight: 0,- '& .react-grid-placeholder': {- backgroundColor: 'primary.main',- opacity: 0.15,- borderRadius: '4px',- },- '& .react-resizable-handle': {- zIndex: 10,- },- }}+ <Box+ ref={containerRef}+ sx={{+ position: 'relative',+ width: '100%',+ height: '100%',+ overflow: 'hidden',+ backgroundColor: '#0a0a0a',+ '& .react-grid-placeholder': {+ backgroundColor: 'primary.main',+ opacity: 0.15,+ borderRadius: '4px',+ },+ '& .react-resizable-handle': {+ zIndex: 10,+ },+ }}+ >+ <ReactGridLayout+ width={width}+ layout={layout}+ gridConfig={gridConfig}+ dragConfig={{enabled: true}}+ resizeConfig={{enabled: true}}+ compactor={noCompactor}+ {...gridHandlers}>- <ReactGridLayout- width={gridWidth}- layout={gridLayout}- gridConfig={{- cols: GRID_COLS,- rowHeight: gridRowHeight,- margin: GRID_MARGIN,- containerPadding: [0, 0] as [number, number],- }}- dragConfig={{enabled: true}}- resizeConfig={{enabled: true}}- compactor={noCompactor}- onLayoutChange={handleGridLayoutChange}- onDragStart={handleGridDragStart}- onDragStop={handleGridDragStop}- onResizeStop={handleGridResizeStop}- >- {videos.map((video) => (- <div- key={video.videoId}- style={{- position: 'relative',- overflow: 'hidden',- backgroundColor: '#000',- borderRadius: '4px',- border: '1px solid rgba(255,255,255,0.15)',- }}- >- <video- ref={(el) => setVideoRef(video.videoId, el)}- src={video.streamUrl}- preload="auto"- muted- playsInline- style={{width: '100%', height: '100%', objectFit: 'contain'}}- onLoadedMetadata={handleLoadedMetadata}- />-- {settings.showOverlays && (- <>- {/* FRAME NUMBER */}- <Box- ref={(el: HTMLElement | null) => setFrameOverlayRef(video.videoId, el)}- sx={{- position: 'absolute', top: 6, right: 6,- backgroundColor: 'rgba(0, 0, 0, 0.88)',- color: '#00ff88',- px: 1.25, py: 0.4, borderRadius: '4px',- fontSize: '14px', fontWeight: 700,- fontFamily: '"JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", monospace',- letterSpacing: '0.5px', lineHeight: 1,- border: '1px solid rgba(0, 255, 136, 0.3)',- textShadow: '0 0 6px rgba(0, 255, 136, 0.4)',- minWidth: 60, textAlign: 'center',- userSelect: 'none', pointerEvents: 'none', zIndex: 10,- }}- >- {initialFrameText}- </Box>-- {/* CAMERA ID */}- <Box sx={{- position: 'absolute', bottom: 6, left: 6,- backgroundColor: 'rgba(0, 0, 0, 0.75)',- color: '#ccc', px: 1, py: 0.25, borderRadius: '3px',- fontSize: '11px',- fontFamily: '"JetBrains Mono", "Fira Code", monospace',- userSelect: 'none', pointerEvents: 'none', zIndex: 10,- }}>- {video.videoId}- </Box>-- {/* TIMECODE */}- <Tooltip title={timestampsAreReal ? t("timestampFromRecording") : t("estimatedFromFrameNumber")} placement="top-end">- <Box- ref={(el: HTMLElement | null) => setTimeOverlayRef(video.videoId, el)}- sx={{- position: 'absolute', bottom: 6, right: 6,- backgroundColor: 'rgba(0, 0, 0, 0.75)',- color: '#aaa', px: 0.75, py: 0.25, borderRadius: '3px',- fontSize: '10px',- fontFamily: '"JetBrains Mono", "Fira Code", monospace',- userSelect: 'none', zIndex: 10,- }}- >- {initialTimeText}- </Box>- </Tooltip>- </>- )}- </div>- ))}- </ReactGridLayout>- </Box>+ {videos.map((video) => (+ <Box+ key={video.videoId}+ sx={{+ overflow: 'hidden',+ borderRadius: '4px',+ border: '1px solid rgba(255,255,255,0.15)',+ }}+ >+ <ZoomableVideoTile+ videoId={video.videoId}+ streamUrl={video.streamUrl}+ filename={video.filename}+ showOverlays={settings.showOverlays}+ timestampFormat={settings.timestampFormat}+ initialFrameText={initialFrameText}+ initialTimeText={initialTimeText}+ timestampsAreReal={timestampsAreReal}+ setVideoRef={setVideoRef}+ setFrameOverlayRef={setFrameOverlayRef}+ setTimeOverlayRef={setTimeOverlayRef}+ handleLoadedMetadata={handleLoadedMetadata}+ />+ </Box>+ ))}+ </ReactGridLayout>{!allReady && videos.length > 0 && (- <Box sx={{textAlign: 'center', py: 0.5, backgroundColor: theme.palette.warning.dark, color: '#fff'}}>+ <Box sx={{+ position: 'absolute',+ bottom: 0,+ left: 0,+ right: 0,+ zIndex: 10,+ textAlign: 'center',+ py: 0.5,+ backgroundColor: theme.palette.warning.dark,+ color: '#fff',+ }}><Typography variant="caption">{t("loadingVideos", {ready: videosReady, total: videos.length})}</Typography></Box>)}diff --git a/freemocap-ui/src/components/playback/ZoomableVideoTile.tsx b/freemocap-ui/src/components/playback/ZoomableVideoTile.tsxnew file mode 100644index 00000000..9d4903e5--- /dev/null+++ b/freemocap-ui/src/components/playback/ZoomableVideoTile.tsx@@ -0,0 +1,134 @@+import React, {useRef} from 'react';+import {Box, Tooltip} from '@mui/material';+import {useTranslation} from 'react-i18next';+import {useZoomTransform} from '@/hooks/useZoomTransform';+import type {PlaybackController} from './usePlaybackController';++interface ZoomableVideoTileProps {+ videoId: string;+ streamUrl: string;+ filename: string;+ showOverlays: boolean;+ timestampFormat: 'timecode' | 'seconds';+ initialFrameText: string;+ initialTimeText: string;+ timestampsAreReal: boolean;+ setVideoRef: PlaybackController['setVideoRef'];+ setFrameOverlayRef: PlaybackController['setFrameOverlayRef'];+ setTimeOverlayRef: PlaybackController['setTimeOverlayRef'];+ handleLoadedMetadata: PlaybackController['handleLoadedMetadata'];+}++/**+ * Renders a single video tile with scroll-to-zoom, drag-to-pan,+ * and pinch-to-zoom. Can be used as a direct child of ReactGridLayout+ * because the root div has no ref — GridItem's cloneElement safely+ * adds its own ref for drag/resize without clobbering containerRef.+ * The inner div handles zoom coordinate calculations.+ */+export const ZoomableVideoTile: React.FC<ZoomableVideoTileProps> = ({+ videoId,+ streamUrl,+ filename,+ showOverlays,+ initialFrameText,+ initialTimeText,+ timestampsAreReal,+ setVideoRef,+ setFrameOverlayRef,+ setTimeOverlayRef,+ handleLoadedMetadata,+}) => {+ const containerRef = useRef<HTMLDivElement>(null);+ const { zoomWrapperStyle, cursor, containerHandlers } = useZoomTransform(containerRef);+ const { t } = useTranslation();++ return (+ <div+ style={{+ width: '100%',+ height: '100%',+ overflow: 'hidden',+ backgroundColor: '#000',+ position: 'relative',+ cursor,+ }}+ {...containerHandlers}+ >+ <div ref={containerRef} style={zoomWrapperStyle}>+ <video+ ref={(el) => setVideoRef(videoId, el)}+ src={streamUrl}+ preload="auto"+ muted+ playsInline+ style={{ width: '100%', height: '100%', objectFit: 'contain', display: 'block' }}+ onLoadedMetadata={handleLoadedMetadata}+ onError={(e) => {+ const v = e.currentTarget as HTMLVideoElement;+ const err = v.error;+ console.error(+ `[playback] video error for ${videoId}: ` ++ `code=${err?.code} message="${err?.message ?? 'unknown'}" src=${v.src}`+ );+ }}+ />+ </div>++ {showOverlays && (+ <>+ {/* FRAME NUMBER */}+ <Box+ ref={(el: HTMLElement | null) => setFrameOverlayRef(videoId, el)}+ sx={{+ position: 'absolute', top: 6, right: 6,+ backgroundColor: 'rgba(0, 0, 0, 0.88)',+ color: '#00ff88',+ px: 1.25, py: 0.4, borderRadius: '4px',+ fontSize: '14px', fontWeight: 700,+ fontFamily: '"JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", monospace',+ letterSpacing: '0.5px', lineHeight: 1,+ border: '1px solid rgba(0, 255, 136, 0.3)',+ textShadow: '0 0 6px rgba(0, 255, 136, 0.4)',+ minWidth: 60, textAlign: 'center',+ userSelect: 'none', pointerEvents: 'none', zIndex: 10,+ }}+ >+ {initialFrameText}+ </Box>++ {/* CAMERA ID */}+ <Box sx={{+ position: 'absolute', bottom: 6, left: 6,+ backgroundColor: 'rgba(0, 0, 0, 0.75)',+ color: '#ccc', px: 1, py: 0.25, borderRadius: '3px',+ fontSize: '11px',+ fontFamily: '"JetBrains Mono", "Fira Code", monospace',+ userSelect: 'none', pointerEvents: 'none', zIndex: 10,+ }}>+ {filename}+ </Box>++ {/* TIMECODE */}+ <Tooltip title={timestampsAreReal ? t("timestampFromRecording") : t("estimatedFromFrameNumber")} placement="top-end">+ <Box+ ref={(el: HTMLElement | null) => setTimeOverlayRef(videoId, el)}+ sx={{+ position: 'absolute', bottom: 6, right: 6,+ backgroundColor: 'rgba(0, 0, 0, 0.75)',+ color: '#aaa', px: 0.75, py: 0.25, borderRadius: '3px',+ fontSize: '10px',+ fontFamily: '"JetBrains Mono", "Fira Code", monospace',+ userSelect: 'none', zIndex: 10,+ }}+ >+ {initialTimeText}+ </Box>+ </Tooltip>+ </>+ )}+ </div>+ );+};++ZoomableVideoTile.displayName = 'ZoomableVideoTile';diff --git a/freemocap-ui/src/components/playback/usePlaybackController.ts b/freemocap-ui/src/components/playback/usePlaybackController.tsindex 90835c90..cfb55b02 100644--- a/freemocap-ui/src/components/playback/usePlaybackController.ts+++ b/freemocap-ui/src/components/playback/usePlaybackController.ts@@ -105,8 +105,21 @@ export function usePlaybackController({if (recordingFps && recordingFps > 0) fpsRef.current = recordingFps;}, [recordingFps]);- // Elect leader whenever video list changes+ // Track the previous set of video IDs so we only reset state when the+ // actual composition changes. The `videos` prop is a fresh array on every+ // render (from loadedVideos.map() in PlaybackPage), so we can't use+ // array reference equality.+ const prevVideoIdsRef = useRef<string>('');++ // Elect leader and reset per-video-set state only when video IDs changeuseEffect(() => {+ const currentIds = videos.map(v => v.videoId).sort().join('|');+ if (currentIds !== prevVideoIdsRef.current) {+ prevVideoIdsRef.current = currentIds;+ setVideosReady(0);+ totalFramesRef.current = 0;+ didSeekInitialRef.current = false;+ }leaderIdRef.current = videos.length > 0 ? videos[0].videoId : null;}, [videos]);diff --git a/freemocap-ui/src/components/tabbed-bottom-panel/TabbedBottomLeftPanel.tsx b/freemocap-ui/src/components/tabbed-bottom-panel/TabbedBottomLeftPanel.tsxindex 654de4f1..ea9607f1 100644--- a/freemocap-ui/src/components/tabbed-bottom-panel/TabbedBottomLeftPanel.tsx+++ b/freemocap-ui/src/components/tabbed-bottom-panel/TabbedBottomLeftPanel.tsx@@ -1,12 +1,43 @@+import Box from '@mui/material/Box';import FramerateViewerPanel from '@/components/framerate-viewer/FrameRateViewer';import PipelineProgressPanel from '@/components/pipeline-progress/PipelineProgressPanel';import {TabbedContent} from '@/components/ui-components/TabbedContent';+import {useAppSelector} from '@/store/hooks';+import {selectActiveBasePipelineCount} from '@/store/slices/pipelines';-export default function TabbedBottomLeftPanel() {+function PipelineTabLabel() {+ const activeCount = useAppSelector(selectActiveBasePipelineCount);+ return (+ <Box sx={{display: 'flex', alignItems: 'center', gap: 0.75}}>+ Pipelines+ {activeCount > 0 && (+ <Box+ sx={{+ width: 7,+ height: 7,+ borderRadius: '50%',+ bgcolor: 'primary.main',+ flexShrink: 0,+ animation: 'fmcPulse 1.4s ease-in-out infinite',+ '@keyframes fmcPulse': {+ '0%, 100%': {opacity: 1, transform: 'scale(1)'},+ '50%': {opacity: 0.3, transform: 'scale(0.7)'},+ },+ }}+ />+ )}+ </Box>+ );+}++export default function TabbedBottomLeftPanel({isCollapsed = false}: { isCollapsed?: boolean }) {+ if (isCollapsed) {+ return <FramerateViewerPanel isCollapsed={true}/>;+ }return (<TabbedContent tabs={[{label: 'Framerate', content: <FramerateViewerPanel/>},- {label: 'Pipelines', content: <PipelineProgressPanel/>},+ // {label: <PipelineTabLabel/>, content: <PipelineProgressPanel/>},]}/>);}diff --git a/freemocap-ui/src/components/ui-components/Header.tsx b/freemocap-ui/src/components/ui-components/Header.tsxindex 364389da..d772c476 100644--- a/freemocap-ui/src/components/ui-components/Header.tsx+++ b/freemocap-ui/src/components/ui-components/Header.tsx@@ -1,4 +1,3 @@-// Update Header.tsximport * as React from 'react';import AppBar from '@mui/material/AppBar';import Toolbar from '@mui/material/Toolbar';diff --git a/freemocap-ui/src/components/ui-components/MainNavTabs.tsx b/freemocap-ui/src/components/ui-components/MainNavTabs.tsxindex 23f3f439..be425552 100644--- a/freemocap-ui/src/components/ui-components/MainNavTabs.tsx+++ b/freemocap-ui/src/components/ui-components/MainNavTabs.tsx@@ -1,15 +1,107 @@import {useLocation, useNavigate} from "react-router-dom";import {useCallback, useMemo} from "react";import {alpha, darken} from "@mui/material/styles";-import {Tab, Tabs} from "@mui/material";+import {Box, Chip, Link, Tab, Tabs, Tooltip, Typography} from "@mui/material";+import FolderOpenIcon from "@mui/icons-material/FolderOpen";+import {useAppDispatch, useAppSelector} from "@/store";+import {+ activeRecordingCleared,+ selectActiveRecordingFullPath,+ selectActiveRecordingName,+} from "@/store/slices/active-recording/active-recording-slice";+import {useElectronIPC} from "@/services";const NAV_TABS = [{path: '/welcome', label: 'Home'},{path: '/streaming', label: 'Streaming'},{path: '/playback', label: 'Playback'},{path: '/browse', label: 'Recordings'},+ {path: '/active-recording', label: 'Active Recording'},] as const;+const MONO_FONT = '"JetBrains Mono", "Fira Code", "SF Mono", monospace';++const ActiveRecordingTabLabel: React.FC<{isActive: boolean}> = ({isActive}) => {+ const dispatch = useAppDispatch();+ const recordingName = useAppSelector(selectActiveRecordingName);+ const fullPath = useAppSelector(selectActiveRecordingFullPath);+ const {api} = useElectronIPC();++ const handleOpenFolder = async (e: React.MouseEvent) => {+ e.stopPropagation();+ if (!fullPath) return;+ try {+ await api?.fileSystem.openFolder.mutate({path: fullPath});+ } catch (err) {+ console.error('Failed to open recording folder:', err);+ }+ };++ const handleClearRecording = (e: React.MouseEvent) => {+ e.stopPropagation();+ dispatch(activeRecordingCleared());+ };++ const tooltipContent = fullPath ? (+ <Box sx={{p: 0.5}}>+ <Typography variant="caption" sx={{fontFamily: MONO_FONT, display: 'block', mb: 0.5}}>+ {fullPath}+ </Typography>+ <Link+ component="button"+ onClick={handleOpenFolder}+ underline="hover"+ sx={{display: 'inline-flex', alignItems: 'center', gap: 0.5, fontSize: '0.7rem'}}+ >+ <FolderOpenIcon sx={{fontSize: 14}}/>+ Open in Explorer+ </Link>+ </Box>+ ) : (+ <Typography variant="caption">No active recording</Typography>+ );++ return (+ <Tooltip title={tooltipContent} placement="bottom" arrow>+ <Box sx={{display: 'inline-flex', alignItems: 'center', gap: 0.75}}>+ <Typography component="span" sx={{fontSize: 'inherit'}}>Active Recording</Typography>+ {recordingName ? (+ <Chip+ size="small"+ label={recordingName}+ onDelete={handleClearRecording}+ sx={{+ height: 18,+ fontSize: '0.65rem',+ fontFamily: MONO_FONT,+ maxWidth: 220,+ '& .MuiChip-label': {+ px: 0.75,+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap',+ },+ '& .MuiChip-deleteIcon': {+ fontSize: 12,+ opacity: 0,+ transition: 'opacity 0.15s',+ },+ '&:hover .MuiChip-deleteIcon': {opacity: 1},+ }}+ />+ ) : (+ <Typography+ component="span"+ sx={{fontSize: '0.65rem', color: 'text.disabled', fontStyle: 'italic'}}+ >+ (none)+ </Typography>+ )}+ </Box>+ </Tooltip>+ );+};+export const MainNavTabs = () => {const location = useLocation();const navigate = useNavigate();@@ -39,6 +131,7 @@ export const MainNavTabs = () => {py: 0.5,borderRadius: 0.75,position: 'relative',+ textTransform: 'none',},'& .MuiTab-root:not(:last-of-type)::after': {content: '""',@@ -53,9 +146,13 @@ export const MainNavTabs = () => {},})}>- {NAV_TABS.map(tab => (- <Tab key={tab.path} label={tab.label}/>- ))}+ {NAV_TABS.map((tab, idx) => {+ const isActive = idx === activeTab;+ const label = tab.path === '/active-recording'+ ? <ActiveRecordingTabLabel isActive={isActive}/>+ : tab.label;+ return <Tab key={tab.path} label={label}/>;+ })}</Tabs>);};diff --git a/freemocap-ui/src/components/ui-components/TabbedContent.tsx b/freemocap-ui/src/components/ui-components/TabbedContent.tsxindex 93a738d0..b8b2f53d 100644--- a/freemocap-ui/src/components/ui-components/TabbedContent.tsx+++ b/freemocap-ui/src/components/ui-components/TabbedContent.tsx@@ -5,7 +5,7 @@ import Tab from '@mui/material/Tab';import type {SxProps, Theme} from '@mui/material/styles';export interface TabDef {- label: string;+ label: React.ReactNode;content: React.ReactNode;}diff --git a/freemocap-ui/src/components/ui-components/VersionChip.tsx b/freemocap-ui/src/components/ui-components/VersionChip.tsxindex 39a9d90b..bd9939d8 100644--- a/freemocap-ui/src/components/ui-components/VersionChip.tsx+++ b/freemocap-ui/src/components/ui-components/VersionChip.tsx@@ -30,6 +30,7 @@ export const VersionChip: React.FC<VersionChipProps> = ({ variant = 'full' }) =>// Brief success state on the chip itselfconst [showSuccess, setShowSuccess] = useState(false);+ const successTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);useEffect(() => {const prev = prevStatusRef.current;@@ -41,7 +42,8 @@ export const VersionChip: React.FC<VersionChipProps> = ({ variant = 'full' }) =>if (status === 'up-to-date') {setSnackbar({ open: true, severity: 'success', message: t('upToDate') });setShowSuccess(true);- setTimeout(() => setShowSuccess(false), 3000);+ if (successTimerRef.current) clearTimeout(successTimerRef.current);+ successTimerRef.current = setTimeout(() => setShowSuccess(false), 3000);} else if (status === 'available') {setSnackbar({open: true,@@ -55,6 +57,10 @@ export const VersionChip: React.FC<VersionChipProps> = ({ variant = 'full' }) =>message: errorMessage ? `${t('updateError')}: ${errorMessage}` : t('updateError'),});}++ return () => {+ if (successTimerRef.current) clearTimeout(successTimerRef.current);+ };}, [status, updateVersion, errorMessage, t]);if (!version) return null;diff --git a/freemocap-ui/src/components/viewport3d/FileKeypointsSourceProvider.tsx b/freemocap-ui/src/components/viewport3d/FileKeypointsSourceProvider.tsxindex 8867a771..2411c2ff 100644--- a/freemocap-ui/src/components/viewport3d/FileKeypointsSourceProvider.tsx+++ b/freemocap-ui/src/components/viewport3d/FileKeypointsSourceProvider.tsx@@ -1,26 +1,30 @@import React, {useEffect, useMemo, useRef} from "react";import {parquetRead} from "hyparquet";import type {DecodedArray} from "hyparquet";-import {Point3d} from "./helpers/viewport3d-types";import {KeypointsCallback,+ KeypointsFrame,KeypointsSource,KeypointsSourceProvider,} from "./KeypointsSourceContext";import {serverUrls} from "@/constants/server-urls";+import {VIEWPORT_WORKER} from "./ThreeJsCanvas";+import {useAppDispatch, useAppSelector} from "@/store";+import {fetchPlaybackBundle, selectPlaybackBundle} from "@/store/slices/playback-data/playback-data-slice";+import {calibrationLoadedFromBundle} from "@/store/slices/calibration/calibration-slice";/*** KeypointsSource implementation that reads the recording's long-format* `freemocap_data_by_frame.parquet` directly in the browser (via hyparquet),* pivots long→wide into per-trajectory Float32Array buffers, and emits- * per-frame point records in lockstep with the playback slider.+ * per-frame KeypointsFrame values in lockstep with the playback slider.** Design notes:* - Uses parquetRead (columnar API) instead of parquetReadObjects to read column-wise.* - After decode, each trajectory is packed as Float32Array of length* frameCount * K * 3, giving O(1) per-frame indexing.- * - Subscribers receive a pre-allocated scratch record whose Point3d slots- * are mutated in place each tick (zero GC pressure).+ * - Subscribers receive a stable KeypointsFrame whose `scratchInterleaved`+ * buffer is mutated in place each tick (zero GC pressure after first frame).* - Driven by `currentFrameRef` from usePlaybackController, polled via our* own rAF loop. React re-renders are not involved in the hot path.*/@@ -35,6 +39,7 @@ const TRAJECTORY_PARQUET_VALUE: Record<TrajectoryAlias, string> = {const ParquetColumnNames = {frame: "frame",keypoint: "keypoint",+ model: "model",x: "x",y: "y",z: "z",@@ -42,22 +47,25 @@ const ParquetColumnNames = {} as const;interface TrajectoryData {- names: string[];- buffer: Float32Array; // length = frameCount * K * 3+ names: readonly string[];+ buffer: Float32Array; // length = frameCount * K * 3 (x, y, z — no vis in parquet)frameCount: number;keypointCount: number;- scratch: Record<string, Point3d>;+ scratchInterleaved: Float32Array; // length = K * 4 (x, y, z, vis) — mutated each tick+ scratchFrame: KeypointsFrame; // stable reference — interleaved points at scratchInterleavedsubscribers: Set<KeypointsCallback>;- lastEmittedFrame: number; // -1 means "never emitted"+ lastEmittedFrame: number; // -1 means "never emitted"}function emptyTrajectory(): TrajectoryData {+ const scratchInterleaved = new Float32Array(0);return {names: [],buffer: new Float32Array(0),frameCount: 0,keypointCount: 0,- scratch: {},+ scratchInterleaved,+ scratchFrame: { pointNames: [], interleaved: scratchInterleaved },subscribers: new Set(),lastEmittedFrame: -1,};@@ -92,12 +100,12 @@ function convertBigIntArray(arr: DecodedArray): Float64Array | DecodedArray {function concatDecodedArrays(chunks: DecodedArray[]): DecodedArray {// First, convert any BigInt arrays to Float64Arrayconst converted = chunks.map(c => convertBigIntArray(c));-+// Even for a single chunk, check if it was a BigInt array (already converted above)if (converted.length === 1) {return converted[0];}-+const total = converted.reduce((s, c) => s + c.length, 0);const first = converted[0];if (first instanceof Float64Array) {@@ -124,6 +132,25 @@ function concatDecodedArrays(chunks: DecodedArray[]): DecodedArray {return out;}+/**+ * Prefix hand keypoint names with their side so they match the holistic schema's+ * connection endpoint names. Body and face names are returned unchanged — they+ * already carry any needed prefix baked into the landmark name itself.+ *+ * mediapipe.right_hand + wrist → right_hand_wrist+ * mediapipe.left_hand + wrist → left_hand_wrist+ * mediapipe.body + nose → nose+ */+function prefixKeypointName(keypoint: string, model: string): string {+ const dot = model.indexOf(".");+ if (dot === -1) return keypoint;+ const aspect = model.slice(dot + 1);+ if (aspect === "right_hand" || aspect === "left_hand") {+ return `${aspect}_${keypoint}`;+ }+ return keypoint;+}+function buildTrajectory(cols: Record<string, DecodedArray>,parquetValue: string,@@ -132,6 +159,7 @@ function buildTrajectory(// Frame column may be Int32Array or Float64Array (if converted from BigInt)const frameCol = cols[ParquetColumnNames.frame] as Int32Array | Float64Array;const keypointCol = cols[ParquetColumnNames.keypoint] as string[];+ const modelCol = cols[ParquetColumnNames.model] as string[];const xCol = cols[ParquetColumnNames.x] as Float64Array;const yCol = cols[ParquetColumnNames.y] as Float64Array;const zCol = cols[ParquetColumnNames.z] as Float64Array;@@ -139,9 +167,14 @@ function buildTrajectory(const rowCount = frameCol.length;// First pass: collect unique keypoint names for this trajectory.+ // Hand keypoints are prefixed with their side (right_hand_ / left_hand_)+ // so left and right don't collide in the flat name set and so the names+ // match the holistic schema's connection endpoint names.const nameSet = new Set<string>();for (let i = 0; i < rowCount; i++) {- if (trajCol[i] === parquetValue) nameSet.add(keypointCol[i]);+ if (trajCol[i] === parquetValue) {+ nameSet.add(prefixKeypointName(keypointCol[i], modelCol[i]));+ }}if (nameSet.size === 0) return emptyTrajectory();@@ -158,7 +191,7 @@ function buildTrajectory(if (trajCol[i] !== parquetValue) continue;const f = frameCol[i];if (f < 0 || f >= frameCount) continue;- const k = nameToIdx.get(keypointCol[i]);+ const k = nameToIdx.get(prefixKeypointName(keypointCol[i], modelCol[i]));if (k === undefined) continue;const off = (f * K + k) * 3;buffer[off] = xCol[i];@@ -166,52 +199,146 @@ function buildTrajectory(buffer[off + 2] = zCol[i];}- const scratch: Record<string, Point3d> = {};- for (const name of names) scratch[name] = {x: NaN, y: NaN, z: NaN};+ const scratchInterleaved = new Float32Array(K * 4);+ const scratchFrame: KeypointsFrame = { pointNames: names, interleaved: scratchInterleaved };return {names,buffer,frameCount,keypointCount: K,- scratch,+ scratchInterleaved,+ scratchFrame,subscribers: new Set(),lastEmittedFrame: -1,};}+/**+ * Rewrite sequential face_XXXX names produced by skellyforge's model_info+ * (face_0000…face_0135) into the non-contiguous MediaPipe contour-index names+ * from the tracker schema (face_0000, face_0007, face_0010…). The buffer is+ * indexed by position, not name, so only the name list changes — per-frame data+ * stays correct. After this, the schema's face-connection endpoint names match+ * the trajectory's point names and ConnectionRenderer can draw them.+ */+function remapTrajectoryFaceNames(+ traj: TrajectoryData,+ contourNames: string[],+): void {+ if (traj.frameCount === 0 || contourNames.length === 0) return;++ // Collect current face-name slots sorted by their sequential number.+ const slots: { idx: number; seq: number }[] = [];+ const names = traj.names as string[];+ for (let i = 0; i < names.length; i++) {+ if (names[i].startsWith("face_")) {+ const seq = parseInt(names[i].slice(5), 10);+ if (!Number.isNaN(seq)) slots.push({ idx: i, seq });+ }+ }+ slots.sort((a, b) => a.seq - b.seq);++ // Replace each sequential slot with the matching contour name.+ const newNames = [...names];+ for (let i = 0; i < slots.length && i < contourNames.length; i++) {+ newNames[slots[i].idx] = contourNames[i];+ }++ // Mutate in-place so existing refs pick up the new names.+ (traj as { names: readonly string[] }).names = newNames;+ (traj as { scratchFrame: KeypointsFrame }).scratchFrame = {+ pointNames: newNames,+ interleaved: traj.scratchInterleaved,+ };+}+function updateScratch(traj: TrajectoryData, frame: number): void {const K = traj.keypointCount;if (K === 0) return;const clamped = Math.max(0, Math.min(frame, traj.frameCount - 1));const base = clamped * K * 3;const buf = traj.buffer;- const names = traj.names;- const scratch = traj.scratch;+ const scratch = traj.scratchInterleaved;for (let k = 0; k < K; k++) {- const off = base + k * 3;- const slot = scratch[names[k]];- slot.x = buf[off];- slot.y = buf[off + 1];- slot.z = buf[off + 2];+ const srcOff = base + k * 3;+ const dstOff = k * 4;+ const x = buf[srcOff];+ const y = buf[srcOff + 1];+ const z = buf[srcOff + 2];+ scratch[dstOff] = x;+ scratch[dstOff + 1] = y;+ scratch[dstOff + 2] = z;+ scratch[dstOff + 3] = Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z) ? 1.0 : 0.0;}}function fireSubscribers(traj: TrajectoryData): void {for (const cb of traj.subscribers) {- cb(traj.scratch);+ cb(traj.scratchFrame);}}export const FileKeypointsSourceProvider: React.FC<{recordingId: string | null;+ recordingParentDirectory?: string | null;currentFrameRef: React.RefObject<number>;children: React.ReactNode;-}> = ({recordingId, currentFrameRef, children}) => {+}> = ({recordingId, recordingParentDirectory, currentFrameRef, children}) => {const rawRef = useRef<TrajectoryData>(emptyTrajectory());const filteredRef = useRef<TrajectoryData>(emptyTrajectory());+ const faceContourNamesRef = useRef<string[]>([]);+ const dispatch = useAppDispatch();++ // Fetch the playback bundle (calibration + tracker-schema + status) via+ // Redux thunk. The `condition` guard prevents duplicate requests when+ // StrictMode remounts the component.+ useEffect(() => {+ if (!recordingId) return;+ dispatch(fetchPlaybackBundle({+ recordingId,+ recordingParentDirectory,+ }));+ }, [recordingId, recordingParentDirectory, dispatch]);++ // When the bundle arrives from Redux, forward calibration + tracker-schema+ // to the viewport3d worker and populate the calibration Redux slice so+ // ThreeJsCanvas can also consume it.+ const bundle = useAppSelector(selectPlaybackBundle(recordingId));++ useEffect(() => {+ if (!bundle) return;++ // Forward tracker schema to the worker so ConnectionRenderer draws skeleton lines.+ const schemaName: string = (bundle.trackerSchema as any)?.name || "playback_schema";+ VIEWPORT_WORKER.postMessage({+ type: "schemaState",+ data: {+ activeTrackerId: schemaName,+ trackerSchemas: {[schemaName]: bundle.trackerSchema},+ },+ });++ // Remap sequential face_XXXX names to contour YAML names so schema+ // connections match the trajectory's point names.+ const tp: string[] = (bundle.trackerSchema as any)?.tracked_points ?? [];+ faceContourNamesRef.current = tp.filter((n: string) => n.startsWith("face_"));+ if (faceContourNamesRef.current.length > 0) {+ remapTrajectoryFaceNames(rawRef.current, faceContourNamesRef.current);+ remapTrajectoryFaceNames(filteredRef.current, faceContourNamesRef.current);+ if (rawRef.current.lastEmittedFrame >= 0) {+ fireSubscribers(rawRef.current);+ }+ if (filteredRef.current.lastEmittedFrame >= 0) {+ fireSubscribers(filteredRef.current);+ }+ }++ // Populate the calibration Redux slice so ThreeJsCanvas consumes it.+ dispatch(calibrationLoadedFromBundle(bundle.calibration));+ }, [bundle, dispatch]);// Load + decode the parquet whenever recordingId changes.useEffect(() => {@@ -226,7 +353,12 @@ export const FileKeypointsSourceProvider: React.FC<{(async () => {try {const baseUrl = serverUrls.getHttpUrl();- const url = `${baseUrl}/freemocap/playback/${encodeURIComponent(recordingId)}/parquet`;+ const params = new URLSearchParams();+ if (recordingParentDirectory) {+ params.set('recording_parent_directory', recordingParentDirectory);+ }+ const qs = params.toString();+ const url = `${baseUrl}/freemocap/playback/${encodeURIComponent(recordingId)}/parquet${qs ? `?${qs}` : ''}`;const t0 = performance.now();const resp = await fetch(url, {signal: controller.signal});@@ -276,12 +408,21 @@ export const FileKeypointsSourceProvider: React.FC<{rawRef.current = rawTraj;filteredRef.current = filteredTraj;+ // If the playback-bundle schema arrived before the parquet finished+ // loading, remap face names now so the first emitted frame already has+ // correct contour-index names.+ if (faceContourNamesRef.current.length > 0) {+ remapTrajectoryFaceNames(rawTraj, faceContourNamesRef.current);+ remapTrajectoryFaceNames(filteredTraj, faceContourNamesRef.current);+ }+const tBuilt = performance.now();console.info(`[FileKeypointsSource] parquet ready: ${frameCol.length} rows, ${frameCount} frames, ` +`raw K=${rawTraj.keypointCount}, filtered K=${filteredTraj.keypointCount} ` +`(fetch ${(tFetched - t0) | 0}ms, decode ${(tDecoded - tFetched) | 0}ms, pivot ${(tBuilt - tDecoded) | 0}ms)`);+} catch (err) {if ((err as any)?.name !== "AbortError") {console.warn("[FileKeypointsSource] load error", err);@@ -290,7 +431,7 @@ export const FileKeypointsSourceProvider: React.FC<{})();return () => controller.abort();- }, [recordingId]);+ }, [recordingId, recordingParentDirectory]);// rAF loop: poll the controller's frame ref and push updates when the// integer frame changes.@@ -320,18 +461,19 @@ export const FileKeypointsSourceProvider: React.FC<{subscribeToKeypointsRaw: (cb: KeypointsCallback) => {rawRef.current.subscribers.add(cb);if (rawRef.current.frameCount > 0 && rawRef.current.lastEmittedFrame >= 0) {- cb(rawRef.current.scratch);+ cb(rawRef.current.scratchFrame);}return () => { rawRef.current.subscribers.delete(cb); };},subscribeToKeypointsFiltered: (cb: KeypointsCallback) => {filteredRef.current.subscribers.add(cb);if (filteredRef.current.frameCount > 0 && filteredRef.current.lastEmittedFrame >= 0) {- cb(filteredRef.current.scratch);+ cb(filteredRef.current.scratchFrame);}return () => { filteredRef.current.subscribers.delete(cb); };},- getLatestKeypointsRaw: () => rawRef.current.scratch,+ getLatestKeypointsRaw: () =>+ rawRef.current.frameCount > 0 ? rawRef.current.scratchFrame : null,}), []);return (diff --git a/freemocap-ui/src/components/viewport3d/KeypointsSourceContext.tsx b/freemocap-ui/src/components/viewport3d/KeypointsSourceContext.tsxindex 1a5f03b8..9d3d8a4c 100644--- a/freemocap-ui/src/components/viewport3d/KeypointsSourceContext.tsx+++ b/freemocap-ui/src/components/viewport3d/KeypointsSourceContext.tsx@@ -1,6 +1,5 @@import React, {createContext, useContext, useMemo} from "react";-import {Point3d} from "./helpers/viewport3d-types";-import {useServer} from "@/services";+import {useServerOptional} from "@/services/server/server-context";/*** Abstraction over "where do 3D keypoints come from". The Streaming panel@@ -11,12 +10,29 @@ import {useServer} from "@/services";* If no provider is mounted, the hook transparently falls back to `useServer()`* so existing Streaming code keeps working with zero changes at that layer.*/-export type KeypointsCallback = (points: Record<string, Point3d>) => void;++/**+ * A single frame of keypoint data in typed-array form.+ *+ * `interleaved` is a Float32Array laid out as:+ * [x₀, y₀, z₀, vis₀, x₁, y₁, z₁, vis₁, … ]+ * where `pointNames[i]` names the point at stride `i * 4`.+ * Missing / untriangulated points have NaN coords and visibility = 0.+ *+ * The array is dense and schema-ordered when the binary websocket path is+ * active; it may be sparse (only present points) when falling back to JSON.+ */+export interface KeypointsFrame {+ pointNames: readonly string[];+ interleaved: Float32Array; // length === pointNames.length * 4+}++export type KeypointsCallback = (frame: KeypointsFrame) => void;export interface KeypointsSource {subscribeToKeypointsRaw: (cb: KeypointsCallback) => () => void;subscribeToKeypointsFiltered: (cb: KeypointsCallback) => () => void;- getLatestKeypointsRaw: () => Record<string, Point3d>;+ getLatestKeypointsRaw: () => KeypointsFrame | null;}const KeypointsSourceContext = createContext<KeypointsSource | null>(null);@@ -30,24 +46,82 @@ export const KeypointsSourceProvider: React.FC<{</KeypointsSourceContext.Provider>);+/**+ * Returns true when a KeypointsSourceProvider is mounted above the consumer+ * (i.e. during playback mode), false when keypoints come from the live server.+ */+export function useHasKeypointsSourceProvider(): boolean {+ return useContext(KeypointsSourceContext) !== null;+}+/*** Returns the active keypoints source. Falls back to the live server if no* provider is mounted above the consumer.*/export function useKeypointsSource(): KeypointsSource {const ctx = useContext(KeypointsSourceContext);- const server = useServer();+ // useServerOptional returns null when called outside ServerContextProvider+ // (e.g. inside a Web Worker where only WorkerDataStore provides keypoints).+ const server = useServerOptional();// Build the live adapter lazily so it doesn't allocate when a provider is present.- const liveAdapter = useMemo<KeypointsSource>(() => ({- subscribeToKeypointsRaw: server.subscribeToKeypointsRaw,- subscribeToKeypointsFiltered: server.subscribeToKeypointsFiltered,- getLatestKeypointsRaw: server.getLatestKeypointsRaw,- }), [- server.subscribeToKeypointsRaw,- server.subscribeToKeypointsFiltered,- server.getLatestKeypointsRaw,+ const liveAdapter = useMemo<KeypointsSource | null>(() => {+ if (!server) return null;+ return {+ subscribeToKeypointsRaw: server.subscribeToKeypointsRaw,+ subscribeToKeypointsFiltered: server.subscribeToKeypointsFiltered,+ getLatestKeypointsRaw: server.getLatestKeypointsRaw,+ };+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [+ server?.subscribeToKeypointsRaw,+ server?.subscribeToKeypointsFiltered,+ server?.getLatestKeypointsRaw,]);- return ctx ?? liveAdapter;+ const source = ctx ?? liveAdapter;+ if (!source) throw new Error("No KeypointsSource: mount KeypointsSourceProvider or ServerContextProvider");+ return source;+}++// ---------------------------------------------------------------------------+// Utilities shared by multiple producers / consumers+// ---------------------------------------------------------------------------++/** Build a KeypointsFrame from a sparse `Record<string, {x,y,z}>` dict.+ * Used by the JSON fallback path and by renderers that still receive dict data.+ * Allocates one Float32Array; visibility is 1 for every point in the dict.+ */+export function pointDictToFrame(dict: Record<string, {x:number; y:number; z:number}>): KeypointsFrame {+ const pointNames = Object.keys(dict);+ const interleaved = new Float32Array(pointNames.length * 4);+ for (let i = 0; i < pointNames.length; i++) {+ const p = dict[pointNames[i]];+ const off = i * 4;+ interleaved[off] = p.x;+ interleaved[off + 1] = p.y;+ interleaved[off + 2] = p.z;+ interleaved[off + 3] = 1.0;+ }+ return { pointNames, interleaved };+}++/** Build a `Map<string, {x,y,z}>` from a frame. Used by renderers that need+ * name-keyed lookup (ConnectionRenderer, FaceRenderer). Allocates one object+ * per visible point; only called when those renderers receive a new frame.+ */+export function frameToPointMap(frame: KeypointsFrame): Map<string, {x:number; y:number; z:number}> {+ const m = new Map<string, {x:number; y:number; z:number}>();+ const { pointNames, interleaved } = frame;+ for (let i = 0; i < pointNames.length; i++) {+ const off = i * 4;+ if (!interleaved[off + 3]) continue; // vis === 0 → skip+ const x = interleaved[off];+ const y = interleaved[off + 1];+ const z = interleaved[off + 2];+ if (Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z)) {+ m.set(pointNames[i], { x, y, z });+ }+ }+ return m;}diff --git a/freemocap-ui/src/components/viewport3d/ThreeJsCanvas.tsx b/freemocap-ui/src/components/viewport3d/ThreeJsCanvas.tsxindex 998827a3..f6a4cc82 100644--- a/freemocap-ui/src/components/viewport3d/ThreeJsCanvas.tsx+++ b/freemocap-ui/src/components/viewport3d/ThreeJsCanvas.tsx@@ -1,38 +1,311 @@import { useCallback, useEffect, useRef } from "react";-import { Canvas } from "@react-three/fiber";import { Box } from "@mui/material";-import type CameraControlsImpl from "camera-controls";import { Object3D } from "three";-import { ThreeJsScene } from "./ThreeJsScene";+import { ViewportStateProvider, useViewportState } from "./scene/ViewportStateContext";import { ViewportOverlay } from "./scene/ViewportOverlay";-import { ViewportStateProvider } from "./scene/ViewportStateContext";-import { fitCameraToPoints } from "./scene/SceneCamera";-import { useKeypointsSource } from "./KeypointsSourceContext";+import { useHasKeypointsSourceProvider, useKeypointsSource } from "./KeypointsSourceContext";+import { useServer } from "@/services";+import { useAppSelector } from "@/store";+import {+ selectCalibrationConfig,+ selectLoadedCalibration,+} from "@/store/slices/calibration/calibration-slice";+import { useCalibrationTomlLoader } from "./hooks/useCalibrationTomlLoader";+import { type ViewportStats } from "./helpers/viewport3d-types";-// FreeMoCap's world is Z-up (calibration TOML, triangulated keypoints, etc.).-// Set the three.js default up vector before any cameras/objects are created so-// CameraControls orbits around +Z rather than +Y.+// FreeMoCap's world is Z-up — set once before any Three.js objects are created.Object3D.DEFAULT_UP.set(0, 0, 1);+// ---------------------------------------------------------------------------+// Worker (module-level singleton — survives React re-renders / StrictMode)+// ---------------------------------------------------------------------------++console.log("[ThreeJsCanvas] creating viewport3d worker");+export const VIEWPORT_WORKER = new Worker(+ new URL("./viewport3d.worker.tsx", import.meta.url),+ { type: "module" },+);+console.log("[ThreeJsCanvas] viewport3d worker created", VIEWPORT_WORKER);+VIEWPORT_WORKER.addEventListener("error", (e) =>+ console.error("[ThreeJsCanvas] worker error", e),+);+VIEWPORT_WORKER.addEventListener("messageerror", (e) =>+ console.error("[ThreeJsCanvas] worker messageerror", e),+);++// transferControlToOffscreen() can only be called once per HTMLCanvasElement.+// React 19 StrictMode double-mounts components in dev; it reuses the same DOM+// element across the mount→unmount→remount cycle, so a module-level flag that+// gets reset in a cleanup function will still double-transfer the same element.+//+// Instead we mark the DOM element itself via a data attribute. This survives+// StrictMode's double-mount (same element, attribute persists) but naturally+// expires on tab switches (old element destroyed, new element is clean).++// ---------------------------------------------------------------------------+// Helper components rendered inside ViewportStateProvider+// ---------------------------------------------------------------------------++/** Forwards visibility changes to the worker so the scene shows/hides layers. */+function VisibilityForwarder() {+ const { visibility } = useViewportState();+ useEffect(() => {+ VIEWPORT_WORKER.postMessage({ type: "visibility", data: visibility });+ }, [visibility]);+ return null;+}++/** Receives stats from the worker and writes them into the main-thread statsRef. */+function WorkerStatsReceiver() {+ const { statsRef } = useViewportState();+ useEffect(() => {+ const handler = (e: MessageEvent<{ type?: string; data?: ViewportStats }>) => {+ if (e.data?.type === "stats" && e.data.data) {+ Object.assign(statsRef.current, e.data.data);+ }+ };+ VIEWPORT_WORKER.addEventListener("message", handler);+ return () => VIEWPORT_WORKER.removeEventListener("message", handler);+ }, [statsRef]);+ return null;+}++// ---------------------------------------------------------------------------+// DOM-event serialization for forwarding to the worker+//+// CameraControls reads these fields off the events it receives. Stripping the+// rest avoids sending non-cloneable structures (target, view, etc.) over+// postMessage and keeps the payload small enough to forward at full input rate.+// ---------------------------------------------------------------------------++function serializePointerEvent(e: PointerEvent, rect: DOMRect) {+ return {+ eventType: e.type,+ init: {+ pointerId: e.pointerId,+ pointerType: e.pointerType,+ isPrimary: e.isPrimary,+ button: e.button,+ buttons: e.buttons,+ clientX: e.clientX - rect.left,+ clientY: e.clientY - rect.top,+ offsetX: e.offsetX,+ offsetY: e.offsetY,+ pageX: e.pageX - rect.left,+ pageY: e.pageY - rect.top,+ screenX: e.screenX,+ screenY: e.screenY,+ movementX: e.movementX,+ movementY: e.movementY,+ ctrlKey: e.ctrlKey,+ shiftKey: e.shiftKey,+ altKey: e.altKey,+ metaKey: e.metaKey,+ },+ };+}++function serializeWheelEvent(e: WheelEvent, rect: DOMRect) {+ return {+ eventType: "wheel",+ init: {+ deltaX: e.deltaX,+ deltaY: e.deltaY,+ deltaZ: e.deltaZ,+ deltaMode: e.deltaMode,+ clientX: e.clientX - rect.left,+ clientY: e.clientY - rect.top,+ ctrlKey: e.ctrlKey,+ shiftKey: e.shiftKey,+ altKey: e.altKey,+ metaKey: e.metaKey,+ },+ };+}++// ---------------------------------------------------------------------------+// Main component+// ---------------------------------------------------------------------------+export function ThreeJsCanvas() {- const controlsRef = useRef<CameraControlsImpl>(null!);+ const server = useServer();+ const calibrationConfig = useAppSelector(selectCalibrationConfig);+ const loadedCalibration = useAppSelector(selectLoadedCalibration);+ const { subscribeToKeypointsRaw, subscribeToKeypointsFiltered, getLatestKeypointsRaw } =+ useKeypointsSource();+ const isPlayback = useHasKeypointsSourceProvider();const containerRef = useRef<HTMLDivElement>(null);- const { getLatestKeypointsRaw } = useKeypointsSource();+ const canvasRef = useRef<HTMLCanvasElement>(null);++ useCalibrationTomlLoader();++ // ── OffscreenCanvas transfer + worker init ────────────────────────────+ // Uses a data-attribute on the DOM element itself (not a module-level flag)+ // to prevent double-transfer. React StrictMode reuses the same canvas DOM+ // element across its mount→unmount→remount cycle, so the attribute survives+ // the cleanup/remount and correctly blocks the second transfer. On a real+ // tab switch the old element is destroyed — the new element has no attribute.+ //+ // No cleanup teardown message: on a real unmount the worker's existing root+ // may briefly become orphaned (rendering to a now-detached OffscreenCanvas),+ // but the next mount's "init" triggers initRoot() which tears down any stale+ // root before creating a new one. This avoids the StrictMode false-positive+ // where cleanup→reinit would race with the async root.configure().+ useEffect(() => {+ const canvas = canvasRef.current;+ const container = containerRef.current;+ if (!canvas || !container) return;+ if (canvas.dataset.offscreenTransferred === "true") return;+ canvas.dataset.offscreenTransferred = "true";++ const rect = container.getBoundingClientRect();+ const width = Math.max(1, Math.floor(rect.width));+ const height = Math.max(1, Math.floor(rect.height));+ const pixelRatio = Math.min(globalThis.devicePixelRatio ?? 1, 2);++ const offscreen = canvas.transferControlToOffscreen();+ VIEWPORT_WORKER.postMessage(+ {+ type: "init",+ payload: { canvas: offscreen, width, height, pixelRatio },+ },+ [offscreen],+ );+ }, []);+ // ── High-frequency streaming data ────────────────────────────────────────+ // Frames are structured-cloned across the worker boundary. The Float32Array+ // inside each KeypointsFrame is copied, not transferred, so the main thread+ // retains access for getLatestKeypointsRaw (camera fit).+ useEffect(() => {+ return subscribeToKeypointsRaw((frame) => {+ VIEWPORT_WORKER.postMessage({ type: "keypointsRaw", data: frame });+ });+ }, [subscribeToKeypointsRaw]);++ useEffect(() => {+ return subscribeToKeypointsFiltered((frame) => {+ VIEWPORT_WORKER.postMessage({ type: "keypointsFiltered", data: frame });+ });+ }, [subscribeToKeypointsFiltered]);++ // ── Low-frequency config data ─────────────────────────────────────────────+ // During playback, FileKeypointsSourceProvider owns the schema (fetched from+ // the recording's tracker_schema.json). Pushing the live-server schema here+ // would overwrite it with rtmpose_wholebody, breaking hand/face connections.+ useEffect(() => {+ if (isPlayback) return;+ VIEWPORT_WORKER.postMessage({+ type: "schemaState",+ data: {+ activeTrackerId: server.activeTrackerId,+ trackerSchemas: server.trackerSchemas,+ },+ });+ }, [isPlayback, server.activeTrackerId, server.trackerSchemas]);++ useEffect(() => {+ VIEWPORT_WORKER.postMessage({ type: "calibrationConfig", data: calibrationConfig });+ }, [calibrationConfig]);++ useEffect(() => {+ VIEWPORT_WORKER.postMessage({ type: "calibration", data: loadedCalibration });+ }, [loadedCalibration]);++ // ── Camera commands ───────────────────────────────────────────────────────const handleFit = useCallback(() => {- fitCameraToPoints(controlsRef.current, getLatestKeypointsRaw());+ VIEWPORT_WORKER.postMessage({ type: "fitCamera", data: getLatestKeypointsRaw() });}, [getLatestKeypointsRaw]);const handleReset = useCallback(() => {- controlsRef.current?.reset(true);+ VIEWPORT_WORKER.postMessage({ type: "resetCamera" });}, []);- // "F" key shortcut+ // ── Resize ───────────────────────────────────────────────────────────────+ useEffect(() => {+ const el = containerRef.current;+ const canvas = canvasRef.current;+ if (!el || !canvas) return;+ const ro = new ResizeObserver((entries) => {+ const { width, height } = entries[0].contentRect;+ if (width === 0 && height === 0) return;+ // Read layout properties BEFORE writing CSS to avoid forced reflow.+ const top = el.offsetTop;+ const left = el.offsetLeft;+ // Set CSS size on the visible canvas — the OffscreenCanvas backing+ // store is sized by the worker via root.configure({size}).+ canvas.style.width = `${width}px`;+ canvas.style.height = `${height}px`;+ VIEWPORT_WORKER.postMessage({+ type: "resize",+ payload: {+ width: Math.floor(width),+ height: Math.floor(height),+ top,+ left,+ },+ });+ });+ ro.observe(el);+ return () => ro.disconnect();+ }, []);++ // ── Pointer / wheel event forwarding ─────────────────────────────────────+ useEffect(() => {+ const canvas = canvasRef.current;+ if (!canvas) return;++ const onPointer = (e: PointerEvent) => {+ // capture pointer on the visible element so move/up still fire after leaving the canvas+ if (e.type === "pointerdown") {+ try { canvas.setPointerCapture(e.pointerId); } catch { /* noop */ }+ }+ const rect = canvas.getBoundingClientRect();+ VIEWPORT_WORKER.postMessage({+ type: "domEvent",+ payload: serializePointerEvent(e, rect),+ });+ };+ const onWheel = (e: WheelEvent) => {+ e.preventDefault();+ const rect = canvas.getBoundingClientRect();+ VIEWPORT_WORKER.postMessage({+ type: "domEvent",+ payload: serializeWheelEvent(e, rect),+ });+ };+ const onContextMenu = (e: Event) => e.preventDefault();++ const pointerTypes = [+ "pointerdown",+ "pointermove",+ "pointerup",+ "pointercancel",+ "pointerleave",+ ] as const;+ pointerTypes.forEach((t) =>+ canvas.addEventListener(t, onPointer as EventListener, { passive: false }),+ );+ canvas.addEventListener("wheel", onWheel as EventListener, { passive: false });+ canvas.addEventListener("contextmenu", onContextMenu);+ return () => {+ pointerTypes.forEach((t) =>+ canvas.removeEventListener(t, onPointer as EventListener),+ );+ canvas.removeEventListener("wheel", onWheel as EventListener);+ canvas.removeEventListener("contextmenu", onContextMenu);+ };+ }, []);++ // ── "F" key shortcut ─────────────────────────────────────────────────────useEffect(() => {const el = containerRef.current;if (!el) return;const onKey = (e: KeyboardEvent) => {- if (e.key === "f" || e.key === "F") { e.preventDefault(); handleFit(); }+ if (e.key === "f" || e.key === "F") {+ e.preventDefault();+ handleFit();+ }};el.addEventListener("keydown", onKey);return () => el.removeEventListener("keydown", onKey);@@ -40,19 +313,22 @@ export function ThreeJsCanvas() {return (<ViewportStateProvider>+ <VisibilityForwarder />+ <WorkerStatsReceiver /><Boxref={containerRef}tabIndex={0}sx={{ width: "100%", height: "100%", position: "relative", outline: "none" }}>- <Canvas- shadows- camera={{ position: [1e3, 1e3, 1e3], fov: 75, near: 0.1, far: 1e5 }}- gl={{ antialias: true, logarithmicDepthBuffer: true }}- >- <ThreeJsScene cameraControlsRef={controlsRef} />- </Canvas>-+ <canvas+ ref={canvasRef}+ style={{+ width: "100%",+ height: "100%",+ display: "block",+ touchAction: "none",+ }}+ /><ViewportOverlay onFitCamera={handleFit} onResetCamera={handleReset} /></Box></ViewportStateProvider>diff --git a/freemocap-ui/src/components/viewport3d/ThreeJsScene.tsx b/freemocap-ui/src/components/viewport3d/ThreeJsScene.tsxindex 7afadd66..428cae05 100644--- a/freemocap-ui/src/components/viewport3d/ThreeJsScene.tsx+++ b/freemocap-ui/src/components/viewport3d/ThreeJsScene.tsx@@ -1,5 +1,6 @@-import {RefObject} from "react";+import {RefObject, useEffect} from "react";import type CameraControlsImpl from "camera-controls";+import {useFrame, useThree} from "@react-three/fiber";import {SceneCamera} from "./scene/SceneCamera";import {SceneEnvironment} from "./scene/SceneEnvironment";import {KeypointsRenderer} from "./renderers/KeypointsRenderer";@@ -7,7 +8,46 @@ import {FaceRenderer} from "@/components/viewport3d/renderers/FaceRenderer";import {ConnectionRenderer} from "@/components/viewport3d/renderers/ConnectionRenderer";import {MocapCameraRenderer} from "@/components/viewport3d/renderers/MocapCameraRenderer";import {useViewportState} from "@/components/viewport3d/scene/ViewportStateContext";-import {useCalibrationTomlLoader} from "@/components/viewport3d/hooks/useCalibrationTomlLoader";+import {useKeypointsSource} from "./KeypointsSourceContext";+import {workerDataStore} from "./WorkerDataStore";++/**+ * Calls invalidate() whenever scene data changes so the WebGL render loop+ * only fires on-demand instead of 60fps. Covers keypoints (high-frequency),+ * visibility, calibration, and schema (low-frequency).+ * CameraControls from drei handles its own invalidation while the camera moves.+ */+function DataInvalidator() {+ const invalidate = useThree(state => state.invalidate);+ const { subscribeToKeypointsRaw, subscribeToKeypointsFiltered } = useKeypointsSource();++ useEffect(() => {+ const unsubs = [+ subscribeToKeypointsRaw(() => invalidate()),+ subscribeToKeypointsFiltered(() => invalidate()),+ workerDataStore.subscribeToVisibility(() => invalidate()),+ workerDataStore.subscribeToCalibration(() => invalidate()),+ workerDataStore.subscribeToSchemaState(() => invalidate()),+ ];+ return () => unsubs.forEach(fn => fn());+ }, [invalidate, subscribeToKeypointsRaw, subscribeToKeypointsFiltered]);++ return null;+}++/** Logs when a single R3F frame's work (useFrame callbacks + GPU upload) takes too long. */+function FrameProfiler() {+ useFrame(() => {+ const t0 = performance.now();+ // queueMicrotask fires after all useFrame hooks and Three.js GPU uploads in this+ // tick but before the next browser task, giving a real intra-frame cost.+ queueMicrotask(() => {+ const elapsed = performance.now() - t0;+ if (elapsed > 8) console.warn(`R3F frame cost: ${elapsed.toFixed(1)}ms`);+ });+ });+ return null;+}interface ThreeJsSceneProps {cameraControlsRef: RefObject<CameraControlsImpl>;@@ -15,10 +55,11 @@ interface ThreeJsSceneProps {export function ThreeJsScene({ cameraControlsRef }: ThreeJsSceneProps) {const { visibility } = useViewportState();- useCalibrationTomlLoader();return (<>+ <DataInvalidator />+ <FrameProfiler /><SceneCamera controlsRef={cameraControlsRef} /><SceneEnvironment /><KeypointsRenderer />diff --git a/freemocap-ui/src/components/viewport3d/WorkerDataContext.tsx b/freemocap-ui/src/components/viewport3d/WorkerDataContext.tsxnew file mode 100644index 00000000..bac1ef66--- /dev/null+++ b/freemocap-ui/src/components/viewport3d/WorkerDataContext.tsx@@ -0,0 +1,117 @@+/**+ * React context that exposes per-scene configuration to renderer components+ * running inside the viewport3d Web Worker.+ *+ * Renderers call `useWorkerData()` instead of `useServer()` + `useAppSelector()`+ * so they work transparently whether they run on the main thread (future) or in+ * a worker (current). The provider subscribes to `workerDataStore` and promotes+ * low-frequency config changes into React state so components re-render only when+ * schemas / calibration actually change — not on every keyframe.+ *+ * Visibility is handled separately: `WorkerVisibilitySync` listens to the store+ * and forwards visibility changes into the nearest `ViewportStateProvider`.+ */++import React, {+ createContext,+ useCallback,+ useContext,+ useEffect,+ useMemo,+ useState,+} from "react";+import type { TrackedObjectDefinition } from "@/services/server/server-helpers/tracked-object-definition";+import type {+ CalibrationConfig,+ LoadedCalibration,+} from "@/store/slices/calibration/calibration-types";+import { workerDataStore, type SchemaState } from "./WorkerDataStore";+import { useViewportState } from "./scene/ViewportStateContext";++// ---------------------------------------------------------------------------+// Context value shape+// ---------------------------------------------------------------------------++export interface WorkerDataContextValue {+ activeTrackerId: string | null;+ trackerSchemas: Record<string, TrackedObjectDefinition>;+ getActiveSchema: () => TrackedObjectDefinition | null;+ calibrationConfig: CalibrationConfig;+ loadedCalibration: LoadedCalibration | null;+}++const WorkerDataContext = createContext<WorkerDataContextValue | null>(null);++// ---------------------------------------------------------------------------+// Provider+// ---------------------------------------------------------------------------++export function WorkerDataProvider({ children }: { children: React.ReactNode }) {+ const [schemaState, setSchemaState] = useState<SchemaState>(+ workerDataStore.getSchemaState,+ );+ const [loadedCalibration, setLoadedCalibration] = useState<LoadedCalibration | null>(+ workerDataStore.getCalibration,+ );+ const [calibrationConfig, setCalibrationConfig] = useState<CalibrationConfig>(+ workerDataStore.getCalibrationConfig,+ );++ useEffect(() => {+ const unsubs = [+ workerDataStore.subscribeToSchemaState(setSchemaState),+ workerDataStore.subscribeToCalibration(setLoadedCalibration),+ workerDataStore.subscribeToCalibrationConfig(setCalibrationConfig),+ ];+ return () => unsubs.forEach((fn) => fn());+ }, []);++ const getActiveSchema = useCallback((): TrackedObjectDefinition | null => {+ if (!schemaState.activeTrackerId) return null;+ return schemaState.trackerSchemas[schemaState.activeTrackerId] ?? null;+ }, [schemaState]);++ const value = useMemo<WorkerDataContextValue>(+ () => ({+ activeTrackerId: schemaState.activeTrackerId,+ trackerSchemas: schemaState.trackerSchemas,+ getActiveSchema,+ calibrationConfig,+ loadedCalibration,+ }),+ [schemaState, getActiveSchema, calibrationConfig, loadedCalibration],+ );++ return (+ <WorkerDataContext.Provider value={value}>+ {children}+ </WorkerDataContext.Provider>+ );+}++// ---------------------------------------------------------------------------+// Hook+// ---------------------------------------------------------------------------++export function useWorkerData(): WorkerDataContextValue {+ const ctx = useContext(WorkerDataContext);+ if (!ctx) throw new Error("useWorkerData must be used within WorkerDataProvider");+ return ctx;+}++// ---------------------------------------------------------------------------+// WorkerVisibilitySync — bridge store visibility into ViewportStateContext+// Must be rendered inside both WorkerDataProvider and ViewportStateProvider.+// ---------------------------------------------------------------------------++export function WorkerVisibilitySync() {+ const { setVisibility } = useViewportState();++ useEffect(() => {+ // Immediately apply whatever visibility the main thread already sent.+ setVisibility(workerDataStore.getVisibility());+ return workerDataStore.subscribeToVisibility(setVisibility);+ }, [setVisibility]);++ return null;+}diff --git a/freemocap-ui/src/components/viewport3d/WorkerDataStore.ts b/freemocap-ui/src/components/viewport3d/WorkerDataStore.tsnew file mode 100644index 00000000..b8e3d31b--- /dev/null+++ b/freemocap-ui/src/components/viewport3d/WorkerDataStore.ts@@ -0,0 +1,149 @@+/**+ * Module-level data store for the viewport3d Web Worker.+ *+ * Receives all scene data from the main thread via postMessage and distributes+ * it to React components via subscriptions. For high-frequency keypoints (every+ * frame) a lightweight pub/sub pattern is used (no React state) so that the+ * existing refs + useFrame pattern keeps working. For low-frequency config data+ * (schemas, calibration, visibility) React state is used, driven by this store.+ */++import type { TrackedObjectDefinition } from "@/services/server/server-helpers/tracked-object-definition";+import type { CalibrationConfig, LoadedCalibration } from "@/store/slices/calibration/calibration-types";+import { DEFAULT_VISIBILITY, type ViewportVisibility } from "./helpers/viewport3d-types";+import type { KeypointsFrame, KeypointsSource } from "./KeypointsSourceContext";++// ---------------------------------------------------------------------------+// Shared channel primitive+// ---------------------------------------------------------------------------++type Listener<T> = (data: T) => void;++function makeChannel<T>(initial: T) {+ const subscribers = new Set<Listener<T>>();+ let latest = initial;+ return {+ dispatch(data: T) {+ latest = data;+ subscribers.forEach((cb) => cb(data));+ },+ subscribe(cb: Listener<T>): () => void {+ subscribers.add(cb);+ return () => subscribers.delete(cb);+ },+ getLatest: () => latest,+ };+}++// ---------------------------------------------------------------------------+// Channels+// ---------------------------------------------------------------------------++export interface SchemaState {+ activeTrackerId: string | null;+ trackerSchemas: Record<string, TrackedObjectDefinition>;+}++const DEFAULT_CALIBRATION_CONFIG: CalibrationConfig = {+ charucoBoard: { squares_x: 5, squares_y: 3, square_length_mm: 54 },+ minSharedViewsPerCamera: 200,+ autoStopOnMinViewCount: true,+ solverMethod: "anipose",+ useGroundplane: false,+};++const rawChan = makeChannel<KeypointsFrame | null>(null);+const filteredChan = makeChannel<KeypointsFrame | null>(null);+const schemaChan = makeChannel<SchemaState>({ activeTrackerId: null, trackerSchemas: {} });+const calibChan = makeChannel<LoadedCalibration | null>(null);+const calibConfigChan = makeChannel<CalibrationConfig>(DEFAULT_CALIBRATION_CONFIG);+const visibilityChan = makeChannel<ViewportVisibility>(DEFAULT_VISIBILITY);++// One-shot command channels (fit/reset camera)+const fitCameraChan = makeChannel<KeypointsFrame | null>(null);+const resetCameraChan = makeChannel<null>(null);++// ---------------------------------------------------------------------------+// Public store — also satisfies KeypointsSource for the KeypointsSourceProvider+// ---------------------------------------------------------------------------++export const workerDataStore: KeypointsSource & {+ subscribeToSchemaState: (cb: Listener<SchemaState>) => () => void;+ getSchemaState: () => SchemaState;+ subscribeToCalibration: (cb: Listener<LoadedCalibration | null>) => () => void;+ getCalibration: () => LoadedCalibration | null;+ subscribeToCalibrationConfig: (cb: Listener<CalibrationConfig>) => () => void;+ getCalibrationConfig: () => CalibrationConfig;+ subscribeToVisibility: (cb: Listener<ViewportVisibility>) => () => void;+ getVisibility: () => ViewportVisibility;+ subscribeToFitCamera: (cb: Listener<KeypointsFrame | null>) => () => void;+ subscribeToResetCamera: (cb: Listener<null>) => () => void;+ dispatch: (type: string, data: unknown) => void;+} = {+ // KeypointsSource interface — channels hold KeypointsFrame|null but callbacks expect non-null.+ // Replay the latest value on subscribe so the 3D viewport shows frame 0 immediately on load+ // instead of staying blank until the user presses play (the first frame dispatch races ahead+ // of React effects, which haven't mounted the KeypointsRenderer subscriber yet).+ subscribeToKeypointsRaw: (cb) => {+ const unsub = rawChan.subscribe((f) => { if (f) cb(f); });+ const latest = rawChan.getLatest();+ if (latest) cb(latest);+ return unsub;+ },+ subscribeToKeypointsFiltered: (cb) => {+ const unsub = filteredChan.subscribe((f) => { if (f) cb(f); });+ const latest = filteredChan.getLatest();+ if (latest) cb(latest);+ return unsub;+ },+ getLatestKeypointsRaw: rawChan.getLatest,++ // Schema state+ subscribeToSchemaState: schemaChan.subscribe,+ getSchemaState: schemaChan.getLatest,++ // Loaded calibration (camera poses)+ subscribeToCalibration: calibChan.subscribe,+ getCalibration: calibChan.getLatest,++ // Calibration config (charuco board dims, etc.)+ subscribeToCalibrationConfig: calibConfigChan.subscribe,+ getCalibrationConfig: calibConfigChan.getLatest,++ // Viewport visibility toggles+ subscribeToVisibility: visibilityChan.subscribe,+ getVisibility: visibilityChan.getLatest,++ // Camera commands (one-shot)+ subscribeToFitCamera: fitCameraChan.subscribe,+ subscribeToResetCamera: resetCameraChan.subscribe,++ dispatch(type: string, data: unknown) {+ switch (type) {+ case "keypointsRaw":+ rawChan.dispatch(data as KeypointsFrame);+ break;+ case "keypointsFiltered":+ filteredChan.dispatch(data as KeypointsFrame);+ break;+ case "schemaState":+ schemaChan.dispatch(data as SchemaState);+ break;+ case "calibration":+ calibChan.dispatch(data as LoadedCalibration | null);+ break;+ case "calibrationConfig":+ calibConfigChan.dispatch(data as CalibrationConfig);+ break;+ case "visibility":+ visibilityChan.dispatch(data as ViewportVisibility);+ break;+ case "fitCamera":+ fitCameraChan.dispatch(data as KeypointsFrame | null);+ break;+ case "resetCamera":+ resetCameraChan.dispatch(null);+ break;+ }+ },+};diff --git a/freemocap-ui/src/components/viewport3d/helpers/skeleton-colors.ts b/freemocap-ui/src/components/viewport3d/helpers/skeleton-colors.tsindex f9ba4dc2..2c091608 100644--- a/freemocap-ui/src/components/viewport3d/helpers/skeleton-colors.ts+++ b/freemocap-ui/src/components/viewport3d/helpers/skeleton-colors.ts@@ -9,4 +9,5 @@ export const SKELETON_COLORS = {face: new Color('#FFD700'),hidden: new Color('#000000'),charuco: new Color('#00FF00'),+ aruco: new Color('#FF6400'),} as const;diff --git a/freemocap-ui/src/components/viewport3d/helpers/skeleton-config.ts b/freemocap-ui/src/components/viewport3d/helpers/skeleton-config.tsindex 7487647a..6ba7b258 100644--- a/freemocap-ui/src/components/viewport3d/helpers/skeleton-config.ts+++ b/freemocap-ui/src/components/viewport3d/helpers/skeleton-config.ts@@ -4,33 +4,35 @@ import {SKELETON_COLORS} from "@/components/viewport3d/helpers/skeleton-colors";import {PointStyle} from "@/components/viewport3d/helpers/viewport3d-types";import {TrackedObjectDefinition} from "@/services/server/server-helpers/tracked-object-definition";-// Maximum tracked points the instanced mesh can hold-export const MAX_POINTS = 1000;-// Z-axis offset applied to all tracked points to center the skeleton in view-export const Z_OFFSET = -15;-// --- Point classification (shared by 3D point + segment styling) --------------//-// These helpers are the single place we encode "what body part does this name-// look like" — everything else defers to them. They work on any tracker's-// naming scheme as long as body/hand/face names carry identifiable substrings.+type PointClass = 'face' | 'left_hand' | 'right_hand' | 'left' | 'right' | 'center' | 'aruco';-export function classifyPointName(name: string): 'face' | 'left_hand' | 'right_hand' | 'left' | 'right' | 'center' {+const classifyCache = new Map<string, PointClass>();++export function classifyPointName(name: string): PointClass {+ const cached = classifyCache.get(name);+ if (cached !== undefined) return cached;const lc = name.toLowerCase();- if (lc.startsWith('face') || lc.includes('.face') || /^face[._-]/.test(lc)) return 'face';- if (lc.includes('left_hand')) return 'left_hand';- if (lc.includes('right_hand')) return 'right_hand';- if (lc.includes('left')) return 'left';- if (lc.includes('right')) return 'right';- return 'center';+ let result: PointClass;+ if (lc.startsWith('face') || lc.includes('.face') || /^face[._-]/.test(lc)) result = 'face';+ else if (lc.startsWith('arucomarkercorner')) result = 'aruco';+ else if (lc.includes('left_hand')) result = 'left_hand';+ else if (lc.includes('right_hand')) result = 'right_hand';+ else if (lc.includes('left')) result = 'left';+ else if (lc.includes('right')) result = 'right';+ else result = 'center';+ classifyCache.set(name, result);+ return result;}// --- Point styling: color + sphere scale per body part ----------------------+// Accepts pre-built Color objects (keyed by point name) so callers in render+// loops can avoid allocating a new Color on every frame.export function getPointStyle(name: string,- colorHints?: Record<string, string>,+ colorHints?: Record<string, Color>,): PointStyle {const hinted = colorHints?.[name];const klass = classifyPointName(name);@@ -40,27 +42,31 @@ export function getPointStyle(switch (klass) {case 'face':- color = hinted ? new Color(hinted) : SKELETON_COLORS.face;+ color = hinted ?? SKELETON_COLORS.face;scale = 0.02;break;case 'left_hand':- color = hinted ? new Color(hinted) : SKELETON_COLORS.leftHand;+ color = hinted ?? SKELETON_COLORS.leftHand;scale = 0.075;break;case 'right_hand':- color = hinted ? new Color(hinted) : SKELETON_COLORS.rightHand;+ color = hinted ?? SKELETON_COLORS.rightHand;scale = 0.075;break;case 'left':- color = hinted ? new Color(hinted) : SKELETON_COLORS.left;+ color = hinted ?? SKELETON_COLORS.left;scale = sizeForBodyPoint(name);break;case 'right':- color = hinted ? new Color(hinted) : SKELETON_COLORS.right;+ color = hinted ?? SKELETON_COLORS.right;scale = sizeForBodyPoint(name);break;+ case 'aruco':+ color = hinted ?? SKELETON_COLORS.aruco;+ scale = 0.08;+ break;default:- color = hinted ? new Color(hinted) : SKELETON_COLORS.center;+ color = hinted ?? SKELETON_COLORS.center;scale = sizeForBodyPoint(name);}@@ -90,7 +96,7 @@ export function getSegmentColor(const dk = classifyPointName(distal);// Prefer the more specific classification.const rank: Record<string, number> = {- face: 5, left_hand: 4, right_hand: 4, left: 3, right: 3, center: 1,+ face: 5, left_hand: 4, right_hand: 4, left: 3, right: 3, aruco: 2, center: 1,};const best = (rank[pk] ?? 0) >= (rank[dk] ?? 0) ? pk : dk;switch (best) {@@ -99,6 +105,7 @@ export function getSegmentColor(case 'right_hand': return SKELETON_COLORS.rightHand;case 'left': return SKELETON_COLORS.left;case 'right': return SKELETON_COLORS.right;+ case 'aruco': return SKELETON_COLORS.aruco;default: return SKELETON_COLORS.center;}}diff --git a/freemocap-ui/src/components/viewport3d/renderers/ConnectionRenderer.tsx b/freemocap-ui/src/components/viewport3d/renderers/ConnectionRenderer.tsxindex 2cecf4a1..5c28a29f 100644--- a/freemocap-ui/src/components/viewport3d/renderers/ConnectionRenderer.tsx+++ b/freemocap-ui/src/components/viewport3d/renderers/ConnectionRenderer.tsx@@ -1,39 +1,72 @@-import { useEffect, useMemo, useRef } from "react";+import { useEffect, useMemo, useRef, useState } from "react";+import { InterleavedBufferAttribute, Vector2 } from "three";+import { useFrame, useThree } from "@react-three/fiber";import {- BufferAttribute,- BufferGeometry,- LineBasicMaterial,- LineSegments,-} from "three";-import { useFrame } from "@react-three/fiber";-import { useServer } from "@/services";-import { Point3d } from "@/components/viewport3d";-import { useKeypointsSource } from "../KeypointsSourceContext";+ LineSegments2,+ LineSegmentsGeometry,+ LineMaterial,+} from "three-stdlib";+import { useWorkerData } from "../WorkerDataContext";+import { Point3d } from "../helpers/viewport3d-types";+import { useKeypointsSource, type KeypointsFrame } from "../KeypointsSourceContext";import { useViewportState } from "../scene/ViewportStateContext";import {buildSegmentsFromSchema,+ classifyPointName,MAX_SEGMENT_EXTRAS,} from "../helpers/skeleton-config";import { resolvePoint } from "../helpers/virtual-points";-import { useAppSelector } from "@/store";-import { selectCalibrationConfig } from "@/store/slices/calibration/calibration-slice";import { SKELETON_COLORS } from "../helpers/skeleton-colors";+const ARUCO_EDGES: [number, number][] = [[0, 1], [1, 2], [2, 3], [3, 0]];++// Per-category line widths (px). Body includes charuco / aruco calibration markers.+const BODY_CONNECTION_LINE_WIDTH = 2;+const HAND_CONNECTION_LINE_WIDTH = 1.5;+const FACE_CONNECTION_LINE_WIDTH = 1;++type SegmentCategory = "body" | "hand" | "face";++function classifySegment(proximal: string, distal: string): SegmentCategory {+ const pk = classifyPointName(proximal);+ const dk = classifyPointName(distal);+ const rank: Record<string, number> = {+ face: 5, left_hand: 4, right_hand: 4, left: 3, right: 3, aruco: 2, center: 1,+ };+ const best = (rank[pk] ?? 0) >= (rank[dk] ?? 0) ? pk : dk;+ if (best === "face") return "face";+ if (best === "left_hand" || best === "right_hand") return "hand";+ return "body";+}++/** Per-layer state: geometry, material, the mesh object, and segment write info. */+interface ConnectionLayer {+ lineObj: LineSegments2;+ geo: LineSegmentsGeometry;+ mat: LineMaterial;+ /** Maps write-slot index → index in the flat `segments`/`colors` arrays. */+ segmentIndices: Int32Array;+}+/**- * Renders skeleton connections as colored line segments.+ * Renders skeleton connections as colored line segments at per-category widths.*- * Segments are derived from the active `TrackedObjectDefinition` pushed from- * the backend via the `tracker_schemas` WS handshake. Charuco grid- * connections are appended in a reserved tail region of the same buffer.+ * Body, hand, and face connections each get their own LineMaterial with a+ * different `linewidth`, because the shader-based approach uses a uniform —+ * one width per draw call. Charuco grid and aruco outlines are appended to the+ * body layer.*/export function ConnectionRenderer() {- const { getActiveSchema, activeTrackerId, trackerSchemas } = useServer();- const { subscribeToKeypointsRaw } = useKeypointsSource();+ const { activeTrackerId, trackerSchemas, calibrationConfig } = useWorkerData();+ const { subscribeToKeypointsRaw, subscribeToKeypointsFiltered } = useKeypointsSource();const { statsRef } = useViewportState();- const calibrationConfig = useAppSelector(selectCalibrationConfig);+ const { invalidate, size } = useThree();- const linesRef = useRef<LineSegments>(null);const pointsRef = useRef<Map<string, Point3d>>(new Map());+ const rawPointsRef = useRef<Map<string, Point3d>>(new Map());+ const arucoMarkersRef = useRef<Map<number, (Point3d | undefined)[]>>(new Map());+ const prevArucoNamesRef = useRef<Set<string>>(new Set());+ const arucoNameCacheRef = useRef<Map<string, {markerId: number; cornerIdx: number}>>(new Map());const dirtyRef = useRef(false);// Build the segment list whenever the active schema changes.@@ -42,131 +75,368 @@ export function ConnectionRenderer() {return trackerSchemas[activeTrackerId] ?? null;}, [activeTrackerId, trackerSchemas]);- const {segments, colors} = useMemo(+ const {segments, colors: allColors} = useMemo(() => buildSegmentsFromSchema(activeSchema),[activeSchema],);- const maxSegments = useMemo(- () => segments.length + MAX_SEGMENT_EXTRAS,- [segments.length],- );+ // Split schema segments into per-category index arrays.+ const binned = useMemo(() => {+ const body: number[] = [];+ const hand: number[] = [];+ const face: number[] = [];+ for (let i = 0; i < segments.length; i++) {+ const cat = classifySegment(segments[i].proximal, segments[i].distal);+ if (cat === "face") face.push(i);+ else if (cat === "hand") hand.push(i);+ else body.push(i);+ }+ return {+ body: new Int32Array(body),+ hand: new Int32Array(hand),+ face: new Int32Array(face),+ };+ }, [segments]);++ // ---------- Body layer (includes charuco + aruco headroom) ----------+ const bodyGeoSegments = binned.body.length + MAX_SEGMENT_EXTRAS;- const geo = useMemo(() => {- const g = new BufferGeometry();- const n = maxSegments * 2; // 2 vertices per segment- g.setAttribute("position", new BufferAttribute(new Float32Array(n * 3).fill(1e5), 3));- g.setAttribute("color", new BufferAttribute(new Float32Array(n * 3).fill(0), 3));+ const bodyGeo = useMemo(() => {+ const g = new LineSegmentsGeometry();+ g.setPositions(new Float32Array(bodyGeoSegments * 2 * 3).fill(1e5));+ g.setColors(new Float32Array(bodyGeoSegments * 2 * 3).fill(0));return g;- }, [maxSegments]);+ }, [bodyGeoSegments]);- const mat = useMemo(() => new LineBasicMaterial({+ const bodyMat = useMemo(() => new LineMaterial({vertexColors: true,transparent: true,opacity: 0.85,- }), []);+ linewidth: BODY_CONNECTION_LINE_WIDTH,+ resolution: new Vector2(size.width, size.height),+ }), [size.width, size.height]);- useEffect(() => {- return subscribeToKeypointsRaw((allPts: Record<string, Point3d>) => {- const map = new Map<string, Point3d>();- for (const [name, pt] of Object.entries(allPts)) {- map.set(name, pt);+ const [bodyObj] = useState(() => new LineSegments2());++ useEffect(() => () => { bodyGeo.dispose(); bodyMat.dispose(); }, [bodyGeo, bodyMat]);++ // ---------- Hand layer ----------+ const handGeo = useMemo(() => {+ const g = new LineSegmentsGeometry();+ const n = binned.hand.length || 1; // never zero — LineSegmentsGeometry needs ≥1 segment+ g.setPositions(new Float32Array(n * 2 * 3).fill(1e5));+ g.setColors(new Float32Array(n * 2 * 3).fill(0));+ return g;+ }, [binned.hand.length]);++ const handMat = useMemo(() => new LineMaterial({+ vertexColors: true,+ transparent: true,+ opacity: 0.85,+ linewidth: HAND_CONNECTION_LINE_WIDTH,+ resolution: new Vector2(size.width, size.height),+ }), [size.width, size.height]);++ const [handObj] = useState(() => new LineSegments2());++ useEffect(() => () => { handGeo.dispose(); handMat.dispose(); }, [handGeo, handMat]);++ // ---------- Face layer ----------+ const faceGeo = useMemo(() => {+ const g = new LineSegmentsGeometry();+ const n = binned.face.length || 1;+ g.setPositions(new Float32Array(n * 2 * 3).fill(1e5));+ g.setColors(new Float32Array(n * 2 * 3).fill(0));+ return g;+ }, [binned.face.length]);++ const faceMat = useMemo(() => new LineMaterial({+ vertexColors: true,+ transparent: true,+ opacity: 0.85,+ linewidth: FACE_CONNECTION_LINE_WIDTH,+ resolution: new Vector2(size.width, size.height),+ }), [size.width, size.height]);++ const [faceObj] = useState(() => new LineSegments2());++ useEffect(() => () => { faceGeo.dispose(); faceMat.dispose(); }, [faceGeo, faceMat]);++ // Populate helpers shared by both subscriptions.+ const populateMap = (m: Map<string, Point3d>, frame: KeypointsFrame) => {+ const { pointNames, interleaved } = frame;+ for (let i = 0; i < pointNames.length; i++) {+ const off = i * 4;+ if (!interleaved[off + 3]) continue;+ const x = interleaved[off];+ const y = interleaved[off + 1];+ const z = interleaved[off + 2];+ if (Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z)) {+ m.set(pointNames[i], { x, y, z });}- pointsRef.current = map;+ }+ };++ const mergeRawIntoPoints = () => {+ const merged = pointsRef.current;+ for (const [name, pt] of rawPointsRef.current) {+ if (!merged.has(name)) merged.set(name, pt);+ }+ };++ // Raw keypoints: cached separately so hand/face endpoints can be looked up+ // even when the filtered trajectory (rigid_3d_xyz) doesn't carry them.+ useEffect(() => {+ return subscribeToKeypointsRaw((frame: KeypointsFrame) => {+ const raw = rawPointsRef.current;+ raw.clear();+ populateMap(raw, frame);+ mergeRawIntoPoints();dirtyRef.current = true;+ invalidate();});- }, [subscribeToKeypointsRaw]);-- useFrame(() => {- if (!dirtyRef.current) return;- const pts = pointsRef.current;- const positions = geo.attributes.position.array as Float32Array;- const vertexColors = geo.attributes.color.array as Float32Array;+ }, [subscribeToKeypointsRaw, invalidate]);- let visibleCount = 0;+ // Filtered keypoints: body landmarks from the rigid-body solver (smoothed).+ useEffect(() => {+ return subscribeToKeypointsFiltered((frame: KeypointsFrame) => {+ const m = pointsRef.current;+ m.clear();+ populateMap(m, frame);+ mergeRawIntoPoints();+ dirtyRef.current = true;+ invalidate();+ });+ }, [subscribeToKeypointsFiltered, invalidate]);- for (let i = 0; i < segments.length; i++) {+ /** Write one category of schema segments into a layer's geometry buffer. */+ function writeSegments(+ pos: Float32Array,+ col: Float32Array,+ indices: Int32Array,+ ): number {+ let visible = 0;+ for (let slot = 0; slot < indices.length; slot++) {+ const i = indices[slot];const seg = segments[i];- const a = resolvePoint(pts, seg.proximal, activeSchema);- const b = resolvePoint(pts, seg.distal, activeSchema);- const base = i * 6;- const c = colors[i];+ const a = resolvePoint(pointsRef.current, seg.proximal, activeSchema);+ const b = resolvePoint(pointsRef.current, seg.distal, activeSchema);+ const base = slot * 6;+ const c = allColors[i];const aOk = a && Number.isFinite(a.x) && Number.isFinite(a.y) && Number.isFinite(a.z);const bOk = b && Number.isFinite(b.x) && Number.isFinite(b.y) && Number.isFinite(b.z);if (aOk && bOk) {- positions[base] = a.x; positions[base + 1] = a.y; positions[base + 2] = a.z;- positions[base + 3] = b.x; positions[base + 4] = b.y; positions[base + 5] = b.z;- vertexColors[base] = c.r; vertexColors[base + 1] = c.g; vertexColors[base + 2] = c.b;- vertexColors[base + 3] = c.r; vertexColors[base + 4] = c.g; vertexColors[base + 5] = c.b;- visibleCount++;+ pos[base] = a.x; pos[base + 1] = a.y; pos[base + 2] = a.z;+ pos[base + 3] = b.x; pos[base + 4] = b.y; pos[base + 5] = b.z;+ col[base] = c.r; col[base + 1] = c.g; col[base + 2] = c.b;+ col[base + 3] = c.r; col[base + 4] = c.g; col[base + 5] = c.b;+ visible++;} else {- for (let j = 0; j < 6; j++) positions[base + j] = 1e5;- for (let j = 0; j < 6; j++) vertexColors[base + j] = 0;+ for (let j = 0; j < 6; j++) pos[base + j] = 1e5;+ for (let j = 0; j < 6; j++) col[base + j] = 0;}}+ return visible;+ }- // Charuco grid connections — appended after the schema-driven segments.+ useFrame(() => {+ if (!dirtyRef.current) return;+ const t0 = performance.now();+ let visibleCount = 0;++ // ---- body layer (schema body segments + charuco + aruco) ----+ const bodyPosAttr = bodyGeo.attributes.instanceStart as InterleavedBufferAttribute;+ const bodyColAttr = bodyGeo.attributes.instanceColorStart as InterleavedBufferAttribute;+ const bodyPos = bodyPosAttr.data.array as Float32Array;+ const bodyCol = bodyColAttr.data.array as Float32Array;++ visibleCount += writeSegments(bodyPos, bodyCol, binned.body);++ // Charuco grid connections — appended after body schema segments.const cols = calibrationConfig.charucoBoard.squares_x - 1;const rows = calibrationConfig.charucoBoard.squares_y - 1;- let segIdx = segments.length;+ const pts = pointsRef.current;+ let segIdx = binned.body.length;const cr = SKELETON_COLORS.charuco.r;const cg = SKELETON_COLORS.charuco.g;const cb = SKELETON_COLORS.charuco.b;+ const maxBodySlots = binned.body.length + MAX_SEGMENT_EXTRAS;for (let r = 0; r < rows; r++) {for (let c = 0; c < cols; c++) {const id = r * cols + c;const pt = pts.get(`CharucoCorner-${id}`);- if (c < cols - 1 && segIdx < maxSegments) {+ if (c < cols - 1 && segIdx < maxBodySlots) {const right = pts.get(`CharucoCorner-${id + 1}`);const base = segIdx * 6;if (pt && right) {- positions[base] = pt.x; positions[base + 1] = pt.y; positions[base + 2] = pt.z;- positions[base + 3] = right.x; positions[base + 4] = right.y; positions[base + 5] = right.z;- vertexColors[base] = cr; vertexColors[base + 1] = cg; vertexColors[base + 2] = cb;- vertexColors[base + 3] = cr; vertexColors[base + 4] = cg; vertexColors[base + 5] = cb;+ bodyPos[base] = pt.x; bodyPos[base + 1] = pt.y; bodyPos[base + 2] = pt.z;+ bodyPos[base + 3] = right.x; bodyPos[base + 4] = right.y; bodyPos[base + 5] = right.z;+ bodyCol[base] = cr; bodyCol[base + 1] = cg; bodyCol[base + 2] = cb;+ bodyCol[base + 3] = cr; bodyCol[base + 4] = cg; bodyCol[base + 5] = cb;visibleCount++;} else {- for (let j = 0; j < 6; j++) positions[base + j] = 1e5;- for (let j = 0; j < 6; j++) vertexColors[base + j] = 0;+ for (let j = 0; j < 6; j++) bodyPos[base + j] = 1e5;+ for (let j = 0; j < 6; j++) bodyCol[base + j] = 0;}segIdx++;}- if (r < rows - 1 && segIdx < maxSegments) {+ if (r < rows - 1 && segIdx < maxBodySlots) {const below = pts.get(`CharucoCorner-${id + cols}`);const base = segIdx * 6;if (pt && below) {- positions[base] = pt.x; positions[base + 1] = pt.y; positions[base + 2] = pt.z;- positions[base + 3] = below.x; positions[base + 4] = below.y; positions[base + 5] = below.z;- vertexColors[base] = cr; vertexColors[base + 1] = cg; vertexColors[base + 2] = cb;- vertexColors[base + 3] = cr; vertexColors[base + 4] = cg; vertexColors[base + 5] = cb;+ bodyPos[base] = pt.x; bodyPos[base + 1] = pt.y; bodyPos[base + 2] = pt.z;+ bodyPos[base + 3] = below.x; bodyPos[base + 4] = below.y; bodyPos[base + 5] = below.z;+ bodyCol[base] = cr; bodyCol[base + 1] = cg; bodyCol[base + 2] = cb;+ bodyCol[base + 3] = cr; bodyCol[base + 4] = cg; bodyCol[base + 5] = cb;visibleCount++;} else {- for (let j = 0; j < 6; j++) positions[base + j] = 1e5;- for (let j = 0; j < 6; j++) vertexColors[base + j] = 0;+ for (let j = 0; j < 6; j++) bodyPos[base + j] = 1e5;+ for (let j = 0; j < 6; j++) bodyCol[base + j] = 0;}segIdx++;}}}- // Zero out any unused tail slots so stale data doesn't render.- for (let i = segIdx; i < maxSegments; i++) {+ // Aruco marker outline squares — 4 orange edges per detected marker.+ const ar = SKELETON_COLORS.aruco.r;+ const ag = SKELETON_COLORS.aruco.g;+ const ab = SKELETON_COLORS.aruco.b;++ const ARUCO_PREFIX = "ArucoMarkerCorner-";+ const arucoMarkers = arucoMarkersRef.current;+ const prevNames = prevArucoNamesRef.current;++ let arucoChanged = false;+ let newArucoCount = 0;+ for (const name of pts.keys()) {+ if (!name.startsWith(ARUCO_PREFIX)) continue;+ newArucoCount++;+ if (!prevNames.has(name)) { arucoChanged = true; }+ }+ if (newArucoCount !== prevNames.size) arucoChanged = true;++ if (arucoChanged) {+ arucoMarkers.clear();+ prevNames.clear();+ arucoNameCacheRef.current.clear();+ for (const [name, pt] of pts.entries()) {+ if (!name.startsWith(ARUCO_PREFIX)) continue;+ prevNames.add(name);+ const rest = name.slice(ARUCO_PREFIX.length);+ const sep = rest.indexOf("-");+ if (sep === -1) continue;+ const markerId = parseInt(rest.slice(0, sep));+ const cornerIdx = parseInt(rest.slice(sep + 1));+ arucoNameCacheRef.current.set(name, {markerId, cornerIdx});+ if (!arucoMarkers.has(markerId)) {+ arucoMarkers.set(markerId, [undefined, undefined, undefined, undefined]);+ }+ arucoMarkers.get(markerId)![cornerIdx] = pt;+ }+ } else {+ const nameCache = arucoNameCacheRef.current;+ for (const [name, pt] of pts.entries()) {+ if (!name.startsWith(ARUCO_PREFIX)) continue;+ const cached = nameCache.get(name);+ if (!cached) continue;+ const corners = arucoMarkers.get(cached.markerId);+ if (corners) corners[cached.cornerIdx] = pt;+ }+ }++ for (const corners of arucoMarkers.values()) {+ for (const [i, j] of ARUCO_EDGES) {+ if (segIdx >= maxBodySlots) break;+ const a = corners[i];+ const b = corners[j];+ const base = segIdx * 6;+ const aOk = a && Number.isFinite(a.x) && Number.isFinite(a.y) && Number.isFinite(a.z);+ const bOk = b && Number.isFinite(b.x) && Number.isFinite(b.y) && Number.isFinite(b.z);+ if (aOk && bOk) {+ bodyPos[base] = a.x; bodyPos[base + 1] = a.y; bodyPos[base + 2] = a.z;+ bodyPos[base + 3] = b.x; bodyPos[base + 4] = b.y; bodyPos[base + 5] = b.z;+ bodyCol[base] = ar; bodyCol[base + 1] = ag; bodyCol[base + 2] = ab;+ bodyCol[base + 3] = ar; bodyCol[base + 4] = ag; bodyCol[base + 5] = ab;+ visibleCount++;+ } else {+ for (let k = 0; k < 6; k++) bodyPos[base + k] = 1e5;+ for (let k = 0; k < 6; k++) bodyCol[base + k] = 0;+ }+ segIdx++;+ }+ }++ // Zero out unused tail slots in body buffer.+ for (let i = segIdx; i < maxBodySlots; i++) {const base = i * 6;- for (let j = 0; j < 6; j++) positions[base + j] = 1e5;- for (let j = 0; j < 6; j++) vertexColors[base + j] = 0;+ for (let j = 0; j < 6; j++) bodyPos[base + j] = 1e5;+ for (let j = 0; j < 6; j++) bodyCol[base + j] = 0;+ }++ bodyPosAttr.needsUpdate = true;+ bodyColAttr.needsUpdate = true;++ // ---- hand layer ----+ if (binned.hand.length > 0) {+ const hPosAttr = handGeo.attributes.instanceStart as InterleavedBufferAttribute;+ const hColAttr = handGeo.attributes.instanceColorStart as InterleavedBufferAttribute;+ const hPos = hPosAttr.data.array as Float32Array;+ const hCol = hColAttr.data.array as Float32Array;+ visibleCount += writeSegments(hPos, hCol, binned.hand);+ for (let i = binned.hand.length, n = hPos.length / 6; i < n; i++) {+ const base = i * 6;+ for (let j = 0; j < 6; j++) hPos[base + j] = 1e5;+ for (let j = 0; j < 6; j++) hCol[base + j] = 0;+ }+ hPosAttr.needsUpdate = true;+ hColAttr.needsUpdate = true;+ }++ // ---- face layer ----+ if (binned.face.length > 0) {+ const fPosAttr = faceGeo.attributes.instanceStart as InterleavedBufferAttribute;+ const fColAttr = faceGeo.attributes.instanceColorStart as InterleavedBufferAttribute;+ const fPos = fPosAttr.data.array as Float32Array;+ const fCol = fColAttr.data.array as Float32Array;+ visibleCount += writeSegments(fPos, fCol, binned.face);+ for (let i = binned.face.length, n = fPos.length / 6; i < n; i++) {+ const base = i * 6;+ for (let j = 0; j < 6; j++) fPos[base + j] = 1e5;+ for (let j = 0; j < 6; j++) fCol[base + j] = 0;+ }+ fPosAttr.needsUpdate = true;+ fColAttr.needsUpdate = true;}- geo.attributes.position.needsUpdate = true;- geo.attributes.color.needsUpdate = true;dirtyRef.current = false;statsRef.current.connections = visibleCount;+ const elapsed = performance.now() - t0;+ if (elapsed > 8) console.warn(`ConnectionRenderer useFrame: ${elapsed.toFixed(1)}ms`);});return (- <lineSegments ref={linesRef} geometry={geo} material={mat} frustumCulled={false} />+ <>+ <primitive object={bodyObj} frustumCulled={false}>+ <primitive object={bodyGeo} attach="geometry" />+ <primitive object={bodyMat} attach="material" />+ </primitive>+ {binned.hand.length > 0 && (+ <primitive object={handObj} frustumCulled={false}>+ <primitive object={handGeo} attach="geometry" />+ <primitive object={handMat} attach="material" />+ </primitive>+ )}+ {binned.face.length > 0 && (+ <primitive object={faceObj} frustumCulled={false}>+ <primitive object={faceGeo} attach="geometry" />+ <primitive object={faceMat} attach="material" />+ </primitive>+ )}+ </>);}diff --git a/freemocap-ui/src/components/viewport3d/renderers/FaceRenderer.tsx b/freemocap-ui/src/components/viewport3d/renderers/FaceRenderer.tsxindex a4fc9d43..f91711cc 100644--- a/freemocap-ui/src/components/viewport3d/renderers/FaceRenderer.tsx+++ b/freemocap-ui/src/components/viewport3d/renderers/FaceRenderer.tsx@@ -4,33 +4,31 @@ import {BufferGeometry,LineBasicMaterial,LineSegments,- InstancedMesh,- MeshBasicMaterial,- Object3D,- SphereGeometry,- Vector3,+ Points,+ PointsMaterial,} from "three";-import { useFrame } from "@react-three/fiber";-import { Point3d } from "../helpers/viewport3d-types";+import { useFrame, useThree } from "@react-three/fiber";+import type { Point3d } from "../helpers/viewport3d-types";+import type { KeypointsFrame } from "../KeypointsSourceContext";import { useViewportState } from "../scene/ViewportStateContext";import { COLORS } from "../helpers/colors";import {FACE_CONTOUR_GROUPS} from "@/components/viewport3d/helpers/face-contours";import { useKeypointsSource } from "../KeypointsSourceContext";const MAX_FACE_POINTS = 512;-const DOT_RADIUS = 0.015;-const DUMMY = new Object3D();-const FAR_AWAY = new Vector3(1e5, 1e5, 1e5);+const DOT_SIZE = 2; // PointsMaterial sizeAttenuation=false → pixels/**- * Renders face mesh as small dots + contour line segments.- * Subscribes to raw keypoints and filters for face.* names.+ * Renders face mesh as small dots (THREE.Points) + contour line segments.+ * THREE.Points avoids per-instance matrix work of InstancedMesh — just writes+ * x/y/z directly into a Float32Array, which is a 10-20x speedup for 468 points.*/export function FaceRenderer() {const { subscribeToKeypointsRaw } = useKeypointsSource();const { statsRef } = useViewportState();+ const { invalidate } = useThree();- const dotsRef = useRef<InstancedMesh>(null);+ const dotsRef = useRef<Points>(null);const linesRef = useRef<LineSegments>(null);const pointsRef = useRef<Map<string, Point3d>>(new Map());@@ -38,8 +36,17 @@ export function FaceRenderer() {const nextIdx = useRef(0);const dirtyRef = useRef(false);- const dotGeo = useMemo(() => new SphereGeometry(1, 4, 3), []);- const dotMat = useMemo(() => new MeshBasicMaterial({ color: COLORS.face }), []);+ const dotGeo = useMemo(() => {+ const g = new BufferGeometry();+ g.setAttribute("position", new BufferAttribute(new Float32Array(MAX_FACE_POINTS * 3).fill(1e5), 3));+ return g;+ }, []);++ const dotMat = useMemo(() => new PointsMaterial({+ color: COLORS.face,+ size: DOT_SIZE,+ sizeAttenuation: false,+ }), []);const lineMat = useMemo(() => new LineBasicMaterial({color: COLORS.face,@@ -50,18 +57,32 @@ export function FaceRenderer() {const lineGeo = useMemo(() => {const g = new BufferGeometry();const n = FACE_CONTOUR_GROUPS.reduce((acc, g) => acc + g.connections.length, 0);- const pos = new Float32Array(n * 3).fill(1e5);+ const pos = new Float32Array(n * 6).fill(1e5);g.setAttribute("position", new BufferAttribute(pos, 3));return g;}, []);+ useEffect(() => () => {+ dotGeo.dispose();+ dotMat.dispose();+ lineMat.dispose();+ lineGeo.dispose();+ }, [dotGeo, dotMat, lineMat, lineGeo]);+useEffect(() => {- return subscribeToKeypointsRaw((allPts: Record<string, Point3d>) => {- const face = new Map<string, Point3d>();- for (const [name, pt] of Object.entries(allPts)) {- if (name.startsWith("face.")) face.set(name, pt);+ return subscribeToKeypointsRaw((frame: KeypointsFrame) => {+ const face = pointsRef.current;+ face.clear();+ const { pointNames, interleaved } = frame;+ for (let i = 0; i < pointNames.length; i++) {+ if (!pointNames[i].startsWith("face_")) continue;+ const off = i * 4;+ if (!interleaved[off + 3]) continue;+ const x = interleaved[off];+ const y = interleaved[off + 1];+ const z = interleaved[off + 2];+ face.set(pointNames[i], { x, y, z });}- pointsRef.current = face;dirtyRef.current = true;for (const name of face.keys()) {@@ -69,46 +90,36 @@ export function FaceRenderer() {nameToIdx.current.set(name, nextIdx.current++);}}- });- }, [subscribeToKeypointsRaw]);- useEffect(() => {- const mesh = dotsRef.current;- if (!mesh) return;- for (let i = 0; i < MAX_FACE_POINTS; i++) {- DUMMY.position.copy(FAR_AWAY);- DUMMY.scale.set(0, 0, 0);- DUMMY.updateMatrix();- mesh.setMatrixAt(i, DUMMY.matrix);- }- mesh.instanceMatrix.needsUpdate = true;- mesh.count = MAX_FACE_POINTS;- }, []);+ invalidate();+ });+ }, [subscribeToKeypointsRaw, invalidate]);useFrame(() => {- const dots = dotsRef.current;- if (!dots || !dirtyRef.current) return;+ if (!dirtyRef.current) return;+ const t0 = performance.now();const pts = pointsRef.current;+ const dotPositions = dotGeo.attributes.position.array as Float32Array;let count = 0;for (const [name, idx] of nameToIdx.current) {const pt = pts.get(name);+ const base = idx * 3;if (pt) {- DUMMY.position.set(pt.x, pt.y, pt.z);- DUMMY.scale.setScalar(DOT_RADIUS);+ dotPositions[base] = pt.x;+ dotPositions[base + 1] = pt.y;+ dotPositions[base + 2] = pt.z;count++;} else {- DUMMY.position.copy(FAR_AWAY);- DUMMY.scale.set(0, 0, 0);+ dotPositions[base] = dotPositions[base + 1] = dotPositions[base + 2] = 1e5;}- DUMMY.updateMatrix();- dots.setMatrixAt(idx, DUMMY.matrix);}- dots.instanceMatrix.needsUpdate = true;+ dotGeo.attributes.position.needsUpdate = true;+ dotGeo.setDrawRange(0, nextIdx.current);// Update line segments- const positions = lineGeo.attributes.position.array as Float32Array;+ const linePositions = lineGeo.attributes.position.array as Float32Array;let i = 0;for (const group of FACE_CONTOUR_GROUPS) {for (const [ai, bi] of group.connections) {@@ -116,10 +127,10 @@ export function FaceRenderer() {const b = pts.get(`${group.prefix}_${bi}`);const base = i * 6;if (a && b) {- positions[base] = a.x; positions[base+1] = a.y; positions[base+2] = a.z;- positions[base+3] = b.x; positions[base+4] = b.y; positions[base+5] = b.z;+ linePositions[base] = a.x; linePositions[base+1] = a.y; linePositions[base+2] = a.z;+ linePositions[base+3] = b.x; linePositions[base+4] = b.y; linePositions[base+5] = b.z;} else {- for (let j = 0; j < 6; j++) positions[base + j] = 1e5;+ for (let j = 0; j < 6; j++) linePositions[base + j] = 1e5;}i++;}@@ -128,11 +139,13 @@ export function FaceRenderer() {dirtyRef.current = false;statsRef.current.facePoints = count;+ const elapsed = performance.now() - t0;+ if (elapsed > 8) console.warn(`FaceRenderer useFrame: ${elapsed.toFixed(1)}ms`);});return (<>- <instancedMesh ref={dotsRef} args={[dotGeo, dotMat, MAX_FACE_POINTS]} frustumCulled={false} />+ <points ref={dotsRef} geometry={dotGeo} material={dotMat} frustumCulled={false} /><lineSegments ref={linesRef} geometry={lineGeo} material={lineMat} frustumCulled={false} /></>);diff --git a/freemocap-ui/src/components/viewport3d/renderers/KeypointsRenderer.tsx b/freemocap-ui/src/components/viewport3d/renderers/KeypointsRenderer.tsxindex dc7209cf..d66a394b 100644--- a/freemocap-ui/src/components/viewport3d/renderers/KeypointsRenderer.tsx+++ b/freemocap-ui/src/components/viewport3d/renderers/KeypointsRenderer.tsx@@ -2,26 +2,52 @@ import { useEffect, useMemo, useRef } from "react";import {Color,InstancedMesh,- MeshStandardMaterial,+ MeshBasicMaterial,Object3D,SphereGeometry,Vector3,} from "three";-import { useFrame } from "@react-three/fiber";-import { useServer } from "@/services";-import { Point3d } from "../helpers/viewport3d-types";+import { useFrame, useThree } from "@react-three/fiber";+import { useWorkerData } from "../WorkerDataContext";import { useViewportState } from "../scene/ViewportStateContext";import { COLORS } from "../helpers/colors";import { classifyPointName, getPointStyle } from "../helpers/skeleton-config";-import { useKeypointsSource, type KeypointsSource } from "../KeypointsSourceContext";+import { useKeypointsSource, type KeypointsSource, type KeypointsFrame } from "../KeypointsSourceContext";const MAX_POINTS = 1024;const DUMMY = new Object3D();const FAR_AWAY = new Vector3(1e5, 1e5, 1e5);-const RAW_RADIUS = 0.08;-const FILTERED_RADIUS = 0.12;+// ---------------------------------------------------------------------------+// Per‑category keypoint radii.+//+// The sphere geometry has radius 50, so the visual world‑space radius is+// roughly <constant> × 50. Tweak these to taste — the filtered (colored‑by‑+// body‑part) layer uses the per‑category values, while the raw layer uses+// RAW_KEYPOINT_RADIUS uniformly.+// ---------------------------------------------------------------------------+const RAW_KEYPOINT_RADIUS = 0.07;+const BODY_KEYPOINT_RADIUS = 0.12;+const HAND_KEYPOINT_RADIUS = 0.05;+const FACE_KEYPOINT_RADIUS = 0.02;+const UNSPECIFIED_KEYPOINT_RADIUS = 0.1;++function getKeypointRadius(name: string): number {+ switch (classifyPointName(name)) {+ case "face": return FACE_KEYPOINT_RADIUS;+ case "left_hand":+ case "right_hand": return HAND_KEYPOINT_RADIUS;+ case "left":+ case "right":+ case "center": return BODY_KEYPOINT_RADIUS;+ default: return UNSPECIFIED_KEYPOINT_RADIUS;+ }+}++// ---------------------------------------------------------------------------+// KeypointLayer — one instanced‑mesh pass (raw or filtered).+// ---------------------------------------------------------------------------interface KeypointLayerProps {subscribeKey: "subscribeToKeypointsRaw" | "subscribeToKeypointsFiltered";color: Color;@@ -31,44 +57,63 @@ interface KeypointLayerProps {}function KeypointLayer({ subscribeKey, color, radius, statsKey, colorMode = "uniform" }: KeypointLayerProps) {- const server = useServer();+ const workerData = useWorkerData();const keypointsSource: KeypointsSource = useKeypointsSource();const { statsRef } = useViewportState();+ const { invalidate } = useThree();const meshRef = useRef<InstancedMesh>(null);- const pointsRef = useRef<Record<string, Point3d>>({}); // plain object, matches wire format+ const frameRef = useRef<KeypointsFrame | null>(null);const dirtyRef = useRef(false);- const nameToIdx = useRef<Map<string, number>>(new Map());+ const nameToInstanceIdx = useRef<Map<string, number>>(new Map());+ const frameIdxByName = useRef<Map<string, number>>(new Map());+ const lastPointNamesRef = useRef<readonly string[] | null>(null);const nextIdx = useRef(0);- const geo = useMemo(() => new SphereGeometry(100, 8, 6), []);- const mat = useMemo(() => new MeshStandardMaterial({- color: "#00ff00",- // roughness: 0.4,- // metalness: 0.3,- }), []);+ // Low-poly sphere (6×4 = 24 tris vs 8×6 = 48). MeshBasicMaterial skips all+ // lighting calculations — significant savings at 1024 instanced meshes.+ const geo = useMemo(() => new SphereGeometry(50, 6, 4), []);+ const mat = useMemo(() => new MeshBasicMaterial({ color: "#ffffff" }), []);++ useEffect(() => () => { geo.dispose(); mat.dispose(); }, [geo, mat]);// Pull color hints from the active schema (if any) so per-name palette// overrides from the YAML propagate into the 3D view.- const colorHints = useMemo(() => {- const schema = server.getActiveSchema();+ const rawColorHints = useMemo(() => {+ const schema = workerData.getActiveSchema();return schema?.color_hints;- }, [server, server.activeTrackerId, server.trackerSchemas]);+ }, [workerData, workerData.activeTrackerId, workerData.trackerSchemas]);++ // Pre-build Color objects so getPointStyle doesn't allocate inside useFrame.+ const colorHints = useMemo((): Record<string, Color> | undefined => {+ if (!rawColorHints) return undefined;+ return Object.fromEntries(+ Object.entries(rawColorHints).map(([name, hex]) => [name, new Color(hex)])+ ) as Record<string, Color>;+ }, [rawColorHints]);useEffect(() => {const subscribeFn = keypointsSource[subscribeKey];- return subscribeFn((pts: Record<string, Point3d>) => {- pointsRef.current = pts;+ return subscribeFn((frame: KeypointsFrame) => {+ frameRef.current = frame;dirtyRef.current = true;- for (const name of Object.keys(pts)) {- // Face points are rendered by FaceRenderer, not here.- if (!nameToIdx.current.has(name)- && nextIdx.current < MAX_POINTS- && classifyPointName(name) !== 'face') {- nameToIdx.current.set(name, nextIdx.current++);+ invalidate();++ // Only rebuild index maps when the point-name list changes (e.g. on schema switch).+ if (frame.pointNames !== lastPointNamesRef.current) {+ lastPointNamesRef.current = frame.pointNames;+ frameIdxByName.current.clear();+ for (let i = 0; i < frame.pointNames.length; i++) {+ const name = frame.pointNames[i];+ frameIdxByName.current.set(name, i);+ if (!nameToInstanceIdx.current.has(name)+ && nextIdx.current < MAX_POINTS+ && classifyPointName(name) !== 'face') {+ nameToInstanceIdx.current.set(name, nextIdx.current++);+ }}}});- }, [keypointsSource, subscribeKey]);+ }, [keypointsSource, subscribeKey, invalidate]);useEffect(() => {const mesh = meshRef.current;@@ -88,34 +133,52 @@ function KeypointLayer({ subscribeKey, color, radius, statsKey, colorMode = "uniuseFrame(() => {const mesh = meshRef.current;if (!mesh || !dirtyRef.current) return;- const pts = pointsRef.current;+ const t0 = performance.now();+ const frame = frameRef.current;+ const interleaved = frame?.interleaved;let count = 0;- for (const [name, idx] of nameToIdx.current) {- const pt = pts[name];- const visible = pt && Number.isFinite(pt.x) && Number.isFinite(pt.y) && Number.isFinite(pt.z);+ for (const [name, instanceIdx] of nameToInstanceIdx.current) {+ const frameIdx = interleaved ? frameIdxByName.current.get(name) : undefined;+ let visible = false;+ let x = 0, y = 0, z = 0;++ if (frameIdx !== undefined && interleaved) {+ const off = frameIdx * 4;+ const vis = interleaved[off + 3];+ x = interleaved[off];+ y = interleaved[off + 1];+ z = interleaved[off + 2];+ visible = vis > 0 && Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z);+ }+if (visible) {- const style = colorMode === "byBodyPart" ? getPointStyle(name, colorHints) : null;- let scale = style ? style.scale : radius;- if (name.includes("hand")) scale *= 0.5; // smaller radius for hand keypoints- DUMMY.position.set(pt.x, pt.y, pt.z);+ const scale = colorMode === "byBodyPart"+ ? getKeypointRadius(name)+ : radius;+ const pointColor = colorMode === "byBodyPart"+ ? getPointStyle(name, colorHints).color+ : color;++ DUMMY.position.set(x, y, z);DUMMY.scale.setScalar(scale);- mesh.setColorAt(idx, style ? style.color : color);+ mesh.setColorAt(instanceIdx, pointColor);count++;} else {- // Not in this packet — hide itDUMMY.position.copy(FAR_AWAY);DUMMY.scale.set(0, 0, 0);- mesh.setColorAt(idx, COLORS.hidden);+ mesh.setColorAt(instanceIdx, COLORS.hidden);}DUMMY.updateMatrix();- mesh.setMatrixAt(idx, DUMMY.matrix);+ mesh.setMatrixAt(instanceIdx, DUMMY.matrix);}mesh.instanceMatrix.needsUpdate = true;if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;dirtyRef.current = false;statsRef.current[statsKey] = count;+ const elapsed = performance.now() - t0;+ if (elapsed > 8) console.warn(`KeypointLayer (${statsKey}) useFrame: ${elapsed.toFixed(1)}ms`);});return (@@ -132,7 +195,7 @@ export function KeypointsRenderer() {<KeypointLayersubscribeKey="subscribeToKeypointsRaw"color={COLORS.raw}- radius={RAW_RADIUS}+ radius={RAW_KEYPOINT_RADIUS}statsKey="keypointsRaw"/>)}@@ -140,7 +203,7 @@ export function KeypointsRenderer() {<KeypointLayersubscribeKey="subscribeToKeypointsFiltered"color={COLORS.filtered}- radius={FILTERED_RADIUS}+ radius={RAW_KEYPOINT_RADIUS}statsKey="keypointsFiltered"colorMode="byBodyPart"/>diff --git a/freemocap-ui/src/components/viewport3d/renderers/MocapCameraRenderer.tsx b/freemocap-ui/src/components/viewport3d/renderers/MocapCameraRenderer.tsxindex e39dac8f..8f6babd4 100644--- a/freemocap-ui/src/components/viewport3d/renderers/MocapCameraRenderer.tsx+++ b/freemocap-ui/src/components/viewport3d/renderers/MocapCameraRenderer.tsx@@ -7,17 +7,14 @@ import {Quaternion,Vector3,} from "three";-import { useAppSelector } from "@/store";-import {- CalibrationCameraData,- selectLoadedCalibration,-} from "@/store/slices/calibration/calibration-slice";+import type { CalibrationCameraData } from "@/store/slices/calibration/calibration-slice";+import { useWorkerData } from "../WorkerDataContext";import { useViewportState } from "../scene/ViewportStateContext";const FRUSTUM_DEPTH_MM = 75;const BODY_SIZE_MM = 20;-const FRUSTUM_COLOR = "#106995";-const BODY_COLOR = "#2080b0";+const FRUSTUM_COLOR = "#08855e";+const BODY_COLOR = "#08855e";interface CameraPose {position: Vector3;@@ -102,7 +99,7 @@ function MocapCameraInstance({ cam }: { cam: CalibrationCameraData }) {}export function MocapCameraRenderer() {- const loaded = useAppSelector(selectLoadedCalibration);+ const { loadedCalibration: loaded } = useWorkerData();const { statsRef } = useViewportState();useEffect(() => {diff --git a/freemocap-ui/src/components/viewport3d/renderers/RigidBodyRenderer.tsx b/freemocap-ui/src/components/viewport3d/renderers/RigidBodyRenderer.tsxindex b1c7a0e4..e508cc60 100644--- a/freemocap-ui/src/components/viewport3d/renderers/RigidBodyRenderer.tsx+++ b/freemocap-ui/src/components/viewport3d/renderers/RigidBodyRenderer.tsx@@ -66,6 +66,14 @@ export function RigidBodyRenderer() {const xMat = useMemo(() => new MeshStandardMaterial({ color: COLORS.rigidBodyX }), []);const yMat = useMemo(() => new MeshStandardMaterial({ color: COLORS.rigidBodyY }), []);+ useEffect(() => () => {+ shaftGeo.dispose();+ crossbarGeo.dispose();+ shaftMat.dispose();+ xMat.dispose();+ yMat.dispose();+ }, [shaftGeo, crossbarGeo, shaftMat, xMat, yMat]);+useEffect(() => {return subscribeToRigidBodies((newPoses: Map<string, RigidBodyPose>) => {posesRef.current = newPoses;diff --git a/freemocap-ui/src/components/viewport3d/scene/SceneCamera.tsx b/freemocap-ui/src/components/viewport3d/scene/SceneCamera.tsxindex 8dd5c49c..8d9fab60 100644--- a/freemocap-ui/src/components/viewport3d/scene/SceneCamera.tsx+++ b/freemocap-ui/src/components/viewport3d/scene/SceneCamera.tsx@@ -2,9 +2,8 @@ import { useCallback, useEffect } from "react";import { CameraControls } from "@react-three/drei";import type CameraControlsImpl from "camera-controls";import { Box3, Vector3 } from "three";-import { useServer } from "@/services";-import { Point3d } from "../helpers/viewport3d-types";import { RefObject } from "react";+import type { KeypointsFrame } from "../KeypointsSourceContext";const PADDING = 0.5;@@ -16,16 +15,25 @@ export function SceneCamera({ controlsRef }: SceneCameraProps) {return <CameraControls ref={controlsRef} makeDefault />;}-/** Fit camera to bounding box of all keypoints. */+/** Fit camera to bounding box of all visible keypoints. */export function fitCameraToPoints(controls: CameraControlsImpl | null,- points: Record<string, Point3d>,+ frame: KeypointsFrame | null,): void {- if (!controls || Object.keys(points).length === 0) return;+ if (!controls || !frame || frame.pointNames.length === 0) return;+ const { pointNames, interleaved } = frame;const box = new Box3();- for (const pt of Object.values(points)) {- box.expandByPoint(new Vector3(pt.x, pt.y, pt.z));+ for (let i = 0; i < pointNames.length; i++) {+ const off = i * 4;+ const vis = interleaved[off + 3];+ const x = interleaved[off];+ const y = interleaved[off + 1];+ const z = interleaved[off + 2];+ if (vis > 0 && Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z)) {+ box.expandByPoint(new Vector3(x, y, z));+ }}+ if (box.isEmpty()) return;box.expandByScalar(PADDING);controls.fitToBox(box, true);}diff --git a/freemocap-ui/src/components/viewport3d/scene/ViewportOverlay.tsx b/freemocap-ui/src/components/viewport3d/scene/ViewportOverlay.tsxindex 4caa8b8a..efc74959 100644--- a/freemocap-ui/src/components/viewport3d/scene/ViewportOverlay.tsx+++ b/freemocap-ui/src/components/viewport3d/scene/ViewportOverlay.tsx@@ -1,4 +1,4 @@-import { useCallback, useEffect, useState } from "react";+import { memo, useCallback, useEffect, useState } from "react";import {Box,Checkbox,@@ -26,9 +26,23 @@ export function ViewportOverlay({ onFitCamera, onResetCamera }: ViewportOverlayPconst [stats, setStats] = useState<ViewportStats>({ keypointsRaw: 0, keypointsFiltered: 0, rigidBodies: 0, facePoints: 0, connections: 0, cameras: 0 });const [expanded, setExpanded] = useState(false);- // Poll stats from the mutable ref at ~4 Hz (no re-render coupling to the frame loop)+ // Poll stats from the mutable ref at ~2 Hz. Use functional setState with shallow+ // equality so we only trigger a re-render when a count actually changed.useEffect(() => {- const id = setInterval(() => setStats({ ...statsRef.current }), 250);+ const id = setInterval(() => {+ setStats(prev => {+ const next = statsRef.current;+ if (+ prev.keypointsRaw === next.keypointsRaw &&+ prev.keypointsFiltered === next.keypointsFiltered &&+ prev.rigidBodies === next.rigidBodies &&+ prev.facePoints === next.facePoints &&+ prev.connections === next.connections &&+ prev.cameras === next.cameras+ ) return prev;+ return { ...next };+ });+ }, 500);return () => clearInterval(id);}, [statsRef]);@@ -96,7 +110,7 @@ export function ViewportOverlay({ onFitCamera, onResetCamera }: ViewportOverlayP);}-function VisToggle({ label, checked, onChange }: { label: string; checked: boolean; onChange: () => void }) {+const VisToggle = memo(function VisToggle({ label, checked, onChange }: { label: string; checked: boolean; onChange: () => void }) {return (<FormControlLabelsx={{ m: 0, ml: -0.5, "& .MuiTypography-root": { fontSize: "0.7rem" } }}@@ -104,7 +118,7 @@ function VisToggle({ label, checked, onChange }: { label: string; checked: boolelabel={label}/>);-}+});const btnSx = {bgcolor: "rgba(0,0,0,0.6)",diff --git a/freemocap-ui/src/components/viewport3d/viewport3d.worker.tsx b/freemocap-ui/src/components/viewport3d/viewport3d.worker.tsxnew file mode 100644index 00000000..494152c0--- /dev/null+++ b/freemocap-ui/src/components/viewport3d/viewport3d.worker.tsx@@ -0,0 +1,250 @@+/**+ * Web Worker entry point for the viewport3d OffscreenCanvas renderer.+ *+ * Uses R3F v9's `createRoot(OffscreenCanvas)` API directly — no+ * @react-three/offscreen wrapper. We own the message protocol, the root+ * lifecycle, and the synthetic DOM-event plumbing CameraControls needs.+ */++import "./worker-polyfill"; // must be first — stubs `window` before @react-refresh runs+import React, { useEffect, useRef } from "react";+import { createRoot, extend, type ReconcilerRoot } from "@react-three/fiber";+import * as THREE from "three";+import { Object3D } from "three";++// R3F v9's createRoot does NOT auto-register THREE intrinsics the way <Canvas> does.+// Without this, <ambientLight/>, <mesh/>, <group/>, etc. throw "not part of the+// THREE namespace" at reconcile time. Must run before any render.+extend(THREE as any);+import type CameraControlsImpl from "camera-controls";++import { workerDataStore } from "./WorkerDataStore";+import { WorkerDataProvider, WorkerVisibilitySync } from "./WorkerDataContext";+import { KeypointsSourceProvider } from "./KeypointsSourceContext";+import { ViewportStateProvider, useViewportState } from "./scene/ViewportStateContext";+import { ThreeJsScene } from "./ThreeJsScene";+import { fitCameraToPoints } from "./scene/SceneCamera";++console.log("[viewport3d worker] module loaded");++// Z-up world — must match the main thread setting in ThreeJsCanvas.+Object3D.DEFAULT_UP.set(0, 0, 1);++// ---------------------------------------------------------------------------+// Synthetic DOM stubs for CameraControls+//+// CameraControls (camera-controls package, used via @react-three/drei) calls a+// handful of DOM methods on the canvas element it attaches to. OffscreenCanvas+// is an EventTarget — addEventListener works — but it lacks+// getBoundingClientRect / setPointerCapture / style / ownerDocument. We+// monkey-patch them so the worker-side canvas behaves like a regular element.+// ---------------------------------------------------------------------------++let canvasSize = { width: 1, height: 1, top: 0, left: 0 };++function enhanceOffscreenCanvas(canvas: OffscreenCanvas) {+ const c = canvas as unknown as Record<string, unknown>;+ c.getBoundingClientRect = () => ({+ x: 0,+ y: 0,+ left: 0,+ top: 0,+ right: canvasSize.width,+ bottom: canvasSize.height,+ width: canvasSize.width,+ height: canvasSize.height,+ toJSON: () => ({}),+ });+ c.setPointerCapture = () => {};+ c.releasePointerCapture = () => {};+ c.hasPointerCapture = () => false;+ c.focus = () => {};+ c.blur = () => {};+ c.setAttribute = () => {};+ c.removeAttribute = () => {};+ c.getAttribute = () => null;+ c.hasAttribute = () => false;+ c.contains = () => false;+ c.parentElement = null;+ c.style = new Proxy(+ { touchAction: "none", cursor: "" },+ { set: () => true, get: (t, k) => (t as Record<string, string>)[k as string] ?? "" },+ );+ c.clientWidth = canvasSize.width;+ c.clientHeight = canvasSize.height;+ // CameraControls attaches pointermove/up to ownerDocument after pointerdown+ // so drags survive leaving the canvas. We capture pointer on the main thread,+ // so all those events come to this canvas regardless — just delegate+ // addEventListener/removeEventListener through to the canvas itself.+ c.ownerDocument = {+ defaultView: globalThis,+ addEventListener: (t: string, l: EventListener, opts?: AddEventListenerOptions) =>+ canvas.addEventListener(t, l, opts),+ removeEventListener: (t: string, l: EventListener, opts?: EventListenerOptions) =>+ canvas.removeEventListener(t, l, opts),+ dispatchEvent: (e: Event) => canvas.dispatchEvent(e),+ };+ Object.defineProperty(c, "clientWidth", { get: () => canvasSize.width });+ Object.defineProperty(c, "clientHeight", { get: () => canvasSize.height });+}++// Synthetic event class — workers may not expose PointerEvent in all engines,+// and even where they do, constructing one cross-realm from postMessage data is+// fiddly. A plain Event subclass with the fields copied on satisfies every+// access pattern CameraControls and r3f's event manager use.+class SyntheticDomEvent extends Event {+ constructor(type: string, init: Record<string, unknown>) {+ super(type, { bubbles: true, cancelable: true });+ Object.assign(this, init);+ }+}++// ---------------------------------------------------------------------------+// Root lifecycle+// ---------------------------------------------------------------------------++let root: ReconcilerRoot<OffscreenCanvas> | null = null;+let canvas: OffscreenCanvas | null = null;++async function initRoot(+ offscreen: OffscreenCanvas,+ width: number,+ height: number,+ pixelRatio: number,+) {+ // If a previous root is still alive (e.g. from a prior mount before a tab+ // switch), tear it down first so we don't leak WebGL contexts.+ if (root) {+ console.log("[viewport3d worker] tearing down previous root before re-init");+ root.unmount();+ root = null;+ }++ canvas = offscreen;+ canvasSize = { width, height, top: 0, left: 0 };+ enhanceOffscreenCanvas(offscreen);++ const newRoot = createRoot<OffscreenCanvas>(offscreen);+ root = newRoot;+ await newRoot.configure({+ size: { width, height, top: 0, left: 0 },+ dpr: pixelRatio,+ camera: { position: [1500, 1500, 1500], fov: 75, near: 0.1, far: 100000 },+ gl: { antialias: false, logarithmicDepthBuffer: false },+ frameloop: "demand",+ // No event manager — pointer events are dispatched directly to the+ // canvas EventTarget, where CameraControls listens via addEventListener.+ events: undefined,+ });++ // If teardown was called while we were awaiting configure, abort.+ if (root !== newRoot) return;++ newRoot.render(<WorkerScene />);+ console.log("[viewport3d worker] root created and rendering");+}++async function resizeRoot(width: number, height: number, top: number, left: number) {+ if (!root) return;+ canvasSize = { width, height, top, left };+ await root.configure({ size: { width, height, top, left } });+}++// ---------------------------------------------------------------------------+// Message router (single handler — no dual-listener kludge)+// ---------------------------------------------------------------------------++self.addEventListener("message", (event: MessageEvent) => {+ const msg = event.data as { type?: string; data?: unknown; payload?: unknown };+ const type = msg?.type;+ if (!type) return;++ switch (type) {+ case "init": {+ const p = msg.payload as {+ canvas: OffscreenCanvas;+ width: number;+ height: number;+ pixelRatio: number;+ };+ initRoot(p.canvas, p.width, p.height, p.pixelRatio);+ break;+ }+ case "resize": {+ const p = msg.payload as { width: number; height: number; top: number; left: number };+ resizeRoot(p.width, p.height, p.top, p.left);+ break;+ }+ case "teardown": {+ if (root) {+ console.log("[viewport3d worker] tearing down root");+ root.unmount();+ root = null;+ }+ canvas = null;+ break;+ }+ case "domEvent": {+ const p = msg.payload as { eventType: string; init: Record<string, unknown> };+ if (canvas) {+ canvas.dispatchEvent(new SyntheticDomEvent(p.eventType, p.init));+ }+ break;+ }+ default:+ // App data → store+ workerDataStore.dispatch(type, msg.data);+ }+});++// ---------------------------------------------------------------------------+// Stats forwarder+// ---------------------------------------------------------------------------++function WorkerStatsForwarder() {+ const { statsRef } = useViewportState();+ useEffect(() => {+ const id = setInterval(() => {+ (self as unknown as Worker).postMessage({+ type: "stats",+ data: { ...statsRef.current },+ });+ }, 500);+ return () => clearInterval(id);+ }, [statsRef]);+ return null;+}++// ---------------------------------------------------------------------------+// Root scene component+// ---------------------------------------------------------------------------++function WorkerScene() {+ const controlsRef = useRef<CameraControlsImpl>(null!);++ useEffect(() => {+ console.log("[viewport3d worker] WorkerScene mounted");+ const unsub1 = workerDataStore.subscribeToFitCamera((pts) => {+ fitCameraToPoints(controlsRef.current, pts);+ });+ const unsub2 = workerDataStore.subscribeToResetCamera(() => {+ controlsRef.current?.reset(true);+ });+ return () => {+ unsub1();+ unsub2();+ };+ }, []);++ return (+ <KeypointsSourceProvider source={workerDataStore}>+ <ViewportStateProvider>+ <WorkerVisibilitySync />+ <WorkerStatsForwarder />+ <WorkerDataProvider>+ <ThreeJsScene cameraControlsRef={controlsRef} />+ </WorkerDataProvider>+ </ViewportStateProvider>+ </KeypointsSourceProvider>+ );+}diff --git a/freemocap-ui/src/components/viewport3d/worker-polyfill.ts b/freemocap-ui/src/components/viewport3d/worker-polyfill.tsnew file mode 100644index 00000000..ed65a2d9--- /dev/null+++ b/freemocap-ui/src/components/viewport3d/worker-polyfill.ts@@ -0,0 +1,7 @@+// Vite's Fast Refresh transform injects `window`, `$RefreshReg$`, and `$RefreshSig$`+// into every React file. None of these exist in Web Worker scope. Stub them out so+// the preamble doesn't throw. Must be imported before any React modules in the worker.+(globalThis as any).window ??= globalThis;+(globalThis as any).$RefreshReg$ ??= () => {};+// $RefreshSig$ must return a passthrough function (wraps component for HMR tracking)+(globalThis as any).$RefreshSig$ ??= () => (type: unknown) => type;diff --git a/freemocap-ui/src/constants/external-urls.ts b/freemocap-ui/src/constants/external-urls.tsindex 4e11f7b2..3d743115 100644--- a/freemocap-ui/src/constants/external-urls.ts+++ b/freemocap-ui/src/constants/external-urls.ts@@ -5,6 +5,7 @@ export const EXTERNAL_URLS = {GITHUB_RELEASES: 'https://github.com/freemocap/freemocap/releases',GITHUB_ISSUES: 'https://github.com/freemocap/freemocap/issues/new',GITHUB_ORG: 'https://github.com/freemocap/',+ DONATION_LINK: 'https://freemocap.org/about-us.html#donate',FREEMOCAP_ORG: 'https://freemocap.org',TRANSLATION_LOCALES: 'https://github.com/freemocap/freemocap/blob/development/freemocap-ui/src/i18n/locales',TRANSLATING_GUIDE: 'https://github.com/freemocap/freemocap/blob/development/TRANSLATING.md',diff --git a/freemocap-ui/src/constants/server-urls.ts b/freemocap-ui/src/constants/server-urls.tsindex a9743148..4ec27869 100644--- a/freemocap-ui/src/constants/server-urls.ts+++ b/freemocap-ui/src/constants/server-urls.ts@@ -51,6 +51,9 @@ class ServerUrls {updateConfigs: `${baseUrl}/skellycam/camera/update`,pauseUnpauseCameras: `${baseUrl}/skellycam/camera/group/all/pause_unpause`,detectMicrophones: `${baseUrl}/skellycam/camera/microphone/detect`,+ // Recording endpoints+ startRecording: `${baseUrl}/skellycam/camera/group/all/record/start`,+ stopRecording: `${baseUrl}/skellycam/camera/group/all/record/stop`,// Playback endpointsplaybackRecordings: `${baseUrl}/freemocap/playback/recordings`,@@ -64,10 +67,9 @@ class ServerUrls {`${baseUrl}/freemocap/playback/${encodeURIComponent(recordingId)}/videos/${encodeURIComponent(videoId)}/timestamps`,playbackRecordingStatus: (recordingId: string) =>`${baseUrl}/freemocap/playback/${encodeURIComponent(recordingId)}/status`,+ playbackBundle: (recordingId: string) =>+ `${baseUrl}/freemocap/playback/${encodeURIComponent(recordingId)}/bundle`,- // Recording endpoints- startRecording: `${baseUrl}/freemocap/camera/group/all/record/start`,- stopRecording: `${baseUrl}/freemocap/camera/group/all/record/stop`,// Realtime pipeline endpointsrealtimeConnectOrUpdate: `${baseUrl}/freemocap/realtime/apply`,@@ -83,6 +85,10 @@ class ServerUrls {mocapStopRecording: `${baseUrl}/freemocap/mocap/recording/stop`,processMocapRecording: `${baseUrl}/freemocap/mocap/recording/process`,+ // Posthoc pipeline control+ stopPipeline: (pipelineId: string) => `${baseUrl}/freemocap/posthoc/pipeline/${encodeURIComponent(pipelineId)}`,+ stopAllPipelines: `${baseUrl}/freemocap/posthoc/pipeline`,+// Blender endpointsblenderDetect: `${baseUrl}/freemocap/blender/detect`,blenderExport: `${baseUrl}/freemocap/blender/export`,diff --git a/freemocap-ui/src/hooks/useCalibration.ts b/freemocap-ui/src/hooks/useCalibration.tsindex 8c9e6637..4c87cc07 100644--- a/freemocap-ui/src/hooks/useCalibration.ts+++ b/freemocap-ui/src/hooks/useCalibration.ts@@ -1,17 +1,15 @@// hooks/useCalibration.tsimport {useCallback} from 'react';import {useAppDispatch, useAppSelector} from '@/store/hooks';-+import {store} from '@/store';import {useElectronIPC} from '@/services';import {calibrateRecording,CalibrationConfig,calibrationConfigUpdated,+ CalibrationDirectoryInfo,calibrationDirectoryInfoUpdated,calibrationErrorCleared,- lastCalibrationRecordingPathCleared,- manualCalibrationRecordingPathChanged,- manualCalibrationRecordingPathCleared,selectCalibration,selectCalibrationDirectoryInfo,selectCalibrationRecordingPath,@@ -21,7 +19,26 @@ import {startCalibrationRecording,stopCalibrationRecording,} from "@/store/slices/calibration";++function calibrationDirectoryInfoEqual(a: CalibrationDirectoryInfo | null, b: CalibrationDirectoryInfo): boolean {+ if (!a) return false;+ return (+ a.exists === b.exists &&+ a.canRecord === b.canRecord &&+ a.canCalibrate === b.canCalibrate &&+ a.hasSynchronizedVideos === b.hasSynchronizedVideos &&+ a.hasVideos === b.hasVideos &&+ a.cameraCalibrationTomlPath === b.cameraCalibrationTomlPath &&+ a.lastSuccessfulCalibrationTomlPath === b.lastSuccessfulCalibrationTomlPath &&+ a.errorMessage === b.errorMessage+ );+}import {pathRecomputed} from "@/store/slices/recording";+import {+ activeRecordingCleared,+ activeRecordingSet,+ splitParentAndName,+} from "@/store/slices/active-recording/active-recording-slice";export function useCalibration() {const dispatch = useAppDispatch();@@ -50,7 +67,10 @@ export function useCalibration() {try {const info = await api.fileSystem.validateCalibrationDirectory.query({ directoryPath });- dispatch(calibrationDirectoryInfoUpdated(info));+ const current = store.getState().calibration.directoryInfo;+ if (!calibrationDirectoryInfoEqual(current, info)) {+ dispatch(calibrationDirectoryInfoUpdated(info));+ }} catch (error) {console.error('Failed to validate calibration directory:', error);// Don't throw - just log the error@@ -61,16 +81,21 @@ export function useCalibration() {const setManualRecordingPath = useCallback(async (path: string) => {- dispatch(manualCalibrationRecordingPathChanged(path));- // Validate the new path+ const parsed = splitParentAndName(path);+ if (parsed) {+ dispatch(activeRecordingSet({+ recordingName: parsed.recordingName,+ baseDirectory: parsed.baseDirectory,+ origin: 'browsed',+ }));+ }await validateDirectory(path);},[dispatch, validateDirectory]);const clearManualRecordingPath = useCallback(() => {- dispatch(manualCalibrationRecordingPathCleared());- dispatch(lastCalibrationRecordingPathCleared());+ dispatch(activeRecordingCleared());dispatch(pathRecomputed());}, [dispatch]);diff --git a/freemocap-ui/src/hooks/useGridLayout.ts b/freemocap-ui/src/hooks/useGridLayout.tsnew file mode 100644index 00000000..2152b427--- /dev/null+++ b/freemocap-ui/src/hooks/useGridLayout.ts@@ -0,0 +1,215 @@+import {useCallback, useEffect, useMemo, useRef, useState} from 'react';+import type {Layout, LayoutItem} from 'react-grid-layout';+import {+ type Tiling,+ computeOptimalTiling,+ tilingFromColumns,+ buildLayout,+} from '@/utils/gridTiling';++// ── Defaults ────────────────────────────────────────────────────────────────++const DEFAULT_GRID_COLS = 12;+const DEFAULT_MARGIN: [number, number] = [4, 4];+const DEFAULT_MIN_ROW_HEIGHT = 30;+const DEFAULT_WIDTH = 800;+const DEFAULT_HEIGHT = 600;++// ── Types ───────────────────────────────────────────────────────────────────++export interface UseGridLayoutOptions {+ /** Ordered list of unique IDs for the items to arrange in the grid. */+ itemIds: string[];+ /** Number of abstract grid columns. Default: 12 */+ gridCols?: number;+ /** Gap between items in pixels [horizontal, vertical]. Default: [4, 4] */+ margin?: [number, number];+ /** null = auto-optimize tiling, number = force N columns. Default: null */+ manualColumns?: number | null;+ /** Increment to force a full layout reset. Default: 0 */+ resetKey?: number;+ /** If true, observe the PARENT of containerRef (avoids ResizeObserver feedback+ * loops when the container has percentage dimensions). Default: true */+ measureParent?: boolean;+ /** Minimum row height in pixels. Default: 30 */+ minRowHeight?: number;+ /** Additional dependencies that trigger user-override reset. When any change,+ * drag/resize overrides are discarded. */+ extraResetDeps?: React.DependencyList;+}++export interface UseGridLayoutResult {+ /** Ref to attach to the container element whose dimensions define the grid area. */+ containerRef: React.RefObject<HTMLDivElement | null>;+ /** Current measured width of the container in pixels. */+ width: number;+ /** Computed tiling (cols, rows). */+ tiling: Tiling;+ /** Resolved layout items (user override or auto-computed). */+ layout: LayoutItem[];+ /** Event handlers to spread onto <ReactGridLayout>. */+ gridHandlers: {+ onLayoutChange: (layout: Layout) => void;+ onDragStart: () => void;+ onDragStop: (layout: Layout, oldItem: LayoutItem | null, newItem: LayoutItem | null) => void;+ onResizeStop: (layout: Layout) => void;+ };+ /** Pre-built gridConfig for <ReactGridLayout>. */+ gridConfig: {+ cols: number;+ rowHeight: number;+ margin: [number, number];+ containerPadding: [number, number];+ };+}++// ── Hook ────────────────────────────────────────────────────────────────────++export function useGridLayout(options: UseGridLayoutOptions): UseGridLayoutResult {+ const {+ itemIds,+ gridCols = DEFAULT_GRID_COLS,+ margin = DEFAULT_MARGIN,+ manualColumns = null,+ resetKey = 0,+ measureParent = true,+ minRowHeight = DEFAULT_MIN_ROW_HEIGHT,+ extraResetDeps = [],+ } = options;++ // ── Container measurement ───────────────────────────────────────────────++ const containerRef = useRef<HTMLDivElement>(null);+ const [width, setWidth] = useState(DEFAULT_WIDTH);+ const [height, setHeight] = useState(DEFAULT_HEIGHT);++ useEffect(() => {+ const el = containerRef.current;+ const target = measureParent ? el?.parentElement : el;+ if (!target) return;++ const measure = () => {+ const rect = target.getBoundingClientRect();+ setWidth(rect.width);+ setHeight(rect.height);+ };++ measure();+ const observer = new ResizeObserver(() => measure());+ observer.observe(target);+ return () => observer.disconnect();+ }, [measureParent]);++ // ── Tiling computation ──────────────────────────────────────────────────++ const prevTilingRef = useRef<Tiling>({cols: 1, rows: 1});+ const tiling = useMemo(() => {+ const candidate = manualColumns !== null+ ? tilingFromColumns(itemIds.length, manualColumns)+ : computeOptimalTiling(itemIds.length, width, height, margin);+ const prev = prevTilingRef.current;+ if (candidate.cols === prev.cols && candidate.rows === prev.rows) {+ return prev;+ }+ prevTilingRef.current = candidate;+ return candidate;+ }, [itemIds.length, width, height, manualColumns, margin]);++ // ── Layout state ────────────────────────────────────────────────────────++ // null = auto-compute; non-null = user has dragged or resized+ const [userLayout, setUserLayout] = useState<LayoutItem[] | null>(null);++ // Reset user overrides when the auto layout would change+ useEffect(() => {+ setUserLayout(null);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [itemIds, tiling, resetKey, ...extraResetDeps]);++ const layout = useMemo(() => {+ if (userLayout !== null) return userLayout;+ return buildLayout(itemIds, tiling, gridCols);+ }, [itemIds, tiling, gridCols, userLayout]);++ // ── Row height & grid config ────────────────────────────────────────────++ const rowHeight = useMemo(() => {+ const totalMargin = (tiling.rows - 1) * margin[1];+ return Math.max(minRowHeight, (height - totalMargin) / tiling.rows);+ }, [height, tiling.rows, margin, minRowHeight]);++ const gridConfig = useMemo(() => ({+ cols: gridCols,+ rowHeight,+ margin,+ containerPadding: [0, 0] as [number, number],+ }), [gridCols, rowHeight, margin]);++ // ── Drag / resize handlers ──────────────────────────────────────────────++ const layoutBeforeDragRef = useRef<LayoutItem[]>([]);++ const handleDragStart = useCallback(() => {+ layoutBeforeDragRef.current = layout;+ }, [layout]);++ const handleDragStop = useCallback((+ _newLayout: Layout,+ _oldItem: LayoutItem | null,+ newItem: LayoutItem | null,+ ) => {+ if (!newItem) return;+ const preDrag = layoutBeforeDragRef.current;+ const draggedBefore = preDrag.find((l) => l.i === newItem.i);+ if (!draggedBefore) return;++ const swapTarget = preDrag.find((l) => {+ if (l.i === newItem.i) return false;+ return newItem.x < l.x + l.w && newItem.x + newItem.w > l.x+ && newItem.y < l.y + l.h && newItem.y + newItem.h > l.y;+ });++ if (swapTarget) {+ setUserLayout(preDrag.map((l) => {+ if (l.i === newItem.i) return {...l, x: swapTarget.x, y: swapTarget.y};+ if (l.i === swapTarget.i) return {...l, x: draggedBefore.x, y: draggedBefore.y};+ return l;+ }));+ } else {+ const maxX = gridCols - newItem.w;+ const maxY = tiling.rows - newItem.h;+ setUserLayout(preDrag.map((l) => {+ if (l.i === newItem.i) {+ return {+ ...l,+ x: Math.max(0, Math.min(newItem.x, maxX)),+ y: Math.max(0, Math.min(newItem.y, maxY)),+ };+ }+ return l;+ }));+ }+ }, [tiling.rows, gridCols]);++ const handleResizeStop = useCallback((newLayout: Layout) => {+ setUserLayout([...newLayout]);+ }, []);++ const handleLayoutChange = useCallback((_layout: Layout) => {}, []);++ const gridHandlers = useMemo(() => ({+ onLayoutChange: handleLayoutChange,+ onDragStart: handleDragStart,+ onDragStop: handleDragStop,+ onResizeStop: handleResizeStop,+ }), [handleLayoutChange, handleDragStart, handleDragStop, handleResizeStop]);++ return {+ containerRef,+ width,+ tiling,+ layout,+ gridHandlers,+ gridConfig,+ };+}diff --git a/freemocap-ui/src/hooks/useMenuActions.ts b/freemocap-ui/src/hooks/useMenuActions.tsindex 904d3e7e..0b4a02d5 100644--- a/freemocap-ui/src/hooks/useMenuActions.ts+++ b/freemocap-ui/src/hooks/useMenuActions.ts@@ -7,8 +7,11 @@ import {themeModeToggled} from '@/store/slices/theme';import {camerasConnectOrUpdate, closeCameras, detectCameras, pauseUnpauseCameras} from '@/store/slices/cameras';import {stopRecording} from '@/store/slices/recording';import {selectVideoLoadFolder} from '@/store/slices/videos';+import {activeRecordingCleared, activeRecordingSet} from '@/store/slices/active-recording';+import {calibrationConfigUpdated} from '@/store/slices/calibration/calibration-slice';+import {pipelineSnackbarShown} from '@/store/slices/pipelines';// import { localeChanged, selectLocale, localeToggled } from '@/store/slices/settings';-import {isElectron} from '@/services/electron-ipc/electron-ipc';+import {isElectron, useElectronIPC} from '@/services/electron-ipc/electron-ipc';import {SUPPORTED_LOCALES} from '@/i18n';import type {MenuAction} from '../../electron/main/services/menu-builder';@@ -18,6 +21,9 @@ const MENU_LABEL_KEYS = ['menuView','menuCamera','menuRecording',+ 'menuData',+ 'menuLoadTestData',+ 'menuClearActiveRecording','menuHelp','menuDetectCameras','menuConnectCameras',@@ -35,6 +41,7 @@ const MENU_LABEL_KEYS = ['menuAbout','menuCheckForUpdates','menuPlayback',+ 'menuShowPipelineProgress','home','cameras','settings',@@ -57,6 +64,7 @@ export function useMenuActions({ onToggleSidebar }: UseMenuActionsParams): voidconst dispatch = useAppDispatch();const navigate = useNavigate();const { t, i18n } = useTranslation();+ const { api } = useElectronIPC();const isRecording = useAppSelector((state) => state.recording.isRecording);// const currentLocale = useAppSelector(selectLocale);@@ -80,7 +88,7 @@ export function useMenuActions({ onToggleSidebar }: UseMenuActionsParams): voiduseEffect(() => {if (!isElectron() || !window.electronAPI?.onMenuAction) return;- const cleanup = window.electronAPI.onMenuAction((action: string) => {+ const cleanup = window.electronAPI.onMenuAction(async (action: string) => {// Handle locale change actions (dynamic pattern: "change-locale:xx")if (action.startsWith('change-locale:')) {const localeCode = action.slice('change-locale:'.length);@@ -164,9 +172,36 @@ export function useMenuActions({ onToggleSidebar }: UseMenuActionsParams): voiddispatch(selectVideoLoadFolder());navigate('/playback');break;+ case 'show-pipeline-progress':+ dispatch(pipelineSnackbarShown());+ break;++ // Data actions+ case 'load-test-data': {+ if (!api) break;+ try {+ const home: string = await api.fileSystem.getHomeDirectory.query();+ const sep = home.includes('\\') ? '\\' : '/';+ const baseDirectory = `${home}${sep}freemocap_data${sep}recordings`;+ dispatch(activeRecordingSet({+ baseDirectory,+ recordingName: 'freemocap_test_data',+ origin: 'browsed',+ }));+ dispatch(calibrationConfigUpdated({+ charucoBoard: { squares_x: 7, squares_y: 5, square_length_mm: 58 },+ }));+ } catch (error) {+ console.error('Failed to resolve home directory for test data:', error);+ }+ break;+ }+ case 'clear-active-recording':+ dispatch(activeRecordingCleared());+ break;}});return cleanup;- }, [dispatch, navigate, isRecording, onToggleSidebar]);+ }, [dispatch, navigate, isRecording, onToggleSidebar, api]);}diff --git a/freemocap-ui/src/hooks/useMocap.ts b/freemocap-ui/src/hooks/useMocap.tsindex 007a93d3..9c6ea3fe 100644--- a/freemocap-ui/src/hooks/useMocap.ts+++ b/freemocap-ui/src/hooks/useMocap.ts@@ -1,13 +1,12 @@import {useCallback} from 'react';import {useAppDispatch, useAppSelector} from '@/store/hooks';+import {store} from '@/store';import {useElectronIPC} from '@/services';import {calibrationTomlPathChanged,calibrationTomlPathCleared,- lastMocapRecordingPathCleared,- manualMocapRecordingPathChanged,- manualMocapRecordingPathCleared,MediapipeDetectorConfig,+ MocapDirectoryInfo,mocapDetectorConfigReplaced,mocapDetectorConfigUpdated,mocapDirectoryInfoUpdated,@@ -28,7 +27,26 @@ import {startMocapRecording,stopMocapRecording,} from "@/store/slices/mocap";++function mocapDirectoryInfoEqual(a: MocapDirectoryInfo | null, b: MocapDirectoryInfo): boolean {+ if (!a) return false;+ return (+ a.exists === b.exists &&+ a.canRecord === b.canRecord &&+ a.canCalibrate === b.canCalibrate &&+ a.hasSynchronizedVideos === b.hasSynchronizedVideos &&+ a.hasVideos === b.hasVideos &&+ a.cameraMocapTomlPath === b.cameraMocapTomlPath &&+ a.lastSuccessfulCalibrationTomlPath === b.lastSuccessfulCalibrationTomlPath &&+ a.errorMessage === b.errorMessage+ );+}import {pathRecomputed} from "@/store/slices/recording";+import {+ activeRecordingCleared,+ activeRecordingSet,+ splitParentAndName,+} from "@/store/slices/active-recording/active-recording-slice";export function useMocap() {const dispatch = useAppDispatch();@@ -110,7 +128,10 @@ export function useMocap() {try {const info = await api.fileSystem.validateMocapDirectory.query({directoryPath});- dispatch(mocapDirectoryInfoUpdated(info));+ const current = store.getState().mocap.directoryInfo;+ if (!mocapDirectoryInfoEqual(current, info)) {+ dispatch(mocapDirectoryInfoUpdated(info));+ }} catch (error) {console.error('Failed to validate mocap directory:', error);}@@ -120,15 +141,21 @@ export function useMocap() {const setManualRecordingPath = useCallback(async (path: string) => {- dispatch(manualMocapRecordingPathChanged(path));+ const parsed = splitParentAndName(path);+ if (parsed) {+ dispatch(activeRecordingSet({+ recordingName: parsed.recordingName,+ baseDirectory: parsed.baseDirectory,+ origin: 'browsed',+ }));+ }await validateDirectory(path);},[dispatch, validateDirectory]);const clearManualRecordingPath = useCallback(() => {- dispatch(manualMocapRecordingPathCleared());- dispatch(lastMocapRecordingPathCleared());+ dispatch(activeRecordingCleared());dispatch(pathRecomputed());}, [dispatch]);diff --git a/freemocap-ui/src/hooks/useZoomTransform.ts b/freemocap-ui/src/hooks/useZoomTransform.tsnew file mode 100644index 00000000..58c414bb--- /dev/null+++ b/freemocap-ui/src/hooks/useZoomTransform.ts@@ -0,0 +1,217 @@+import {useCallback, useEffect, useMemo, useRef, useState} from 'react';++const MIN_ZOOM = 1.0;+const MAX_ZOOM = 100;+const ZOOM_SPEED = 0.0015;++function getTouchDistance(touches: React.TouchList): number {+ const dx = touches[0].clientX - touches[1].clientX;+ const dy = touches[0].clientY - touches[1].clientY;+ return Math.sqrt(dx * dx + dy * dy);+}++export interface ZoomTransformResult {+ /** CSS to apply to the content wrapper div (transform + transformOrigin + size) */+ zoomWrapperStyle: React.CSSProperties;+ /** Cursor to apply to the outer container */+ cursor: 'auto' | 'grab' | 'grabbing';+ /** Event handlers to spread onto the outer container div */+ containerHandlers: {+ onPointerDown: (e: React.PointerEvent<HTMLDivElement>) => void;+ onPointerMove: (e: React.PointerEvent<HTMLDivElement>) => void;+ onPointerUp: (e: React.PointerEvent<HTMLDivElement>) => void;+ onPointerLeave: (e: React.PointerEvent<HTMLDivElement>) => void;+ onTouchStart: (e: React.TouchEvent<HTMLDivElement>) => void;+ onTouchMove: (e: React.TouchEvent<HTMLDivElement>) => void;+ onTouchEnd: (e: React.TouchEvent<HTMLDivElement>) => void;+ onDoubleClick: () => void;+ };+}++/**+ * Encapsulates scroll-to-zoom (mouse wheel + trackpad pinch), drag-to-pan+ * when zoomed in, touch pinch-to-zoom, and double-click to reset.+ *+ * The caller must render an outer container div (overflow: hidden) with+ * a content-wrapper div (receiving `zoomWrapperStyle`). Event handlers+ * are spread onto the outer container. The native wheel listener is+ * attached to `containerRef.current` on mount.+ */+export function useZoomTransform(+ containerRef: React.RefObject<HTMLDivElement | null>,+): ZoomTransformResult {+ const [zoom, setZoom] = useState(1);+ const [pan, setPan] = useState<{ x: number; y: number }>({ x: 0, y: 0 });+ const [isDragging, setIsDragging] = useState(false);++ // Refs mirror state so callbacks always read the latest values without+ // depending on React state closures (avoids one-frame pan/zoom mismatch).+ const zoomRef = useRef(zoom);+ const panRef = useRef(pan);+ const isDraggingRef = useRef(isDragging);+ zoomRef.current = zoom;+ panRef.current = pan;+ isDraggingRef.current = isDragging;++ const dragStartRef = useRef<{ x: number; y: number }>({ x: 0, y: 0 });+ const lastPinchDistanceRef = useRef<number | null>(null);+ const touchStartRef = useRef<{ x: number; y: number } | null>(null);++ // ── Wheel: scroll-to-zoom centered at cursor ────────────────────────+ // Must be a native listener with {passive: false} so e.preventDefault()+ // is guaranteed to fire. React's onWheel is delegated to the root element+ // (React 17+) where Chrome silently ignores preventDefault on passive+ // listeners — the panel scrolls slightly, shifting getBoundingClientRect()+ // between events and drifting the zoom anchor away from the cursor.+ useEffect(() => {+ const container = containerRef.current;+ if (!container) return;++ const onWheel = (e: WheelEvent) => {+ e.preventDefault();++ const rect = container.getBoundingClientRect();+ const mouseX = e.clientX - rect.left;+ const mouseY = e.clientY - rect.top;++ const currentZoom = zoomRef.current;+ const currentPan = panRef.current;++ const newZoom = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, currentZoom * (1 - e.deltaY * ZOOM_SPEED)));+ if (newZoom === currentZoom) return;++ const ratio = newZoom / currentZoom;+ setZoom(newZoom);+ setPan(newZoom <= MIN_ZOOM+ ? { x: 0, y: 0 }+ : {+ x: mouseX - (mouseX - currentPan.x) * ratio,+ y: mouseY - (mouseY - currentPan.y) * ratio,+ });+ };++ container.addEventListener('wheel', onWheel, { passive: false });+ return () => container.removeEventListener('wheel', onWheel);+ }, []);++ // ── Pointer: drag-to-pan when zoomed in (mouse only) ────────────────+ const handlePointerDown = useCallback((e: React.PointerEvent) => {+ if (e.pointerType === 'touch') return;+ if (zoomRef.current <= 1) return;+ e.preventDefault();+ e.stopPropagation();+ (e.target as HTMLElement).setPointerCapture(e.pointerId);+ const currentPan = panRef.current;+ dragStartRef.current = { x: e.clientX - currentPan.x, y: e.clientY - currentPan.y };+ setIsDragging(true);+ }, []);++ const handlePointerMove = useCallback((e: React.PointerEvent) => {+ if (!isDraggingRef.current) return;+ e.preventDefault();+ setPan({ x: e.clientX - dragStartRef.current.x, y: e.clientY - dragStartRef.current.y });+ }, []);++ const handlePointerUp = useCallback((e: React.PointerEvent) => {+ if (!isDraggingRef.current) return;+ (e.target as HTMLElement).releasePointerCapture(e.pointerId);+ setIsDragging(false);+ }, []);++ // ── Touch: pinch-to-zoom (two fingers) + drag-to-pan (one finger) ──+ const handleTouchStart = useCallback((e: React.TouchEvent) => {+ if (e.touches.length === 2) {+ e.preventDefault();+ lastPinchDistanceRef.current = getTouchDistance(e.touches);+ touchStartRef.current = null;+ } else if (e.touches.length === 1 && zoomRef.current > 1) {+ const touch = e.touches[0];+ const currentPan = panRef.current;+ dragStartRef.current = { x: touch.clientX - currentPan.x, y: touch.clientY - currentPan.y };+ touchStartRef.current = { x: touch.clientX, y: touch.clientY };+ }+ }, []);++ const handleTouchMove = useCallback((e: React.TouchEvent) => {+ const lastDist = lastPinchDistanceRef.current;++ if (e.touches.length === 2 && lastDist !== null) {+ e.preventDefault();+ e.stopPropagation();++ const dist = getTouchDistance(e.touches);+ const container = containerRef.current;+ if (!container) return;++ const rect = container.getBoundingClientRect();+ const midX = (e.touches[0].clientX + e.touches[1].clientX) / 2 - rect.left;+ const midY = (e.touches[0].clientY + e.touches[1].clientY) / 2 - rect.top;++ const currentZoom = zoomRef.current;+ const currentPan = panRef.current;++ const newZoom = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, currentZoom * (dist / lastDist)));+ if (newZoom === currentZoom) return;++ const ratio = newZoom / currentZoom;+ setPan({+ x: midX - (midX - currentPan.x) * ratio,+ y: midY - (midY - currentPan.y) * ratio,+ });+ setZoom(newZoom);+ lastPinchDistanceRef.current = dist;+ } else if (e.touches.length === 1 && zoomRef.current > 1 && touchStartRef.current !== null) {+ e.preventDefault();+ const touch = e.touches[0];+ setPan({ x: touch.clientX - dragStartRef.current.x, y: touch.clientY - dragStartRef.current.y });+ }+ }, []);++ const handleTouchEnd = useCallback((e: React.TouchEvent) => {+ if (e.touches.length < 2) {+ lastPinchDistanceRef.current = null;+ }+ if (e.touches.length === 0) {+ touchStartRef.current = null;+ }+ }, []);++ // ── Double-click: reset zoom ────────────────────────────────────────+ const handleDoubleClick = useCallback(() => {+ setZoom(1);+ setPan({ x: 0, y: 0 });+ }, []);++ // ── Computed values ─────────────────────────────────────────────────+ const isZoomed = zoom > 1;+ const cursor: 'auto' | 'grab' | 'grabbing' =+ isDragging ? 'grabbing' : isZoomed ? 'grab' : 'auto';++ const zoomWrapperStyle = useMemo((): React.CSSProperties => {+ const style: React.CSSProperties = {+ width: '100%',+ height: '100%',+ };+ // Only apply transform when there's actual zoom or pan.+ // CSS transform (even scale(1)) creates a new containing block+ // that can break percentage-height resolution in flex layouts.+ if (zoom !== 1 || pan.x !== 0 || pan.y !== 0) {+ style.transform = `scale(${zoom}) translate(${pan.x / zoom}px, ${pan.y / zoom}px)`;+ style.transformOrigin = '0 0';+ }+ return style;+ }, [zoom, pan]);++ const containerHandlers = useMemo(() => ({+ onPointerDown: handlePointerDown,+ onPointerMove: handlePointerMove,+ onPointerUp: handlePointerUp,+ onPointerLeave: handlePointerUp,+ onTouchStart: handleTouchStart,+ onTouchMove: handleTouchMove,+ onTouchEnd: handleTouchEnd,+ onDoubleClick: handleDoubleClick,+ }), [handlePointerDown, handlePointerMove, handlePointerUp, handleTouchStart, handleTouchMove, handleTouchEnd, handleDoubleClick]);++ return { zoomWrapperStyle, cursor, containerHandlers };+}diff --git a/freemocap-ui/src/i18n/locales/en-english.json b/freemocap-ui/src/i18n/locales/en-english.jsonindex 3d02b55a..749b5bf7 100644--- a/freemocap-ui/src/i18n/locales/en-english.json+++ b/freemocap-ui/src/i18n/locales/en-english.json@@ -228,6 +228,9 @@"menuView": "View","menuCamera": "Camera","menuRecording": "Recording",+ "menuData": "Data",+ "menuLoadTestData": "Load Test Data",+ "menuClearActiveRecording": "Clear Active Recording","menuHelp": "Help","menuDetectCameras": "Detect Cameras","menuConnectCameras": "Connect Cameras",diff --git a/freemocap-ui/src/layout/BasePanelLayout.tsx b/freemocap-ui/src/layout/BasePanelLayout.tsxindex 6019d2f0..d533f63e 100644--- a/freemocap-ui/src/layout/BasePanelLayout.tsx+++ b/freemocap-ui/src/layout/BasePanelLayout.tsx@@ -14,7 +14,9 @@ import {MainNavTabs} from "@/components/ui-components/MainNavTabs";export const BasePanelLayout = ({children}: { children?: React.ReactNode }) => {const theme = useTheme();const leftPanelRef = useRef<ImperativePanelHandle>(null);+ const bottomPanelRef = useRef<ImperativePanelHandle>(null);const [isCollapsed, setIsCollapsed] = useState(false);+ const [isBottomCollapsed, setIsBottomCollapsed] = useState(false);const handleToggleCollapse = useCallback(() => {const panel = leftPanelRef.current;@@ -35,6 +37,9 @@ export const BasePanelLayout = ({children}: { children?: React.ReactNode }) => {setIsCollapsed(false);}, []);+ const handleBottomPanelCollapse = useCallback(() => setIsBottomCollapsed(true), []);+ const handleBottomPanelExpand = useCallback(() => setIsBottomCollapsed(false), []);+// Connect native menu actions to the appuseMenuActions({ onToggleSidebar: handleToggleCollapse });@@ -91,8 +96,16 @@ export const BasePanelLayout = ({children}: { children?: React.ReactNode }) => {}}/>- <Panel collapsible defaultSize={13} minSize={10} collapsedSize={4}>- <BottomPanelContent/>+ <Panel+ ref={bottomPanelRef}+ collapsible+ defaultSize={13}+ minSize={10}+ collapsedSize={4}+ onCollapse={handleBottomPanelCollapse}+ onExpand={handleBottomPanelExpand}+ >+ <BottomPanelContent isCollapsed={isBottomCollapsed}/></Panel></PanelGroup></Box>diff --git a/freemocap-ui/src/layout/content/BaseContentRouter.tsx b/freemocap-ui/src/layout/content/BaseContentRouter.tsxindex c366c7a9..1fe42656 100644--- a/freemocap-ui/src/layout/content/BaseContentRouter.tsx+++ b/freemocap-ui/src/layout/content/BaseContentRouter.tsx@@ -4,6 +4,7 @@ import WelcomePage from "@/pages/WelcomePage";import {StreamingViewPage} from "@/pages/StreamingViewPage";import PlaybackPage from "@/pages/PlaybackPage";import BrowserPage from "@/pages/BrowserPage";+import ActiveRecordingPage from "@/pages/ActiveRecordingPage";export const BaseContentRouter: React.FC = () => {return (@@ -13,6 +14,7 @@ export const BaseContentRouter: React.FC = () => {<Route path="/streaming" element={<StreamingViewPage/>}/><Route path="/browse" element={<BrowserPage/>}/><Route path="/playback" element={<PlaybackPage/>}/>+ <Route path="/active-recording" element={<ActiveRecordingPage/>}/><Route path="*" element={<Navigate to="/welcome" replace/>}/></Routes>);diff --git a/freemocap-ui/src/layout/content/BottomPanelContent.tsx b/freemocap-ui/src/layout/content/BottomPanelContent.tsxindex aae404a2..bfe341d0 100644--- a/freemocap-ui/src/layout/content/BottomPanelContent.tsx+++ b/freemocap-ui/src/layout/content/BottomPanelContent.tsx@@ -1,12 +1,12 @@// freemocap-ui/src/components/ui-components/BottomPanelContent.tsximport * as React from 'react';import Box from '@mui/material/Box';-import {LogTerminal} from "@/components/LogTerminal";+import {LogTerminal} from "@/components/log-terminal";import {Panel, PanelGroup, PanelResizeHandle} from "react-resizable-panels";import {useTheme} from "@mui/material/styles";import TabbedBottomLeftPanel from "@/components/tabbed-bottom-panel/TabbedBottomLeftPanel";-export default function BottomPanelContent() {+export default function BottomPanelContent({isCollapsed}: { isCollapsed: boolean }) {const theme = useTheme();return (@@ -15,7 +15,7 @@ export default function BottomPanelContent() {{/* Framerate Viewer Panel */}<Panel defaultSize={30} minSize={20}><Box sx={{height: '100%', overflow: 'auto'}}>- <TabbedBottomLeftPanel/>+ <TabbedBottomLeftPanel isCollapsed={isCollapsed}/></Box></Panel>@@ -31,7 +31,7 @@ export default function BottomPanelContent() {{/* Logs Terminal Panel */}<Panel defaultSize={70} minSize={20}><Box sx={{height: '100%', overflow: 'auto'}}>- <LogTerminal/>+ <LogTerminal isCollapsed={isCollapsed}/></Box></Panel></PanelGroup>diff --git a/freemocap-ui/src/layout/content/SidePanelContent.tsx b/freemocap-ui/src/layout/content/SidePanelContent.tsxindex eae6324f..e1c7e1ea 100644--- a/freemocap-ui/src/layout/content/SidePanelContent.tsx+++ b/freemocap-ui/src/layout/content/SidePanelContent.tsx@@ -18,7 +18,6 @@ import {useLocation, useNavigate} from 'react-router-dom';import DirectionsRunIcon from '@mui/icons-material/DirectionsRun';import {SortableSectionWrapper} from '@/components/common/SortableSectionWrapper';-import {ServerConnectionStatus} from '@/components/ServerConnectionStatus';import {CameraConfigTreeView} from '@/components/control-panels/camera-config-panel/camera-config-tree-view/CameraConfigTreeView';@@ -26,6 +25,7 @@ import {RecordingInfoPanel} from "@/components/control-panels/recording-info-panimport {RealtimePipelinePanel} from "@/components/control-panels/realtime-panel/RealtimePipelinePanel";import {MocapPanel} from "@/components/control-panels/mocap-control-panel/MocapPanel";import {CalibrationPanel} from "@/components/control-panels/calibration-control-panel/CalibrationPanel";+import {ServerConnectionStatus} from "@/components/control-panels/server-connection";const STORAGE_KEY = 'freemocap-sidebar-section-order';diff --git a/freemocap-ui/src/pages/ActiveRecordingPage.tsx b/freemocap-ui/src/pages/ActiveRecordingPage.tsxnew file mode 100644index 00000000..95dfabc9--- /dev/null+++ b/freemocap-ui/src/pages/ActiveRecordingPage.tsx@@ -0,0 +1,264 @@+import React, {useCallback} from 'react';+import {Box, Button, Chip, Stack, Tooltip, Typography, useTheme} from '@mui/material';+import FolderOpenIcon from '@mui/icons-material/FolderOpen';+import VideoLibraryIcon from '@mui/icons-material/VideoLibrary';+import PlayArrowIcon from '@mui/icons-material/PlayArrow';+import {useNavigate} from 'react-router-dom';+import {Footer} from '@/components/ui-components/Footer';+import ErrorBoundary from '@/components/common/ErrorBoundary';+import {RecordingStatusPanel} from '@/components/common/RecordingStatusPanel';+import {useRecordingStatus} from '@/hooks/useRecordingStatus';+import {useAppSelector} from '@/store';+import {+ selectActiveRecordingBaseDirectory,+ selectActiveRecordingFullPath,+ selectActiveRecordingName,+ selectActiveRecordingOrigin,+ selectActiveRecordingStructure,+} from '@/store/slices/active-recording/active-recording-slice';+import {useElectronIPC} from '@/services';+import {useTranslation} from 'react-i18next';+import {useBlender} from "@/hooks/useBlender";+import LaunchIcon from "@mui/icons-material/Launch";+import {RecordingInfoPanel} from '@/components/control-panels/recording-info-panel/RecordingInfoPanel';+import {CalibrationPanel} from '@/components/control-panels/calibration-control-panel/CalibrationPanel';+import {MocapPanel} from '@/components/control-panels/mocap-control-panel/MocapPanel';++const MONO_FONT = '"JetBrains Mono", "Fira Code", "SF Mono", monospace';++const ORIGIN_LABEL: Record<string, string> = {+ 'pending-capture': 'Pending capture',+ 'just-captured': 'Just captured',+ 'browsed': 'Browsed',+ 'auto-latest': 'Auto-loaded',+};++const ActiveRecordingPage: React.FC = () => {+ const theme = useTheme();+ const {t} = useTranslation();+ const navigate = useNavigate();+ const {api} = useElectronIPC();++ const {triggerOpenInBlender} = useBlender();++ const isDark = theme.palette.mode === 'dark';++ const recordingName = useAppSelector(selectActiveRecordingName);+ const baseDirectory = useAppSelector(selectActiveRecordingBaseDirectory);+ const fullPath = useAppSelector(selectActiveRecordingFullPath);+ const origin = useAppSelector(selectActiveRecordingOrigin);+ const structure = useAppSelector(selectActiveRecordingStructure);+ const {+ status,+ isLoading: statusLoading,+ error: statusError,+ refresh: refreshStatus,+ } = useRecordingStatus(recordingName, {+ autoFetch: !!recordingName,+ recordingParentDirectory: baseDirectory,+ });++ const handleOpenFolder = useCallback(async () => {+ if (!fullPath) return;+ try {+ await api?.fileSystem.openFolder.mutate({path: fullPath});+ } catch (err) {+ console.error('Failed to open recording folder:', err);+ }+ }, [fullPath, api]);++ const handleOpenInBlender = useCallback(async () => {+ if (!fullPath) return;+ void triggerOpenInBlender(fullPath);+ }, [structure?.blendPath, triggerOpenInBlender]);++++ const pageBg = theme.palette.mode === 'dark'+ ? theme.palette.background.default+ : theme.palette.background.paper;++ return (+ <Box+ sx={{+ width: '100%',+ height: '100%',+ display: 'flex',+ flexDirection: 'column',+ overflowY: 'auto',+ overflowX: 'hidden',+ backgroundColor: pageBg,+ borderStyle: 'solid',+ borderWidth: '1px',+ borderColor: theme.palette.divider,+ }}+ >+ <Box sx={{display: 'flex', flexDirection: 'column', p: 2, gap: 2}}>+ <ErrorBoundary>+ {!recordingName ? (+ <Box sx={{py: 4, px: 2}}>+ <Stack spacing={2} alignItems="flex-start">+ <Typography variant="body2" color="text.disabled" sx={{fontStyle: 'italic'}}>+ No active recording. This folder will be created when you start recording.+ </Typography>+ <Stack direction="row" spacing={1} sx={{mt: 1}}>+ <Button variant="outlined" onClick={() => navigate('/streaming')}>+ Go to Streaming+ </Button>+ <Button variant="outlined" onClick={() => navigate('/browse')}>+ Browse recordings+ </Button>+ </Stack>+ </Stack>+ <RecordingInfoPanel/>+ </Box>+ ) : (+ <>+ {/* Identity header */}+ <Box+ sx={{+ p: 2,+ borderRadius: 1,+ border: `1px solid ${theme.palette.divider}`,+ backgroundColor: isDark ? 'rgba(255,255,255,0.03)' : 'rgba(0,0,0,0.02)',+ }}+ >+ <Stack direction="row" alignItems="center" spacing={1} sx={{mb: 1, flexWrap: 'wrap'}}>+ <Typography+ variant="h6"+ sx={{fontFamily: MONO_FONT, fontWeight: 600}}+ >+ {recordingName}+ </Typography>+ {origin && (+ <Chip+ label={ORIGIN_LABEL[origin] ?? origin}+ size="small"+ variant="outlined"+ sx={{height: 20, fontSize: '0.7rem'}}+ />+ )}+ </Stack>+ <Tooltip title={fullPath ?? ''}>+ <Typography+ variant="body2"+ sx={{+ fontFamily: MONO_FONT,+ color: theme.palette.text.secondary,+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap',+ }}+ >+ {fullPath}+ </Typography>+ </Tooltip>+ <Stack direction="row" spacing={1} sx={{mt: 2, flexWrap: 'wrap'}}>+ <Button+ size="small"+ variant="outlined"+ startIcon={<FolderOpenIcon/>}+ onClick={handleOpenFolder}+ >+ {t('openFolder')}+ </Button>+ <Button+ size="small"+ variant="outlined"+ startIcon={<PlayArrowIcon/>}+ onClick={() => navigate('/playback')}+ >+ Open in Playback+ </Button>+ <Button+ size="small"+ variant="outlined"+ startIcon={<LaunchIcon/>}+ onClick={handleOpenInBlender}+ >+ Open in Blender+ </Button>+ <Button+ size="small"+ variant="outlined"+ startIcon={<VideoLibraryIcon/>}+ onClick={() => navigate('/browse')}+ >+ Browse recordings+ </Button>+ </Stack>+ </Box>++ {/*/!* Derived-path summary *!/*/}+ {/*{structure && (*/}+ {/* <Box*/}+ {/* sx={{*/}+ {/* p: 2,*/}+ {/* borderRadius: 1,*/}+ {/* border: `1px solid ${theme.palette.divider}`,*/}+ {/* }}*/}+ {/* >*/}+ {/* <Typography variant="subtitle2" sx={{mb: 1}}>Canonical layout</Typography>*/}+ {/* <Stack spacing={0.5}>*/}+ {/* <PathRow label="videos/synchronized" value={structure.videosSynchronizedDir}/>*/}+ {/* <PathRow label="videos/annotated" value={structure.videosAnnotatedDir}/>*/}+ {/* <PathRow label="output/" value={structure.outputDir}/>*/}+ {/* <PathRow label="calibration.toml" value={structure.calibrationTomlPath}/>*/}+ {/* <PathRow label="recording_info.json" value={structure.recordingInfoPath}/>*/}+ {/* <PathRow label="data.parquet" value={structure.dataParquetPath}/>*/}+ {/* <PathRow label=".blend" value={structure.blendPath}/>*/}+ {/* </Stack>*/}+ {/* </Box>*/}+ {/*)}*/}++ {/* Stage checklist */}+ <Box+ sx={{+ p: 2,+ borderRadius: 1,+ border: `1px solid ${theme.palette.divider}`,+ }}+ >+ <Typography variant="subtitle2" sx={{mb: 1}}>Pipeline stages</Typography>+ <RecordingStatusPanel+ status={status}+ isLoading={statusLoading}+ error={statusError}+ onRefresh={refreshStatus}+ defaultExpanded+ recordingFolderPath={fullPath}+ />+ </Box>++ {/* Control panels */}+ <CalibrationPanel/>+ <MocapPanel/>+ </>+ )}+ </ErrorBoundary>+ </Box>+ <Box component="footer" sx={{p: 0.5}}>+ <Footer/>+ </Box>+ </Box>+ );+};++const PathRow: React.FC<{ label: string; value: string }> = ({label, value}) => (+ <Stack direction="row" spacing={1} sx={{alignItems: 'center'}}>+ <Typography variant="caption" sx={{minWidth: 160, color: 'text.secondary'}}>{label}</Typography>+ <Typography+ variant="caption"+ sx={{+ fontFamily: MONO_FONT,+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap',+ }}+ >+ {value}+ </Typography>+ </Stack>+);++export default ActiveRecordingPage;diff --git a/freemocap-ui/src/pages/BrowserPage.tsx b/freemocap-ui/src/pages/BrowserPage.tsxindex e05051f4..a018e188 100644--- a/freemocap-ui/src/pages/BrowserPage.tsx+++ b/freemocap-ui/src/pages/BrowserPage.tsx@@ -5,11 +5,14 @@ import {Footer} from '@/components/ui-components/Footer';import ErrorBoundary from '@/components/common/ErrorBoundary';import {RecordingBrowser} from '@/components/playback/RecordingBrowser';import {usePlaybackContext} from '@/components/playback/PlaybackContext';+import {useAppSelector} from '@/store';+import {selectActiveRecordingFullPath} from '@/store/slices/active-recording/active-recording-slice';const BrowserPage: React.FC = () => {const theme = useTheme();const navigate = useNavigate();const ctx = usePlaybackContext();+ const activeRecordingPath = useAppSelector(selectActiveRecordingFullPath);return (<Box@@ -29,9 +32,9 @@ const BrowserPage: React.FC = () => {<Box sx={{flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden'}}><ErrorBoundary><RecordingBrowser- activeRecordingPath={ctx?.recordingPath ?? null}- onRecordingLoaded={(videos, recPath, recFps) => {- ctx?.onRecordingLoaded(videos, recPath, recFps);+ activeRecordingPath={activeRecordingPath}+ onRecordingLoaded={(videos, recPath, recFps, sources, preferred) => {+ ctx?.onRecordingLoaded(videos, recPath, recFps, sources, preferred);navigate('/playback');}}/>diff --git a/freemocap-ui/src/pages/PlaybackPage.tsx b/freemocap-ui/src/pages/PlaybackPage.tsxindex 46912a2d..0a9629a0 100644--- a/freemocap-ui/src/pages/PlaybackPage.tsx+++ b/freemocap-ui/src/pages/PlaybackPage.tsx@@ -12,38 +12,30 @@ import {usePlaybackController} from '@/components/playback/usePlaybackControllerimport {usePlaybackContext} from '@/components/playback/PlaybackContext';import {useElectronIPC} from '@/services';import {useTranslation} from 'react-i18next';-import {useLocation, useNavigate} from 'react-router-dom';+import {useNavigate} from 'react-router-dom';import type {CameraSettings} from '@/pages/StreamingViewPage';import {SettingsOverlay} from "@/components/ui-components/SettingsOverlay";import {Panel, PanelGroup, PanelResizeHandle} from "react-resizable-panels";import {ThreeJsCanvas} from "@/components/viewport3d/ThreeJsCanvas";import {FileKeypointsSourceProvider} from "@/components/viewport3d/FileKeypointsSourceProvider";-import {useAppDispatch} from "@/store";-import {loadCalibrationForRecording} from "@/store/slices/calibration/calibration-thunks";+import {useAppSelector} from "@/store";+import {+ selectActiveRecordingBaseDirectory,+ selectActiveRecordingFullPath,+ selectActiveRecordingName,+} from "@/store/slices/active-recording/active-recording-slice";const PlaybackPage: React.FC = () => {const theme = useTheme();const {t} = useTranslation();const {api} = useElectronIPC();- const location = useLocation();const navigate = useNavigate();const isDark = theme.palette.mode === 'dark';- const locationState = location.state as { loadRecordingPath?: string } | null;const ctx = usePlaybackContext();- const dispatch = useAppDispatch();-- // Pass initialLoadPath from route state to the context- useEffect(() => {- const path = locationState?.loadRecordingPath ?? null;- if (path) ctx?.setInitialLoadPath(path);- }, [locationState?.loadRecordingPath]);-- const recordingPathForCalibration = ctx?.recordingPath ?? null;- useEffect(() => {- if (!recordingPathForCalibration) return;- dispatch(loadCalibrationForRecording(recordingPathForCalibration));- }, [dispatch, recordingPathForCalibration]);+ const activeRecordingPath = useAppSelector(selectActiveRecordingFullPath);+ const activeRecordingName = useAppSelector(selectActiveRecordingName);+ const activeRecordingBaseDirectory = useAppSelector(selectActiveRecordingBaseDirectory);const [settings, setSettings] = useState<CameraSettings>({columns: null,@@ -55,10 +47,13 @@ const PlaybackPage: React.FC = () => {const isHorizontal = settings.layoutDirection === 'horizontal';const loadedVideos = ctx?.loadedVideos ?? [];- const recordingPath = ctx?.recordingPath ?? null;+ const recordingPath = activeRecordingPath;const recordingFps = ctx?.recordingFps;const frameTimestamps = ctx?.frameTimestamps ?? null;const onFrameChange = ctx?.onFrameChange;+ const availableSources = ctx?.availableSources ?? null;+ const selectedSource = ctx?.selectedSource ?? null;+ const setSelectedSource = ctx?.setSelectedSource;const handleOpenFolder = useCallback(async () => {if (!recordingPath) return;@@ -311,7 +306,8 @@ const PlaybackPage: React.FC = () => {<Panel defaultSize={40} minSize={10}><Box sx={{height: '100%'}}><FileKeypointsSourceProvider- recordingId={recordingPath}+ recordingId={activeRecordingName}+ recordingParentDirectory={activeRecordingBaseDirectory}currentFrameRef={controller.currentFrameRef}><ThreeJsCanvas/>@@ -350,6 +346,9 @@ const PlaybackPage: React.FC = () => {onSeekToEnd={controller.handleSeekToEnd}isLooping={controller.isLooping}onToggleLoop={controller.handleToggleLoop}+ availableSources={availableSources}+ selectedSource={selectedSource}+ onSourceChange={setSelectedSource}/></Box></ErrorBoundary>diff --git a/freemocap-ui/src/services/server/ServerContextProvider.tsx b/freemocap-ui/src/services/server/ServerContextProvider.tsxindex 35ce4446..a213c627 100644--- a/freemocap-ui/src/services/server/ServerContextProvider.tsx+++ b/freemocap-ui/src/services/server/ServerContextProvider.tsx@@ -1,5 +1,7 @@// ServerContextProvider.tsx-import React, {createContext, ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react';+import React, {ReactNode, useCallback, useEffect, useMemo, useRef, useState} from 'react';+import { ServerContext, type ServerContextValue } from './server-context';+export { useServer, useServerOptional, ServerContext, type ServerContextValue } from './server-context';import {ConnectionState, WebSocketConnection} from "@/services/server/server-helpers/websocket-connection";import {FrameProcessor} from "@/services/server/server-helpers/frame-processor/frame-processor";@@ -7,10 +9,12 @@ import {CanvasManager} from "@/services/server/server-helpers/canvas-manager";import {serverUrls} from "@/services";import {FramerateStore} from "@/services/server/server-helpers/framerate-store";import {LogStore} from "@/services/server/server-helpers/log-store";+import {installConsoleLogBridge} from "@/services/server/server-helpers/console-log-bridge";import {OverlayManager} from "@/services/server/server-helpers/image-overlay/overlay-renderer-factory";import {CharucoObservation} from "@/services/server/server-helpers/image-overlay/charuco-types";import {MediapipeObservation} from "@/services/server/server-helpers/image-overlay/mediapipe-types";import {+ FrontendPayloadMessage,isFramerateUpdate,isFrontendPayload,isLogRecord,@@ -18,34 +22,20 @@ import {isTrackerSchemas,} from "@/services/server/server-helpers/websocket-message-types";import {TrackedObjectDefinition} from "@/services/server/server-helpers/tracked-object-definition";-import {Point3d, RigidBodyPose} from "@/components/viewport3d";+import {+ BLOCK_KIND,+ isKeypointsMessage,+ parseKeypointsMessage,+} from "@/services/server/server-helpers/frame-processor/keypoints-binary-parser";+import {RigidBodyPose} from "@/components/viewport3d";+import {+ KeypointsCallback,+ KeypointsFrame,+ pointDictToFrame,+} from "@/components/viewport3d/KeypointsSourceContext";import {store} from "@/store";import {pipelineProgressUpdated, PipelinePhase, PipelineType} from "@/store/slices/pipelines";-interface ServerContextValue {- isConnected: boolean;- connect: () => void;- disconnect: () => void;- sendWebsocketMessage: (data: string | object) => void;- setCanvasForCamera: (cameraId: string, canvas: HTMLCanvasElement) => void;- getFps: (cameraId: string) => number | null;- getServerFps: () => number | null;- getFramerateStore: () => FramerateStore;- getLogStore: () => LogStore;- connectedCameraIds: string[];- updateServerConnection: (host: string, port: number) => void;- subscribeToKeypointsRaw: (cb: (points: Record<string, Point3d>) => void) => () => void;- subscribeToKeypointsFiltered: (cb: (points: Record<string, Point3d>) => void) => () => void;- subscribeToRigidBodies: (cb: (poses: Map<string, RigidBodyPose>) => void) => () => void;- getLatestKeypointsRaw: () => Record<string, Point3d>;- setOverlayVisibility: (charuco: boolean, skeleton: boolean) => void;- trackerSchemas: Record<string, TrackedObjectDefinition>;- activeTrackerId: string | null;- getActiveSchema: () => TrackedObjectDefinition | null;-}--const ServerContext = createContext<ServerContextValue | null>(null);-// Compare two already-sorted string arrays without allocatingfunction sortedArraysEqual(a: string[], b: string[]): boolean {if (a.length !== b.length) return false;@@ -79,6 +69,10 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childr// Overlay data refs - NO REACT STATE to avoid re-renders!const latestCharucoRef = useRef<Map<string, CharucoObservation>>(new Map());const latestMediapipeRef = useRef<Map<string, MediapipeObservation>>(new Map());+ // Tracks when each camera last received overlay data; used to evict stale+ // overlays when the pipeline stops or a camera is removed from it.+ const OVERLAY_STALE_MS = 500;+ const lastOverlayTimeRef = useRef<Map<string, number>>(new Map());// Overlay visibility flags - toggled by UI, applied in dispatchFramesconst charucoEnabledRef = useRef<boolean>(true);@@ -87,14 +81,16 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childr// Latest server-side (backend) FPS stored in a ref for non-reactive accessconst serverFpsRef = useRef<number | null>(null);+ // Last-dispatched progress per pipeline — skip dispatch when value is unchanged+ const lastPipelineProgressRef = useRef<Record<string, string>>({});+// 3D data refs and subscriber sets- // Plain Record — matches JSON.parse output directly, no remapping needed.- const trackedPointsRef = useRef<Record<string, Point3d>>({});+ const trackedPointsRef = useRef<KeypointsFrame | null>(null);const rigidBodiesRef = useRef<Map<string, RigidBodyPose>>(new Map());- const trackedPointsSubscribersRef = useRef<Set<(points: Record<string, Point3d>) => void>>(new Set());+ const trackedPointsSubscribersRef = useRef<Set<KeypointsCallback>>(new Set());const rigidBodiesSubscribersRef = useRef<Set<(poses: Map<string, RigidBodyPose>) => void>>(new Set());- const keypointsFilteredRef = useRef<Record<string, Point3d>>({});- const keypointsFilteredSubscribersRef = useRef<Set<(points: Record<string, Point3d>) => void>>(new Set());+ const keypointsFilteredRef = useRef<KeypointsFrame | null>(null);+ const keypointsFilteredSubscribersRef = useRef<Set<KeypointsCallback>>(new Set());// Holds the latest binary payload received from the WebSocket.@@ -106,13 +102,33 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childr// back-to-back in a single macrotask without yielding.// TODO - Check if this is nonsenseconst pendingPayloadRef = useRef<ArrayBuffer | null>(null);+ const pendingJsonPayloadRef = useRef<FrontendPayloadMessage | null>(null);+ // Latest binary keypoints frame (only when FREEMOCAP_BINARY_KEYPOINTS=1+ // is set on the backend). Older unprocessed frames are overwritten.+ const pendingKeypointsRef = useRef<ArrayBuffer | null>(null);const processingFrameRef = useRef<boolean>(false);const frameLoopRef = useRef<number | null>(null);+ // Frame number extracted from the binary header immediately on receipt.+ // Sent as the ack at the top of the next rAF tick — long before decode+ // finishes — so the backend can pipeline the next frame without waiting+ // for our JPEG decode + overlay compositing to complete.+ const pendingAckFrameNumberRef = useRef<number | null>(null);// Cached sorted camera IDs from the last frame — compared by value to avoid// per-frame Array.from().sort() allocations when the camera list hasn't changed.const lastCameraIdsRef = useRef<string[]>([]);+ // Tracks what ran in the most recent rAF tick for jank diagnosis.+ const lastTickRef = useRef({+ sentAck: false,+ processedJson: false,+ processedBinaryKP: false,+ startedDecode: false,+ decodingInProgress: false,+ wsMessageCount: 0, // WS messages received since last tick+ });+ const wsMessagesSinceLastTickRef = useRef(0);+// Initialize services onceuseEffect(() => {wsConnectionRef.current = new WebSocketConnection({@@ -125,7 +141,18 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childrcanvasManagerRef.current = new CanvasManager();overlayManagerRef.current = new OverlayManager();+ // Persist logs on tab close / navigation so the last batch isn't lost.+ const handleBeforeUnload = (): void => {+ logStoreRef.current?.persistNow();+ };+ window.addEventListener('beforeunload', handleBeforeUnload);++ // const uninstallConsoleBridge = installConsoleLogBridge(logStoreRef.current);+return () => {+ window.removeEventListener('beforeunload', handleBeforeUnload);+ logStoreRef.current?.dispose();+ // uninstallConsoleBridge();if (wsConnectionRef.current) {wsConnectionRef.current.disconnect();}@@ -154,13 +181,17 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childrserverFpsRef.current = null;processingFrameRef.current = false;pendingPayloadRef.current = null;+ pendingJsonPayloadRef.current = null;+ pendingKeypointsRef.current = null;+ pendingAckFrameNumberRef.current = null;lastCameraIdsRef.current = [];framerateStoreRef.current.clear();- trackedPointsRef.current = {};+ trackedPointsRef.current = null;rigidBodiesRef.current = new Map();- keypointsFilteredRef.current = {};+ keypointsFilteredRef.current = null;latestCharucoRef.current.clear();latestMediapipeRef.current.clear();+ lastOverlayTimeRef.current.clear();overlayManagerRef.current?.clearAll();trackerSchemasRef.current = {};activeTrackerIdRef.current = null;@@ -170,13 +201,19 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childr}};- // Process a decoded frame result: update camera list, dispatch to workers, send ack.- const dispatchFrames = async (+ let lastFrontendFrameTime = 0;+ const frontendDurations: number[] = [];++ // Process a decoded frame result: update camera list, dispatch to workers.+ // Synchronous — overlay compositing is fire-and-forget so it never blocks+ // the rAF loop. The ack is sent at the top of processFrameLoop, well before+ // decode finishes, so the backend pipelines the next frame sooner.+ const dispatchFrames = (result: Awaited<ReturnType<FrameProcessor['processFramePayload']>>- ): Promise<void> => {+ ): void => {if (!result) return;- const {frames, cameraIds, frameNumbers} = result;+ const {frames, cameraIds} = result;// Only allocate a new sorted array if the camera set actually changed.const lastIds = lastCameraIdsRef.current;@@ -208,68 +245,259 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childr});}- // Composite overlays onto frames before sending to canvas workers+ // Composite overlays onto frames and dispatch to canvas workers.+ // Fire-and-forget: overlay compositing runs asynchronously and never+ // blocks the rAF loop. The canvas worker renders the composited bitmap+ // when it arrives (overwriting any earlier raw frame for that camera).const overlayManager = overlayManagerRef.current!;for (const frameData of frames) {- const charucoObs = charucoEnabledRef.current+ const overlayAge = performance.now() - (lastOverlayTimeRef.current.get(frameData.cameraId) ?? 0);+ const overlayFresh = overlayAge <= OVERLAY_STALE_MS;+ if (!overlayFresh) {+ latestCharucoRef.current.delete(frameData.cameraId);+ latestMediapipeRef.current.delete(frameData.cameraId);+ lastOverlayTimeRef.current.delete(frameData.cameraId);+ }+ const charucoObs = (charucoEnabledRef.current && overlayFresh)? latestCharucoRef.current.get(frameData.cameraId) ?? null: null;- const mediapipeObs = skeletonEnabledRef.current+ const mediapipeObs = (skeletonEnabledRef.current && overlayFresh)? latestMediapipeRef.current.get(frameData.cameraId) ?? null: null;- let compositeBitmap: ImageBitmap;if (charucoObs || mediapipeObs) {- compositeBitmap = await overlayManager.processFrame(+ overlayManager.processFrame(frameData.cameraId,frameData.bitmap,charucoObs,mediapipeObs,- );+ ).then(compositeBitmap => {+ canvasManagerRef.current?.sendFrameToWorker(frameData.cameraId, compositeBitmap);+ }).catch(err => console.error('Overlay error for camera', frameData.cameraId, err));} else {- compositeBitmap = frameData.bitmap;+ canvasManagerRef.current!.sendFrameToWorker(frameData.cameraId, frameData.bitmap);}+ }- canvasManagerRef.current!.sendFrameToWorker(- frameData.cameraId,- compositeBitmap,- );+ // Measure display fps from decoded frame arrivals — fires every frame+ // regardless of pipeline state, so the framerate panel always has data.+ const now = performance.now();+ if (lastFrontendFrameTime > 0) {+ const dur = now - lastFrontendFrameTime;+ frontendDurations.push(dur);+ if (frontendDurations.length > 30) frontendDurations.shift();+ if (frontendDurations.length >= 2) {+ let sum = 0, min = Infinity, max = -Infinity;+ for (const d of frontendDurations) {+ sum += d;+ if (d < min) min = d;+ if (d > max) max = d;+ }+ const mean = sum / frontendDurations.length;+ framerateStoreRef.current.updateFrontend({+ mean_frame_duration_ms: mean,+ mean_frames_per_second: mean > 0 ? 1000 / mean : 0,+ frame_duration_mean: mean,+ frame_duration_median: mean,+ frame_duration_min: min,+ frame_duration_max: max,+ frame_duration_stddev: 0,+ frame_duration_coefficient_of_variation: 0,+ calculation_window_size: frontendDurations.length,+ framerate_source: 'Display (browser)',+ });+ }}+ lastFrontendFrameTime = now;+ };- if (frameNumbers.size > 0) {- const maxFrameNumber = Math.max(...Array.from(frameNumbers));- ws.send({type: 'frameAcknowledgment', frameNumber: maxFrameNumber});+ // Dispatches a buffered frontend_payload to all 3D-scene subscribers.+ // Called from the rAF loop (not from the WebSocket handler) so subscriber+ // work happens during the animation frame, not mid-message-storm.+ const dispatchJsonPayload = (payload: FrontendPayloadMessage): void => {+ const overlayNow = performance.now();+ if (payload.charuco_overlays) {+ for (const [cameraId, charuco] of Object.entries(payload.charuco_overlays)) {+ latestCharucoRef.current.set(cameraId, charuco as CharucoObservation);+ lastOverlayTimeRef.current.set(cameraId, overlayNow);+ }+ }+ if (payload.skeleton_overlays) {+ for (const [cameraId, skeleton] of Object.entries(payload.skeleton_overlays)) {+ latestMediapipeRef.current.set(cameraId, skeleton as MediapipeObservation);+ lastOverlayTimeRef.current.set(cameraId, overlayNow);+ }+ }++ if (payload.keypoints_raw) {+ const frame = pointDictToFrame(payload.keypoints_raw as Record<string, {x:number;y:number;z:number}>);+ trackedPointsRef.current = frame;+ for (const cb of trackedPointsSubscribersRef.current) cb(frame);+ }++ if (payload.keypoints_filtered) {+ const frame = pointDictToFrame(payload.keypoints_filtered as Record<string, {x:number;y:number;z:number}>);+ keypointsFilteredRef.current = frame;+ for (const cb of keypointsFilteredSubscribersRef.current) cb(frame);+ }++ if (payload.rigid_body_poses) {+ const posesMap = new Map<string, RigidBodyPose>();+ for (const [key, pose] of Object.entries(payload.rigid_body_poses)) {+ posesMap.set(key, pose as RigidBodyPose);+ }+ rigidBodiesRef.current = posesMap;+ for (const cb of rigidBodiesSubscribersRef.current) cb(posesMap);+ }+ };++ // Decode the binary keypoints message and dispatch typed frames+ // directly — no Point3d object creation, no JSON parsing.+ const dispatchBinaryKeypoints = (buf: ArrayBuffer): void => {+ const parsed = parseKeypointsMessage(buf);+ for (const block of parsed.blocks) {+ const schema = trackerSchemasRef.current[block.trackerId];+ if (!schema) {+ // Schema handshake hasn't arrived yet — drop silently.+ continue;+ }+ // Cast to Float32Array (the serializer always uses float32).+ const interleaved = block.interleaved instanceof Float32Array+ ? block.interleaved+ : new Float32Array(block.interleaved);+ const frame: KeypointsFrame = {+ pointNames: schema.tracked_points,+ interleaved,+ };+ if (block.kind === BLOCK_KIND.KEYPOINTS_RAW_3D) {+ trackedPointsRef.current = frame;+ for (const cb of trackedPointsSubscribersRef.current) cb(frame);+ } else if (block.kind === BLOCK_KIND.KEYPOINTS_FILTERED_3D) {+ keypointsFilteredRef.current = frame;+ for (const cb of keypointsFilteredSubscribersRef.current) cb(frame);+ }}};- // requestAnimationFrame(rAF)-driven processing loop. Runs on its own macrotask boundary,- // so createImageBitmap promises can resolve without being starved- // by the WebSocket onmessage dispatch loop.- //TODO - check if this is nonsense- const processFrameLoop = async (): Promise<void> => {+ // rAF-driven processing loop. Non-async so the next rAF is always+ // registered immediately — the async decode+dispatch chain runs via+ // .then() and never blocks rAF re-registration.+ let lastRafTime = 0;+ let lastBodyDuration = 0;+ let decodeStartTime = 0;+ const processFrameLoop = (): void => {+ const now = performance.now();+ const rafGap = lastRafTime > 0 ? now - lastRafTime : 0;+ // Time the body: measure from now to just before we register next rAF.+ // This separates "our body was slow" from "browser delayed the next rAF".+ const bodyStart = now;+ lastRafTime = now;++ // if (rafGap > 50) {+ // const prev = lastTickRef.current;+ // const decoding = processingFrameRef.current;+ // const tag = decoding+ // ? `decode-busy (${(now - decodeStartTime).toFixed(0)}ms)`+ // : 'main-thread jank';+ // console.warn(+ // `rAF gap: ${rafGap.toFixed(0)}ms [${tag}] prevBody:${lastBodyDuration.toFixed(0)}ms` ++ // ` | prev: ack=${prev.sentAck} json=${prev.processedJson}` ++ // ` binKP=${prev.processedBinaryKP} decode=${prev.startedDecode}` ++ // ` decoding=${prev.decodingInProgress} wsMsg=${prev.wsMessageCount}` ++ // ` | cur: pendJson=${pendingJsonPayloadRef.current !== null}` ++ // ` pendBinKP=${pendingKeypointsRef.current !== null}` ++ // ` pendImg=${pendingPayloadRef.current !== null}`+ // );+ // }++ // Snapshot tick activity for the next jank report+ const tick = {+ sentAck: false,+ processedJson: false,+ processedBinaryKP: false,+ startedDecode: false,+ decodingInProgress: processingFrameRef.current,+ wsMessageCount: wsMessagesSinceLastTickRef.current,+ };+ wsMessagesSinceLastTickRef.current = 0;++ // Ack the most-recently-received image frame immediately — before+ // decode starts. This unblocks the backend's result_consumed_event+ // ~100-150ms earlier, allowing it to pipeline the next frame.+ if (pendingAckFrameNumberRef.current !== null) {+ ws.send({type: 'frameAcknowledgment', frameNumber: pendingAckFrameNumberRef.current});+ pendingAckFrameNumberRef.current = null;+ tick.sentAck = true;+ }++ // Dispatch buffered JSON payload (keypoints, overlays, rigid bodies).+ // Processed here rather than in the WebSocket handler to keep the+ // handler minimal and move subscriber work into the animation frame.+ if (pendingJsonPayloadRef.current !== null) {+ const jsonPayload = pendingJsonPayloadRef.current;+ pendingJsonPayloadRef.current = null;+ dispatchJsonPayload(jsonPayload);+ tick.processedJson = true;+ }++ // Decode any buffered binary keypoints frame after the JSON+ // payload — when both are present for the same frame the binary+ // copy is authoritative for keypoints (the backend already nulls+ // those JSON fields when binary is active, but order it this way+ // anyway so a stray JSON copy can't clobber the binary one).+ if (pendingKeypointsRef.current !== null) {+ const buf = pendingKeypointsRef.current;+ pendingKeypointsRef.current = null;+ try {+ dispatchBinaryKeypoints(buf);+ tick.processedBinaryKP = true;+ } catch (err) {+ console.error('Error parsing binary keypoints message:', err);+ }+ }+if (!processingFrameRef.current && pendingPayloadRef.current !== null) {const payload = pendingPayloadRef.current;pendingPayloadRef.current = null;processingFrameRef.current = true;- try {- const result = await frameProcessorRef.current!.processFramePayload(payload);- await dispatchFrames(result);- } catch (error) {- console.error('Error processing frame:', error);- } finally {- processingFrameRef.current = false;- }+ decodeStartTime = performance.now();+ tick.startedDecode = true;+ frameProcessorRef.current!.processFramePayload(payload)+ .then(result => {+ const decodeMs = performance.now() - decodeStartTime;+ if (decodeMs > 20) console.warn(`decode spike: ${decodeMs.toFixed(1)}ms`);+ dispatchFrames(result);+ })+ .catch(err => console.error('Error processing frame:', err))+ .finally(() => { processingFrameRef.current = false; });}++ lastBodyDuration = performance.now() - bodyStart;+ lastTickRef.current = tick;frameLoopRef.current = requestAnimationFrame(processFrameLoop);};frameLoopRef.current = requestAnimationFrame(processFrameLoop);const handleMessage = (event: MessageEvent): void => {- // Handle binary frame data: just buffer the latest payload.- // Older unprocessed payloads are overwritten (frame dropping).+ wsMessagesSinceLastTickRef.current++;+ // Handle binary frame data: demux on the first byte. Image frames+ // start with MessageType.PAYLOAD_HEADER (0); keypoints messages+ // start with KEYPOINTS_PAYLOAD_HEADER (3). Older unprocessed+ // payloads of either kind are overwritten (frame dropping).if (event.data instanceof ArrayBuffer) {- pendingPayloadRef.current = event.data;+ if (isKeypointsMessage(event.data)) {+ pendingKeypointsRef.current = event.data;+ } else {+ // Extract frame number immediately from the binary header+ // (BigInt64 at byte offset 8, little-endian) so we can ack+ // at the top of the next rAF — before decode starts.+ if (event.data.byteLength >= 16) {+ const view = new DataView(event.data);+ pendingAckFrameNumberRef.current = Number(view.getBigInt64(8, true));+ }+ pendingPayloadRef.current = event.data;+ }}// Handle text/JSON messages (logs, framerate updates, frontend payloads, etc.)else if (typeof event.data === 'string') {@@ -283,8 +511,8 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childrif (isLogRecord(jsonData)) {logStoreRef.current.add(jsonData);}- // Handle tracker schema handshake (sent once on connect,- // or again when the pipeline reconfigures). Passed straight+ // Handle tracker schema handshake (sent once on connect,+ // or again when the pipeline reconfigures). Passed straight// through to the 2D overlay renderer via OverlayManager.else if (isTrackerSchemas(jsonData)) {const schemas = jsonData.schemas;@@ -296,68 +524,80 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childrsetActiveTrackerId(firstId);overlayManagerRef.current?.setTrackerSchemas(schemas, firstId ?? undefined);}- // Handle framerate updates+ // Handle framerate updates — backend_framerate stored; frontend_framerate+ // is now measured locally in dispatchJsonPayload so we skip it here.else if (isFramerateUpdate(jsonData)) {- // Store backend FPS in ref for fast non-reactive accessserverFpsRef.current = jsonData.backend_framerate.mean_frames_per_second;- // Update mutable framerate store (no Redux, no re-renders)framerateStoreRef.current.updateBackend(jsonData.backend_framerate);- framerateStoreRef.current.updateFrontend(jsonData.frontend_framerate);}- // Handle charuco overlay data+ // Buffer frontend_payload for dispatch in the rAF loop.+ // Older unprocessed payloads are overwritten (keep latest only).else if (isFrontendPayload(jsonData)) {- if (jsonData.charuco_overlays) {- for (const [cameraId, charuco] of Object.entries(jsonData.charuco_overlays)) {- latestCharucoRef.current.set(cameraId, charuco as CharucoObservation);- }- }- if (jsonData.skeleton_overlays) {- for (const [cameraId, skeleton] of Object.entries(jsonData.skeleton_overlays)) {- latestMediapipeRef.current.set(cameraId, skeleton as MediapipeObservation);- }- }+ pendingJsonPayloadRef.current = jsonData;+ } else if (isPosthocProgress(jsonData)) {+ // console.debug('[WS:progress] raw msg:', jsonData);- // Keypoints arrive as plain JSON objects — assign directly, no remapping.- if (jsonData.keypoints_raw) {- trackedPointsRef.current = jsonData.keypoints_raw as Record<string, Point3d>;- for (const cb of trackedPointsSubscribersRef.current) {- cb(trackedPointsRef.current);- }- }-- if (jsonData.keypoints_filtered) {- keypointsFilteredRef.current = jsonData.keypoints_filtered as Record<string, Point3d>;- for (const cb of keypointsFilteredSubscribersRef.current) {- cb(keypointsFilteredRef.current);- }- }-- if (jsonData.rigid_body_poses) {- const posesMap = new Map<string, RigidBodyPose>();- for (const [key, pose] of Object.entries(jsonData.rigid_body_poses)) {- posesMap.set(key, pose as RigidBodyPose);+ const PIPELINE_TYPE_MAP: Record<string, PipelineType> = {+ calibration: PipelineType.CALIBRATION,+ mocap: PipelineType.MOCAP,+ };+ const pipelineType = PIPELINE_TYPE_MAP[jsonData.pipeline_type];+ if (!pipelineType) {+ console.error('[WS] Unknown pipeline_type in progress message:', jsonData.pipeline_type, jsonData);+ } else {+ const progress = Math.round(jsonData.progress_fraction * 100);+ const dedupeKey = `${jsonData.phase}:${progress}`;+ if (lastPipelineProgressRef.current[jsonData.pipeline_id] !== dedupeKey) {+ lastPipelineProgressRef.current[jsonData.pipeline_id] = dedupeKey;+ // console.debug('[WS:progress] dispatching:', jsonData.pipeline_id, jsonData.phase, progress + '%');+ const BACKEND_PHASE_MAP: Record<string, PipelinePhase> = {+ // Queued (emitted at pipeline creation time, before workers start)+ queued: PipelinePhase.QUEUED,+ // VideoNodePhase+ setting_up: PipelinePhase.SETTING_UP,+ processing_images: PipelinePhase.PROCESSING_VIDEOS,+ // AggregatorPhase+ collecting_camera_output: PipelinePhase.SETTING_UP,+ // MocapStage+ building_recorders: PipelinePhase.AGGREGATING,+ triangulating: PipelinePhase.AGGREGATING,+ exporting_blender: PipelinePhase.FINALIZING,+ // CalibrationStage+ validating_observations: PipelinePhase.AGGREGATING,+ running_solver: PipelinePhase.AGGREGATING,+ saving_calibration: PipelinePhase.FINALIZING,+ // terminal+ complete: PipelinePhase.COMPLETE,+ failed: PipelinePhase.FAILED,+ };+ store.dispatch(pipelineProgressUpdated({+ pipelineId: jsonData.pipeline_id,+ pipelineType,+ phase: BACKEND_PHASE_MAP[jsonData.phase] ?? PipelinePhase.PROCESSING_VIDEOS,+ progress,+ detail: jsonData.detail,+ recordingName: jsonData.recording_name,+ recordingPath: jsonData.recording_path,+ }));+ // Base pipeline (aggregator) messages update the type-specific slice.+ // Use raw action type strings to avoid circular imports through @/services barrel.+ if (!jsonData.pipeline_id.includes(':')) {+ if (pipelineType === PipelineType.MOCAP) {+ store.dispatch({+ type: 'mocap/posthocProgressReceived',+ payload: {phase: jsonData.phase, progress_fraction: jsonData.progress_fraction, detail: jsonData.detail},+ });+ } else {+ store.dispatch({+ type: 'calibration/calibrationPipelineProgressReceived',+ payload: {phase: jsonData.phase},+ });+ }+ }}- rigidBodiesRef.current = posesMap;- for (const cb of rigidBodiesSubscribersRef.current) cb(posesMap);}- }- else if (isPosthocProgress(jsonData)) {- const BACKEND_PHASE_MAP: Record<string, PipelinePhase> = {- collecting_frames: PipelinePhase.SETTING_UP,- detecting_frames: PipelinePhase.PROCESSING_VIDEOS,- all_frames_collected: PipelinePhase.AGGREGATING,- processing: PipelinePhase.AGGREGATING,- running_task: PipelinePhase.AGGREGATING,- complete: PipelinePhase.COMPLETE,- failed: PipelinePhase.FAILED,- };- store.dispatch(pipelineProgressUpdated({- pipelineId: jsonData.pipeline_id,- pipelineType: PipelineType.MOCAP, // TODO: backend should send type- phase: BACKEND_PHASE_MAP[jsonData.phase] ?? PipelinePhase.PROCESSING_VIDEOS,- progress: Math.round(jsonData.progress_fraction * 100),- detail: jsonData.detail,- }));+ } else {+ console.warn('[WS] unhandled JSON message:', jsonData.message_type ?? '(no message_type)', jsonData);}} catch (error) {console.error('Error parsing JSON message:', error);@@ -414,12 +654,12 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childrreturn logStoreRef.current;}, []);- const subscribeToKeypointsRaw = useCallback((cb: (points: Record<string, Point3d>) => void): () => void => {+ const subscribeToKeypointsRaw = useCallback((cb: KeypointsCallback): () => void => {trackedPointsSubscribersRef.current.add(cb);return () => { trackedPointsSubscribersRef.current.delete(cb); };}, []);- const subscribeToKeypointsFiltered = useCallback((cb: (points: Record<string, Point3d>) => void): () => void => {+ const subscribeToKeypointsFiltered = useCallback((cb: KeypointsCallback): () => void => {keypointsFilteredSubscribersRef.current.add(cb);return () => { keypointsFilteredSubscribersRef.current.delete(cb); };}, []);@@ -431,7 +671,7 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childr};}, []);- const getLatestKeypointsRaw = useCallback((): Record<string, Point3d> => {+ const getLatestKeypointsRaw = useCallback((): KeypointsFrame | null => {return trackedPointsRef.current;}, []);@@ -490,9 +730,3 @@ export const ServerContextProvider: React.FC<{ children: ReactNode }> = ({childr</ServerContext.Provider>);};--export const useServer = (): ServerContextValue => {- const context = useContext(ServerContext);- if (!context) throw new Error('useServer must be used within ServerContextProvider');- return context;-};diff --git a/freemocap-ui/src/services/server/server-context.ts b/freemocap-ui/src/services/server/server-context.tsnew file mode 100644index 00000000..8ba4f003--- /dev/null+++ b/freemocap-ui/src/services/server/server-context.ts@@ -0,0 +1,41 @@+import { createContext, useContext } from 'react';+import type { FramerateStore } from './server-helpers/framerate-store';+import type { LogStore } from './server-helpers/log-store';+import type { TrackedObjectDefinition } from './server-helpers/tracked-object-definition';+import type { RigidBodyPose } from '@/components/viewport3d';+import type { KeypointsCallback, KeypointsFrame } from '@/components/viewport3d/KeypointsSourceContext';++export interface ServerContextValue {+ isConnected: boolean;+ connect: () => void;+ disconnect: () => void;+ sendWebsocketMessage: (data: string | object) => void;+ setCanvasForCamera: (cameraId: string, canvas: HTMLCanvasElement) => void;+ getFps: (cameraId: string) => number | null;+ getServerFps: () => number | null;+ getFramerateStore: () => FramerateStore;+ getLogStore: () => LogStore;+ connectedCameraIds: string[];+ updateServerConnection: (host: string, port: number) => void;+ subscribeToKeypointsRaw: (cb: KeypointsCallback) => () => void;+ subscribeToKeypointsFiltered: (cb: KeypointsCallback) => () => void;+ subscribeToRigidBodies: (cb: (poses: Map<string, RigidBodyPose>) => void) => () => void;+ getLatestKeypointsRaw: () => KeypointsFrame | null;+ setOverlayVisibility: (charuco: boolean, skeleton: boolean) => void;+ trackerSchemas: Record<string, TrackedObjectDefinition>;+ activeTrackerId: string | null;+ getActiveSchema: () => TrackedObjectDefinition | null;+}++export const ServerContext = createContext<ServerContextValue | null>(null);++export const useServer = (): ServerContextValue => {+ const context = useContext(ServerContext);+ if (!context) throw new Error('useServer must be used within ServerContextProvider');+ return context;+};++/** Returns null when called outside ServerContextProvider (e.g. in a Web Worker). */+export const useServerOptional = (): ServerContextValue | null => {+ return useContext(ServerContext);+};diff --git a/freemocap-ui/src/services/server/server-helpers/console-log-bridge.ts b/freemocap-ui/src/services/server/server-helpers/console-log-bridge.tsnew file mode 100644index 00000000..854ab6ba--- /dev/null+++ b/freemocap-ui/src/services/server/server-helpers/console-log-bridge.ts@@ -0,0 +1,193 @@+// src/services/server/server-helpers/console-log-bridge.ts+//+// Mirrors browser console output (and unhandled errors) into the LogStore so+// the in-app LogTerminal shows the same messages a developer would see in+// DevTools. The original console methods are still invoked, so DevTools is+// unaffected.++import {LogRecord, LogStore} from './log-store';++type ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'debug';++const METHOD_LEVELS: Record<ConsoleMethod, string> = {+ log: 'INFO',+ info: 'INFO',+ warn: 'WARNING',+ error: 'ERROR',+ debug: 'DEBUG',+};++const UI_LOGGER_NAME = 'ui-console';+const BRIDGE_FILE_MARKER = 'console-log-bridge';++let installed = false;+let installedCleanup: (() => void) | null = null;++interface CallerInfo {+ funcName: string;+ pathname: string;+ filename: string;+ module: string;+ lineno: number;+}++/** Walk the V8/SpiderMonkey stack to find the first frame outside this bridge file. */+function extractCallerInfo(): CallerInfo {+ const stack = new Error().stack ?? '';+ for (const line of stack.split('\n')) {+ const trimmed = line.trim();+ if (!trimmed.startsWith('at ')) continue;+ if (trimmed.includes(BRIDGE_FILE_MARKER)) continue;+ // Format: "at FuncName (path/file.ts:line:col)" or "at path/file.ts:line:col"+ const match = trimmed.match(/at (?:(.+?) \()?(.+?):(\d+):\d+\)?/);+ if (match) {+ const funcName = match[1]?.trim() || '';+ const pathname = match[2] || 'browser';+ const lineno = parseInt(match[3], 10) || 0;+ const filename = pathname.split('/').pop() || pathname;+ const mod = filename.replace(/\.[^.]+$/, '');+ return {funcName, pathname, filename, module: mod, lineno};+ }+ }+ return {funcName: '', pathname: 'browser', filename: 'browser', module: 'browser', lineno: 0};+}++function formatArg(arg: unknown): string {+ if (typeof arg === 'string') return arg;+ if (arg instanceof Error) return arg.stack ?? `${arg.name}: ${arg.message}`;+ if (arg === null || arg === undefined) return String(arg);+ if (typeof arg === 'object') {+ try {+ return JSON.stringify(arg);+ } catch {+ return String(arg);+ }+ }+ return String(arg);+}++function buildUiConsoleRecord(+ levelname: string,+ args: unknown[],+ caller: CallerInfo,+ stackInfo: string | null = null,+): LogRecord {+ const message = args.map(formatArg).join(' ');+ const now = Date.now();+ const date = new Date(now);+ // HH:MM:SS,mmm — close to Python logging's default asctime+ const pad = (n: number, w = 2): string => String(n).padStart(w, '0');+ const asctime =+ `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` ++ `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())},` ++ `${pad(date.getMilliseconds(), 3)}`;++ const levelno =+ levelname === 'DEBUG' ? 10 :+ levelname === 'INFO' ? 20 :+ levelname === 'WARNING' ? 30 :+ levelname === 'ERROR' ? 40 :+ levelname === 'CRITICAL' ? 50 : 20;++ return {+ name: UI_LOGGER_NAME,+ msg: message,+ args: [],+ levelname,+ levelno,+ pathname: caller.pathname,+ filename: caller.filename,+ module: caller.module,+ exc_info: null,+ exc_text: null,+ stack_info: stackInfo,+ lineno: caller.lineno,+ funcName: caller.funcName,+ created: now / 1000,+ msecs: date.getMilliseconds(),+ relativeCreated: 0,+ thread: 0,+ threadName: 'main',+ processName: 'ui',+ process: 0,+ delta_t: '',+ message,+ asctime,+ formatted_message: `${asctime} [${UI_LOGGER_NAME}] ${levelname} - ${message}`,+ type: 'log_record',+ source: 'ui',+ };+}++/**+ * Wraps console.{log,info,warn,error,debug} so each call also appends a+ * LogRecord to the given store. Also captures `error` and+ * `unhandledrejection` window events as ERROR records.+ *+ * Idempotent: subsequent calls are no-ops and return the same cleanup. This+ * keeps things sane under React StrictMode's double-invoked effects.+ *+ * Returns a cleanup function that restores the original console methods and+ * removes the global error listeners.+ */+export function installConsoleLogBridge(store: LogStore): () => void {+ if (installed && installedCleanup) {+ return installedCleanup;+ }++ const originals: Partial<Record<ConsoleMethod, (...args: unknown[]) => void>> = {};++ (Object.keys(METHOD_LEVELS) as ConsoleMethod[]).forEach((method) => {+ const original = console[method].bind(console);+ originals[method] = original;+ console[method] = (...args: unknown[]): void => {+ original(...args);+ try {+ const caller = extractCallerInfo();+ store.add(buildUiConsoleRecord(METHOD_LEVELS[method], args, caller));+ } catch {+ // Never let logging blow up the caller.+ }+ };+ });++ const onError = (event: ErrorEvent): void => {+ const err = event.error;+ const stack = err instanceof Error ? (err.stack ?? null) : null;+ const msg = err instanceof Error+ ? `${err.name}: ${err.message}`+ : (event.message || 'Uncaught error');+ try {+ store.add(buildUiConsoleRecord('ERROR', [msg], extractCallerInfo(), stack));+ } catch { /* ignore */ }+ };++ const onUnhandledRejection = (event: PromiseRejectionEvent): void => {+ const reason = event.reason;+ const stack = reason instanceof Error ? (reason.stack ?? null) : null;+ const msg = reason instanceof Error+ ? `Unhandled promise rejection: ${reason.name}: ${reason.message}`+ : `Unhandled promise rejection: ${formatArg(reason)}`;+ try {+ store.add(buildUiConsoleRecord('ERROR', [msg], extractCallerInfo(), stack));+ } catch { /* ignore */ }+ };++ window.addEventListener('error', onError);+ window.addEventListener('unhandledrejection', onUnhandledRejection);++ installed = true;+ installedCleanup = (): void => {+ (Object.keys(originals) as ConsoleMethod[]).forEach((method) => {+ const original = originals[method];+ if (original) {+ console[method] = original;+ }+ });+ window.removeEventListener('error', onError);+ window.removeEventListener('unhandledrejection', onUnhandledRejection);+ installed = false;+ installedCleanup = null;+ };+ return installedCleanup;+}diff --git a/freemocap-ui/src/services/server/server-helpers/frame-processor/frame-decode.worker.ts b/freemocap-ui/src/services/server/server-helpers/frame-processor/frame-decode.worker.tsindex 56fbafa8..5436a7c9 100644--- a/freemocap-ui/src/services/server/server-helpers/frame-processor/frame-decode.worker.ts+++ b/freemocap-ui/src/services/server/server-helpers/frame-processor/frame-decode.worker.ts@@ -141,30 +141,32 @@ async function decodePayload(data) {frameMetadata.length = validFrameCount;- // Decode JPEGs sequentially so only one Blob's backing store exists- // at a time. Blob data lives in the browser's blob subsystem (outside- // the V8 heap) and relies on Blink GC to free it. In a Worker with no- // idle time, parallel Blob creation causes backing stores to accumulate- // faster than GC can reclaim them, producing a slowly rising memory- // floor. Sequential decode with explicit nulling keeps peak blob memory- // at one JPEG instead of N, and gives the browser a clear release signal.- const frames = new Array(validFrameCount);- for (let i = 0; i < validFrameCount; i++) {- const meta = frameMetadata[i];- const jpegData = new Uint8Array(data, meta.jpegStart, meta.jpegLength);- let blob = new Blob([jpegData], { type: 'image/jpeg' });- const bitmap = await createImageBitmap(blob, BITMAP_OPTIONS);- blob = null;- frames[i] = {- cameraId: meta.cameraId,- cameraIndex: meta.cameraIndex,- frameNumber: meta.frameNumber,- width: meta.width,- height: meta.height,- colorChannels: meta.colorChannels,- bitmap: bitmap,- };- }+ // Decode JPEGs in parallel across all cameras. At realtime rates (≤10fps,+ // ≤8 cameras) the GC has enough idle time between frames to reclaim Blob+ // backing stores before the next batch — so parallel decode is safe and+ // cuts total decode latency from N×24ms to ~24ms (one camera's worth).+ // If memory pressure ever appears in long sessions, fall back to the+ // sequential loop below (swap the Promise.all for a for-loop).+ const decodeT0 = performance.now();+ const frames = await Promise.all(+ frameMetadata.slice(0, validFrameCount).map(async (meta) => {+ const jpegData = new Uint8Array(data, meta.jpegStart, meta.jpegLength);+ let blob = new Blob([jpegData], { type: 'image/jpeg' });+ const bitmap = await createImageBitmap(blob, BITMAP_OPTIONS);+ blob = null;+ return {+ cameraId: meta.cameraId,+ cameraIndex: meta.cameraIndex,+ frameNumber: meta.frameNumber,+ width: meta.width,+ height: meta.height,+ colorChannels: meta.colorChannels,+ bitmap,+ };+ })+ );+ const decodeMs = performance.now() - decodeT0;+ if (decodeMs > 40) console.warn('parallel decode spike: ' + decodeMs.toFixed(1) + 'ms (' + validFrameCount + ' cams)');return frames;}diff --git a/freemocap-ui/src/services/server/server-helpers/frame-processor/keypoints-binary-parser.ts b/freemocap-ui/src/services/server/server-helpers/frame-processor/keypoints-binary-parser.tsnew file mode 100644index 00000000..fd109106--- /dev/null+++ b/freemocap-ui/src/services/server/server-helpers/frame-processor/keypoints-binary-parser.ts@@ -0,0 +1,164 @@+// keypoints-binary-parser.ts+/**+ * Decodes the binary keypoints websocket message produced by+ * `freemocap/core/viz/frontend_keypoints_serializer.py`.+ *+ * Returns typed-array views into the original ArrayBuffer (no copies). Hold+ * onto the buffer while you use the views. For step 1 of the JSON→binary+ * refactor we also expose a helper that materializes the legacy+ * `Record<string, Point3d>` shape so the existing renderer subscription+ * contract can stay unchanged. A follow-up will hand the typed arrays to the+ * renderer directly and `postMessage(buf, [buf])` them to web workers.+ */+import {+ BLOCK_KIND,+ BlockKind,+ DTYPE_CODE,+ DtypeCode,+ KEYPOINTS_BLOCK_HEADER_FIELDS,+ KEYPOINTS_BLOCK_HEADER_SIZE,+ KEYPOINTS_MESSAGE_TYPE,+ KEYPOINTS_PAYLOAD_FOOTER_SIZE,+ KEYPOINTS_PAYLOAD_HEADER_FIELDS,+ KEYPOINTS_PAYLOAD_HEADER_SIZE,+ dtypeByteSize,+ readAsciiField,+} from "./keypoints-protocol";++export interface KeypointBlock {+ kind: BlockKind;+ trackerId: string;+ cameraId: string; // "" for 3D blocks+ numPoints: number;+ dims: 2 | 3;+ dtypeCode: DtypeCode;+ /**+ * Interleaved [x, y, (z,) visibility] view over the original buffer.+ * Length = numPoints * (dims + 1). Missing points have NaN coords and+ * visibility 0.+ */+ interleaved: Float32Array | Float64Array;+}++export interface ParsedKeypointsMessage {+ frameNumber: number;+ blocks: KeypointBlock[];+}++/** Returns `true` if the buffer's first byte identifies it as a keypoints message. */+export function isKeypointsMessage(buf: ArrayBuffer): boolean {+ if (buf.byteLength < 1) return false;+ return new Uint8Array(buf, 0, 1)[0] === KEYPOINTS_MESSAGE_TYPE.KEYPOINTS_PAYLOAD_HEADER;+}++export function parseKeypointsMessage(buf: ArrayBuffer): ParsedKeypointsMessage {+ if (buf.byteLength < KEYPOINTS_PAYLOAD_HEADER_SIZE + KEYPOINTS_PAYLOAD_FOOTER_SIZE) {+ throw new Error(`Keypoints buffer too small: ${buf.byteLength} bytes`);+ }+ const view = new DataView(buf);+ const headerType = view.getUint8(KEYPOINTS_PAYLOAD_HEADER_FIELDS.message_type.offset);+ if (headerType !== KEYPOINTS_MESSAGE_TYPE.KEYPOINTS_PAYLOAD_HEADER) {+ throw new Error(`Unexpected payload header message_type=${headerType}`);+ }++ // BigInt → Number: frame numbers fit in JS safe-integer range for any+ // realistic session (>200 years at 60 fps).+ const frameNumberBig = view.getBigInt64(KEYPOINTS_PAYLOAD_HEADER_FIELDS.frame_number.offset, true);+ const frameNumber = Number(frameNumberBig);+ const numBlocks = view.getUint32(KEYPOINTS_PAYLOAD_HEADER_FIELDS.num_blocks.offset, true);++ const blocks: KeypointBlock[] = [];+ let cursor = KEYPOINTS_PAYLOAD_HEADER_SIZE;++ for (let b = 0; b < numBlocks; b++) {+ if (cursor + KEYPOINTS_BLOCK_HEADER_SIZE > buf.byteLength) {+ throw new Error(`Block ${b} header runs past end of buffer`);+ }+ const blockView = new DataView(buf, cursor, KEYPOINTS_BLOCK_HEADER_SIZE);+ const messageType = blockView.getUint8(KEYPOINTS_BLOCK_HEADER_FIELDS.message_type.offset);+ if (messageType !== KEYPOINTS_MESSAGE_TYPE.KEYPOINTS_BLOCK_HEADER) {+ throw new Error(`Block ${b} has unexpected message_type=${messageType}`);+ }+ const kind = blockView.getUint8(KEYPOINTS_BLOCK_HEADER_FIELDS.block_kind.offset) as BlockKind;+ const dtypeCode = blockView.getUint8(KEYPOINTS_BLOCK_HEADER_FIELDS.dtype_code.offset) as DtypeCode;+ const dims = blockView.getUint8(KEYPOINTS_BLOCK_HEADER_FIELDS.dims.offset);+ if (dims !== 2 && dims !== 3) {+ throw new Error(`Block ${b} has unsupported dims=${dims}`);+ }+ const cameraId = readAsciiField(blockView, KEYPOINTS_BLOCK_HEADER_FIELDS.camera_id.offset, KEYPOINTS_BLOCK_HEADER_FIELDS.camera_id.size);+ const trackerId = readAsciiField(blockView, KEYPOINTS_BLOCK_HEADER_FIELDS.tracker_id.offset, KEYPOINTS_BLOCK_HEADER_FIELDS.tracker_id.size);+ const numPoints = blockView.getUint32(KEYPOINTS_BLOCK_HEADER_FIELDS.num_points.offset, true);+ const dataByteLength = blockView.getUint32(KEYPOINTS_BLOCK_HEADER_FIELDS.data_byte_length.offset, true);++ const expectedDataBytes = numPoints * (dims + 1) * dtypeByteSize(dtypeCode);+ if (dataByteLength !== expectedDataBytes) {+ throw new Error(+ `Block ${b} data_byte_length=${dataByteLength} does not match expected ${expectedDataBytes}`,+ );+ }++ cursor += KEYPOINTS_BLOCK_HEADER_SIZE;+ if (cursor + dataByteLength > buf.byteLength) {+ throw new Error(`Block ${b} data runs past end of buffer`);+ }++ const elementCount = numPoints * (dims + 1);+ const interleaved = dtypeCode === DTYPE_CODE.FLOAT32+ ? new Float32Array(buf, cursor, elementCount)+ : new Float64Array(buf, cursor, elementCount);++ blocks.push({+ kind,+ trackerId,+ cameraId,+ numPoints,+ dims: dims as 2 | 3,+ dtypeCode,+ interleaved,+ });+ cursor += dataByteLength;+ }++ if (cursor + KEYPOINTS_PAYLOAD_FOOTER_SIZE > buf.byteLength) {+ throw new Error(`Footer runs past end of buffer (cursor=${cursor}, total=${buf.byteLength})`);+ }+ const footerType = view.getUint8(cursor + KEYPOINTS_PAYLOAD_HEADER_FIELDS.message_type.offset);+ if (footerType !== KEYPOINTS_MESSAGE_TYPE.KEYPOINTS_PAYLOAD_FOOTER) {+ throw new Error(`Footer has unexpected message_type=${footerType}`);+ }++ return { frameNumber, blocks };+}++export interface Point3dLike { x: number; y: number; z: number; }++/**+ * Materialize a `Record<string, Point3d>` keyed by point name from a 3D block.+ * Skips rows where visibility is 0 or any coordinate is NaN — matches the+ * sparse-dict semantics of the legacy JSON path. Allocates one object per+ * visible point; intended as a drop-in replacement for the JSON dispatch+ * path during step 1 of the refactor.+ */+export function blockToPointDict(+ block: KeypointBlock,+ pointNames: ReadonlyArray<string>,+): Record<string, Point3dLike> {+ if (block.dims !== 3) return {};+ const out: Record<string, Point3dLike> = {};+ const arr = block.interleaved;+ const stride = block.dims + 1;+ const limit = Math.min(block.numPoints, pointNames.length);+ for (let i = 0; i < limit; i++) {+ const off = i * stride;+ const visibility = arr[off + 3];+ if (!visibility) continue;+ const x = arr[off + 0];+ const y = arr[off + 1];+ const z = arr[off + 2];+ if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) continue;+ out[pointNames[i]] = { x, y, z };+ }+ return out;+}++export { BLOCK_KIND };diff --git a/freemocap-ui/src/services/server/server-helpers/frame-processor/keypoints-protocol.ts b/freemocap-ui/src/services/server/server-helpers/frame-processor/keypoints-protocol.tsnew file mode 100644index 00000000..8def633f--- /dev/null+++ b/freemocap-ui/src/services/server/server-helpers/frame-processor/keypoints-protocol.ts@@ -0,0 +1,99 @@+// keypoints-protocol.ts+/**+ * Binary protocol for the keypoints websocket message.+ * Mirrors freemocap/api/websocket/binary_keypoints_protocol.py — all field+ * offsets and sizes here MUST match the numpy dtype layout produced with+ * `align=True` on the Python side. See test_binary_keypoints_protocol.py.+ *+ * Wire layout:+ * PAYLOAD_HEADER (24B)+ * For each block:+ * BLOCK_HEADER (60B)+ * BLOCK_DATA (num_points * (dims + 1) * sizeof(dtype) bytes)+ * PAYLOAD_FOOTER (24B)+ *+ * The first byte of every binary websocket frame carries `message_type`,+ * which we demultiplex against the existing JPEG image protocol (which uses+ * 0/1/2 — we use 3/4/5 here).+ */++export const KEYPOINTS_MESSAGE_TYPE = {+ KEYPOINTS_PAYLOAD_HEADER: 3,+ KEYPOINTS_BLOCK_HEADER: 4,+ KEYPOINTS_PAYLOAD_FOOTER: 5,+} as const;++export const BLOCK_KIND = {+ KEYPOINTS_RAW_3D: 0,+ KEYPOINTS_FILTERED_3D: 1,+ SKELETON_OVERLAY_2D: 2,+ CHARUCO_OVERLAY_2D: 3,+} as const;++export type BlockKind = typeof BLOCK_KIND[keyof typeof BLOCK_KIND];++export const DTYPE_CODE = {+ FLOAT32: 0,+ FLOAT64: 1,+} as const;++export type DtypeCode = typeof DTYPE_CODE[keyof typeof DTYPE_CODE];++// Fixed string field widths (must match Python CAMERA_ID_BYTES / TRACKER_ID_BYTES)+export const CAMERA_ID_BYTES = 16;+export const TRACKER_ID_BYTES = 32;++// PAYLOAD header / footer (numpy dtype with align=True):+// message_type (u1) at 0+// <7B padding>+// frame_number (i8) at 8+// num_blocks (u4) at 16+// <4B padding>+export const KEYPOINTS_PAYLOAD_HEADER_FIELDS = {+ message_type: { offset: 0, size: 1 },+ frame_number: { offset: 8, size: 8 },+ num_blocks: { offset: 16, size: 4 },+} as const;++export const KEYPOINTS_PAYLOAD_HEADER_SIZE = 24;+export const KEYPOINTS_PAYLOAD_FOOTER_SIZE = 24;++// BLOCK header (numpy dtype with align=True):+// message_type (u1) at 0+// block_kind (u1) at 1+// dtype_code (u1) at 2+// dims (u1) at 3+// camera_id (S16) at 4 -> ends at 20+// tracker_id (S32) at 20 -> ends at 52+// num_points (u4) at 52+// data_byte_length (u4) at 56+// <0B padding> itemsize 60+export const KEYPOINTS_BLOCK_HEADER_FIELDS = {+ message_type: { offset: 0, size: 1 },+ block_kind: { offset: 1, size: 1 },+ dtype_code: { offset: 2, size: 1 },+ dims: { offset: 3, size: 1 },+ camera_id: { offset: 4, size: CAMERA_ID_BYTES },+ tracker_id: { offset: 4 + CAMERA_ID_BYTES, size: TRACKER_ID_BYTES },+ num_points: { offset: 4 + CAMERA_ID_BYTES + TRACKER_ID_BYTES, size: 4 },+ data_byte_length: { offset: 8 + CAMERA_ID_BYTES + TRACKER_ID_BYTES, size: 4 },+} as const;++export const KEYPOINTS_BLOCK_HEADER_SIZE = 12 + CAMERA_ID_BYTES + TRACKER_ID_BYTES; // 60++export function dtypeByteSize(code: DtypeCode): number {+ switch (code) {+ case DTYPE_CODE.FLOAT32: return 4;+ case DTYPE_CODE.FLOAT64: return 8;+ }+}++/** Read a fixed-width null-padded ASCII string from a DataView. */+export function readAsciiField(view: DataView, offset: number, size: number): string {+ const bytes = new Uint8Array(view.buffer, view.byteOffset + offset, size);+ let end = bytes.indexOf(0);+ if (end === -1) end = size;+ let s = "";+ for (let i = 0; i < end; i++) s += String.fromCharCode(bytes[i]);+ return s;+}diff --git a/freemocap-ui/src/services/server/server-helpers/framerate-store.ts b/freemocap-ui/src/services/server/server-helpers/framerate-store.tsindex 03099874..db63f1a6 100644--- a/freemocap-ui/src/services/server/server-helpers/framerate-store.ts+++ b/freemocap-ui/src/services/server/server-helpers/framerate-store.ts@@ -204,8 +204,13 @@ export class FramerateStore {private _frontendStats = new WindowedStats(this._recentFrontendDurations, MAX_DURATION_HISTORY);private _backendStats = new WindowedStats(this._recentBackendDurations, MAX_DURATION_HISTORY);+ private _writeVersion = 0;+ private _snapshotVersion = -1;+ private _cachedSnapshot: FramerateSnapshot | null = null;+updateBackend(data: DetailedFramerate): void {this.currentBackendFramerate = data;+ this._writeVersion++;if (data.mean_frame_duration_ms > 0) {this._recentBackendDurations.push(Date.now(), data.mean_frame_duration_ms);}@@ -213,14 +218,20 @@ export class FramerateStore {updateFrontend(data: DetailedFramerate): void {this.currentFrontendFramerate = data;+ this._writeVersion++;if (data.mean_frame_duration_ms > 0) {this._recentFrontendDurations.push(Date.now(), data.mean_frame_duration_ms);}}- /** Returns a snapshot for React components to read during render. */+ /** Returns a snapshot for React components to read during render.+ * Cached until the next update so polling callers get the same object. */getSnapshot(): FramerateSnapshot {- return {+ if (this._cachedSnapshot && this._snapshotVersion === this._writeVersion) {+ return this._cachedSnapshot;+ }++ this._cachedSnapshot = {currentBackendFramerate: this.currentBackendFramerate,currentFrontendFramerate: this.currentFrontendFramerate,aggregateBackendFramerate: this._backendStats.computeAggregate(@@ -232,6 +243,8 @@ export class FramerateStore {recentFrontendDurations: this._recentFrontendDurations.toArray(),recentBackendDurations: this._recentBackendDurations.toArray(),};+ this._snapshotVersion = this._writeVersion;+ return this._cachedSnapshot;}clear(): void {@@ -239,5 +252,8 @@ export class FramerateStore {this.currentFrontendFramerate = null;this._recentFrontendDurations.clear();this._recentBackendDurations.clear();+ this._writeVersion++;+ this._cachedSnapshot = null;+ this._snapshotVersion = -1;}}diff --git a/freemocap-ui/src/services/server/server-helpers/log-store.ts b/freemocap-ui/src/services/server/server-helpers/log-store.tsindex d0cf1f27..792dce39 100644--- a/freemocap-ui/src/services/server/server-helpers/log-store.ts+++ b/freemocap-ui/src/services/server/server-helpers/log-store.ts@@ -28,11 +28,15 @@ export const LogRecordSchema = z.object({asctime: z.string(),formatted_message: z.string(),type: z.string(),+ // 'ui' for browser console logs, 'server' (default) for backend logs+ source: z.string().optional().default('server'),});export type LogRecord = z.infer<typeof LogRecordSchema>;-const MAX_ENTRIES = 1000;+const MAX_ENTRIES = 10_000;+const STORAGE_KEY = 'freemocap_log_store';+const AUTO_SAVE_INTERVAL_MS = 5_000;export type LogSnapshot = {entries: LogRecord[];@@ -49,6 +53,11 @@ export type LogSnapshot = {* Uses a version counter to avoid copying the entries array when nothing has* changed since the last snapshot. The snapshot's entries array is only* reallocated when new logs have arrived.+ *+ * Persists log entries to localStorage so logs survive page refreshes / app+ * restarts. A divider entry is inserted on each mount to visually separate+ * sessions. Persistence uses a dirty flag + periodic save to avoid serializing+ * the full entries array on every incoming log message.*/export class LogStore {private entries: LogRecord[] = [];@@ -65,6 +74,26 @@ export class LogStore {private cachedEntries: LogRecord[] = [];private cachedCountsByLevel: Record<string, number> = {};+ /** Set when entries change since the last persist. */+ private dirty: boolean = false;++ /** Periodic save timer handle. */+ private saveInterval: ReturnType<typeof setInterval> | null = null;++ constructor() {+ this.restoreFromLocalStorage();+ this.saveInterval = setInterval(() => this.persistIfDirty(), AUTO_SAVE_INTERVAL_MS);+ }++ /** Stop the auto-save timer and flush one last time. Call on teardown. */+ dispose(): void {+ if (this.saveInterval !== null) {+ clearInterval(this.saveInterval);+ this.saveInterval = null;+ }+ this.persistToLocalStorage();+ }+add(record: LogRecord): void {this.entries.push(record);this.version++;@@ -90,6 +119,8 @@ export class LogStore {this.hasErrors = (this.countsByLevel['ERROR'] ?? 0) > 0|| (this.countsByLevel['CRITICAL'] ?? 0) > 0;}++ this.dirty = true;}/**@@ -116,9 +147,120 @@ export class LogStore {this.entries = [];this.countsByLevel = {};this.hasErrors = false;+ this.dirty = false;this.version++;this.cachedEntries = [];this.cachedCountsByLevel = {};this.lastSnapshotVersion = this.version;+ this.clearLocalStorage();+ }++ /** Force an immediate persist (used for beforeunload). */+ persistNow(): void {+ this.persistToLocalStorage();+ }++ // ── private persistence helpers ──────────────────────────────────────++ private persistIfDirty(): void {+ if (this.dirty) {+ this.persistToLocalStorage();+ }+ }++ private persistToLocalStorage(): void {+ try {+ localStorage.setItem(STORAGE_KEY, JSON.stringify(this.entries));+ this.dirty = false;+ } catch {+ // localStorage full or unavailable — silently ignore+ }+ }++ private restoreFromLocalStorage(): void {+ try {+ const raw = localStorage.getItem(STORAGE_KEY);+ if (!raw) return;++ const parsed = JSON.parse(raw);+ if (!Array.isArray(parsed) || parsed.length === 0) return;++ // Validate each entry (schema-safe against future changes)+ const restored: LogRecord[] = [];+ for (const item of parsed) {+ const result = LogRecordSchema.safeParse(item);+ if (result.success) {+ restored.push(result.data);+ }+ }++ if (restored.length === 0) return;++ // Truncate to capacity, leaving room for the divider + new logs+ if (restored.length >= MAX_ENTRIES) {+ restored.splice(0, restored.length - MAX_ENTRIES + 1);+ }++ this.entries = restored;++ // Recalculate aggregate state from restored entries+ this.countsByLevel = {};+ this.hasErrors = false;+ for (const entry of this.entries) {+ if (entry.type === 'divider') continue;+ const lvl = entry.levelname;+ this.countsByLevel[lvl] = (this.countsByLevel[lvl] || 0) + 1;+ if (lvl === 'ERROR' || lvl === 'CRITICAL') {+ this.hasErrors = true;+ }+ }++ this.addDivider();+ this.version++;+ } catch {+ // Corrupted data — start fresh+ }+ }++ private addDivider(): void {+ const now = new Date();+ const divider: LogRecord = {+ name: '',+ msg: '',+ args: [],+ levelname: 'DIVIDER',+ levelno: -1,+ pathname: '',+ filename: '',+ module: '',+ exc_info: null,+ exc_text: null,+ stack_info: null,+ lineno: 0,+ funcName: '',+ created: now.getTime() / 1000,+ msecs: now.getMilliseconds(),+ relativeCreated: 0,+ thread: 0,+ threadName: '',+ processName: '',+ process: 0,+ delta_t: '',+ message: '────── App restarted ──────',+ asctime: now.toLocaleString(),+ formatted_message: '',+ type: 'divider',+ source: 'system',+ };+ this.entries.push(divider);+ this.dirty = true;+ }++ private clearLocalStorage(): void {+ try {+ localStorage.removeItem(STORAGE_KEY);+ } catch {+ // ignore+ }}}diff --git a/freemocap-ui/src/services/server/server-helpers/offscreen-renderer.worker.ts b/freemocap-ui/src/services/server/server-helpers/offscreen-renderer.worker.tsindex 78e55f3a..36ceda36 100644--- a/freemocap-ui/src/services/server/server-helpers/offscreen-renderer.worker.ts+++ b/freemocap-ui/src/services/server/server-helpers/offscreen-renderer.worker.ts@@ -10,6 +10,15 @@ let stats = {totalRenderTime: 0};+let renderLoopScheduled = false;++function scheduleRenderLoop() {+ if (!renderLoopScheduled) {+ renderLoopScheduled = true;+ requestAnimationFrame(renderLoop);+ }+}+self.onmessage = (e) => {const { type } = e.data;@@ -33,10 +42,7 @@ function initCanvas(data) {// Use ImageBitmapRenderingContext - fastest for bitmap streamingctx = offscreenCanvas.getContext('bitmaprenderer');-- // Start render loop- renderLoop();-+self.postMessage({ type: 'initialized' });}@@ -64,9 +70,13 @@ function handleFrame(data) {stats.framesDropped++;}pendingFrame = bitmap;++ // Wake up the render loop if it is idle.+ scheduleRenderLoop();}function renderLoop() {+ renderLoopScheduled = false;const startTime = performance.now();if (pendingFrame && !isRendering) {@@ -92,9 +102,11 @@ function renderLoop() {isRendering = false;lastRenderTime = performance.now();++ // If another frame arrived while we were rendering, keep going.+ if (pendingFrame) {+ scheduleRenderLoop();+ }}-- // Use requestAnimationFrame in worker for smooth rendering- requestAnimationFrame(renderLoop);}`;diff --git a/freemocap-ui/src/services/server/server-helpers/websocket-message-types.ts b/freemocap-ui/src/services/server/server-helpers/websocket-message-types.tsindex 7ffc3b1f..3747aa73 100644--- a/freemocap-ui/src/services/server/server-helpers/websocket-message-types.ts+++ b/freemocap-ui/src/services/server/server-helpers/websocket-message-types.ts@@ -1,3 +1,4 @@+import {z} from 'zod';import {CharucoObservation,CharucoOverlayDataMessage,@@ -88,18 +89,23 @@ export function isTrackerSchemas(data: any): data is TrackerSchemasMessage {);}-export interface PosthocProgressMessage {- message_type: 'posthoc_progress';- pipeline_id: string;- phase: string;- progress_fraction: number;- detail: string;-}+export const PosthocProgressSchema = z.object({+ message_type: z.literal('posthoc_progress'),+ pipeline_id: z.string(),+ pipeline_type: z.string(),+ phase: z.string(),+ progress_fraction: z.number().min(0).max(1),+ detail: z.string().default(''),+ recording_name: z.string().default(''),+ recording_path: z.string().default(''),+});++export type PosthocProgressMessage = z.infer<typeof PosthocProgressSchema>;export function isPosthocProgress(data: unknown): data is PosthocProgressMessage {- return (- typeof data === 'object' &&- data !== null &&- (data as PosthocProgressMessage).message_type === 'posthoc_progress'- );+ const result = PosthocProgressSchema.safeParse(data);+ if (!result.success && typeof data === 'object' && data !== null && (data as Record<string, unknown>).message_type === 'posthoc_progress') {+ console.error('[WS] posthoc_progress message failed schema validation:', result.error.format(), data);+ }+ return result.success;}diff --git a/freemocap-ui/src/store/camera-config-listener.ts b/freemocap-ui/src/store/camera-config-listener.tsnew file mode 100644index 00000000..d26f7bc1--- /dev/null+++ b/freemocap-ui/src/store/camera-config-listener.ts@@ -0,0 +1,39 @@+import {createListenerMiddleware, ListenerEffectAPI} from '@reduxjs/toolkit';+import {cameraDesiredConfigUpdated, configCopiedToAll, recommendExposureForAll} from './slices/cameras/cameras-slice';+import {camerasConnectOrUpdate} from './slices/cameras/cameras-thunks';+import {RootState} from './types';++export const cameraConfigListenerMiddleware = createListenerMiddleware();++// Applies desired config to the backend when auto-apply is enabled.+// Debounced so rapid sequential changes coalesce into a single request.+// Errors are silently swallowed — cameras may not be connected yet when changes come in.+const autoApply = async (_: unknown, api: ListenerEffectAPI<any, any>) => {+ const state = api.getState() as RootState;+ if (!state.cameras.autoApply) return;++ // debounce: supersede any queued request so only the last value is sent+ api.cancelActiveListeners();+ await api.delay(350);++ try {+ await api.dispatch(camerasConnectOrUpdate()).unwrap();+ } catch {+ // no-op: backend may be unavailable or no cameras selected+ }+};++cameraConfigListenerMiddleware.startListening({+ actionCreator: cameraDesiredConfigUpdated,+ effect: autoApply,+});++cameraConfigListenerMiddleware.startListening({+ actionCreator: configCopiedToAll,+ effect: autoApply,+});++cameraConfigListenerMiddleware.startListening({+ actionCreator: recommendExposureForAll,+ effect: autoApply,+});diff --git a/freemocap-ui/src/store/index.ts b/freemocap-ui/src/store/index.tsindex 803e80ea..68de5457 100644--- a/freemocap-ui/src/store/index.ts+++ b/freemocap-ui/src/store/index.ts@@ -12,3 +12,4 @@ export * from './slices/realtime';export * from './slices/mocap';export * from './slices/pipelines';export * from './slices/blender';+export * from './slices/active-recording';diff --git a/freemocap-ui/src/store/persistence-listener.ts b/freemocap-ui/src/store/persistence-listener.tsnew file mode 100644index 00000000..4c6f131b--- /dev/null+++ b/freemocap-ui/src/store/persistence-listener.ts@@ -0,0 +1,96 @@+import {createListenerMiddleware} from '@reduxjs/toolkit';+import {RootState} from './types';+import {saveToStorage} from './persistence';++export const persistenceListenerMiddleware = createListenerMiddleware();++// How long to wait after the last change before writing to localStorage.+// Rapid sequential actions (e.g. dragging a slider) collapse into one write.+const DEBOUNCE_MS = 300;++// ─── activeRecording ──────────────────────────────────────────────────────────+// Only persist the 3 user-meaningful fields; 'origin' is transient.+persistenceListenerMiddleware.startListening({+ predicate: (_, curr, prev) => {+ const c = (curr as RootState).activeRecording;+ const p = (prev as RootState).activeRecording;+ return c.recordingName !== p.recordingName+ || c.baseDirectory !== p.baseDirectory+ || c.layoutPreset !== p.layoutPreset;+ },+ effect: async (_, api) => {+ api.cancelActiveListeners();+ await api.delay(DEBOUNCE_MS);+ const s = api.getState() as RootState;+ saveToStorage('activeRecording', {+ recordingName: s.activeRecording.recordingName,+ baseDirectory: s.activeRecording.baseDirectory,+ layoutPreset: s.activeRecording.layoutPreset,+ });+ },+});++// ─── recording.config ─────────────────────────────────────────────────────────+persistenceListenerMiddleware.startListening({+ predicate: (_, curr, prev) =>+ (curr as RootState).recording.config !== (prev as RootState).recording.config,+ effect: async (_, api) => {+ api.cancelActiveListeners();+ await api.delay(DEBOUNCE_MS);+ saveToStorage('recording.config', (api.getState() as RootState).recording.config);+ },+});++// ─── recording.directory ──────────────────────────────────────────────────────+persistenceListenerMiddleware.startListening({+ predicate: (_, curr, prev) =>+ (curr as RootState).recording.recordingDirectory !== (prev as RootState).recording.recordingDirectory,+ effect: async (_, api) => {+ api.cancelActiveListeners();+ await api.delay(DEBOUNCE_MS);+ saveToStorage('recording.directory', (api.getState() as RootState).recording.recordingDirectory);+ },+});++// ─── calibration.config ───────────────────────────────────────────────────────+persistenceListenerMiddleware.startListening({+ predicate: (_, curr, prev) =>+ (curr as RootState).calibration.config !== (prev as RootState).calibration.config,+ effect: async (_, api) => {+ api.cancelActiveListeners();+ await api.delay(DEBOUNCE_MS);+ saveToStorage('calibration.config', (api.getState() as RootState).calibration.config);+ },+});++// ─── mocap.config ─────────────────────────────────────────────────────────────+persistenceListenerMiddleware.startListening({+ predicate: (_, curr, prev) =>+ (curr as RootState).mocap.config !== (prev as RootState).mocap.config,+ effect: async (_, api) => {+ api.cancelActiveListeners();+ await api.delay(DEBOUNCE_MS);+ saveToStorage('mocap.config', (api.getState() as RootState).mocap.config);+ },+});++// ─── blender.settings ─────────────────────────────────────────────────────────+persistenceListenerMiddleware.startListening({+ predicate: (_, curr, prev) => {+ const c = (curr as RootState).blender;+ const p = (prev as RootState).blender;+ return c.blenderExePath !== p.blenderExePath+ || c.exportToBlenderEnabled !== p.exportToBlenderEnabled+ || c.autoOpenBlendFile !== p.autoOpenBlendFile;+ },+ effect: async (_, api) => {+ api.cancelActiveListeners();+ await api.delay(DEBOUNCE_MS);+ const s = api.getState() as RootState;+ saveToStorage('blender.settings', {+ blenderExePath: s.blender.blenderExePath,+ exportToBlenderEnabled: s.blender.exportToBlenderEnabled,+ autoOpenBlendFile: s.blender.autoOpenBlendFile,+ });+ },+});diff --git a/freemocap-ui/src/store/persistence.ts b/freemocap-ui/src/store/persistence.tsnew file mode 100644index 00000000..76f90238--- /dev/null+++ b/freemocap-ui/src/store/persistence.ts@@ -0,0 +1,18 @@+const PREFIX = 'freemocap:';++export function loadFromStorage<T>(key: string, fallback: T): T {+ if (typeof localStorage === 'undefined') return fallback;+ const raw = localStorage.getItem(PREFIX + key);+ if (raw === null) return fallback;+ try {+ return JSON.parse(raw) as T;+ } catch {+ localStorage.removeItem(PREFIX + key);+ return fallback;+ }+}++export function saveToStorage<T>(key: string, value: T): void {+ if (typeof localStorage === 'undefined') return;+ localStorage.setItem(PREFIX + key, JSON.stringify(value));+}diff --git a/freemocap-ui/src/store/slices/active-recording/active-recording-slice.ts b/freemocap-ui/src/store/slices/active-recording/active-recording-slice.tsnew file mode 100644index 00000000..aca38ecb--- /dev/null+++ b/freemocap-ui/src/store/slices/active-recording/active-recording-slice.ts@@ -0,0 +1,160 @@+import {createSelector, createSlice, PayloadAction} from '@reduxjs/toolkit';+import {RootState} from '@/store/types';+import {startRecording, stopRecording} from '@/store/slices/recording/recording-thunks';+import {buildRecordingStructure, RecordingStructure} from './recording-structure';+import type {RecordingLayoutPresetName} from './layout-presets/layout-presets';+import {loadFromStorage} from '@/store/persistence';++export type ActiveRecordingOrigin =+ | 'pending-capture'+ | 'just-captured'+ | 'browsed'+ | 'auto-latest';++export interface ActiveRecordingState {+ baseDirectory: string;+ recordingName: string | null;+ origin: ActiveRecordingOrigin | null;+ layoutPreset: RecordingLayoutPresetName;+}++const DEFAULT_BASE_DIRECTORY = '~/freemocap_data/recordings';+const DEFAULT_LAYOUT_PRESET: RecordingLayoutPresetName = 'canonical';++interface PersistedActiveRecording {+ recordingName: string | null;+ baseDirectory: string;+ layoutPreset: RecordingLayoutPresetName;+}++const _persisted = loadFromStorage<PersistedActiveRecording | null>('activeRecording', null);++const initialState: ActiveRecordingState = {+ baseDirectory: _persisted?.baseDirectory ?? DEFAULT_BASE_DIRECTORY,+ recordingName: _persisted?.recordingName ?? null,+ // Normalize origin on restore — 'just-captured' and 'auto-latest' are transient+ origin: _persisted?.recordingName ? 'browsed' : null,+ layoutPreset: _persisted?.layoutPreset ?? DEFAULT_LAYOUT_PRESET,+};++export interface ActiveRecordingSetPayload {+ recordingName: string;+ origin: ActiveRecordingOrigin;+ baseDirectory?: string;+ layoutPreset?: RecordingLayoutPresetName;+}++export const splitParentAndName = (fullPath: string): {baseDirectory: string; recordingName: string} | null => {+ const normalized = fullPath.replace(/\\/g, '/').replace(/\/+$/, '');+ const lastSlash = normalized.lastIndexOf('/');+ if (lastSlash <= 0) return null;+ return {+ baseDirectory: normalized.substring(0, lastSlash),+ recordingName: normalized.substring(lastSlash + 1),+ };+};++export const activeRecordingSlice = createSlice({+ name: 'activeRecording',+ initialState,+ reducers: {+ activeRecordingSet: (state, action: PayloadAction<ActiveRecordingSetPayload>) => {+ state.recordingName = action.payload.recordingName;+ state.origin = action.payload.origin;+ if (action.payload.baseDirectory) {+ state.baseDirectory = action.payload.baseDirectory;+ }+ state.layoutPreset = action.payload.layoutPreset ?? DEFAULT_LAYOUT_PRESET;+ },+ activeRecordingBaseDirectoryChanged: (state, action: PayloadAction<string>) => {+ state.baseDirectory = action.payload;+ },+ activeRecordingLayoutSet: (state, action: PayloadAction<RecordingLayoutPresetName>) => {+ state.layoutPreset = action.payload;+ },+ activeRecordingCleared: (state) => {+ state.recordingName = null;+ state.origin = 'pending-capture';+ state.layoutPreset = DEFAULT_LAYOUT_PRESET;+ },+ },+ extraReducers: (builder) => {+ // Clear active recording as soon as a new capture begins so playback doesn't show stale data+ builder.addCase(startRecording.pending, (state) => {+ state.recordingName = null;+ state.origin = 'pending-capture';+ state.layoutPreset = DEFAULT_LAYOUT_PRESET;+ });++ builder.addCase(stopRecording.fulfilled, (state, action) => {+ if (!action.payload) return;+ const parsed = splitParentAndName(action.payload.recording_path);+ if (parsed) {+ state.baseDirectory = parsed.baseDirectory;+ state.recordingName = parsed.recordingName;+ } else {+ state.recordingName = action.payload.recording_name;+ }+ state.origin = 'just-captured';+ state.layoutPreset = DEFAULT_LAYOUT_PRESET;+ });+ },+});++export const {+ activeRecordingSet,+ activeRecordingBaseDirectoryChanged,+ activeRecordingLayoutSet,+ activeRecordingCleared,+} = activeRecordingSlice.actions;++// ==================== Selectors ====================++export const selectActiveRecording = (state: RootState) => state.activeRecording;+export const selectActiveRecordingName = (state: RootState) => state.activeRecording.recordingName;+export const selectActiveRecordingBaseDirectory = (state: RootState) => state.activeRecording.baseDirectory;+export const selectActiveRecordingOrigin = (state: RootState) => state.activeRecording.origin;+export const selectActiveRecordingLayoutPreset = (state: RootState) => state.activeRecording.layoutPreset;++export const selectHasActiveRecording = createSelector(+ [selectActiveRecordingName],+ (name): boolean => name !== null && name.length > 0,+);++export const selectActiveRecordingStructure = createSelector(+ [selectActiveRecordingBaseDirectory, selectActiveRecordingName, selectActiveRecordingLayoutPreset],+ (baseDirectory, recordingName, layoutPreset): RecordingStructure | null => {+ if (!recordingName) return null;+ return buildRecordingStructure({baseDirectory, recordingName}, {preset: layoutPreset});+ },+);++export const selectActiveRecordingFullPath = createSelector(+ [selectActiveRecordingStructure],+ (structure): string | null => structure?.fullPath ?? null,+);++export const selectEffectiveRecordingPath = createSelector(+ [selectActiveRecordingFullPath],+ (activePath): string | null => activePath ?? null,+);++export const selectActiveRecordingCalibrationTomlPath = createSelector(+ [selectActiveRecordingStructure],+ (structure): string | null => structure?.calibrationTomlPath ?? null,+);++export const selectActiveRecordingDataParquetPath = createSelector(+ [selectActiveRecordingStructure],+ (structure): string | null => structure?.dataParquetPath ?? null,+);++export const selectActiveRecordingVideosSynchronizedDir = createSelector(+ [selectActiveRecordingStructure],+ (structure): string | null => structure?.videosSynchronizedDir ?? null,+);++export const selectActiveRecordingVideosAnnotatedDir = createSelector(+ [selectActiveRecordingStructure],+ (structure): string | null => structure?.videosAnnotatedDir ?? null,+);diff --git a/freemocap-ui/src/store/slices/active-recording/index.ts b/freemocap-ui/src/store/slices/active-recording/index.tsnew file mode 100644index 00000000..ba79aff0--- /dev/null+++ b/freemocap-ui/src/store/slices/active-recording/index.ts@@ -0,0 +1,2 @@+export * from './active-recording-slice';+export * from './recording-structure';diff --git a/freemocap-ui/src/store/slices/active-recording/layout-presets/layout-presets.ts b/freemocap-ui/src/store/slices/active-recording/layout-presets/layout-presets.tsnew file mode 100644index 00000000..291ab277--- /dev/null+++ b/freemocap-ui/src/store/slices/active-recording/layout-presets/layout-presets.ts@@ -0,0 +1,58 @@+import {load as parseYaml} from 'js-yaml';+import {z} from 'zod';++import layoutPresetsYaml from './layout-presets.yaml?raw';++export const PATH_TEMPLATE_FIELDS = [+ 'videosSynchronizedDir',+ 'videosAnnotatedDir',+ 'outputDir',+ 'logsDir',+ 'calibrationTomlPath',+ 'recordingInfoPath',+ 'dataParquetPath',+ 'blendPath',+] as const;++export type PathTemplateField = (typeof PATH_TEMPLATE_FIELDS)[number];++const PathTemplatesSchema = z.object({+ videosSynchronizedDir: z.string(),+ videosAnnotatedDir: z.string(),+ outputDir: z.string(),+ logsDir: z.string(),+ calibrationTomlPath: z.string(),+ recordingInfoPath: z.string(),+ dataParquetPath: z.string(),+ blendPath: z.string(),+});++export type PathTemplates = z.infer<typeof PathTemplatesSchema>;++export const LayoutPresetsFileSchema = z.object({+ canonical: PathTemplatesSchema,+ legacy_v1: PathTemplatesSchema,+});++export type RecordingLayoutPresetName = keyof z.infer<typeof LayoutPresetsFileSchema>;++const parsed = parseYaml(layoutPresetsYaml);+export const LAYOUT_PRESETS = LayoutPresetsFileSchema.parse(parsed);++export const RECORDING_LAYOUT_PRESET_NAMES: readonly RecordingLayoutPresetName[] =+ Object.keys(LAYOUT_PRESETS) as RecordingLayoutPresetName[];++const TOKEN_RE = /\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;++export const renderPathTemplate = (+ template: string,+ context: {fullPath: string; recordingName: string},+): string => {+ return template.replace(TOKEN_RE, (_, token: string) => {+ if (token === 'fullPath') return context.fullPath;+ if (token === 'recordingName') return context.recordingName;+ throw new Error(+ `Unknown token "{${token}}" in layout-preset path template: ${template}`,+ );+ });+};diff --git a/freemocap-ui/src/store/slices/active-recording/layout-presets/layout-presets.yaml b/freemocap-ui/src/store/slices/active-recording/layout-presets/layout-presets.yamlnew file mode 100644index 00000000..0ee6ab51--- /dev/null+++ b/freemocap-ui/src/store/slices/active-recording/layout-presets/layout-presets.yaml@@ -0,0 +1,31 @@+# Recording folder layout presets.+#+# Tokens in path templates:+# {fullPath} -> {baseDirectory}/{recordingName}+# {recordingName} -> the recording folder name+#+# Templates are passed through joinPath at resolution time for separator+# normalization, so forward slashes are canonical here.+#+# Keep in sync with the backend RecordingStructure spec at+# freemocap/system/recording_structure/recording_structure.py++canonical:+ videosSynchronizedDir: "{fullPath}/videos/synchronized"+ videosAnnotatedDir: "{fullPath}/videos/annotated"+ outputDir: "{fullPath}/output"+ logsDir: "{fullPath}/logs"+ calibrationTomlPath: "{fullPath}/{recordingName}_calibration.toml"+ recordingInfoPath: "{fullPath}/{recordingName}_recording_info.json"+ dataParquetPath: "{fullPath}/{recordingName}_data.parquet"+ blendPath: "{fullPath}/{recordingName}.blend"++legacy_v1:+ videosSynchronizedDir: "{fullPath}/synchronized_videos"+ videosAnnotatedDir: "{fullPath}/annotated_videos"+ outputDir: "{fullPath}/output_data"+ logsDir: "{fullPath}/logs"+ calibrationTomlPath: "{fullPath}/{recordingName}_camera_calibration.toml"+ recordingInfoPath: "{fullPath}/{recordingName}_recording_info.json"+ dataParquetPath: "{fullPath}/output_data/freemocap_data_by_frame.parquet"+ blendPath: "{fullPath}/{recordingName}.blend"diff --git a/freemocap-ui/src/store/slices/active-recording/recording-structure.ts b/freemocap-ui/src/store/slices/active-recording/recording-structure.tsnew file mode 100644index 00000000..4997df88--- /dev/null+++ b/freemocap-ui/src/store/slices/active-recording/recording-structure.ts@@ -0,0 +1,171 @@+import {z} from 'zod';++import {+ LAYOUT_PRESETS,+ PATH_TEMPLATE_FIELDS,+ type PathTemplates,+ type RecordingLayoutPresetName,+ renderPathTemplate,+} from './layout-presets/layout-presets';++/**+ * Canonical folder layout for a freemocap recording.+ *+ * A recording is a single self-contained folder. Calibration / mocap are+ * *recording types* (tagged in `recording_info.json`), not separate folders.+ *+ * {base_dir}/{recording_name}/+ * ├── videos/+ * │ ├── synchronized/ (camera-sync raw videos)+ * │ └── annotated/ (videos with keypoint overlays)+ * ├── output/ (split mocap artifacts)+ * ├── logs/+ * ├── {recording_name}_calibration.toml (may be copied from another recording)+ * ├── {recording_name}_recording_info.json (camera configs, type tags, metadata)+ * ├── {recording_name}_data.parquet (primary mocap data store)+ * └── {recording_name}.blend (optional Blender export)+ *+ * Matches the backend `RecordingStructure` Pydantic model (source of truth spec+ * lives alongside that file). Any change here should be mirrored server-side.+ *+ * Path resolution is preset-driven: see ./layout-presets/layout-presets.yaml for+ * the canonical + legacy preset definitions.+ */++export const RecordingIdentitySchema = z.object({+ baseDirectory: z.string(),+ recordingName: z.string(),+});++export type RecordingIdentity = z.infer<typeof RecordingIdentitySchema>;++export interface RecordingStructure {+ baseDirectory: string;+ recordingName: string;+ fullPath: string;+ layoutPreset: RecordingLayoutPresetName;+ videosSynchronizedDir: string;+ videosAnnotatedDir: string;+ outputDir: string;+ logsDir: string;+ calibrationTomlPath: string;+ recordingInfoPath: string;+ dataParquetPath: string;+ blendPath: string;+}++export const joinPath = (...parts: string[]): string => {+ return parts+ .map((part, idx) => idx === 0 ? part.replace(/[\\/]+$/, '') : part.replace(/^[\\/]+|[\\/]+$/g, ''))+ .filter(part => part.length > 0)+ .join('/');+};++export type RecordingLayoutOverrides = Partial<PathTemplates>;++export interface BuildRecordingStructureOptions {+ preset?: RecordingLayoutPresetName;+ overrides?: RecordingLayoutOverrides;+}++export const buildRecordingStructure = (+ identity: RecordingIdentity,+ options: BuildRecordingStructureOptions = {},+): RecordingStructure => {+ const {baseDirectory, recordingName} = identity;+ const preset = options.preset ?? 'canonical';+ const overrides = options.overrides ?? {};+ const presetTemplates = LAYOUT_PRESETS[preset];+ const fullPath = joinPath(baseDirectory, recordingName);+ const ctx = {fullPath, recordingName};++ const resolved = PATH_TEMPLATE_FIELDS.reduce((acc, field) => {+ const template = overrides[field] ?? presetTemplates[field];+ acc[field] = joinPath(renderPathTemplate(template, ctx));+ return acc;+ }, {} as Record<(typeof PATH_TEMPLATE_FIELDS)[number], string>);++ return {+ baseDirectory,+ recordingName,+ fullPath,+ layoutPreset: preset,+ ...resolved,+ };+};++export const RecordingTypeTagSchema = z.enum(['calibration', 'mocap']);+export type RecordingTypeTag = z.infer<typeof RecordingTypeTagSchema>;++export const RecordingInfoJsonSchema = z.object({+ recording_name: z.string(),+ recording_types: z.array(RecordingTypeTagSchema).default([]),+ created_at: z.string().nullable().optional(),+ camera_configs: z.record(z.string(), z.unknown()).optional(),+ notes: z.string().nullable().optional(),+}).passthrough();++export type RecordingInfoJson = z.infer<typeof RecordingInfoJsonSchema>;++export const synthesizeRecordingInfoStub = (recordingName: string): RecordingInfoJson => ({+ recording_name: recordingName,+ recording_types: [],+});++/**+ * Mirrors the backend `RecordingLayoutValidation` Pydantic model. Field names+ * are snake_case to match the JSON wire format emitted by FastAPI.+ */+export const FilePresenceSchema = z.object({+ path: z.string(),+ exists: z.boolean(),+ size_bytes: z.number().nullable().optional(),+});++export type FilePresence = z.infer<typeof FilePresenceSchema>;++export const RecordingLayoutValidationSchema = z.object({+ full_path: z.string(),+ is_legacy_layout: z.boolean().default(false),+ videos_synchronized: FilePresenceSchema,+ videos_annotated: FilePresenceSchema,+ output_dir: FilePresenceSchema,+ calibration_toml: FilePresenceSchema,+ recording_info: FilePresenceSchema,+ data_parquet: FilePresenceSchema,+ blend: FilePresenceSchema,+ synchronized_videos_dir: FilePresenceSchema,+ annotated_videos_dir: FilePresenceSchema,+ output_data_dir: FilePresenceSchema,+ camera_calibration_toml: FilePresenceSchema,+ legacy_parquet_in_output_data: FilePresenceSchema,+});++export type RecordingLayoutValidation = z.infer<typeof RecordingLayoutValidationSchema>;++export const LEGACY_MARKER_FIELDS = [+ 'synchronized_videos_dir',+ 'annotated_videos_dir',+ 'output_data_dir',+ 'camera_calibration_toml',+ 'legacy_parquet_in_output_data',+] as const satisfies readonly (keyof RecordingLayoutValidation)[];++export const detectLayoutPreset = (+ validation: RecordingLayoutValidation,+): RecordingLayoutPresetName => {+ const legacy = LEGACY_MARKER_FIELDS.some(+ (field) => (validation[field] as FilePresence).exists,+ );+ const canonical =+ validation.videos_synchronized.exists ||+ validation.data_parquet.exists ||+ validation.calibration_toml.exists;+ // half-migrated folders prefer canonical+ return legacy && !canonical ? 'legacy_v1' : 'canonical';+};++export const listDetectedLegacyMarkers = (+ validation: RecordingLayoutValidation,+): readonly (typeof LEGACY_MARKER_FIELDS)[number][] =>+ LEGACY_MARKER_FIELDS.filter((field) => (validation[field] as FilePresence).exists);diff --git a/freemocap-ui/src/store/slices/blender/blender-slice.ts b/freemocap-ui/src/store/slices/blender/blender-slice.tsindex 5939ce1c..b5f7f920 100644--- a/freemocap-ui/src/store/slices/blender/blender-slice.ts+++ b/freemocap-ui/src/store/slices/blender/blender-slice.ts@@ -1,6 +1,7 @@import {createSlice, PayloadAction} from '@reduxjs/toolkit';import {RootState} from '@/store/types';import {detectBlender, exportRecordingToBlender, openRecordingInBlender} from './blender-thunks';+import {loadFromStorage} from '@/store/persistence';export interface BlenderState {blenderExePath: string | null;@@ -14,11 +15,19 @@ export interface BlenderState {error: string | null;}+interface PersistedBlenderSettings {+ blenderExePath: string | null;+ exportToBlenderEnabled: boolean;+ autoOpenBlendFile: boolean;+}++const _persistedBlender = loadFromStorage<PersistedBlenderSettings | null>('blender.settings', null);+const initialState: BlenderState = {- blenderExePath: null,+ blenderExePath: _persistedBlender?.blenderExePath ?? null,detectedBlenderExePath: null,- exportToBlenderEnabled: true,- autoOpenBlendFile: true,+ exportToBlenderEnabled: _persistedBlender?.exportToBlenderEnabled ?? true,+ autoOpenBlendFile: _persistedBlender?.autoOpenBlendFile ?? true,isExporting: false,isDetecting: false,isOpening: false,diff --git a/freemocap-ui/src/store/slices/blender/blender-thunks.ts b/freemocap-ui/src/store/slices/blender/blender-thunks.tsindex 7c017d24..e80a99aa 100644--- a/freemocap-ui/src/store/slices/blender/blender-thunks.ts+++ b/freemocap-ui/src/store/slices/blender/blender-thunks.ts@@ -2,6 +2,7 @@ import {createAsyncThunk} from '@reduxjs/toolkit';import {RootState} from '@/store/types';import {serverUrls} from '@/services';import {getDetailedErrorMessage} from '@/store/slices/thunk-helpers';+import {selectActiveRecordingFullPath} from '@/store/slices/active-recording/active-recording-slice';interface DetectBlenderResult {blenderExePath: string | null;@@ -51,8 +52,7 @@ export const exportRecordingToBlender = createAsyncThunk<const blender = state.blender;const recordingFolderPath =(arg && arg.recordingFolderPath) ||- state.mocap.manualMocapRecordingPath ||- state.mocap.lastMocapRecordingPath;+ selectActiveRecordingFullPath(state);if (!recordingFolderPath) {return rejectWithValue('No recording folder path available for Blender export');@@ -103,8 +103,7 @@ export const openRecordingInBlender = createAsyncThunk<const blender = state.blender;const recordingFolderPath =(arg && arg.recordingFolderPath) ||- state.mocap.manualMocapRecordingPath ||- state.mocap.lastMocapRecordingPath;+ selectActiveRecordingFullPath(state);if (!recordingFolderPath) {return rejectWithValue('No recording folder path available to open in Blender');diff --git a/freemocap-ui/src/store/slices/calibration/calibration-slice.ts b/freemocap-ui/src/store/slices/calibration/calibration-slice.tsindex 82a718fa..6c272b25 100644--- a/freemocap-ui/src/store/slices/calibration/calibration-slice.ts+++ b/freemocap-ui/src/store/slices/calibration/calibration-slice.ts@@ -1,30 +1,27 @@import {createSelector, createSlice, PayloadAction} from '@reduxjs/toolkit';import {RootState} from '../../types';+import {loadFromStorage} from '@/store/persistence';import {calibrateRecording,loadCalibrationForRecording,loadCalibrationToml,startCalibrationRecording,stopCalibrationRecording,-} from "@/store/slices/calibration/calibration-thunks";--// ==================== Types ====================--export type CalibrationSolverMethod = 'anipose' | 'pyceres';--export interface CharucoBoardConfig {- squares_x: number;- squares_y: number;- square_length_mm: number;-}--export interface CalibrationConfig {- charucoBoard: CharucoBoardConfig;- minSharedViewsPerCamera: number;- autoStopOnMinViewCount: boolean;- solverMethod: CalibrationSolverMethod;- useGroundplane: boolean;-}+} from '@/store/slices/calibration/calibration-thunks';+import {+ selectActiveRecordingFullPath,+ selectActiveRecordingOrigin,+ selectEffectiveRecordingPath,+} from '@/store/slices/active-recording/active-recording-slice';++export type {+ CalibrationSolverMethod,+ CharucoBoardConfig,+ CalibrationConfig,+ CalibrationCameraData,+ LoadedCalibration,+} from './calibration-types';+import type { CalibrationConfig, LoadedCalibration } from './calibration-types';export interface CalibrationDirectoryInfo {exists: boolean;@@ -37,59 +34,36 @@ export interface CalibrationDirectoryInfo {errorMessage: string | null;}-export interface CalibrationCameraData {- id: string;- name: string;- size: [number, number];- matrix: number[][];- distortions: number[];- rotation: [number, number, number];- translation: [number, number, number];- world_orientation: number[][];- world_position: [number, number, number];-}--export interface LoadedCalibration {- path: string;- mtimeMs: number;- cameras: CalibrationCameraData[];- metadata: Record<string, any> | null;-}-export interface CalibrationState {config: CalibrationConfig;isRecording: boolean;recordingProgress: number;isLoading: boolean;error: string | null;- lastCalibrationRecordingPath: string | null;- manualCalibrationRecordingPath: string | null;directoryInfo: CalibrationDirectoryInfo | null;loadedCalibration: LoadedCalibration | null;}-// ==================== Initial State ====================+const DEFAULT_CALIBRATION_CONFIG: CalibrationConfig = {+ charucoBoard: { squares_x: 5, squares_y: 3, square_length_mm: 54 },+ minSharedViewsPerCamera: 200,+ autoStopOnMinViewCount: true,+ solverMethod: 'anipose',+ useGroundplane: false,+};++const _persistedCalibrationConfig = loadFromStorage<CalibrationConfig | null>('calibration.config', null);const initialState: CalibrationState = {- config: {- charucoBoard: { squares_x: 5, squares_y: 3, square_length_mm: 54 },- minSharedViewsPerCamera: 200,- autoStopOnMinViewCount: true,- solverMethod: 'anipose',- useGroundplane: false,- },+ config: _persistedCalibrationConfig ?? { ...DEFAULT_CALIBRATION_CONFIG },isRecording: false,recordingProgress: 0,isLoading: false,error: null,- lastCalibrationRecordingPath: null,- manualCalibrationRecordingPath: null,directoryInfo: null,loadedCalibration: null,};-// ==================== Slice ====================-export const calibrationSlice = createSlice({name: 'calibration',initialState,@@ -97,47 +71,35 @@ export const calibrationSlice = createSlice({calibrationConfigUpdated: (state, action: PayloadAction<Partial<CalibrationConfig>>) => {state.config = { ...state.config, ...action.payload };},-calibrationProgressUpdated: (state, action: PayloadAction<number>) => {state.recordingProgress = action.payload;},-calibrationErrorCleared: (state) => {state.error = null;},-- manualCalibrationRecordingPathChanged: (state, action: PayloadAction<string>) => {- state.manualCalibrationRecordingPath = action.payload;- },-- manualCalibrationRecordingPathCleared: (state) => {- state.manualCalibrationRecordingPath = null;- },-- lastCalibrationRecordingPathCleared: (state) => {- state.lastCalibrationRecordingPath = null;- },-calibrationDirectoryInfoUpdated: (state, action: PayloadAction<CalibrationDirectoryInfo>) => {state.directoryInfo = action.payload;},-+ calibrationPipelineProgressReceived: (state, action: PayloadAction<{phase: string}>) => {+ if (action.payload.phase === 'complete' || action.payload.phase === 'failed') {+ state.isLoading = false;+ }+ },+ calibrationLoadedFromBundle: (state, action: PayloadAction<LoadedCalibration | null>) => {+ state.loadedCalibration = action.payload;+ },resetCalibrationState: () => initialState,},-extraReducers: (builder) => {builder.addCase(startCalibrationRecording.pending, (state) => {state.isLoading = true;state.error = null;})- .addCase(startCalibrationRecording.fulfilled, (state, action) => {+ .addCase(startCalibrationRecording.fulfilled, (state) => {state.isLoading = false;state.isRecording = true;state.recordingProgress = 0;- if (action.payload.calibrationRecordingPath) {- state.lastCalibrationRecordingPath = action.payload.calibrationRecordingPath;- }}).addCase(startCalibrationRecording.rejected, (state, action) => {state.isLoading = false;@@ -191,13 +153,9 @@ export const calibrationSlice = createSlice({state.isLoading = false;state.error = action.payload || 'Failed to calibrate recording';});--},});-// ==================== Selectors ====================-export const selectCalibration = (state: RootState) => state.calibration;export const selectCalibrationConfig = (state: RootState) => state.calibration.config;export const selectCalibrationIsLoading = (state: RootState) => state.calibration.isLoading;@@ -207,38 +165,22 @@ export const selectCalibrationError = (state: RootState) => state.calibration.erexport const selectCalibrationDirectoryInfo = (state: RootState) => state.calibration.directoryInfo;export const selectLoadedCalibration = (state: RootState) => state.calibration.loadedCalibration;-export const selectCalibrationRecordingPath = createSelector(- [- (state: RootState) => state.calibration.manualCalibrationRecordingPath,- (state: RootState) => state.calibration.lastCalibrationRecordingPath,- (state: RootState) => state.recording.computed,- ],- (manualPath, lastPath, recordingComputed) => {- if (manualPath) return manualPath;- if (lastPath) return lastPath;-- const calibrationFolderName = `${recordingComputed.recordingName}_calibration`;- return `${recordingComputed.fullRecordingPath}/${calibrationFolderName}`;- }-);+export const selectCalibrationRecordingPath = selectActiveRecordingFullPath;export const selectIsUsingManualCalibrationPath = createSelector(- [- (state: RootState) => state.calibration.manualCalibrationRecordingPath,- (state: RootState) => state.calibration.lastCalibrationRecordingPath,- ],- (manualPath, lastPath) => manualPath !== null || lastPath !== null+ [selectActiveRecordingOrigin],+ (origin) => origin === 'browsed',);export const selectCanStartCalibrationRecording = createSelector([selectCalibrationIsRecording,selectCalibrationIsLoading,- selectCalibrationRecordingPath,+ selectEffectiveRecordingPath,selectCalibrationDirectoryInfo],- (isRecording, isLoading, recordingPath, directoryInfo) => {- return !isRecording && !isLoading && !!recordingPath && (directoryInfo?.canRecord ?? true);+ (isRecording, isLoading, effectivePath, directoryInfo) => {+ return !isRecording && !isLoading && !!effectivePath && (directoryInfo?.canRecord ?? true);});@@ -247,24 +189,24 @@ export const selectCanCalibrate = createSelector(selectCalibrationRecordingPath,selectCalibrationIsLoading,selectCalibrationIsRecording,- selectCalibrationDirectoryInfo+ selectCalibrationDirectoryInfo,],- (calibrationPath, isLoading, isRecording, directoryInfo) => {- return !!calibrationPath && !isLoading && !isRecording && (directoryInfo?.canCalibrate ?? false);+ (recordingPath, isLoading, isRecording, directoryInfo) => {+ return (+ !!recordingPath &&+ !isLoading &&+ !isRecording &&+ (directoryInfo?.canCalibrate ?? true)+ );});-// ==================== Actions Export ====================-export const {calibrationConfigUpdated,calibrationProgressUpdated,calibrationErrorCleared,- manualCalibrationRecordingPathChanged,- manualCalibrationRecordingPathCleared,- lastCalibrationRecordingPathCleared,calibrationDirectoryInfoUpdated,- resetCalibrationState+ calibrationPipelineProgressReceived,+ calibrationLoadedFromBundle,+ resetCalibrationState,} = calibrationSlice.actions;--export default calibrationSlice.reducer;diff --git a/freemocap-ui/src/store/slices/calibration/calibration-thunks.ts b/freemocap-ui/src/store/slices/calibration/calibration-thunks.tsindex 316dccc4..e45529c0 100644--- a/freemocap-ui/src/store/slices/calibration/calibration-thunks.ts+++ b/freemocap-ui/src/store/slices/calibration/calibration-thunks.ts@@ -5,16 +5,22 @@ import {getDetailedErrorMessage} from "@/store/slices/thunk-helpers";import {serverUrls} from "@/services";import {electronIpc} from "@/services/electron-ipc/electron-ipc";import type {LoadedCalibration} from "./calibration-slice";+import {pipelineProgressUpdated, PipelinePhase, PipelineType} from "@/store/slices/pipelines";export const loadCalibrationForRecording = createAsyncThunk<LoadedCalibration | null,- string,+ { recordingId: string; recordingParentDirectory?: string | null },{ state: RootState; rejectValue: string }>('calibration/loadCalibrationForRecording',- async (recordingId, { rejectWithValue }) => {+ async ({ recordingId, recordingParentDirectory }, { rejectWithValue }) => {try {- const url = `${serverUrls.getHttpUrl()}/freemocap/playback/${encodeURIComponent(recordingId)}/calibration`;+ const params = new URLSearchParams();+ if (recordingParentDirectory) {+ params.set('recording_parent_directory', recordingParentDirectory);+ }+ const qs = params.toString();+ const url = `${serverUrls.getHttpUrl()}/freemocap/playback/${encodeURIComponent(recordingId)}/calibration${qs ? `?${qs}` : ''}`;const resp = await fetch(url);if (resp.status === 404) {console.warn(`[calibration] No calibration found for recording: ${recordingId}`);@@ -101,12 +107,12 @@ export const startCalibrationRecording = createAsyncThunk<);export const stopCalibrationRecording = createAsyncThunk<- { success: boolean },+ { success: boolean; pipeline_id?: string; recording_name?: string; recording_path?: string },void,{ state: RootState; rejectValue: string }>('calibration/stopRecording',- async (_, { getState, rejectWithValue }) => {+ async (_, { getState, rejectWithValue, dispatch }) => {try {const state = getState();const calibrationTaskConfig = state.calibration.config;@@ -128,6 +134,17 @@ export const stopCalibrationRecording = createAsyncThunk<const result = await response.json();console.log('✅ Stopped calibration recording:', result);+ if (result.pipeline_id) {+ dispatch(pipelineProgressUpdated({+ pipelineId: result.pipeline_id,+ pipelineType: PipelineType.CALIBRATION,+ phase: PipelinePhase.QUEUED,+ progress: 0,+ detail: 'Pipeline queued, starting workers...',+ recordingName: result.recording_name ?? '',+ recordingPath: result.recording_path ?? '',+ }));+ }return result;} catch (error) {const errorMessage = error instanceof Error ? error.message : 'Unknown error';@@ -138,12 +155,12 @@ export const stopCalibrationRecording = createAsyncThunk<);export const calibrateRecording = createAsyncThunk<- { success: boolean; message?: string; results?: unknown },+ { success: boolean; message?: string; results?: unknown; pipeline_id?: string },void,{ state: RootState; rejectValue: string }>('calibration/calibrateRecording',- async (_, { getState, rejectWithValue }) => {+ async (_, { getState, rejectWithValue, dispatch }) => {try {const state = getState();const calibrationTaskConfig = state.calibration.config;@@ -171,6 +188,17 @@ export const calibrateRecording = createAsyncThunk<const result = await response.json();console.log('✅ Calibration completed:', result);+ if (result.pipeline_id) {+ dispatch(pipelineProgressUpdated({+ pipelineId: result.pipeline_id,+ pipelineType: PipelineType.CALIBRATION,+ phase: PipelinePhase.QUEUED,+ progress: 0,+ detail: 'Pipeline queued, starting workers...',+ recordingName: calibrationRecordingDirectory?.split(/[/\\]/).pop() ?? '',+ recordingPath: calibrationRecordingDirectory ?? '',+ }));+ }return result;} catch (error) {const errorMessage = error instanceof Error ? error.message : 'Unknown error';diff --git a/freemocap-ui/src/store/slices/calibration/calibration-types.ts b/freemocap-ui/src/store/slices/calibration/calibration-types.tsnew file mode 100644index 00000000..e3cfd9b0--- /dev/null+++ b/freemocap-ui/src/store/slices/calibration/calibration-types.ts@@ -0,0 +1,34 @@+export type CalibrationSolverMethod = 'anipose' | 'pyceres';++export interface CharucoBoardConfig {+ squares_x: number;+ squares_y: number;+ square_length_mm: number;+}++export interface CalibrationConfig {+ charucoBoard: CharucoBoardConfig;+ minSharedViewsPerCamera: number;+ autoStopOnMinViewCount: boolean;+ solverMethod: CalibrationSolverMethod;+ useGroundplane: boolean;+}++export interface CalibrationCameraData {+ id: string;+ name: string;+ size: [number, number];+ matrix: number[][];+ distortions: number[];+ rotation: [number, number, number];+ translation: [number, number, number];+ world_orientation: number[][];+ world_position: [number, number, number];+}++export interface LoadedCalibration {+ path: string;+ mtimeMs: number;+ cameras: CalibrationCameraData[];+ metadata: Record<string, any> | null;+}diff --git a/freemocap-ui/src/store/slices/cameras/camera-settings-storage.ts b/freemocap-ui/src/store/slices/cameras/camera-settings-storage.tsindex 984c4888..860ccd7e 100644--- a/freemocap-ui/src/store/slices/cameras/camera-settings-storage.ts+++ b/freemocap-ui/src/store/slices/cameras/camera-settings-storage.ts@@ -5,6 +5,7 @@ const STORAGE_KEY = 'freemocap-camera-settings';// What we persist per camera: the user-tunable settings + selection stateexport interface PersistedCameraSettings {selected: boolean;+ realtimeEnabled: boolean;desiredConfig: Partial<CameraConfig>;}@@ -40,9 +41,11 @@ export function clearPersistedCameraSettings(): void {export function buildPersistedEntry(desiredConfig: CameraConfig,selected: boolean,+ realtimeEnabled: boolean,): PersistedCameraSettings {return {selected,+ realtimeEnabled,desiredConfig: extractConfigSettings(desiredConfig),};}diff --git a/freemocap-ui/src/store/slices/cameras/cameras-selectors.ts b/freemocap-ui/src/store/slices/cameras/cameras-selectors.tsindex 72be5043..bdb8db47 100644--- a/freemocap-ui/src/store/slices/cameras/cameras-selectors.ts+++ b/freemocap-ui/src/store/slices/cameras/cameras-selectors.ts@@ -7,6 +7,7 @@ import {CameraConfig} from './cameras-types';export const selectCameras = (state: RootState) => state.cameras.cameras;export const selectIsPaused = (state: RootState) => state.cameras.isPaused;export const selectIsLoading = (state: RootState) => state.cameras.isLoading;+export const selectAutoApply = (state: RootState) => state.cameras.autoApply;export const selectError = (state: RootState) => state.cameras.error;// ========== Derived Selectors ==========@@ -39,6 +40,22 @@ export const selectSelectedCameraConfigs = createSelector(});+// Get desired configs for cameras enabled for the realtime pipeline (selected AND realtimeEnabled)+export const selectRealtimeEnabledCameraConfigs = createSelector(+ [selectCameras],+ (cameras): Record<string, CameraConfig> => {+ return cameras+ .filter(cam => cam.selected && cam.realtimeEnabled)+ .reduce(+ (configs, camera) => ({+ ...configs,+ [camera.id]: camera.desiredConfig,+ }),+ {} as Record<string, CameraConfig>+ );+ }+);+// Get actual configs for all camerasexport const selectActualCameraConfigs = createSelector([selectCameras],diff --git a/freemocap-ui/src/store/slices/cameras/cameras-slice.ts b/freemocap-ui/src/store/slices/cameras/cameras-slice.tsindex 2ba77650..db92004a 100644--- a/freemocap-ui/src/store/slices/cameras/cameras-slice.ts+++ b/freemocap-ui/src/store/slices/cameras/cameras-slice.ts@@ -7,7 +7,7 @@ import {createDefaultCameraConfig,extractConfigSettings,} from './cameras-types';-import {camerasConnectOrUpdate, closeCameras, detectCameras, pauseUnpauseCameras,} from './cameras-thunks';+import {camerasConnectOrUpdate, closeCameras, detectCameras, pauseUnpauseCameras, recommendExposureSent,} from './cameras-thunks';import {buildPersistedEntry,clearPersistedCameraSettings,@@ -19,7 +19,7 @@ import {function persistAllCameraSettings(state: CamerasState): void {const settingsMap: PersistedCameraSettingsMap = {};for (const camera of state.cameras) {- settingsMap[camera.id] = buildPersistedEntry(camera.desiredConfig, camera.selected);+ settingsMap[camera.id] = buildPersistedEntry(camera.desiredConfig, camera.selected, camera.realtimeEnabled);}savePersistedCameraSettings(settingsMap);}@@ -28,6 +28,7 @@ const initialState: CamerasState = {cameras: [],isPaused: false,isLoading: false,+ autoApply: true,error: null,};@@ -41,6 +42,17 @@ export const cameraSlice = createSlice({if (camera) {camera.selected = !camera.selected;camera.desiredConfig.use_this_camera = camera.selected;+ if (!camera.selected) {+ camera.realtimeEnabled = false;+ }+ }+ persistAllCameraSettings(state);+ },++ cameraRealtimeToggled: (state, action: PayloadAction<string>) => {+ const camera = state.cameras.find(cam => cam.id === action.payload);+ if (camera) {+ camera.realtimeEnabled = !camera.realtimeEnabled;}persistAllCameraSettings(state);},@@ -85,6 +97,18 @@ export const cameraSlice = createSlice({persistAllCameraSettings(state);},+ recommendExposureForAll: (state) => {+ state.cameras.forEach(camera => {+ camera.desiredConfig = { ...camera.desiredConfig, exposure_mode: 'RECOMMEND' };+ camera.hasConfigMismatch = !areConfigsEqual(camera.actualConfig, camera.desiredConfig);+ });+ persistAllCameraSettings(state);+ },++ autoApplyToggled: (state) => {+ state.autoApply = !state.autoApply;+ },+savedSettingsCleared: (state) => {clearPersistedCameraSettings();for (const camera of state.cameras) {@@ -95,6 +119,7 @@ export const cameraSlice = createSlice({);camera.desiredConfig = defaultConfig;camera.selected = true;+ camera.realtimeEnabled = true;camera.hasConfigMismatch = !areConfigsEqual(camera.actualConfig, defaultConfig);}},@@ -119,6 +144,16 @@ export const cameraSlice = createSlice({state.error = action.error.message || 'Failed to detect cameras';})+ // ========== Recommend Exposure Sent ==========+ .addCase(recommendExposureSent, (state) => {+ state.cameras.forEach(camera => {+ if (camera.desiredConfig.exposure_mode === 'RECOMMEND') {+ camera.desiredConfig = { ...camera.desiredConfig, exposure_mode: 'MANUAL' };+ }+ });+ persistAllCameraSettings(state);+ })+// ========== Connect Cameras ==========.addCase(camerasConnectOrUpdate.pending, (state) => {state.isLoading = true;@@ -165,7 +200,10 @@ export const cameraSlice = createSlice({export const {cameraSelectionToggled,+ cameraRealtimeToggled,cameraDesiredConfigUpdated,configCopiedToAll,+ recommendExposureForAll,+ autoApplyToggled,savedSettingsCleared,} = cameraSlice.actions;diff --git a/freemocap-ui/src/store/slices/cameras/cameras-thunks.ts b/freemocap-ui/src/store/slices/cameras/cameras-thunks.tsindex 1d40b39e..6fe2404e 100644--- a/freemocap-ui/src/store/slices/cameras/cameras-thunks.ts+++ b/freemocap-ui/src/store/slices/cameras/cameras-thunks.ts@@ -1,5 +1,5 @@// cameras-thunks.ts-import {createAsyncThunk} from '@reduxjs/toolkit';+import {createAction, createAsyncThunk} from '@reduxjs/toolkit';import {RootState} from '../../types';import {serverUrls} from '@/services';import {@@ -18,6 +18,11 @@ import {savePersistedCameraSettings,} from './camera-settings-storage';+// Dispatched before a connect request that includes RECOMMEND mode cameras.+// Handled by the slice to optimistically flip RECOMMEND → MANUAL so the UI+// clears immediately and the listener doesn't re-trigger during the long request.+export const recommendExposureSent = createAction('cameras/recommendExposureSent');+export const detectCameras = createAsyncThunk<Camera[],DetectCamerasRequest | undefined,@@ -48,9 +53,10 @@ export const detectCameras = createAsyncThunk<// Storage was corrupted and has been cleared — proceed with defaults}- const detectedIds = new Set(data.cameras.map(c => c.index.toString()));+ const detectedIds = new Set(data.cameras.map(c => c.camera_id));++ // Prune persisted entries for cameras that are no longer detected.- // Prune persisted entries for cameras that are no longer detectedconst prunedPersisted: PersistedCameraSettingsMap = {};for (const [id, settings] of Object.entries(persisted)) {if (detectedIds.has(id)) {@@ -60,7 +66,7 @@ export const detectCameras = createAsyncThunk<savePersistedCameraSettings(prunedPersisted);return data.cameras.map((serverCamera): Camera => {- const cameraId = serverCamera.index.toString();+ const cameraId = serverCamera.camera_id;const existing = existingCameras.find(cam => cam.id === cameraId);const saved = prunedPersisted[cameraId];@@ -78,6 +84,10 @@ export const detectCameras = createAsyncThunk<?? saved?.selected?? true;+ const realtimeEnabled: boolean = existing?.realtimeEnabled+ ?? saved?.realtimeEnabled+ ?? true;+return {id: cameraId,name: serverCamera.name,@@ -87,6 +97,7 @@ export const detectCameras = createAsyncThunk<hasConfigMismatch: existing?.hasConfigMismatch ?? false,connectionStatus: 'available',selected,+ realtimeEnabled,deviceInfo: {vendorId: serverCamera.vendor_id,productId: serverCamera.product_id,@@ -103,7 +114,7 @@ export const camerasConnectOrUpdate = createAsyncThunk<{ state: RootState }>('cameras/connect',- async (_, { getState }) => {+ async (_, { getState, dispatch }) => {const state = getState();const cameraConfigs = selectSelectedCameraConfigs(state);@@ -111,13 +122,33 @@ export const camerasConnectOrUpdate = createAsyncThunk<throw new Error('No cameras selected for connection');}+ const hasRecommend = Object.values(cameraConfigs).some(+ c => c.exposure_mode === 'RECOMMEND'+ );+const request: CamerasConnectOrUpdateRequest = { camera_configs: cameraConfigs };- const response = await fetch(serverUrls.endpoints.camerasConnectOrUpdate, {- method: 'POST',- headers: { 'Content-Type': 'application/json' },- body: JSON.stringify(request),- });+ // Optimistically flip RECOMMEND → MANUAL before the request goes out so+ // the UI clears immediately and the listener won't queue another call.+ if (hasRecommend) {+ dispatch(recommendExposureSent());+ }++ // RECOMMEND triggers a slow backend algorithm; give it enough time.+ const timeoutMs = hasRecommend ? 60_000 : 3_000;+ const controller = new AbortController();+ const timeout = setTimeout(() => controller.abort(), timeoutMs);+ let response: Response;+ try {+ response = await fetch(serverUrls.endpoints.camerasConnectOrUpdate, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify(request),+ signal: controller.signal,+ });+ } finally {+ clearTimeout(timeout);+ }if (!response.ok) {const error = await response.json();diff --git a/freemocap-ui/src/store/slices/cameras/cameras-types.ts b/freemocap-ui/src/store/slices/cameras/cameras-types.tsindex 640ac3e4..cc88b9f4 100644--- a/freemocap-ui/src/store/slices/cameras/cameras-types.ts+++ b/freemocap-ui/src/store/slices/cameras/cameras-types.ts@@ -72,6 +72,7 @@ export interface Camera {hasConfigMismatch: boolean; // Whether actual differs from desiredconnectionStatus: 'available' | 'connected' | 'error'; // Connection stateselected: boolean; // UI selection state+ realtimeEnabled: boolean; // Whether to include in realtime pipeline// Device info (from detection)deviceInfo: {@@ -93,6 +94,7 @@ export interface CamerasState {cameras: Camera[];isPaused: boolean;isLoading: boolean;+ autoApply: boolean;error: string | null;}@@ -103,6 +105,7 @@ export interface DetectCamerasRequest {export interface DetectCamerasResponse {cameras: Array<{+ camera_id: string;index: number;name: string;vendor_id?: string;diff --git a/freemocap-ui/src/store/slices/mocap/mocap-slice.ts b/freemocap-ui/src/store/slices/mocap/mocap-slice.tsindex d2aaeb97..ca3888ca 100644--- a/freemocap-ui/src/store/slices/mocap/mocap-slice.ts+++ b/freemocap-ui/src/store/slices/mocap/mocap-slice.ts@@ -1,10 +1,16 @@import {createSelector, createSlice, PayloadAction} from '@reduxjs/toolkit';import {RootState} from '../../types';+import {loadFromStorage} from '@/store/persistence';import {processMocapRecording,startMocapRecording,stopMocapRecording,} from "@/store/slices/mocap/mocap-thunks";+import {+ selectActiveRecordingFullPath,+ selectActiveRecordingOrigin,+ selectEffectiveRecordingPath,+} from "@/store/slices/active-recording/active-recording-slice";// ==================== Types ====================@@ -139,8 +145,6 @@ export interface MocapState {recordingProgress: number;isLoading: boolean;error: string | null;- lastMocapRecordingPath: string | null;- manualMocapRecordingPath: string | null;directoryInfo: MocapDirectoryInfo | null;/** User-specified calibration TOML path override. null = use most recent (default). */calibrationTomlPath: string | null;@@ -150,8 +154,10 @@ export interface MocapState {// ==================== Initial State ====================+const _persistedMocapConfig = loadFromStorage<MocapConfig | null>('mocap.config', null);+const initialState: MocapState = {- config: {+ config: _persistedMocapConfig ?? {detector: { ...MEDIAPIPE_REALTIME_PRESET },skeleton_filter: { ...DEFAULT_REALTIME_FILTER_CONFIG },},@@ -159,8 +165,6 @@ const initialState: MocapState = {recordingProgress: 0,isLoading: false,error: null,- lastMocapRecordingPath: null,- manualMocapRecordingPath: null,directoryInfo: null,calibrationTomlPath: null,processingProgress: 0,@@ -201,18 +205,6 @@ export const mocapSlice = createSlice({state.error = null;},- manualMocapRecordingPathChanged: (state, action: PayloadAction<string>) => {- state.manualMocapRecordingPath = action.payload;- },-- manualMocapRecordingPathCleared: (state) => {- state.manualMocapRecordingPath = null;- },-- lastMocapRecordingPathCleared: (state) => {- state.lastMocapRecordingPath = null;- },-mocapDirectoryInfoUpdated: (state, action: PayloadAction<MocapDirectoryInfo>) => {state.directoryInfo = action.payload;},@@ -242,13 +234,10 @@ export const mocapSlice = createSlice({state.isLoading = true;state.error = null;})- .addCase(startMocapRecording.fulfilled, (state, action) => {+ .addCase(startMocapRecording.fulfilled, (state) => {state.isLoading = false;state.isRecording = true;state.recordingProgress = 0;- if (action.payload.mocapRecordingPath) {- state.lastMocapRecordingPath = action.payload.mocapRecordingPath;- }}).addCase(startMocapRecording.rejected, (state, action) => {state.isLoading = false;@@ -304,38 +293,22 @@ export const selectCalibrationTomlPath = (state: RootState) => state.mocap.calibexport const selectProcessingProgress = (state: RootState) => state.mocap.processingProgress;export const selectProcessingPhase = (state: RootState) => state.mocap.processingPhase;-export const selectMocapRecordingPath = createSelector(- [- (state: RootState) => state.mocap.manualMocapRecordingPath,- (state: RootState) => state.mocap.lastMocapRecordingPath,- (state: RootState) => state.recording.computed,- ],- (manualPath, lastPath, recordingComputed) => {- if (manualPath) return manualPath;- if (lastPath) return lastPath;-- const mocapFolderName = `${recordingComputed.recordingName}_mocap`;- return `${recordingComputed.fullRecordingPath}/${mocapFolderName}`;- }-);+export const selectMocapRecordingPath = selectActiveRecordingFullPath;export const selectIsUsingManualMocapPath = createSelector(- [- (state: RootState) => state.mocap.manualMocapRecordingPath,- (state: RootState) => state.mocap.lastMocapRecordingPath,- ],- (manualPath, lastPath) => manualPath !== null || lastPath !== null+ [selectActiveRecordingOrigin],+ (origin) => origin === 'browsed',);export const selectCanStartMocapRecording = createSelector([selectMocapIsRecording,selectMocapIsLoading,- selectMocapRecordingPath,+ selectEffectiveRecordingPath,selectMocapDirectoryInfo],- (isRecording, isLoading, recordingPath, directoryInfo) => {- return !isRecording && !isLoading && !!recordingPath && (directoryInfo?.canRecord ?? true);+ (isRecording, isLoading, effectivePath, directoryInfo) => {+ return !isRecording && !isLoading && !!effectivePath && (directoryInfo?.canRecord ?? true);});@@ -366,9 +339,6 @@ export const {skeletonFilterConfigUpdated,mocapProgressUpdated,mocapErrorCleared,- manualMocapRecordingPathChanged,- manualMocapRecordingPathCleared,- lastMocapRecordingPathCleared,mocapDirectoryInfoUpdated,calibrationTomlPathChanged,calibrationTomlPathCleared,diff --git a/freemocap-ui/src/store/slices/mocap/mocap-thunks.ts b/freemocap-ui/src/store/slices/mocap/mocap-thunks.tsindex f23ee01c..df1752b2 100644--- a/freemocap-ui/src/store/slices/mocap/mocap-thunks.ts+++ b/freemocap-ui/src/store/slices/mocap/mocap-thunks.ts@@ -3,6 +3,7 @@ import {RootState} from "@/store";import {selectMocapRecordingPath} from "./mocap-slice";import {getDetailedErrorMessage} from "@/store/slices/thunk-helpers";import {serverUrls} from "@/services";+import {pipelineProgressUpdated, PipelinePhase, PipelineType} from "@/store/slices/pipelines";export const startMocapRecording = createAsyncThunk<{ success: boolean; message?: string; mocapRecordingPath?: string },@@ -61,12 +62,12 @@ export const startMocapRecording = createAsyncThunk<);export const stopMocapRecording = createAsyncThunk<- { success: boolean },+ { success: boolean; pipeline_id?: string; recording_name?: string; recording_path?: string },void,{ state: RootState; rejectValue: string }>('mocap/stopRecording',- async (_, { getState, rejectWithValue }) => {+ async (_, { getState, rejectWithValue, dispatch }) => {try {const state = getState();const mocapTaskConfig = state.mocap.config;@@ -97,6 +98,17 @@ export const stopMocapRecording = createAsyncThunk<const result = await response.json();console.log('✅ Stopped mocap recording:', result);+ if (result.pipeline_id) {+ dispatch(pipelineProgressUpdated({+ pipelineId: result.pipeline_id,+ pipelineType: PipelineType.MOCAP,+ phase: PipelinePhase.QUEUED,+ progress: 0,+ detail: 'Pipeline queued, starting workers...',+ recordingName: result.recording_name ?? '',+ recordingPath: result.recording_path ?? '',+ }));+ }return result;} catch (error) {const errorMessage = error instanceof Error ? error.message : 'Unknown error';@@ -107,12 +119,12 @@ export const stopMocapRecording = createAsyncThunk<);export const processMocapRecording = createAsyncThunk<- { success: boolean; message?: string; results?: unknown },+ { success: boolean; message?: string; results?: unknown; pipeline_id?: string },void,{ state: RootState; rejectValue: string }>('mocap/processMocapRecording',- async (_, { getState, rejectWithValue }) => {+ async (_, { getState, rejectWithValue, dispatch }) => {try {const state = getState();const mocapTaskConfig = state.mocap.config;@@ -153,6 +165,17 @@ export const processMocapRecording = createAsyncThunk<const result = await response.json();console.log('✅ Mocap completed:', result);+ if (result.pipeline_id) {+ dispatch(pipelineProgressUpdated({+ pipelineId: result.pipeline_id,+ pipelineType: PipelineType.MOCAP,+ phase: PipelinePhase.QUEUED,+ progress: 0,+ detail: 'Pipeline queued, starting workers...',+ recordingName: mocapRecordingDirectory?.split(/[/\\]/).pop() ?? '',+ recordingPath: mocapRecordingDirectory ?? '',+ }));+ }return result;} catch (error) {const errorMessage = error instanceof Error ? error.message : 'Unknown error';diff --git a/freemocap-ui/src/store/slices/pipelines/pipelines-slice.ts b/freemocap-ui/src/store/slices/pipelines/pipelines-slice.tsindex c8f6e576..d1687b19 100644--- a/freemocap-ui/src/store/slices/pipelines/pipelines-slice.ts+++ b/freemocap-ui/src/store/slices/pipelines/pipelines-slice.ts@@ -1,5 +1,6 @@import {createSelector, createSlice, PayloadAction} from '@reduxjs/toolkit';import {RootState} from '../../types';+import {stopAllPipelines, stopPipeline} from './pipelines-thunks';// ==================== Pipeline Types ====================@@ -10,6 +11,7 @@ export const PipelineType = {export type PipelineType = (typeof PipelineType)[keyof typeof PipelineType];export const PipelinePhase = {+ QUEUED: 'queued',SETTING_UP: 'setting_up',PROCESSING_VIDEOS: 'processing_videos',AGGREGATING: 'aggregating',@@ -19,7 +21,18 @@ export const PipelinePhase = {} as const;export type PipelinePhase = (typeof PipelinePhase)[keyof typeof PipelinePhase];+export interface PipelineTypeConfig {+ label: string;+ color: string;+}++export const PIPELINE_TYPE_CONFIG: Record<PipelineType, PipelineTypeConfig> = {+ [PipelineType.CALIBRATION]: {label: 'Calibration', color: '#26C6DA'},+ [PipelineType.MOCAP]: {label: 'Mocap', color: '#AB47BC'},+};+export const PHASE_LABELS: Record<PipelinePhase, string> = {+ [PipelinePhase.QUEUED]: 'Queued',[PipelinePhase.SETTING_UP]: 'Setting Up',[PipelinePhase.PROCESSING_VIDEOS]: 'Processing Videos',[PipelinePhase.AGGREGATING]: 'Aggregating',@@ -34,6 +47,8 @@ export interface PipelineProgress {phase: PipelinePhase;progress: number; // 0-100detail: string;+ recordingName: string;+ recordingPath: string;completedAt?: number; // timestamp when completed/failed}@@ -41,18 +56,42 @@ export interface PipelineProgress {interface PipelinesState {activePipelines: Record<string, PipelineProgress>;+ dismissedBasePipelineIds: string[];showCompleted: boolean;filterText: string;+ snackbarVisible: boolean;}const initialState: PipelinesState = {activePipelines: {},+ dismissedBasePipelineIds: [],showCompleted: false,filterText: '',+ snackbarVisible: false,};// ==================== Slice ====================+function forceBasePipelineFailed(state: PipelinesState, baseId: string, detail: string) {+ const now = Date.now();+ for (const [id, p] of Object.entries(state.activePipelines)) {+ const colonIdx = id.indexOf(':');+ const thisBase = colonIdx !== -1 ? id.slice(0, colonIdx) : id;+ if (thisBase === baseId && p.phase !== PipelinePhase.COMPLETE && p.phase !== PipelinePhase.FAILED) {+ state.activePipelines[id] = {...p, phase: PipelinePhase.FAILED, detail, completedAt: now};+ }+ }+}++function forceAllActiveFailed(state: PipelinesState, detail: string) {+ const now = Date.now();+ for (const [id, p] of Object.entries(state.activePipelines)) {+ if (p.phase !== PipelinePhase.COMPLETE && p.phase !== PipelinePhase.FAILED) {+ state.activePipelines[id] = {...p, phase: PipelinePhase.FAILED, detail, completedAt: now};+ }+ }+}+export const pipelinesSlice = createSlice({name: 'pipelines',initialState,@@ -60,10 +99,22 @@ export const pipelinesSlice = createSlice({pipelineProgressUpdated: (state, action: PayloadAction<PipelineProgress>) => {const incoming = action.payload;const isTerminal = incoming.phase === PipelinePhase.COMPLETE || incoming.phase === PipelinePhase.FAILED;+ // Derive base pipeline ID (everything before the first colon)+ const colonIdx = incoming.pipelineId.indexOf(':');+ const baseId = colonIdx !== -1 ? incoming.pipelineId.slice(0, colonIdx) : incoming.pipelineId;+ // Open snackbar when this base pipeline ID is not yet tracked at all+ const baseIsNew = !Object.keys(state.activePipelines).some(id => {+ const c = id.indexOf(':');+ return (c !== -1 ? id.slice(0, c) : id) === baseId;+ });state.activePipelines[incoming.pipelineId] = {...incoming,completedAt: isTerminal ? Date.now() : undefined,};+ if (baseIsNew) {+ state.snackbarVisible = true;+ state.dismissedBasePipelineIds = state.dismissedBasePipelineIds.filter(id => id !== baseId);+ }},toggleShowCompleted: (state) => {state.showCompleted = !state.showCompleted;@@ -71,6 +122,41 @@ export const pipelinesSlice = createSlice({filterTextChanged: (state, action: PayloadAction<string>) => {state.filterText = action.payload;},+ pipelineSnackbarShown: (state) => {+ state.snackbarVisible = true;+ },+ pipelineSnackbarHidden: (state) => {+ state.snackbarVisible = false;+ },+ pipelineDismissed: (state, action: PayloadAction<string>) => {+ if (!state.dismissedBasePipelineIds.includes(action.payload)) {+ state.dismissedBasePipelineIds.push(action.payload);+ }+ },+ allPipelinesCleared: (state) => {+ state.activePipelines = {};+ state.dismissedBasePipelineIds = [];+ // snackbarVisible intentionally unchanged — panel stays open/closed as-is+ },+ },+ extraReducers: (builder) => {+ // Regardless of whether the server stop succeeded or failed, the user+ // asked to stop — force the UI to a terminal FAILED state so it never+ // gets stuck in an active/running limbo.+ builder+ .addCase(stopPipeline.fulfilled, (state, action) => {+ forceBasePipelineFailed(state, action.payload, 'Stopped by user');+ })+ .addCase(stopPipeline.rejected, (state, action) => {+ const baseId = (action.payload ?? action.meta.arg) as string;+ forceBasePipelineFailed(state, baseId, 'Stop failed — marked stopped');+ })+ .addCase(stopAllPipelines.fulfilled, (state) => {+ forceAllActiveFailed(state, 'Stopped by user');+ })+ .addCase(stopAllPipelines.rejected, (state) => {+ forceAllActiveFailed(state, 'Stop failed — marked stopped');+ });},});@@ -116,8 +202,125 @@ export const selectHasCompletedPipelines = createSelector());+// ==================== Grouped Pipeline Selectors ====================++export interface PipelineGroup {+ basePipelineId: string;+ pipelineType: PipelineType | null;+ videoNodes: PipelineProgress[];+ aggregator: PipelineProgress | null;+ isActive: boolean;+ isFailed: boolean;+ isComplete: boolean;+ recordingName: string;+ recordingPath: string;+}++// Shared base: groups all pipelines into PipelineGroup objects without filtering.+// Both selectGroupedPipelines and selectGroupedPipelinesAll derive from this+// so grouping + flag computation runs only once per pipeline state change.+const selectAllGroupsUnfiltered = createSelector(+ [selectActivePipelines],+ (pipelines) => {+ const groups = new Map<string, PipelineGroup>();++ for (const p of Object.values(pipelines)) {+ const colonIdx = p.pipelineId.indexOf(':');+ const basePipelineId = colonIdx !== -1 ? p.pipelineId.slice(0, colonIdx) : p.pipelineId;++ if (!groups.has(basePipelineId)) {+ groups.set(basePipelineId, {+ basePipelineId,+ pipelineType: null,+ videoNodes: [],+ aggregator: null,+ isActive: false,+ isFailed: false,+ isComplete: false,+ recordingName: '',+ recordingPath: '',+ });+ }+ const group = groups.get(basePipelineId)!;+ if (colonIdx !== -1) {+ group.videoNodes.push(p);+ } else {+ group.aggregator = p;+ }+ }++ const isTerminalPhase = (p: PipelineProgress) =>+ p.phase === PipelinePhase.COMPLETE || p.phase === PipelinePhase.FAILED;++ const result: PipelineGroup[] = [];+ for (const group of groups.values()) {+ const allMembers = [...group.videoNodes, ...(group.aggregator ? [group.aggregator] : [])];++ group.isFailed = allMembers.some((p) => p.phase === PipelinePhase.FAILED);+ group.isComplete = !!group.aggregator && group.aggregator.phase === PipelinePhase.COMPLETE;+ group.isActive = allMembers.some((p) => !isTerminalPhase(p));+ group.recordingName = group.aggregator?.recordingName || group.videoNodes[0]?.recordingName || '';+ group.recordingPath = group.aggregator?.recordingPath || group.videoNodes[0]?.recordingPath || '';+ group.pipelineType = group.aggregator?.pipelineType ?? group.videoNodes[0]?.pipelineType ?? null;++ group.videoNodes.sort((a, b) => a.pipelineId.localeCompare(b.pipelineId));+ result.push(group);+ }++ return result.sort((a, b) => {+ if (a.isActive !== b.isActive) return a.isActive ? -1 : 1;+ return a.basePipelineId.localeCompare(b.basePipelineId);+ });+ }+);++export const selectGroupedPipelines = createSelector(+ [selectAllGroupsUnfiltered, selectShowCompleted, selectFilterText],+ (allGroups, showCompleted, filterText) => {+ const needle = filterText.toLowerCase();++ return allGroups.filter(group => {+ if (!group.isActive && !showCompleted) return false;++ if (needle) {+ const allMembers = [...group.videoNodes, ...(group.aggregator ? [group.aggregator] : [])];+ const match =+ group.basePipelineId.toLowerCase().includes(needle) ||+ allMembers.some(+ (p) =>+ p.detail.toLowerCase().includes(needle) ||+ p.pipelineId.toLowerCase().includes(needle)+ );+ if (!match) return false;+ }++ return true;+ });+ }+);++export const selectGroupedPipelinesAll = selectAllGroupsUnfiltered;++export const selectActiveBasePipelineCount = createSelector(+ [selectActivePipelines],+ (pipelines) => {+ const activeBaseIds = new Set<string>();+ for (const p of Object.values(pipelines)) {+ const isTerminal = p.phase === PipelinePhase.COMPLETE || p.phase === PipelinePhase.FAILED;+ if (!isTerminal) {+ const colonIdx = p.pipelineId.indexOf(':');+ activeBaseIds.add(colonIdx !== -1 ? p.pipelineId.slice(0, colonIdx) : p.pipelineId);+ }+ }+ return activeBaseIds.size;+ }+);+// ==================== Actions Export ====================-export const {pipelineProgressUpdated, toggleShowCompleted, filterTextChanged} = pipelinesSlice.actions;+export const selectSnackbarVisible = (state: RootState) => state.pipelines.snackbarVisible;+export const selectDismissedBasePipelineIds = (state: RootState) => state.pipelines.dismissedBasePipelineIds;++export const {pipelineProgressUpdated, toggleShowCompleted, filterTextChanged, pipelineSnackbarShown, pipelineSnackbarHidden, pipelineDismissed, allPipelinesCleared} = pipelinesSlice.actions;export default pipelinesSlice.reducer;diff --git a/freemocap-ui/src/store/slices/pipelines/pipelines-thunks.ts b/freemocap-ui/src/store/slices/pipelines/pipelines-thunks.tsnew file mode 100644index 00000000..3b6edb2a--- /dev/null+++ b/freemocap-ui/src/store/slices/pipelines/pipelines-thunks.ts@@ -0,0 +1,37 @@+import {createAsyncThunk} from '@reduxjs/toolkit';+import {serverUrls} from '@/constants/server-urls';++export const stopPipeline = createAsyncThunk(+ 'pipelines/stopPipeline',+ async (pipelineId: string, {rejectWithValue}) => {+ try {+ const res = await fetch(serverUrls.endpoints.stopPipeline(pipelineId), {method: 'DELETE'});+ if (!res.ok) {+ const text = await res.text();+ console.error(`[pipelines] stop pipeline ${pipelineId} failed (${res.status}): ${text}`);+ return rejectWithValue(pipelineId);+ }+ } catch (e) {+ console.error(`[pipelines] stop pipeline ${pipelineId} network error:`, e);+ return rejectWithValue(pipelineId);+ }+ return pipelineId;+ },+);++export const stopAllPipelines = createAsyncThunk(+ 'pipelines/stopAllPipelines',+ async (_, {rejectWithValue}) => {+ try {+ const res = await fetch(serverUrls.endpoints.stopAllPipelines, {method: 'DELETE'});+ if (!res.ok) {+ const text = await res.text();+ console.error(`[pipelines] stop all pipelines failed (${res.status}): ${text}`);+ return rejectWithValue(null);+ }+ } catch (e) {+ console.error('[pipelines] stop all pipelines network error:', e);+ return rejectWithValue(null);+ }+ },+);diff --git a/freemocap-ui/src/store/slices/playback-data/playback-data-slice.ts b/freemocap-ui/src/store/slices/playback-data/playback-data-slice.tsnew file mode 100644index 00000000..77e76afa--- /dev/null+++ b/freemocap-ui/src/store/slices/playback-data/playback-data-slice.ts@@ -0,0 +1,195 @@+import {createAsyncThunk, createSlice} from '@reduxjs/toolkit';+import {RootState} from '@/store/types';+import {serverUrls} from '@/services';+import type {RecordingStatusSummary} from '@/types/recording-status';+import type {LoadedCalibration} from '@/store/slices/calibration/calibration-slice';++// ---------------------------------------------------------------------------+// Types matching the backend RecordingBundle response+// ---------------------------------------------------------------------------++export interface PlaybackBundle {+ recordingId: string;+ recordingFps: number | null;+ totalFrames: number | null;+ durationSeconds: number | null;+ videos: {+ preferredSource: string;+ sources: Record<string, {+ available: boolean;+ valid: boolean;+ videoCount: number;+ videos: Array<{+ videoId: string;+ filename: string;+ sizeBytes: number;+ streamUrl: string;+ }>;+ }>;+ };+ timestamps: {+ timestamps?: Record<string, number[]>;+ warnings?: string[];+ };+ calibration: LoadedCalibration | null;+ trackerSchema: Record<string, unknown>;+ statusSummary: RecordingStatusSummary;+}++export interface PerRecordingPlaybackData {+ bundle: PlaybackBundle | null;+ isLoading: boolean;+ error: string | null;+ fetchedAt: number | null;+}++export interface PlaybackDataState {+ byRecordingId: Record<string, PerRecordingPlaybackData>;+}++// ---------------------------------------------------------------------------+// Initial state+// ---------------------------------------------------------------------------++const initialState: PlaybackDataState = {+ byRecordingId: {},+};++const emptyEntry = (): PerRecordingPlaybackData => ({+ bundle: null,+ isLoading: false,+ error: null,+ fetchedAt: null,+});++// ---------------------------------------------------------------------------+// Thunk+// ---------------------------------------------------------------------------++export const fetchPlaybackBundle = createAsyncThunk<+ PlaybackBundle,+ { recordingId: string; recordingParentDirectory?: string | null },+ { state: RootState; rejectValue: string }+>(+ 'playbackData/fetchBundle',+ async ({recordingId, recordingParentDirectory}, {rejectWithValue}) => {+ try {+ const bundleUrl = serverUrls.endpoints.playbackBundle(recordingId);+ const params = new URLSearchParams();+ if (recordingParentDirectory) {+ params.set('recording_parent_directory', recordingParentDirectory);+ }+ const queryString = params.toString();+ const url = queryString ? `${bundleUrl}?${queryString}` : bundleUrl;+ const response = await fetch(url);+ if (!response.ok) {+ throw new Error(`Bundle fetch failed: ${response.status}`);+ }+ const data = await response.json();++ const baseUrl = serverUrls.getHttpUrl();+ const sources: PlaybackBundle['videos']['sources'] = {};+ for (const [key, source] of Object.entries(data.videos?.sources ?? {}) as [string, any][]) {+ sources[key] = {+ available: source.available,+ valid: source.valid,+ videoCount: source.video_count,+ videos: (source.videos || []).map((v: any) => ({+ videoId: v.video_id,+ filename: v.filename,+ sizeBytes: v.size_bytes,+ streamUrl: `${baseUrl}${v.stream_url}`,+ })),+ };+ }++ return {+ recordingId: data.recording_id,+ recordingFps: data.recording_fps ?? null,+ totalFrames: data.total_frames ?? null,+ durationSeconds: data.duration_seconds ?? null,+ videos: {+ preferredSource: data.videos.preferred_source,+ sources,+ },+ timestamps: data.timestamps ?? {},+ calibration: data.calibration ?? null,+ trackerSchema: data.tracker_schema ?? {+ name: 'fallback',+ tracker_type: 'unknown',+ tracked_points: [],+ connections: [],+ landmark_schema: 'generic',+ },+ statusSummary: data.status_summary ?? {},+ };+ } catch (error) {+ return rejectWithValue(+ error instanceof Error ? error.message : 'Unknown error',+ );+ }+ },+ {+ condition: ({recordingId}, {getState}) => {+ const state = getState();+ const existing = state.playbackData.byRecordingId[recordingId];+ if (existing?.bundle || existing?.isLoading) return false;+ return true;+ },+ },+);++// ---------------------------------------------------------------------------+// Slice+// ---------------------------------------------------------------------------++export const playbackDataSlice = createSlice({+ name: 'playbackData',+ initialState,+ reducers: {},+ extraReducers: (builder) => {+ builder+ .addCase(fetchPlaybackBundle.pending, (state, action) => {+ const id = action.meta.arg.recordingId;+ const prev = state.byRecordingId[id] ?? emptyEntry();+ state.byRecordingId[id] = {...prev, isLoading: true, error: null};+ })+ .addCase(fetchPlaybackBundle.fulfilled, (state, action) => {+ const id = action.payload.recordingId;+ state.byRecordingId[id] = {+ bundle: action.payload,+ isLoading: false,+ error: null,+ fetchedAt: Date.now(),+ };+ })+ .addCase(fetchPlaybackBundle.rejected, (state, action) => {+ const id = action.meta.arg.recordingId;+ const prev = state.byRecordingId[id] ?? emptyEntry();+ state.byRecordingId[id] = {+ ...prev,+ isLoading: false,+ error: action.payload ?? 'Failed to fetch playback bundle',+ fetchedAt: null,+ };+ });+ },+});++// ---------------------------------------------------------------------------+// Selectors+// ---------------------------------------------------------------------------++export const selectPlaybackBundle = (recordingId: string | null | undefined) =>+ (state: RootState): PlaybackBundle | null => {+ if (!recordingId) return null;+ return state.playbackData.byRecordingId[recordingId]?.bundle ?? null;+ };++export const selectPlaybackBundleIsLoading = (recordingId: string | null | undefined) =>+ (state: RootState): boolean => {+ if (!recordingId) return false;+ return state.playbackData.byRecordingId[recordingId]?.isLoading ?? false;+ };++export default playbackDataSlice.reducer;diff --git a/freemocap-ui/src/store/slices/realtime/realtime-selectors.ts b/freemocap-ui/src/store/slices/realtime/realtime-selectors.tsindex c6c31e84..e19e332f 100644--- a/freemocap-ui/src/store/slices/realtime/realtime-selectors.ts+++ b/freemocap-ui/src/store/slices/realtime/realtime-selectors.ts@@ -1,5 +1,6 @@import {RootState} from "@/store";import {createSelector} from "@reduxjs/toolkit";+import {selectCameras} from "@/store/slices/cameras";// ==================== Primitive Selectors ====================@@ -16,10 +17,10 @@ export const selectAggregatorConfig = (state: RootState) => state.realtime.pipel// ==================== Derived Selectors ====================export const selectCanConnectPipeline = createSelector(- [selectIsPipelineConnected, selectIsPipelineLoading, (state: RootState) => state.cameras.cameras],+ [selectIsPipelineConnected, selectIsPipelineLoading, selectCameras],(isConnected, isLoading, cameras) => {- const anyCameraSelected = cameras.some(cam => cam.selected);- return !isConnected && !isLoading && anyCameraSelected;+ const anyCameraRealtimeEnabled = cameras.some(cam => cam.selected && cam.realtimeEnabled);+ return !isConnected && !isLoading && anyCameraRealtimeEnabled;});diff --git a/freemocap-ui/src/store/slices/realtime/realtime-slice.ts b/freemocap-ui/src/store/slices/realtime/realtime-slice.tsindex 6e2e8f0d..5841c06a 100644--- a/freemocap-ui/src/store/slices/realtime/realtime-slice.ts+++ b/freemocap-ui/src/store/slices/realtime/realtime-slice.ts@@ -12,7 +12,7 @@ const initialState: PipelineState = {};export const realtimeSlice = createSlice({- name: 'pipeline',+ name: 'realtime',initialState,reducers: {pipelineStateReset: () => initialState,diff --git a/freemocap-ui/src/store/slices/realtime/realtime-thunks.ts b/freemocap-ui/src/store/slices/realtime/realtime-thunks.tsindex 9c8d2d7e..4f54b1db 100644--- a/freemocap-ui/src/store/slices/realtime/realtime-thunks.ts+++ b/freemocap-ui/src/store/slices/realtime/realtime-thunks.ts@@ -1,7 +1,8 @@-import {createAsyncThunk, createSelector} from "@reduxjs/toolkit";-import {RootState, selectSelectedCameraConfigs} from "@/store";+import {createAsyncThunk} from "@reduxjs/toolkit";+import {RootState, selectRealtimeEnabledCameraConfigs, selectSelectedCameraConfigs} from "@/store";import {serverUrls} from "@/services";import {PipelineApplyResponse, RealtimePipelineConfig} from "@/store/slices/realtime/realtime-types";+import {selectCalibrationConfig} from "@/store/slices/calibration/calibration-slice";export const applyRealtimePipeline = createAsyncThunk<PipelineApplyResponse,@@ -11,14 +12,26 @@ export const applyRealtimePipeline = createAsyncThunk<'realtime/apply',async (realtimeConfig, {getState}) => {const cameraConfigs = selectSelectedCameraConfigs(getState());+ const realtimeCameraIds = Object.keys(selectRealtimeEnabledCameraConfigs(getState()));+ const calibrationConfig = selectCalibrationConfig(getState());+ const configWithBoard: RealtimePipelineConfig = {+ ...realtimeConfig,+ camera_node_config: {+ ...realtimeConfig.camera_node_config,+ charuco_detector_config: {+ board: calibrationConfig.charucoBoard,+ },+ },+ };const response = await fetch(serverUrls.endpoints.realtimeConnectOrUpdate, {method: 'POST',headers: {'Content-Type': 'application/json'},body: JSON.stringify({- realtimeConfig,- cameraConfigs+ realtimeConfig: configWithBoard,+ cameraConfigs,+ realtimeCameraIds,}),});diff --git a/freemocap-ui/src/store/slices/realtime/realtime-types.ts b/freemocap-ui/src/store/slices/realtime/realtime-types.tsindex a069356b..d7f4054d 100644--- a/freemocap-ui/src/store/slices/realtime/realtime-types.ts+++ b/freemocap-ui/src/store/slices/realtime/realtime-types.ts@@ -1,8 +1,15 @@export type CalibrationSource = 'most_recent' | 'specified';+export interface CharucoBoardConfigForPipeline {+ squares_x: number;+ squares_y: number;+ square_length_mm: number;+}+export interface CameraNodeConfig {charuco_tracking_enabled: boolean;skeleton_tracking_enabled: boolean;+ charuco_detector_config?: { board: CharucoBoardConfigForPipeline } | null;}export interface RealtimeAggregatorNodeConfig {diff --git a/freemocap-ui/src/store/slices/recording-status/recording-status-slice.ts b/freemocap-ui/src/store/slices/recording-status/recording-status-slice.tsindex 7dcd1416..2b85e41a 100644--- a/freemocap-ui/src/store/slices/recording-status/recording-status-slice.ts+++ b/freemocap-ui/src/store/slices/recording-status/recording-status-slice.ts@@ -1,7 +1,7 @@import {createSlice} from '@reduxjs/toolkit';import {RootState} from '@/store/types';import {RecordingStatus} from '@/types/recording-status';-import {fetchRecordingStatus} from './recording-status-thunks';+import {fetchRecordingStatus, fetchAllRecordings, RecordingListEntry} from './recording-status-thunks';export interface PerRecordingStatusState {status: RecordingStatus | null;@@ -12,10 +12,16 @@ export interface PerRecordingStatusState {export interface RecordingStatusState {byRecordingId: Record<string, PerRecordingStatusState>;+ recordingsList: RecordingListEntry[];+ recordingsFetchedAt: number | null;+ recordingsIsLoading: boolean;}const initialState: RecordingStatusState = {byRecordingId: {},+ recordingsList: [],+ recordingsFetchedAt: null,+ recordingsIsLoading: false,};const emptyEntry = (): PerRecordingStatusState => ({@@ -53,6 +59,29 @@ export const recordingStatusSlice = createSlice({isLoading: false,error: action.payload?.error ?? 'Failed to fetch recording status',};+ })+ .addCase(fetchAllRecordings.pending, (state) => {+ state.recordingsIsLoading = true;+ })+ .addCase(fetchAllRecordings.fulfilled, (state, action) => {+ const {recordings, fetchedAt} = action.payload;+ state.recordingsList = recordings;+ state.recordingsFetchedAt = fetchedAt;+ state.recordingsIsLoading = false;+ // Populate per-recording status entries from the batch response+ for (const rec of recordings) {+ if (rec.status) {+ state.byRecordingId[rec.name] = {+ status: rec.status,+ isLoading: false,+ error: null,+ fetchedAt,+ };+ }+ }+ })+ .addCase(fetchAllRecordings.rejected, (state) => {+ state.recordingsIsLoading = false;});},});@@ -63,4 +92,13 @@ export const selectRecordingStatusEntry = (recordingId: string | null | undefinereturn state.recordingStatus.byRecordingId[recordingId] ?? null;};+export const selectRecordingsList = (state: RootState) =>+ state.recordingStatus.recordingsList;++export const selectRecordingsFetchedAt = (state: RootState) =>+ state.recordingStatus.recordingsFetchedAt;++export const selectRecordingsIsLoading = (state: RootState) =>+ state.recordingStatus.recordingsIsLoading;+export default recordingStatusSlice.reducer;diff --git a/freemocap-ui/src/store/slices/recording-status/recording-status-thunks.ts b/freemocap-ui/src/store/slices/recording-status/recording-status-thunks.tsindex 70d194cc..c228ec91 100644--- a/freemocap-ui/src/store/slices/recording-status/recording-status-thunks.ts+++ b/freemocap-ui/src/store/slices/recording-status/recording-status-thunks.ts@@ -2,7 +2,22 @@ import {createAsyncThunk} from '@reduxjs/toolkit';import {RootState} from '@/store/types';import {serverUrls} from '@/services';import {getDetailedErrorMessage} from '@/store/slices/thunk-helpers';-import {RecordingStatus} from '@/types/recording-status';+import {RecordingStatus, RecordingStatusSummary} from '@/types/recording-status';+import {RecordingLayoutValidation} from '@/store/slices/active-recording/recording-structure';++export interface RecordingListEntry {+ name: string;+ path: string;+ video_count: number;+ total_size_bytes: number;+ created_timestamp: string | null;+ total_frames: number | null;+ duration_seconds: number | null;+ fps: number | null;+ status_summary: RecordingStatusSummary;+ status: RecordingStatus | null;+ layout_validation: RecordingLayoutValidation | null;+}export const fetchRecordingStatus = createAsyncThunk<{ recordingId: string; status: RecordingStatus },@@ -30,3 +45,25 @@ export const fetchRecordingStatus = createAsyncThunk<}});++export const fetchAllRecordings = createAsyncThunk<+ { recordings: RecordingListEntry[]; fetchedAt: number },+ { recordingParentDirectory?: string | null } | undefined,+ { state: RootState }+>(+ 'recordingStatus/fetchAll',+ async (options) => {+ const params = new URLSearchParams();+ if (options?.recordingParentDirectory) {+ params.set('recording_parent_directory', options.recordingParentDirectory);+ }+ const qs = params.toString();+ const url = `${serverUrls.endpoints.playbackRecordings}${qs ? `?${qs}` : ''}`;+ const response = await fetch(url);+ if (!response.ok) {+ throw new Error(`Failed to fetch recordings: ${response.status}`);+ }+ const recordings: RecordingListEntry[] = await response.json();+ return { recordings, fetchedAt: Date.now() };+ }+);diff --git a/freemocap-ui/src/store/slices/recording/recording-slice.ts b/freemocap-ui/src/store/slices/recording/recording-slice.tsindex 86d7f6e9..545c2aa5 100644--- a/freemocap-ui/src/store/slices/recording/recording-slice.ts+++ b/freemocap-ui/src/store/slices/recording/recording-slice.ts@@ -1,6 +1,8 @@import {createSlice, PayloadAction} from '@reduxjs/toolkit';-import {ComputedRecordingPath, RecordingConfig, RecordingInfo} from './recording-types';+import {RootState} from '@/store/types';+import {ComputedRecordingPath, PendingOperation, RecordingConfig, RecordingInfo, RecordingTypePreset} from './recording-types';import {startRecording, stopRecording} from './recording-thunks';+import {loadFromStorage} from '@/store/persistence';const getTimestampString = (): string => {const now = new Date();@@ -64,29 +66,41 @@ const computeRecordingPath = (};};+const DEFAULT_RECORDING_DIRECTORY = '~/freemocap_data/recordings';++const DEFAULT_RECORDING_CONFIG: RecordingConfig = {+ useDelayStart: false,+ delaySeconds: 3,+ useTimestamp: true,+ useIncrement: false,+ currentIncrement: 1,+ baseName: 'recording',+ recordingTag: '',+ createSubfolder: false,+ customSubfolderName: '',+ micDeviceIndex: -1,+ recordingTypePreset: 'none',+ autoProcess: true,+};++const _persistedConfig = loadFromStorage<RecordingConfig | null>('recording.config', null);+const _persistedDirectory = loadFromStorage<string | null>('recording.directory', null);+const initialState: RecordingInfo = {isRecording: false,- recordingDirectory: '~/freemocap_data/recordings',+ recordingDirectory: _persistedDirectory ?? DEFAULT_RECORDING_DIRECTORY,recordingName: null,startedAt: null,duration: 0,completionData: null,- config: {- useDelayStart: false,- delaySeconds: 3,- useTimestamp: true,- useIncrement: false,- currentIncrement: 1,- baseName: 'recording',- recordingTag: '',- createSubfolder: false,- customSubfolderName: '',- },+ config: _persistedConfig ?? { ...DEFAULT_RECORDING_CONFIG },computed: {recordingName: '',subfolderName: '',- fullRecordingPath: '~/freemocap_data/recordings',+ fullRecordingPath: _persistedDirectory ?? DEFAULT_RECORDING_DIRECTORY,},+ pendingOperation: null,+ countdown: null,};// Initialize computed values@@ -158,20 +172,41 @@ export const recordingSlice = createSlice({},// Force recomputation of path (useful for timestamp updates)pathRecomputed: (state) => {- state.computed = computeRecordingPath(state.recordingDirectory, state.config);+ const next = computeRecordingPath(state.recordingDirectory, state.config);+ if (+ next.recordingName === state.computed.recordingName &&+ next.subfolderName === state.computed.subfolderName &&+ next.fullRecordingPath === state.computed.fullRecordingPath+ ) return;+ state.computed = next;},recordingCompletionDismissed: (state) => {state.completionData = null;},+ micDeviceIndexChanged: (state, action: PayloadAction<number>) => {+ state.config.micDeviceIndex = action.payload;+ },+ recordingTypePresetChanged: (state, action: PayloadAction<RecordingTypePreset>) => {+ state.config.recordingTypePreset = action.payload;+ },+ autoProcessToggled: (state, action: PayloadAction<boolean>) => {+ state.config.autoProcess = action.payload;+ },+ pendingOperationSet: (state, action: PayloadAction<PendingOperation | null>) => {+ state.pendingOperation = action.payload;+ },+ countdownSet: (state, action: PayloadAction<number | null>) => {+ state.countdown = action.payload;+ },},extraReducers: (builder) => {builder.addCase(startRecording.fulfilled, (state, action) => {state.isRecording = true;state.recordingName = action.meta.arg.recordingName;- state.recordingDirectory = action.meta.arg.recordingDirectory;state.startedAt = new Date().toISOString();state.duration = 0;+ state.pendingOperation = null;}).addCase(stopRecording.fulfilled, (state, action) => {state.isRecording = false;@@ -179,6 +214,7 @@ export const recordingSlice = createSlice({state.startedAt = null;state.duration = 0;state.completionData = action.payload;+ state.pendingOperation = null;});},});@@ -199,5 +235,11 @@ export const {createSubfolderToggled,customSubfolderNameChanged,pathRecomputed,- recordingCompletionDismissed+ recordingCompletionDismissed,+ micDeviceIndexChanged,+ recordingTypePresetChanged,+ autoProcessToggled,+ pendingOperationSet,+ countdownSet,} = recordingSlice.actions;+diff --git a/freemocap-ui/src/store/slices/recording/recording-types.ts b/freemocap-ui/src/store/slices/recording/recording-types.tsindex ac6187a0..ce81c30a 100644--- a/freemocap-ui/src/store/slices/recording/recording-types.ts+++ b/freemocap-ui/src/store/slices/recording/recording-types.ts@@ -1,5 +1,8 @@import {z} from 'zod';+export const RecordingTypePresetSchema = z.enum(['none', 'calibration', 'mocap']);+export type RecordingTypePreset = z.infer<typeof RecordingTypePresetSchema>;+export const RecordingConfigSchema = z.object({// Recording behavior settingsuseDelayStart: z.boolean(),@@ -15,7 +18,18 @@ export const RecordingConfigSchema = z.object({// Folder settingscreateSubfolder: z.boolean(),customSubfolderName: z.string(),++ // Device & preset settings+ micDeviceIndex: z.number(),+ recordingTypePreset: RecordingTypePresetSchema,+ autoProcess: z.boolean(),+});++export const PendingOperationSchema = z.object({+ type: z.enum(['start', 'stop']),+ timestamp: z.number(),});+export type PendingOperation = z.infer<typeof PendingOperationSchema>;const StatsSummarySchema = z.object({median: z.number(),mean: z.number(),@@ -56,6 +70,8 @@ export const RecordingInfoSchema = z.object({config: RecordingConfigSchema,computed: ComputedRecordingPathSchema,completionData: StopRecordingResponseSchema.nullable(),+ pendingOperation: PendingOperationSchema.nullable(),+ countdown: z.number().nullable(),});export type RecordingConfig = z.infer<typeof RecordingConfigSchema>;diff --git a/freemocap-ui/src/store/store.ts b/freemocap-ui/src/store/store.tsindex 9cd2d0c4..564473a2 100644--- a/freemocap-ui/src/store/store.ts+++ b/freemocap-ui/src/store/store.ts@@ -1,4 +1,6 @@import {configureStore} from "@reduxjs/toolkit";+import {cameraConfigListenerMiddleware} from "@/store/camera-config-listener";+import {persistenceListenerMiddleware} from "@/store/persistence-listener";import {cameraSlice} from "@/store/slices/cameras";import {recordingSlice} from "@/store/slices/recording";import {themeSlice} from "@/store/slices/theme";@@ -10,8 +12,14 @@ import {localeSlice} from "@/store/slices/locale";import {pipelinesSlice} from "@/store/slices/pipelines/pipelines-slice";import {blenderSlice} from "@/store/slices/blender/blender-slice";import {recordingStatusSlice} from "@/store/slices/recording-status/recording-status-slice";+import {activeRecordingSlice} from "@/store/slices/active-recording/active-recording-slice";+import playbackDataReducer from "@/store/slices/playback-data/playback-data-slice";export const store = configureStore({+ middleware: (getDefaultMiddleware) =>+ getDefaultMiddleware()+ .concat(cameraConfigListenerMiddleware.middleware)+ .concat(persistenceListenerMiddleware.middleware),reducer: {cameras: cameraSlice.reducer,recording: recordingSlice.reducer,@@ -24,5 +32,7 @@ export const store = configureStore({pipelines: pipelinesSlice.reducer,blender: blenderSlice.reducer,recordingStatus: recordingStatusSlice.reducer,+ activeRecording: activeRecordingSlice.reducer,+ playbackData: playbackDataReducer,},});diff --git a/freemocap-ui/src/utils/gridTiling.ts b/freemocap-ui/src/utils/gridTiling.tsnew file mode 100644index 00000000..a07b919a--- /dev/null+++ b/freemocap-ui/src/utils/gridTiling.ts@@ -0,0 +1,111 @@+import type {LayoutItem} from 'react-grid-layout';++export interface Tiling {+ cols: number;+ rows: number;+}++/**+ * Heuristic for preferred column count based on camera/video count.+ * Mirrors the "old version" logic that gives human-friendly layouts.+ * - 1 item → 1 column+ * - 2–4 items → 2 columns+ * - 5–9 items → 3 columns+ * - 10+ items → 4 columns+ */+export function getPreferredColumns(n: number): number {+ if (n <= 1) return 1;+ if (n <= 4) return 2;+ if (n <= 9) return 3;+ return 4;+}++/**+ * Compute optimal tiling that maximizes visible area while preferring+ * square-ish cells, balanced rows, and human-friendly column counts.+ *+ * @param n Number of items+ * @param containerWidth Available pixel width+ * @param containerHeight Available pixel height+ * @param margin [x, y] gap between items in pixels+ */+export function computeOptimalTiling(+ n: number,+ containerWidth: number,+ containerHeight: number,+ margin: [number, number],+): Tiling {+ if (n === 0) return {cols: 1, rows: 1};+ if (n === 1) return {cols: 1, rows: 1};++ const preferredCols = getPreferredColumns(n);++ const sqrtN = Math.sqrt(n);+ const idealCols = Math.round(sqrtN);++ const minCols = Math.max(1, Math.floor(sqrtN) - 1);+ const maxCols = Math.min(n, Math.ceil(sqrtN) + 2, preferredCols + 1);++ let bestCols = preferredCols;+ let bestScore = -Infinity;++ for (let cols = minCols; cols <= maxCols; cols++) {+ const rows = Math.ceil(n / cols);+ const cellW = (containerWidth - margin[0] * (cols - 1)) / cols;+ const cellH = (containerHeight - margin[1] * (rows - 1)) / rows;++ if (cellW < 80 || cellH < 60) continue;++ // Maximize total area+ const totalArea = n * cellW * cellH;++ // Prefer cells closer to square via log-aspect-ratio penalty+ const aspectRatio = cellW / cellH;+ const aspectPenalty = Math.abs(Math.log(aspectRatio)) * 0.3;++ // Penalize uneven distribution across rows+ const itemsInLastRow = n % cols || cols;+ const balancePenalty = ((cols - itemsInLastRow) / cols) * 0.5;++ // Combined score: maximize area, minimize penalties+ const score = totalArea * (1 - aspectPenalty - balancePenalty);++ // Bonus for matching the preferred column count+ const preferredBonus = cols === preferredCols ? totalArea * 0.1 : 0;++ if (score + preferredBonus > bestScore) {+ bestScore = score + preferredBonus;+ bestCols = cols;+ }+ }++ return {cols: bestCols, rows: Math.ceil(n / bestCols)};+}++/**+ * Build a tiling from a manual column count.+ */+export function tilingFromColumns(n: number, cols: number): Tiling {+ if (n === 0) return {cols: 1, rows: 1};+ const clamped = Math.max(1, Math.min(cols, n));+ return {cols: clamped, rows: Math.ceil(n / clamped)};+}++/**+ * Build a react-grid-layout layout from a tiling and item IDs.+ */+export function buildLayout(ids: string[], tiling: Tiling, gridCols: number): LayoutItem[] {+ if (ids.length === 0) return [];++ const colSpan = Math.floor(gridCols / tiling.cols);++ return ids.map((id, i) => ({+ i: id,+ x: (i % tiling.cols) * colSpan,+ y: Math.floor(i / tiling.cols),+ w: colSpan,+ h: 1,+ minW: 1,+ minH: 1,+ }));+}diff --git a/freemocap-ui/vite.config.ts b/freemocap-ui/vite.config.tsindex 126dc21f..f6b8ea37 100644--- a/freemocap-ui/vite.config.ts+++ b/freemocap-ui/vite.config.ts@@ -20,7 +20,9 @@ export default defineConfig(({command}) => {},},plugins: [- react(),+ // Exclude worker files from React fast-refresh — the @react-refresh+ // preamble references `window` which doesn't exist in worker scope.+ react({ exclude: [/\.worker\.[jt]sx?$/] }),electron({main: {// Shortcut of `build.lib.entry`@@ -64,6 +66,11 @@ export default defineConfig(({command}) => {renderer: {},}),],+ worker: {+ format: "es",+ // Apply React JSX transform in workers without fast-refresh (no window).+ plugins: () => [react({ fastRefresh: false })],+ },optimizeDeps: {},server: process.env.VSCODE_DEBUG? (() => {diff --git a/freemocap.spec b/freemocap.specindex b0f5ab34..959f4bcf 100644--- a/freemocap.spec+++ b/freemocap.spec@@ -3,7 +3,12 @@import syssys.setrecursionlimit(sys.getrecursionlimit() * 5)-from PyInstaller.utils.hooks import collect_all, collect_dynamic_libs, collect_submodules+from PyInstaller.utils.hooks import (+ collect_all,+ collect_data_files,+ collect_dynamic_libs,+ collect_submodules,+)import cv2import os@@ -15,29 +20,108 @@ hiddenimports = ["encodings.idna"]binaries.extend(collect_dynamic_libs('cv2'))hiddenimports.extend(collect_submodules('cv2'))-# ── scipy (uses lazy loading that breaks in frozen envs) ──-scipy_datas, scipy_binaries, scipy_hidden = collect_all('scipy')-datas.extend(scipy_datas)-binaries.extend(scipy_binaries)-hiddenimports.extend(scipy_hidden)+# ── scipy (targeted: only submodules actually imported at runtime) ──+binaries.extend(collect_dynamic_libs('scipy'))+hiddenimports.extend([+ 'scipy.optimize',+ 'scipy.sparse',+ 'scipy.linalg',+ 'scipy.spatial.transform',+ 'scipy.interpolate',+ 'scipy.cluster.hierarchy',+ 'scipy.cluster.vq',+ 'scipy.signal',+])++# ── pandas (standard hook handles most; _cyutility missed by default hook) ──+binaries.extend(collect_dynamic_libs('pandas'))+hiddenimports.append('pandas._libs._cyutility')-# ── mediapipe (needs .tflite model files at runtime) ──+# ── mediapipe (needs .tflite model files at runtime; only solutions/vision/formats) ──import mediapipemp_path = os.path.dirname(mediapipe.__file__)datas.append((os.path.join(mp_path, 'modules'), 'mediapipe/modules'))-hiddenimports.extend(collect_submodules('mediapipe'))+hiddenimports.extend([+ 'mediapipe',+ 'mediapipe.python.solutions',+ 'mediapipe.python.solutions.holistic',+ 'mediapipe.python.solutions.drawing_utils',+ 'mediapipe.python.solutions.face_mesh',+ 'mediapipe.python.solutions.face_mesh_connections',+ 'mediapipe.framework.formats',+ 'mediapipe.framework.formats.landmark_pb2',+ 'mediapipe.tasks.python',+ 'mediapipe.tasks.python.vision',+])# ── skellyforge (yaml config files needed at runtime) ──import skellyforgesf_path = os.path.dirname(skellyforge.__file__)datas.append((os.path.join(sf_path, 'skellymodels', 'tracker_info', '*.yaml'), 'skellyforge/skellymodels/tracker_info'))-# ── setuptools (needed by some vendored deps at runtime) ──-setuptools_datas, _, setuptools_hidden = collect_all('setuptools')-datas.extend(setuptools_datas)-hiddenimports.extend(setuptools_hidden)+# ── skellytracker (active trackers only; exclude v1 legacy, tests, scripts) ──+datas.extend(collect_data_files('skellytracker', includes=['**/*.yaml']))+hiddenimports.extend([+ 'skellytracker',+ 'skellytracker.system',+ 'skellytracker.system.logging_configuration',+ 'skellytracker.system.logging_configuration.handlers',+ 'skellytracker.system.logging_configuration.handlers.websocket_log_queue_handler',+ 'skellytracker.io',+ 'skellytracker.io.process_videos',+ 'skellytracker.io.process_videos.process_single_video',+ 'skellytracker.utilities',+ 'skellytracker.tracked_object_definition',+ 'skellytracker.trackers.mediapipe_tracker',+ 'skellytracker.trackers.rtmpose_tracker',+ 'skellytracker.trackers.rtmpose_tracker.__rtmpose_tracker',+ 'skellytracker.trackers.rtmpose_tracker.run_rtmpose',+ 'skellytracker.trackers.charuco_tracker',+ 'skellytracker.trackers.brightest_point_tracker',+])++# ── NVIDIA CUDA runtime (bundled so users don't need a system CUDA install) ──+# skellytracker's rtmpose_detector does `find_spec("nvidia")` ++# `nvidia_root.glob("*/bin")` at runtime to discover CUDA libraries.+#+# Included — required by ONNX Runtime CUDA execution provider:+# nvidia.cublas (737 MB) — GEMM/BLAS for GPU tensor ops+# nvidia.cuda_runtime (11 MB) — core CUDA runtime (cudart)+# nvidia.cudnn (1006 MB) — cuDNN: primitives for deep neural network inference+#+# Excluded — only needed by TensorRT EP (not currently functional):+# nvidia.cufft (275 MB) — FFT library, not used by ONNX inference+# nvidia.cuda_nvrtc (179 MB) — runtime compilation, TensorRT-only+# nvidia.nvjitlink (84 MB) — JIT linker, TensorRT-only+for nvidia_subpkg in [+ 'nvidia.cublas',+ 'nvidia.cuda_runtime',+ 'nvidia.cudnn',+]:+ try:+ nv_datas, nv_binaries, nv_hidden = collect_all(nvidia_subpkg)+ datas.extend(nv_datas)+ binaries.extend(nv_binaries)+ hiddenimports.extend(nv_hidden)+ except Exception as e:+ print(f"[freemocap.spec] WARNING: could not collect '{nvidia_subpkg}' "+ f"— GPU acceleration may not work in the frozen build. ({e})")++# ── onnxruntime (GPU build — only DLLs + capi bindings; exclude dev tools) ──+binaries.extend(collect_dynamic_libs('onnxruntime'))+hiddenimports.extend(['onnxruntime', 'onnxruntime.capi'])++# ── rtmlib (model registry + configs) ──+rtm_datas, rtm_binaries, rtm_hidden = collect_all('rtmlib')+datas.extend(rtm_datas)+binaries.extend(rtm_binaries)+hiddenimports.extend(rtm_hidden)++# ── onnx (used by rtmpose_session for model loading; separate from onnxruntime) ──+hiddenimports.append('onnx')-# Ensure jaraco.text lorem ipsum file is included+# ── setuptools (_vendor only — jaraco, packaging, etc. needed by vendored deps) ──+hiddenimports.extend(collect_submodules('setuptools._vendor'))jaraco_text_path = os.path.join(os.path.dirname(__import__('setuptools', fromlist=['_vendor']).__file__),'_vendor', 'jaraco', 'text'@@ -67,7 +151,6 @@ a = Analysis('pyinstaller',# ── Heavy unused modules ──- 'torch','tkinter','_tkinter','IPython',@@ -79,6 +162,40 @@ a = Analysis('pdb','cProfile','profile',++ # ── Dependencies in pyproject.toml but never imported ──+ 'numba',+ 'llvmlite',+ 'libsass',+ 'sass',+ 'sklearn',+ 'numpydantic',++ # ── onnxruntime dev tools (not needed at runtime) ──+ 'onnxruntime.transformers',+ 'onnxruntime.tools',+ 'onnxruntime.quantization',+ 'onnxruntime.backend',+ 'onnxruntime.datasets',++ # ── mediapipe dev/bundled tools ──+ 'mediapipe.tasks.python.test',+ 'mediapipe.tasks.python.metadata',+ 'mediapipe.tasks.python.benchmark',++ # ── skellytracker legacy/unused ──+ 'skellytracker.tests',+ 'skellytracker.trackers.v1',+ 'skellytracker.trackers.vitpose_tracker',+ 'skellytracker.trackers.legacy_mediapipe_tracker',+ 'skellytracker.scripts',+ 'skellytracker.__main__',++ # ── setuptools cruft ──+ 'setuptools.tests',+ 'setuptools.command',+ 'setuptools._distutils.command',+ 'setuptools._distutils.tests',],noarchive=False,)@@ -96,8 +213,8 @@ exe = EXE(debug=False,bootloader_ignore_signals=False,strip=False,- upx=False,- upx_exclude=[],+ upx=True,+ upx_exclude=['nvcuda', 'nvrtc', 'cudnn', 'cublas', 'cufft', 'cudart'],runtime_tmpdir=None,console=True,disable_windowed_traceback=False,diff --git a/freemocap/__main__.py b/freemocap/__main__.pyindex 69799829..52cbdc0a 100644--- a/freemocap/__main__.py+++ b/freemocap/__main__.py@@ -34,6 +34,7 @@ async def main(force_preferred_port:bool=True) -> None:format_port_sentinel,)from freemocap.app.app import create_fastapi_app+ from freemocap.utilities.asyncio_exception_handler import suppress_proactor_connection_resetif force_preferred_port:@@ -45,6 +46,8 @@ async def main(force_preferred_port:bool=True) -> None:# flush=True ensures it arrives immediately even when stdout is buffered.print(format_port_sentinel(port=port), flush=True)+ suppress_proactor_connection_reset(asyncio.get_running_loop())+global_kill_flag = multiprocessing.Value("b", False)worker_registry = WorkerRegistry(global_kill_flag=global_kill_flag,@@ -104,11 +107,12 @@ async def main(force_preferred_port:bool=True) -> None:worker_registry.shutdown_all()logger.success("Done! Thank you for using FreeMoCap 💀✨")-+def run_main() -> None:+ asyncio.run(main())if __name__ == "__main__":multiprocessing.freeze_support() # Required for PyInstaller + multiprocessing on Windowstry:- asyncio.run(main())+ run_main()except Exception as e:logger.exception(f"Unhandled exception: {e}")os._exit(1)diff --git a/freemocap/api/http/calibration/calibration_router.py b/freemocap/api/http/calibration/calibration_router.pyindex 26e0bdb2..57377398 100644--- a/freemocap/api/http/calibration/calibration_router.py+++ b/freemocap/api/http/calibration/calibration_router.py@@ -79,6 +79,7 @@ class CalibrateRecordingResponse(BaseModel):success: boolmessage: str | None = Noneresults: dict | None = None+ pipeline_id: str | None = None# ==================== Endpoints ====================@@ -102,19 +103,26 @@ async def start_calibration_recording(@calibration_router.post("/recording/stop")async def stop_calibration_recording(request: StopCalibrationRecordingRequest,-) -> dict[str, bool]:+) -> dict:"""Stop current calibration recording and launch posthoc calibration pipeline."""app = get_freemocap_app()try:recording_info = await app.stop_recording_all()if recording_info is None:- raise RuntimeError("No active recording to stop")- await app.create_posthoc_calibration_pipeline(+ logger.warning("No active recording to stop")+ return {"success": True}+ logger.info(f"Recording stopped - saved to: {recording_info.full_recording_path}")+ pipeline = await app.create_posthoc_calibration_pipeline(recording_info=recording_info,calibration_config=request.calibration_config,)logger.info("Calibration recording stopped, posthoc calibration pipeline launched")- return {"success": True}+ return {+ "success": True,+ "pipeline_id": pipeline.id,+ "recording_name": recording_info.recording_name,+ "recording_path": str(recording_info.full_recording_path),+ }except Exception as e:logger.exception(f"Error stopping calibration recording: {e}")raise HTTPException(status_code=500, detail=str(e))@@ -127,7 +135,7 @@ async def calibrate_recording(request: CalibrateRecordingRequest) -> CalibrateRetry:recording_info = request.to_recording_info()- await app.create_posthoc_calibration_pipeline(+ pipeline = await app.create_posthoc_calibration_pipeline(recording_info=recording_info,calibration_config=request.calibration_config,)@@ -136,6 +144,7 @@ async def calibrate_recording(request: CalibrateRecordingRequest) -> CalibrateResuccess=True,message="Calibration pipeline launched",results={},+ pipeline_id=pipeline.id,)except Exception as e:logger.exception(f"Error calibrating recording: {e}")diff --git a/freemocap/api/http/mocap/mocap_router.py b/freemocap/api/http/mocap/mocap_router.pyindex 3903afba..5bf7ef85 100644--- a/freemocap/api/http/mocap/mocap_router.py+++ b/freemocap/api/http/mocap/mocap_router.py@@ -35,8 +35,7 @@ class StartMocapRecordingRequest(BaseModel):def to_recording_info(self) -> RecordingInfo:recording_dir = Path(self.mocap_recording_directory).expanduser()recording_name = recording_dir.stem- if not recording_name.endswith("_mocap"):- recording_name += "_mocap"+return RecordingInfo(recording_directory=str(recording_dir.parent),recording_name=recording_name,@@ -90,6 +89,7 @@ class MocapRecordingResponse(BaseModel):success: boolmessage: str | None = Noneresults: dict | None = None+ pipeline_id: str | None = None# ==================== Endpoints ====================@@ -118,12 +118,17 @@ async def stop_mocap_recording(request: StopMocapRecordingRequest) -> dict[str,recording_info = await app.stop_recording_all()if recording_info is None:raise RuntimeError("No active recording to stop")- await app.create_posthoc_mocap_pipeline(+ pipeline = await app.create_posthoc_mocap_pipeline(recording_info=recording_info,mocap_config=request.mocap_config,)logger.info("Mocap recording stopped, posthoc mocap pipeline launched")- return {"success": True}+ return {+ "success": True,+ "pipeline_id": pipeline.id,+ "recording_name": recording_info.recording_name,+ "recording_path": str(recording_info.full_recording_path),+ }except Exception as e:logger.exception(f"Error stopping mocap recording: {e}")raise HTTPException(status_code=500, detail=str(e))@@ -135,7 +140,7 @@ async def process_mocap_recording(request: ProcessMocapRecordingRequest) -> Mocaapp = get_freemocap_app()try:recording_info = request.to_recording_info()- await app.create_posthoc_mocap_pipeline(+ pipeline = await app.create_posthoc_mocap_pipeline(recording_info=recording_info,mocap_config=request.mocap_config,)@@ -144,6 +149,7 @@ async def process_mocap_recording(request: ProcessMocapRecordingRequest) -> Mocasuccess=True,message="Mocap processing pipeline launched",results={},+ pipeline_id=pipeline.id,)except Exception as e:logger.exception(f"Error processing mocap recording: {e}")diff --git a/freemocap/api/http/playback/playback_router.py b/freemocap/api/http/playback/playback_router.pyindex d071d87f..894433a6 100644--- a/freemocap/api/http/playback/playback_router.py+++ b/freemocap/api/http/playback/playback_router.py@@ -28,7 +28,15 @@ from freemocap.system.recording_status.recording_status import (compute_recording_status,_find_calibration_toml,)-from freemocap.system.default_paths import get_default_freemocap_recordings_path+from freemocap.system.recording_structure.recording_structure import (+ RecordingLayoutValidation,+ RecordingStructure,+)+from freemocap.system.default_paths import (+ ANNOTATED_VIDEOS_FOLDER_NAME,+ SYNCHRONIZED_VIDEOS_FOLDER_NAME,+ get_default_freemocap_recordings_path,+)_VIEWER_HTML = Path(__file__).parent.parent.parent.parent / "core" / "viz" / "parquet_viewer.html"@@ -51,6 +59,18 @@ class VideoInfo(BaseModel):stream_url: str+class VideoSourceInfo(BaseModel):+ available: bool+ valid: bool+ video_count: int+ videos: list[VideoInfo] = []+++class VideoSourcesResponse(BaseModel):+ preferred_source: str+ sources: dict[str, VideoSourceInfo]++class RecordingStatusSummary(BaseModel):blender_export_ready: bool = Falsehas_blend_file: bool = False@@ -60,6 +80,19 @@ class RecordingStatusSummary(BaseModel):stages_total: int = 0+class RecordingBundle(BaseModel):+ """All playback metadata for a recording in a single response."""+ recording_id: str+ recording_fps: Optional[float] = None+ total_frames: Optional[int] = None+ duration_seconds: Optional[float] = None+ videos: VideoSourcesResponse+ timestamps: dict = {}+ calibration: Optional[dict[str, Any]] = None+ tracker_schema: dict[str, Any]+ status_summary: RecordingStatusSummary++class RecordingListEntry(BaseModel):name: strpath: str@@ -70,6 +103,8 @@ class RecordingListEntry(BaseModel):duration_seconds: Optional[float] = Nonefps: Optional[float] = Nonestatus_summary: RecordingStatusSummary = RecordingStatusSummary()+ status: Optional[RecordingStatus] = None+ layout_validation: Optional[RecordingLayoutValidation] = None# ---------------------------------------------------------------------------@@ -137,6 +172,77 @@ def _find_video_folder(recording_path: Path) -> Path:)+def _validate_video_source(+ recording_path: Path,+ source_name: str,+ recording_id: str,+ recording_parent_directory: str | None = None,+) -> VideoSourceInfo:+ """Validate a video source folder using VideoGroupHelper.++ Returns VideoSourceInfo with:+ - available: folder exists and contains video files+ - valid: VideoGroupHelper constructed successfully (all videos readable,+ all have same frame count)+ - videos: list of VideoInfo for the folder (empty if unavailable)+ """+ folder_name = (+ ANNOTATED_VIDEOS_FOLDER_NAME if source_name == "annotated"+ else SYNCHRONIZED_VIDEOS_FOLDER_NAME+ )+ folder = recording_path / folder_name++ if not folder.is_dir():+ return VideoSourceInfo(available=False, valid=False, video_count=0)++ video_paths = sorted(+ p for p in folder.iterdir()+ if p.is_file() and p.suffix.lower() in VIDEO_EXTENSIONS+ )+ if not video_paths:+ return VideoSourceInfo(available=False, valid=False, video_count=0)++ # Validate frame-count consistency via VideoGroupHelper (imported lazily+ # because it pulls in cv2 + numpy).+ valid = False+ try:+ from freemocap.core.pipeline.posthoc.video_group_helper import (+ VideoGroupHelper,+ )+ VideoGroupHelper.from_video_folder_path(folder)+ valid = True+ except Exception:+ logger.warning(+ f"VideoGroupHelper validation failed for {folder}",+ exc_info=True,+ )++ parent_directory_suffix = (+ f"&recording_parent_directory={recording_parent_directory}"+ if recording_parent_directory+ else ""+ )+ videos = [+ VideoInfo(+ video_id=p.stem,+ filename=p.name,+ size_bytes=p.stat().st_size,+ stream_url=(+ f"/freemocap/playback/{recording_id}/videos/{p.stem}"+ f"?source={source_name}{parent_directory_suffix}"+ ),+ )+ for p in video_paths+ ]++ return VideoSourceInfo(+ available=True,+ valid=valid,+ video_count=len(videos),+ videos=videos,+ )++def _get_total_size(video_folder: Path) -> int:"""Sum of all video file sizes in a folder."""total = 0@@ -149,8 +255,18 @@ def _get_total_size(video_folder: Path) -> int:return total-def _get_recording_stats(recording_path: Path, video_folder: Path) -> dict:- """Try to extract frame count, duration, and fps from timestamp CSV files."""+def _get_recording_stats(+ recording_path: Path,+ video_folder: Path,+ *,+ use_cv2_fallback: bool = True,+) -> dict:+ """Try to extract frame count, duration, and fps from timestamp CSV files.++ When *use_cv2_fallback* is False the cv2 VideoCapture path is skipped+ entirely. Callers that iterate many recordings (e.g. the listing endpoint)+ should pass False to avoid opening video files for every recording on disk.+ """stats: dict = {"total_frames": None,"duration_seconds": None,@@ -215,6 +331,43 @@ def _get_recording_stats(recording_path: Path, video_folder: Path) -> dict:except (OSError, csv.Error):continue+ if not use_cv2_fallback:+ return stats++ # No timestamp CSV found — fall back to reading video metadata with cv2+ logger.warning(+ f"No timestamp CSVs found for '{recording_path.name}'. "+ f"Searched: {[str(d) for d in timestamp_dirs]}. Falling back to cv2."+ )+ try:+ import cv2+ video_files = sorted(+ p for p in video_folder.iterdir()+ if p.is_file() and p.suffix.lower() in VIDEO_EXTENSIONS+ )+ if video_files:+ cap = cv2.VideoCapture(str(video_files[0]))+ frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))+ fps = cap.get(cv2.CAP_PROP_FPS)+ cap.release()+ if frame_count > 0:+ stats["total_frames"] = frame_count+ if fps and fps > 0:+ stats["fps"] = round(fps, 1)+ stats["duration_seconds"] = round(frame_count / fps, 2)+ logger.info(+ f"cv2 fallback for '{recording_path.name}': "+ f"{frame_count} frames @ {fps:.1f} fps "+ f"(from '{video_files[0].name}')"+ )+ else:+ logger.warning(+ f"cv2 read 0 frames from '{video_files[0].name}' — "+ f"video may be unreadable or empty"+ )+ except Exception as e:+ logger.warning(f"cv2 fallback failed for '{video_folder}': {e}")+return stats@@ -326,8 +479,12 @@ def list_recordings(if video_count > 0:total_size = _get_total_size(video_folder)created_ts = _get_created_timestamp(child)- stats = _get_recording_stats(child, video_folder)+ stats = _get_recording_stats(child, video_folder, use_cv2_fallback=False)status = compute_recording_status(child)+ layout_validation = RecordingStructure(+ base_directory=child.parent,+ recording_name=child.name,+ ).validate_layout()stages_complete = sum(1 for s in status.stages if s.complete)entries.append(RecordingListEntry(@@ -347,6 +504,8 @@ def list_recordings(stages_complete=stages_complete,stages_total=len(status.stages),),+ status=status,+ layout_validation=layout_validation,))except (FileNotFoundError, PermissionError):continue@@ -371,7 +530,8 @@ def get_recording_status(@playback_router.get("/{recording_id}/videos",- summary="List videos in a recording",+ summary="List videos in a recording (annotated + synchronized sources)",+ response_model=VideoSourcesResponse,)def list_videos(recording_id: str,@@ -379,28 +539,93 @@ def list_videos(default=None,description="Override the default recordings directory",),-) -> list[VideoInfo]:+) -> VideoSourcesResponse:recording_path = _resolve_recording_path(recording_id, recording_parent_directory)- try:- video_folder = _find_video_folder(recording_path)- except FileNotFoundError as e:- raise HTTPException(status_code=404, detail=str(e))+ annotated = _validate_video_source(recording_path, "annotated", recording_id, recording_parent_directory)+ synchronized = _validate_video_source(recording_path, "synchronized", recording_id, recording_parent_directory)- videos = _discover_videos(video_folder)- if not videos:- raise HTTPException(status_code=404, detail=f"No video files found in {video_folder}")+ # Fall back to recording root for layouts where videos live directly in the+ # recording folder (not in synchronized_videos/ or annotated_videos/).+ if not annotated.available and not synchronized.available:+ try:+ video_folder = _find_video_folder(recording_path)+ videos = _discover_videos(video_folder)+ if videos:+ parent_directory_suffix = (+ f"?recording_parent_directory={recording_parent_directory}"+ if recording_parent_directory+ else ""+ )+ video_list = [+ VideoInfo(+ video_id=vid_id,+ filename=path.name,+ size_bytes=path.stat().st_size,+ stream_url=f"/freemocap/playback/{recording_id}/videos/{vid_id}{parent_directory_suffix}",+ )+ for vid_id, path in videos.items()+ ]+ root_source = VideoSourceInfo(+ available=True,+ valid=False,+ video_count=len(video_list),+ videos=video_list,+ )+ logger.info(+ f"Recording '{recording_id}': no subfolder sources; "+ f"found {len(video_list)} video(s) in recording root"+ )+ return VideoSourcesResponse(+ preferred_source="synchronized",+ sources={+ "annotated": VideoSourceInfo(available=False, valid=False, video_count=0),+ "synchronized": root_source,+ },+ )+ except FileNotFoundError:+ pass- logger.info(f"Discovered {len(videos)} videos in recording '{recording_id}'")- return [- VideoInfo(- video_id=vid_id,- filename=path.name,- size_bytes=path.stat().st_size,- stream_url=f"/freemocap/playback/{recording_id}/videos/{vid_id}",+ raise HTTPException(+ status_code=404,+ detail=f"No video files found in {recording_path}",)- for vid_id, path in videos.items()- ]++ preferred = (+ "annotated" if (annotated.available and annotated.valid)+ else "synchronized" if (synchronized.available and synchronized.valid)+ else "annotated" if annotated.available+ else "synchronized"+ )++ logger.info(+ f"Recording '{recording_id}': annotated={annotated.available}/{annotated.valid}, "+ f"synchronized={synchronized.available}/{synchronized.valid}, "+ f"preferred={preferred}"+ )++ return VideoSourcesResponse(+ preferred_source=preferred,+ sources={+ "annotated": annotated,+ "synchronized": synchronized,+ },+ )+++def _resolve_video_source_folder(recording_path: Path, source: str) -> Path:+ """Resolve the folder for a named video source."""+ folder_name = (+ ANNOTATED_VIDEOS_FOLDER_NAME if source == "annotated"+ else SYNCHRONIZED_VIDEOS_FOLDER_NAME+ )+ folder = recording_path / folder_name+ if not folder.is_dir():+ raise HTTPException(+ status_code=404,+ detail=f"Video source '{source}' not found in recording",+ )+ return folder@playback_router.get(@@ -410,6 +635,10 @@ def list_videos(def stream_video(recording_id: str,video_id: str,+ source: str | None = Query(+ default=None,+ description="Video source folder: 'annotated' or 'synchronized'. Defaults to synchronized-first lookup.",+ ),recording_parent_directory: str | None = Query(default=None,description="Override the default recordings directory",@@ -417,10 +646,13 @@ def stream_video() -> FileResponse:recording_path = _resolve_recording_path(recording_id, recording_parent_directory)- try:- video_folder = _find_video_folder(recording_path)- except FileNotFoundError as e:- raise HTTPException(status_code=404, detail=str(e))+ if source:+ video_folder = _resolve_video_source_folder(recording_path, source)+ else:+ try:+ video_folder = _find_video_folder(recording_path)+ except FileNotFoundError as e:+ raise HTTPException(status_code=404, detail=str(e))videos = _discover_videos(video_folder)if video_id not in videos:@@ -459,15 +691,46 @@ def get_recording_parquet(),) -> FileResponse:recording_path = _resolve_recording_path(recording_id, recording_parent_directory)- p = recording_path / "output_data" / "freemocap_data_by_frame.parquet"- if not p.is_file():+ p = _find_recording_parquet(recording_path)+ if p is None:raise HTTPException(status_code=404,- detail=f"Parquet file not found: {p}",+ detail=f"No parquet file found in recording: {recording_path}",)return FileResponse(str(p), media_type="application/octet-stream", filename=p.name)+def _find_recording_parquet(recording_path: Path) -> Path | None:+ """Locate a recording's parquet across canonical + legacy layouts.++ Tries, in order:+ 1. {recording}/{name}_data.parquet (canonical)+ 2. {recording}/output_data/freemocap_data_by_frame.parquet (legacy)+ 3. any *.parquet under the recording folder (fallback; warns)+ """+ name = recording_path.name+ canonical = recording_path / f"{name}_data.parquet"+ if canonical.is_file():+ logger.info(f"Found canonical parquet: {canonical}")+ return canonical++ legacy = recording_path / "output_data" / "freemocap_data_by_frame.parquet"+ if legacy.is_file():+ logger.info(f"Found legacy parquet: {legacy}")+ return legacy++ matches = [p for p in recording_path.rglob("*.parquet") if p.is_file()]+ if matches:+ found = matches[0]+ logger.warning(+ f"Parquet not at canonical/legacy location; using fallback match: {found} "+ f"(searched under {recording_path}; {len(matches)} .parquet files found)"+ )+ return found++ return None++@playback_router.get("/{recording_id}/calibration",summary="Return parsed calibration data (camera poses) for a recording",@@ -527,6 +790,41 @@ def get_recording_calibration(}+@playback_router.get(+ "/{recording_id}/tracker-schema",+ summary="Return the tracker schema (tracked points + connections) for a recording",+)+def get_tracker_schema(+ recording_id: str,+ recording_parent_directory: str | None = Query(+ default=None,+ description="Override the default recordings directory",+ ),+) -> dict[str, Any]:+ """Serve the tracker_schema.json saved alongside the mocap outputs.++ Returns the TrackedObjectDefinition (name, tracker_type, landmark_schema,+ tracked_points, connections) so the frontend can render skeleton lines+ without hardcoding any tracker schema.++ Returns 404 for older recordings that predate schema saving.+ """+ import json++ recording_path = _resolve_recording_path(recording_id, recording_parent_directory)+ schema_path = recording_path / "tracker_schema.json"+ if not schema_path.is_file():+ logger.warning(f"No tracker_schema.json in {recording_path}, returning fallback")+ return {+ "name": "fallback",+ "tracker_type": "unknown",+ "tracked_points": [],+ "connections": [],+ "landmark_schema": "generic",+ }+ return json.loads(schema_path.read_text(encoding="utf-8"))++@playback_router.get("/{recording_id}/timestamps",summary="Get timestamps for all videos in a recording",@@ -612,3 +910,193 @@ def get_video_timestamps("headers": [],"row_count": 0,}+++# ---------------------------------------------------------------------------+# Bundle endpoint — single call for all playback metadata+# ---------------------------------------------------------------------------++@playback_router.get(+ "/{recording_id}/bundle",+ summary="All playback metadata for a recording in a single response",+)+def get_recording_bundle(+ recording_id: str,+ recording_parent_directory: str | None = Query(+ default=None,+ description="Override the default recordings directory",+ ),+) -> RecordingBundle:+ """Return videos, timestamps, calibration, tracker schema, and status+ in one response. Individual resources are best-effort — calibration+ returns null if no TOML is present, tracker schema returns a fallback+ if no schema file exists. Only path resolution can produce a 404.+ """+ import json++ recording_path = _resolve_recording_path(recording_id, recording_parent_directory)++ # --- videos ---+ annotated = _validate_video_source(recording_path, "annotated", recording_id, recording_parent_directory)+ synchronized = _validate_video_source(recording_path, "synchronized", recording_id, recording_parent_directory)++ if not annotated.available and not synchronized.available:+ try:+ video_folder = _find_video_folder(recording_path)+ videos_dict = _discover_videos(video_folder)+ if videos_dict:+ parent_directory_suffix = (+ f"?recording_parent_directory={recording_parent_directory}"+ if recording_parent_directory+ else ""+ )+ video_list = [+ VideoInfo(+ video_id=vid_id,+ filename=path.name,+ size_bytes=path.stat().st_size,+ stream_url=f"/freemocap/playback/{recording_id}/videos/{vid_id}{parent_directory_suffix}",+ )+ for vid_id, path in videos_dict.items()+ ]+ root_source = VideoSourceInfo(+ available=True,+ valid=False,+ video_count=len(video_list),+ videos=video_list,+ )+ videos_response = VideoSourcesResponse(+ preferred_source="synchronized",+ sources={+ "annotated": VideoSourceInfo(available=False, valid=False, video_count=0),+ "synchronized": root_source,+ },+ )+ else:+ raise HTTPException(+ status_code=404,+ detail=f"No video files found in {recording_path}",+ )+ except FileNotFoundError:+ raise HTTPException(+ status_code=404,+ detail=f"No video files found in {recording_path}",+ )+ else:+ preferred = (+ "annotated" if (annotated.available and annotated.valid)+ else "synchronized" if (synchronized.available and synchronized.valid)+ else "annotated" if annotated.available+ else "synchronized"+ )+ videos_response = VideoSourcesResponse(+ preferred_source=preferred,+ sources={+ "annotated": annotated,+ "synchronized": synchronized,+ },+ )++ # --- timestamps ---+ timestamps_result: dict = {}+ stats_video_folder = None+ try:+ stats_video_folder = _find_video_folder(recording_path)+ all_timestamps: dict[str, list[float]] = {}+ warnings: list[str] = []+ for vid_id in _discover_videos(stats_video_folder):+ ts_values = _read_timestamp_values_for_video(recording_path, video_id=vid_id)+ if ts_values is not None:+ all_timestamps[vid_id] = ts_values+ else:+ warnings.append(f"No timestamp data found for video '{vid_id}'")+ timestamps_result = {"timestamps": all_timestamps, "warnings": warnings}+ except FileNotFoundError:+ pass++ # --- calibration ---+ calibration_result: dict[str, Any] | None = None+ toml_path = _find_calibration_toml(recording_path)+ if toml_path is not None:+ try:+ raw = toml_path.read_text(encoding="utf-8")+ parsed = toml.loads(raw)+ mtime_ms = toml_path.stat().st_mtime * 1000+ cameras = []+ for key, val in parsed.items():+ if key == "metadata" or not isinstance(val, dict):+ continue+ if "world_position" not in val or "world_orientation" not in val:+ continue+ cameras.append({+ "id": key,+ "name": str(val.get("name", key)),+ "size": val.get("size"),+ "matrix": val.get("matrix"),+ "distortions": val.get("distortions"),+ "rotation": val.get("rotation"),+ "translation": val.get("translation"),+ "world_orientation": val["world_orientation"],+ "world_position": val["world_position"],+ })+ calibration_result = {+ "path": str(toml_path),+ "mtimeMs": mtime_ms,+ "cameras": cameras,+ "metadata": parsed.get("metadata", None),+ }+ except Exception:+ logger.warning(f"Failed to parse calibration TOML for '{recording_id}'", exc_info=True)++ # --- tracker schema ---+ schema_path = recording_path / "tracker_schema.json"+ if schema_path.is_file():+ try:+ tracker_schema_result = json.loads(schema_path.read_text(encoding="utf-8"))+ except Exception:+ tracker_schema_result = {+ "name": "fallback",+ "tracker_type": "unknown",+ "tracked_points": [],+ "connections": [],+ "landmark_schema": "generic",+ }+ else:+ tracker_schema_result = {+ "name": "fallback",+ "tracker_type": "unknown",+ "tracked_points": [],+ "connections": [],+ "landmark_schema": "generic",+ }++ # --- recording stats ---+ stats = {}+ if stats_video_folder is not None:+ try:+ stats = _get_recording_stats(recording_path, stats_video_folder)+ except Exception:+ pass++ # --- status summary ---+ status = compute_recording_status(recording_path)+ status_summary = RecordingStatusSummary(+ blender_export_ready=status.blender_export_ready,+ has_blend_file=status.has_blend_file,+ has_annotated_videos=status.has_annotated_videos,+ has_calibration_toml=status.has_calibration_toml,+ stages_complete=sum(1 for s in status.stages if s.complete),+ stages_total=len(status.stages),+ )++ return RecordingBundle(+ recording_id=recording_id,+ recording_fps=stats.get("fps"),+ total_frames=stats.get("total_frames"),+ duration_seconds=stats.get("duration_seconds"),+ videos=videos_response,+ timestamps=timestamps_result,+ calibration=calibration_result,+ tracker_schema=tracker_schema_result,+ status_summary=status_summary,+ )diff --git a/freemocap/api/http/posthoc/__init__.py b/freemocap/api/http/posthoc/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/freemocap/api/http/posthoc/posthoc_router.py b/freemocap/api/http/posthoc/posthoc_router.pynew file mode 100644index 00000000..ccac5426--- /dev/null+++ b/freemocap/api/http/posthoc/posthoc_router.py@@ -0,0 +1,25 @@+import logging++from fastapi import APIRouter, HTTPException++from freemocap.app.freemocap_application import get_freemocap_app++logger = logging.getLogger(__name__)++posthoc_router = APIRouter(prefix="/posthoc", tags=["Posthoc"])+++@posthoc_router.delete("/pipeline/{pipeline_id}")+async def stop_pipeline(pipeline_id: str) -> dict:+ """Stop a single posthoc pipeline by ID."""+ found = get_freemocap_app().stop_posthoc_pipeline(pipeline_id)+ if not found:+ raise HTTPException(status_code=404, detail=f"Pipeline '{pipeline_id}' not found")+ return {"success": True, "pipeline_id": pipeline_id}+++@posthoc_router.delete("/pipeline")+async def stop_all_pipelines() -> dict:+ """Stop all active posthoc pipelines."""+ get_freemocap_app().stop_all_posthoc_pipelines()+ return {"success": True}diff --git a/freemocap/api/http/realtime/realtime_router.py b/freemocap/api/http/realtime/realtime_router.pyindex 9e206ed7..7fbde868 100644--- a/freemocap/api/http/realtime/realtime_router.py+++ b/freemocap/api/http/realtime/realtime_router.py@@ -3,7 +3,7 @@ import loggingfrom fastapi import APIRouter, Body, HTTPExceptionfrom pydantic import BaseModel, Fieldfrom skellycam.core.camera_group.camera_group import CameraConfigs-from skellycam.core.types.type_overloads import CameraGroupIdString+from skellycam.core.types.type_overloads import CameraGroupIdString, CameraIdStringfrom freemocap.app.freemocap_application import get_freemocap_appfrom freemocap.core.pipeline.realtime.realtime_aggregator_node import RealtimePipelineConfig@@ -18,6 +18,11 @@ class RealtimePipelineConnectRequest(BaseModel):camera_configs: CameraConfigs|None = Field(default=None,alias="cameraConfigs",description="Camera configurations for the CameraGroup we're attaching a pipeline to. If None, use existing camera group (or throw if no camera group connected)")+ realtime_camera_ids: list[CameraIdString] | None = Field(+ default=None,+ alias="realtimeCameraIds",+ description="Subset of camera IDs to attach to pipeline nodes. If None, all cameras in the group are used.",+ )realtime_config: RealtimePipelineConfig = Field(default_factory=RealtimePipelineConfig,description="Configuration for the realtime processing pipeline",@@ -76,7 +81,8 @@ async def pipeline_apply_endpoint(raise RuntimeError("No valid camera configs found in request or current server state")pipeline = await app.create_or_update_realtime_pipeline(pipeline_config=request.realtime_config,- camera_configs=camera_configs,)+ camera_configs=camera_configs,+ realtime_camera_ids=request.realtime_camera_ids,)response = RealtimePipelineCreateResponse.from_pipeline(pipeline=pipeline)logger.api(f"`pipeline/connect` POST request handled successfully - \n {response.model_dump_json(indent=2)}")return responsediff --git a/freemocap/api/middleware/add_middleware.py b/freemocap/api/middleware/add_middleware.pyindex 7fd141f1..d7e5df3a 100644--- a/freemocap/api/middleware/add_middleware.py+++ b/freemocap/api/middleware/add_middleware.py@@ -14,7 +14,21 @@ def add_middleware(app: FastAPI) -> None:@app.middleware("http")async def log_requests(request: Request, call_next) -> Response:start_time = time.perf_counter()- logger.api(f"Received request: {request.method} {request.url}")#"++ body_bytes = await request.body()+ if body_bytes:+ try:+ parsed = json.loads(body_bytes)+ body_str = json.dumps(parsed, indent=2)+ except (json.JSONDecodeError, UnicodeDecodeError):+ # Not JSON — just decode and show the raw text+ try:+ body_str = body_bytes.decode("utf-8")+ except UnicodeDecodeError:+ body_str = f"<binary data, {len(body_bytes)} bytes>"+ logger.api(f"Received request: {request.method} {request.url}. Body:\n{body_str}")+ else:+ logger.api(f"Received request: {request.method} {request.url}. No body.")try:response: Response = await call_next(request)diff --git a/freemocap/api/routers.py b/freemocap/api/routers.pyindex 1f312b92..a038b91c 100644--- a/freemocap/api/routers.py+++ b/freemocap/api/routers.py@@ -6,6 +6,7 @@ from freemocap.api.http.app.shutdown import shutdown_routerfrom freemocap.api.http.blender.blender_router import blender_routerfrom freemocap.api.http.calibration.calibration_router import calibration_routerfrom freemocap.api.http.mocap.mocap_router import mocap_router+from freemocap.api.http.posthoc.posthoc_router import posthoc_routerfrom freemocap.api.http.realtime.realtime_router import realtime_routerAPP_ROUTERS = [health_router,@@ -18,6 +19,7 @@ SKELLYCAM_ROUTERS = [FREEMOCAP_ROUTERS = [realtime_router,calibration_router,mocap_router,+ posthoc_router,blender_router,playback_router]diff --git a/freemocap/api/websocket/binary_keypoints_protocol.py b/freemocap/api/websocket/binary_keypoints_protocol.pynew file mode 100644index 00000000..471a7fda--- /dev/null+++ b/freemocap/api/websocket/binary_keypoints_protocol.py@@ -0,0 +1,124 @@+"""Binary wire format for the keypoints websocket message.++Sibling to skellycam's `frontend_payload_bytearray` (which carries JPEG image+frames). The message payload looks like:++ PAYLOAD_HEADER (24B)+ message_type u1 = MessageType.KEYPOINTS_PAYLOAD_HEADER+ frame_number i8+ num_blocks u4++ For each block:+ BLOCK_HEADER (44B)+ message_type u1 = MessageType.KEYPOINTS_BLOCK_HEADER+ block_kind u1 = BlockKind.*+ dtype_code u1 = Dtype.FLOAT32 | FLOAT64+ dims u1 = 2 or 3+ camera_id S16 (zero-padded; empty for 3D blocks)+ tracker_id S16 (matches the key in TrackerSchemasMessage.schemas)+ num_points u4+ data_byte_length u4 = num_points * (dims + 1) * sizeof(dtype)++ BLOCK_DATA interleaved [x, y, (z,) visibility] per point,+ row-major, length == data_byte_length++ PAYLOAD_FOOTER (24B) mirrors PAYLOAD_HEADER for integrity check+ message_type u1 = MessageType.KEYPOINTS_PAYLOAD_FOOTER+ frame_number i8+ num_blocks u4++The block array layout has visibility as a 4th column so the frontend can take+a single `Float32Array` view per block and index `arr[i*4 + 0..3]` directly.+For points that did not triangulate, the row is filled with NaN and visibility+is 0.++Message-type byte values are chosen to NOT collide with skellycam's image+protocol (which uses 0, 1, 2) so the frontend can demultiplex on the first+byte of any inbound binary frame.+"""+from enum import IntEnum++import numpy as np+++class MessageType(IntEnum):+ KEYPOINTS_PAYLOAD_HEADER = 3+ KEYPOINTS_BLOCK_HEADER = 4+ KEYPOINTS_PAYLOAD_FOOTER = 5+++class BlockKind(IntEnum):+ KEYPOINTS_RAW_3D = 0+ KEYPOINTS_FILTERED_3D = 1+ SKELETON_OVERLAY_2D = 2+ CHARUCO_OVERLAY_2D = 3+++class Dtype(IntEnum):+ FLOAT32 = 0+ FLOAT64 = 1+++_DTYPE_NUMPY: dict[Dtype, np.dtype] = {+ Dtype.FLOAT32: np.dtype("<f4"),+ Dtype.FLOAT64: np.dtype("<f8"),+}+++def numpy_dtype_for(code: Dtype) -> np.dtype:+ return _DTYPE_NUMPY[code]+++# Fixed-width string fields: 16 bytes is enough for camera ids (UUIDs are+# truncated client-side already) and for every tracker name in skellytracker+# (`rtmpose_wholebody`, `charuco`, etc.).+CAMERA_ID_BYTES = 16+# 32 bytes covers `rtmpose_wholebody` (17 chars) and any plausibly-named+# future tracker without truncation. Keep CAMERA_ID at 16 to match the+# skellycam image protocol's camera_id field width.+TRACKER_ID_BYTES = 32+++KEYPOINTS_PAYLOAD_HEADER_FOOTER_DTYPE = np.dtype(+ [+ ("message_type", "<u1"),+ ("frame_number", "<i8"),+ ("num_blocks", "<u4"),+ ],+ align=True,+)+++KEYPOINTS_BLOCK_HEADER_DTYPE = np.dtype(+ [+ ("message_type", "<u1"),+ ("block_kind", "<u1"),+ ("dtype_code", "<u1"),+ ("dims", "<u1"),+ ("camera_id", f"S{CAMERA_ID_BYTES}"),+ ("tracker_id", f"S{TRACKER_ID_BYTES}"),+ ("num_points", "<u4"),+ ("data_byte_length", "<u4"),+ ],+ align=True,+)+++PAYLOAD_HEADER_SIZE = KEYPOINTS_PAYLOAD_HEADER_FOOTER_DTYPE.itemsize+PAYLOAD_FOOTER_SIZE = KEYPOINTS_PAYLOAD_HEADER_FOOTER_DTYPE.itemsize+BLOCK_HEADER_SIZE = KEYPOINTS_BLOCK_HEADER_DTYPE.itemsize+++__all__ = (+ "MessageType",+ "BlockKind",+ "Dtype",+ "CAMERA_ID_BYTES",+ "TRACKER_ID_BYTES",+ "KEYPOINTS_PAYLOAD_HEADER_FOOTER_DTYPE",+ "KEYPOINTS_BLOCK_HEADER_DTYPE",+ "PAYLOAD_HEADER_SIZE",+ "PAYLOAD_FOOTER_SIZE",+ "BLOCK_HEADER_SIZE",+ "numpy_dtype_for",+)diff --git a/freemocap/api/websocket/websocket_server.py b/freemocap/api/websocket/websocket_server.pyindex 042fcff6..3956e04e 100644--- a/freemocap/api/websocket/websocket_server.py+++ b/freemocap/api/websocket/websocket_server.py@@ -6,6 +6,7 @@ import dataclassesimport jsonimport loggingimport time+from queue import Emptyfrom typing import TYPE_CHECKINGimport msgspec@@ -26,7 +27,9 @@ from skellycam.core.recorders.framerate_tracker import FramerateTracker, Currentlogger = logging.getLogger(__name__)-BACKPRESSURE_WARNING_THRESHOLD: int = 100+BACKPRESSURE_WARNING_THRESHOLD: int = 300+# When outstanding acks exceed this, reset rather than stalling the pipeline indefinitely.+BACKPRESSURE_RESET_THRESHOLD: int = 300def _msgspec_enc_hook(obj: object) -> object:@@ -146,10 +149,6 @@ class WebsocketServer:self._logs_relay(),name="WebsocketLogsRelay",),- # asyncio.create_task(- # self._posthoc_progress_relay(),- # name="WebsocketPosthocProgressRelay",- # ),asyncio.create_task(self._client_message_handler(),name="WebsocketClientMessageHandler",@@ -173,22 +172,42 @@ class WebsocketServer:async def _frontend_image_relay(self) -> None:logger.info("Starting frontend image payload relay...")try:- skipped_previous = Falsewhile self.should_continue:- await await_10ms()+ # Always drain and send posthoc progress — never gate this+ # behind backpressure. Progress messages are small JSON+ # payloads that don't cause the queue-growth problem that+ # backpressure is designed to prevent.+ posthoc_progress = self._app.posthoc_pipeline_manager.get_progress_updates()+ posthoc_progress.extend(self._app.posthoc_pipeline_manager.evict_completed())+ for update_message in posthoc_progress:+ await self._send_msgspec_json(update_message)+if not self.last_frame_acknowledged():- skipped_previous = Truebackpressure = self.last_sent_frame_number - self.last_received_frontend_confirmation- if backpressure > BACKPRESSURE_WARNING_THRESHOLD and backpressure % BACKPRESSURE_WARNING_THRESHOLD == 0:- logger.trace(f"Backpressure: {backpressure} frames unacknowledged")- continue+ if backpressure >= BACKPRESSURE_RESET_THRESHOLD:+ # Frontend is too far behind. Reset rather than stalling the aggregator+ # indefinitely — a stalled aggregator causes camera-node queues to grow+ # without bound and eventually OOM the process.+ logger.warning(+ f"Frontend ack lag reached {backpressure} frames "+ f"(threshold={BACKPRESSURE_RESET_THRESHOLD}) — resetting ack counter"+ )+ self.last_received_frontend_confirmation = self.last_sent_frame_number+ # Fall through to send the next frame.+ else:+ # Still within tolerable lag — yield and wait for the ack.+ await await_10ms()+ if backpressure > BACKPRESSURE_WARNING_THRESHOLD and backpressure % BACKPRESSURE_WARNING_THRESHOLD == 0:+ logger.trace(f"Backpressure: {backpressure} frames unacknowledged")+ continue- if skipped_previous:- skipped_previous = False- continue+ # Ack received — block (off the event loop) until the+ # aggregator signals a processed frame is ready, then pull+ # and send immediately+ await self._app.wait_for_realtime_result(timeout=0.5)try:- packets, progress_updates = self._app.get_latest_frontend_payloads(if_newer_than=self.last_sent_frame_number)+ packets, progress_updates = self._app.get_latest_frontend_payloads(if_newer_than=int(self.last_sent_frame_number))except IndexError:logger.warning("Ring buffer overwrite — resetting to latest frame")self.last_sent_frame_number = -1@@ -198,6 +217,10 @@ class WebsocketServer:if packet.frontend_payload is not None:await self._send_msgspec_json(packet.frontend_payload)+ if packet.keypoints_binary_payload is not None:+ async with self._send_lock:+ await self.websocket.send_bytes(packet.keypoints_binary_payload)+if packet.images_bytearray is not None:async with self._send_lock:await self.websocket.send_bytes(packet.images_bytearray)@@ -227,7 +250,7 @@ class WebsocketServer:await self._send_msgspec_json(update_message)# Send framerate updates from our local trackers (throttled to ~4Hz)- now = time.monotonic()+ now = time.perf_counter()if now - self._last_framerate_send_time >= 0.25:for camera_group_id, server_calc in self._server_framerate_calculators.items():if camera_group_id not in self._display_framerate_trackers:@@ -255,18 +278,21 @@ class WebsocketServer:self._websocket_should_continue = Falseraise- async def _logs_relay(self, ws_log_level: int = MIN_LOG_LEVEL_FOR_WEBSOCKET):+ async def _logs_relay(self, ws_log_level: int = int(MIN_LOG_LEVEL_FOR_WEBSOCKET)):logger.info("Starting websocket log relay listener...")logs_queue = get_websocket_log_queue()try:while self.should_continue:- if not logs_queue.empty() and self.websocket.client_state == WebSocketState.CONNECTED:+ if self.websocket.client_state == WebSocketState.CONNECTED:try:# Skellycam's WebSocketQueueHandler puts LogRecordModel dicts# into the queue via put_nowait(). On rare occasions a child# process exit (cancel_join_thread) can leave a partial pickle- # in the pipe — the except below handles that gracefully.+ # in the pipe — EOFError/OSError handles that gracefully.log_entry: dict = logs_queue.get_nowait()+ except Empty:+ await await_10ms()+ continueexcept (EOFError, OSError):# Partial write from a dying child process — skip itcontinue@@ -290,36 +316,6 @@ class WebsocketServer:self._websocket_should_continue = Falseraise- # async def _posthoc_progress_relay(self) -> None:- # logger.info("Starting posthoc progress relay...")- # try:- # while self.should_continue:- # if not progress_queue.empty() and self.websocket.client_state == WebSocketState.CONNECTED:- # try:- # msg = progress_queue.get_nowait()- # except Exception:- # continue- # payload = {- # "message_type": WebsocketMessageType.POSTHOC_PROGRESS,- # "pipeline_id": msg.pipeline_id,- # "phase": msg.phase,- # "progress_fraction": msg.progress_fraction,- # "detail": msg.detail,- # }- # await self._send_msgspec_json(payload)- # else:- # await await_10ms()- # except asyncio.CancelledError:- # logger.debug("Posthoc progress relay task cancelled")- # except WebSocketDisconnect:- # logger.info("Client disconnected, ending posthoc progress relay task...")- # except Exception as e:- # logger.exception(- # f"Error in posthoc progress relay: {e.__class__.__name__}: {e}"- # )- # self._websocket_should_continue = False- # raise-async def _client_message_handler(self):"""Handle messages from the client, including settings messages."""logger.info("Starting client message handler...")diff --git a/freemocap/app/app.py b/freemocap/app/app.pyindex 9846bc34..6f79ce9a 100644--- a/freemocap/app/app.py+++ b/freemocap/app/app.py@@ -3,11 +3,15 @@ Consolidated FastAPI app factory with proper lifecycle management."""import loggingimport multiprocessing+import platform+import subprocess+import sysfrom contextlib import asynccontextmanagerfrom multiprocessing.sharedctypes import Synchronizedfrom pathlib import Pathfrom typing import AsyncGenerator+import psutilimport skellycamfrom fastapi import FastAPIfrom fastapi.openapi.utils import get_openapi@@ -29,6 +33,297 @@ from freemocap.system.default_paths import (logger = logging.getLogger(__name__)+# ── GPU hardware detection ───────────────────────────────────────────────+++def _query_nvidia_smi() -> list[dict]:+ """Query NVIDIA GPUs via nvidia-smi.++ Returns a list of dicts with keys: name, vram_gb, driver_version, compute_capability.+ Returns an empty list if nvidia-smi is unavailable or fails.+ """+ try:+ result = subprocess.run(+ ["nvidia-smi",+ "--query-gpu=name,memory.total,driver_version,compute_cap",+ "--format=csv,noheader"],+ capture_output=True, text=True, timeout=10,+ )+ except (FileNotFoundError, subprocess.TimeoutExpired):+ return []++ if result.returncode != 0 or not result.stdout.strip():+ # Retry without compute_cap for older nvidia-smi versions+ try:+ result = subprocess.run(+ ["nvidia-smi",+ "--query-gpu=name,memory.total,driver_version",+ "--format=csv,noheader"],+ capture_output=True, text=True, timeout=10,+ )+ except (FileNotFoundError, subprocess.TimeoutExpired):+ return []++ if result.returncode != 0 or not result.stdout.strip():+ return []++ gpus: list[dict] = []+ for line in result.stdout.strip().splitlines():+ if not line.strip():+ continue+ parts = [p.strip() for p in line.split(",", maxsplit=3)]+ # memory.total comes back as e.g. "24576 MiB" — strip the unit+ vram_mib = 0.0+ if len(parts) > 1 and parts[1]:+ vram_str = parts[1].replace("MiB", "").replace(" ", "").strip()+ try:+ vram_mib = float(vram_str)+ except ValueError:+ vram_mib = 0.0+ gpu: dict = {+ "name": parts[0] if parts[0] else "Unknown NVIDIA GPU",+ "vram_gb": f"{vram_mib / 1024:.1f} GB" if vram_mib > 0 else None,+ "driver_version": parts[2] if len(parts) > 2 and parts[2] else None,+ "compute_capability": parts[3] if len(parts) > 3 and parts[3] else None,+ }+ gpus.append(gpu)+ return gpus+++def _query_wmic_gpus() -> list[dict]:+ """Fallback GPU detection on Windows via WMIC."""+ try:+ result = subprocess.run(+ ["wmic", "path", "win32_videocontroller",+ "get", "name,adapterram",+ "/format:csv"],+ capture_output=True, timeout=10,+ )+ except (FileNotFoundError, subprocess.TimeoutExpired):+ return []++ if result.returncode != 0 or not result.stdout.strip():+ return []++ # WMIC outputs UTF-16LE with BOM; decode explicitly+ stdout = result.stdout.decode("utf-16-le", errors="replace")++ gpus: list[dict] = []+ for line in stdout.strip().splitlines():+ if not line.strip() or "Node," in line:+ continue+ # WMIC CSV column order is: Node,AdapterRAM,Name+ parts = [p.strip() for p in line.split(",", maxsplit=2)]+ if len(parts) < 3 or not parts[2]:+ continue+ name = parts[2]+ vram_bytes = int(parts[1]) if parts[1].isdigit() else 0+ gpu: dict = {+ "name": name,+ "vram_gb": f"{vram_bytes / 1e9:.1f} GB" if vram_bytes > 0 else None,+ "driver_version": None,+ "compute_capability": None,+ }+ gpus.append(gpu)+ return gpus+++def _query_lspci_gpus() -> list[dict]:+ """Fallback GPU detection on Linux via lspci."""+ try:+ result = subprocess.run(+ ["lspci"], capture_output=True, text=True, timeout=10,+ )+ except (FileNotFoundError, subprocess.TimeoutExpired):+ return []++ if result.returncode != 0:+ return []++ gpus: list[dict] = []+ for line in result.stdout.strip().splitlines():+ if not any(tag in line for tag in ("VGA", "3D", "Display")):+ continue+ # lspci format: "00:02.0 VGA compatible controller: Intel Corporation ..."+ name = line.split(":", 2)[-1].strip() if ":" in line else line.strip()+ gpu: dict = {+ "name": name,+ "vram_gb": None,+ "driver_version": None,+ "compute_capability": None,+ }+ gpus.append(gpu)+ return gpus+++def _query_macos_gpus() -> list[dict]:+ """Fallback GPU detection on macOS via system_profiler."""+ try:+ result = subprocess.run(+ ["system_profiler", "SPDisplaysDataType"],+ capture_output=True, text=True, timeout=10,+ )+ except (FileNotFoundError, subprocess.TimeoutExpired):+ return []++ if result.returncode != 0:+ return []++ gpus: list[dict] = []+ current: dict | None = None+ for line in result.stdout.splitlines():+ stripped = line.strip()+ if stripped.startswith("Chipset Model:"):+ if current is not None:+ gpus.append(current)+ current = {"name": stripped.split(":", 1)[1].strip(),+ "vram_gb": None, "driver_version": None, "compute_capability": None}+ elif current is not None and stripped.startswith("VRAM"):+ vram_str = stripped.split(":", 1)[1].strip()+ # Normalize: "8 GB" or "8192 MB" → "8.0 GB"+ current["vram_gb"] = vram_str+ elif current is not None and stripped.startswith("Metal:"):+ current["metal"] = stripped.split(":", 1)[1].strip()+ if current is not None:+ gpus.append(current)+ return gpus+++def _detect_gpus() -> list[dict]:+ """Detect GPU hardware, trying multiple strategies in priority order."""+ gpus = _query_nvidia_smi()+ if gpus:+ return gpus++ system = platform.system()+ if system == "Windows":+ return _query_wmic_gpus()+ elif system == "Linux":+ return _query_lspci_gpus()+ elif system == "Darwin":+ return _query_macos_gpus()++ return []+++def _format_gpu_section(gpus: list[dict]) -> str:+ """Format the GPU hardware section for log output."""+ if not gpus:+ return " GPU: None detected"++ lines: list[str] = [" GPU:"]+ for i, gpu in enumerate(gpus):+ lines.append(f" GPU {i}: {gpu['name']}")+ if gpu.get("vram_gb"):+ lines.append(f" VRAM: {gpu['vram_gb']}")+ if gpu.get("driver_version"):+ lines.append(f" Driver Version: {gpu['driver_version']}")+ if gpu.get("compute_capability"):+ lines.append(f" Compute Capability: {gpu['compute_capability']}")+ return "\n".join(lines)+++# ── ONNX Runtime detection ───────────────────────────────────────────────+++def _get_onnx_info() -> tuple[str | None, list[str]]:+ """Get ONNX Runtime version and available execution providers."""+ try:+ import onnxruntime # noqa: TC002+ except Exception:+ return None, []+ try:+ return onnxruntime.__version__, onnxruntime.get_available_providers()+ except Exception:+ return None, []+++def _format_onnx_section(version: str | None, providers: list[str], gpus: list[dict]) -> str:+ """Format the ONNX Runtime section for log output."""+ lines: list[str] = [" ONNX Runtime:"]++ if version:+ lines.append(f" Version: {version}")+ else:+ lines.append(" Version: Not installed")++ if providers:+ lines.append(f" Providers: {', '.join(providers)}")++ # GPU acceleration capability summary+ has_cuda = any("CUDA" in p for p in providers)+ has_trt = any("Tensorrt" in p for p in providers)+ has_gpu_hw = bool(gpus)++ if has_cuda:+ lines.append(f" GPU acceleration: Available (CUDAExecutionProvider)")+ elif has_trt:+ lines.append(f" GPU acceleration: Available (TensorrtExecutionProvider)")+ elif has_gpu_hw:+ if not version:+ lines.append(" GPU acceleration: Not available — ONNX Runtime not installed")+ else:+ lines.append(" GPU acceleration: Not available — onnxruntime-gpu may not be installed")+ else:+ lines.append(" GPU acceleration: Not available — no GPU detected")++ return "\n".join(lines)+++# ── Main system info logger ──────────────────────────────────────────────+++def _log_system_info() -> None:+ def _pkg_ver(name: str) -> str:+ try:+ mod = __import__(name)+ return mod.__version__+ except Exception:+ return "n/a"++ skelly_pkgs = {+ "skellycam": _pkg_ver("skellycam"),+ "skellytracker": _pkg_ver("skellytracker"),+ "skellyforge": _pkg_ver("skellyforge"),+ "skellylogs": _pkg_ver("skellylogs"),+ "skellypings": _pkg_ver("skellypings"),+ "freemocap_blender_addon": _pkg_ver("freemocap_blender_addon"),+ }++ skelly_pkg_str = "\n".join(f" {k}={v}" for k, v in skelly_pkgs.items())++ vm = psutil.virtual_memory()+ cpu_physical = psutil.cpu_count(logical=False)+ cpu_logical = psutil.cpu_count(logical=True)+ try:+ cpu_freq_ghz = f"{psutil.cpu_freq().current / 1000:.2f} GHz"+ except Exception:+ cpu_freq_ghz = "unknown"++ gpus = _detect_gpus()+ onnx_version, onnx_providers = _get_onnx_info()++ gpu_section = _format_gpu_section(gpus)+ onnx_section = _format_onnx_section(onnx_version, onnx_providers, gpus)++ logger.info(+ f"\n"+ f" System info:\n"+ f" OS: {platform.system()} {platform.release()} ({platform.version()})\n"+ f" CPU: {platform.processor()} -- {cpu_physical} physical / {cpu_logical} logical cores @ {cpu_freq_ghz}\n"+ f" RAM: {vm.total / 1e9:.1f} GB total, {vm.available / 1e9:.1f} GB available\n"+ f" Python: {sys.version}\n"+ f" FreeMoCap: {freemocap.__version__}\n"+ f"\n"+ f"{gpu_section}\n"+ f"\n"+ f"{onnx_section}\n"+ f"\n"+ f" Skelly Packages:\n"+ f"{skelly_pkg_str}"+ )++@asynccontextmanagerasync def app_lifespan(app: FastAPI@@ -39,6 +334,7 @@ async def app_lifespan("""# ===== STARTUP =====logger.api("FreeMoCap API starting...")+ _log_system_info()# Ensure base folder existsbase_path = Path(get_default_freemocap_base_folder_path())diff --git a/freemocap/app/freemocap_application.py b/freemocap/app/freemocap_application.pyindex 319b8488..4ee3ce2a 100644--- a/freemocap/app/freemocap_application.py+++ b/freemocap/app/freemocap_application.py@@ -12,6 +12,7 @@ from skellycam.core.camera.config.camera_config import CameraConfigsfrom skellycam.core.camera_group.camera_group_manager import CameraGroupManager, get_or_create_camera_group_managerfrom skellycam.core.ipc.process_management.worker_registry import WorkerRegistryfrom skellycam.core.recorders.videos.recording_info import RecordingInfo+from skellycam.core.types.type_overloads import CameraIdStringfrom freemocap.core.pipeline.posthoc.posthoc_pipeline import PosthocPipelinefrom freemocap.core.pipeline.posthoc.posthoc_pipeline_manager import PosthocPipelineManager@@ -22,7 +23,7 @@ from freemocap.core.tasks.calibration.calibration_task_config import PosthocCalifrom freemocap.core.tasks.mocap.mocap_task_config import PosthocMocapPipelineConfigfrom freemocap.core.types.type_overloads import FrameNumberIntfrom freemocap.core.viz.frontend_payload import FrontendImagePacket, FrontendPayload-from freemocap.pubsub.pubsub_topics import PipelineProgressMessage+from freemocap.core.pipeline.posthoc.progress_messages import PipelineProgressMessagelogger = logging.getLogger(__name__)@@ -82,8 +83,9 @@ class FreemocapApplication:async def create_or_update_realtime_pipeline(self,- camera_configs:CameraConfigs,+ camera_configs: CameraConfigs,pipeline_config: RealtimePipelineConfig,+ realtime_camera_ids: list[CameraIdString] | None = None,) -> RealtimePipeline:for pipeline in self.realtime_pipeline_manager.pipelines.values():@@ -96,6 +98,7 @@ class FreemocapApplication:pipeline = self.realtime_pipeline_manager.create_pipeline(camera_group=camera_group,pipeline_config=pipeline_config,+ realtime_camera_ids=realtime_camera_ids,)return pipeline@@ -125,22 +128,36 @@ class FreemocapApplication:)return pipeline+ def stop_posthoc_pipeline(self, pipeline_id: str) -> bool:+ return self.posthoc_pipeline_manager.stop_pipeline(pipeline_id)++ def stop_all_posthoc_pipelines(self) -> None:+ self.posthoc_pipeline_manager.stop_all_pipelines()# ------------------------------------------------------------------# Frontend payloads# ------------------------------------------------------------------+ async def wait_for_realtime_result(self, timeout: float = 0.5) -> None:+ """Yield until at least one realtime pipeline has a processed frame ready.++ Used by the websocket relay for an event-driven wake-up. Falls back immediately when no pipeline is alive (camera-only or idle mode).+ """+ await self.realtime_pipeline_manager.wait_for_any_result_ready(timeout=timeout)+def get_latest_frontend_payloads(self,if_newer_than: FrameNumberInt,- ) ->tuple[list[FrontendImagePacket], list[PipelineProgressMessage]]:- self.posthoc_pipeline_manager.evict_completed()+ ) -> tuple[list[FrontendImagePacket], list[PipelineProgressMessage]]:+ # Drain BEFORE evicting so terminal COMPLETE/FAILED messages aren't lost+ posthoc_progress = self.posthoc_pipeline_manager.get_progress_updates()+ posthoc_progress.extend(self.posthoc_pipeline_manager.evict_completed())realtime_pipelines = self.realtime_pipeline_manager.pipelinesactive_pipelines = [p for p in realtime_pipelines.values() if p.alive]if not active_pipelines:- # Camera-only path+ # Camera-only / posthoc-only pathresults: list[FrontendImagePacket] = []for cg_id, payload in self.camera_group_manager.get_latest_frontend_payloads(if_newer_than=if_newer_than@@ -149,18 +166,16 @@ class FreemocapApplication:results.append(FrontendImagePacket(images_bytearray=image_bytes,multiframe_timestamp=mf_timestamp,- frontend_payload=FrontendPayload(camera_group_id=cg_id,frame_number=frame_number),+ frontend_payload=FrontendPayload(camera_group_id=cg_id, frame_number=frame_number),))- return results, []+ return results, posthoc_progress- # Pipeline path — delegate to manager, which also returns FrontendImagePacket- realtime_pipeline_packets = self.realtime_pipeline_manager.get_latest_frontend_payloads(+ # Realtime pipeline path — delegate to manager, which also returns FrontendImagePacket+ realtime_pipeline_packets = self.realtime_pipeline_manager.get_latest_frontend_payloads(if_newer_than=if_newer_than)- posthoc_pipeline_progress_messages = self.posthoc_pipeline_manager.get_progress_updates()-- return realtime_pipeline_packets, posthoc_pipeline_progress_messages+ return realtime_pipeline_packets, posthoc_progress# ------------------------------------------------------------------# Lifecyclediff --git a/freemocap/core/blender/export_to_blender.py b/freemocap/core/blender/export_to_blender.pyindex 53938ab6..887387a2 100644--- a/freemocap/core/blender/export_to_blender.py+++ b/freemocap/core/blender/export_to_blender.py@@ -82,12 +82,10 @@ def export_to_blender(blender_process = run_subprocess(command_list=command_list)- while True:- output = blender_process.stdout.readline()- if blender_process.poll() is not None:- break- if output:- logging.debug(output.strip().decode())+ stdout, _ = blender_process.communicate()+ if stdout:+ for line in stdout.decode().splitlines():+ logging.debug(line)if blender_process.returncode != 0:logging.error(f"Blender subprocess exited with non-zero return code: {blender_process.returncode}")diff --git a/freemocap/core/pipeline/pipeline_stage_timer.py b/freemocap/core/pipeline/pipeline_stage_timer.pynew file mode 100644index 00000000..7a325159--- /dev/null+++ b/freemocap/core/pipeline/pipeline_stage_timer.py@@ -0,0 +1,69 @@+"""+PipelineStageTimer: per-node accumulator for stage timings.++Records `elapsed_ms` samples per named stage. Periodically flushes the+accumulated samples to a publication queue as a `PipelineTimingMessage`.+The aggregator runs a `PipelineTimingReporter` thread that subscribes,+maintains rolling windows across all nodes, and prints one consolidated+report (see `pipeline_timing_reporter.py`).+"""+import logging+import time+from dataclasses import dataclass, field+from queue import Full++from freemocap.core.types.type_overloads import TopicPublicationQueue++logger = logging.getLogger(__name__)++FLUSH_INTERVAL_SECONDS: float = 5.0+ROLLING_WINDOW_FRAMES: int = 500+++@dataclass+class PipelineStageTimer:+ """Accumulates per-stage elapsed times and flushes them to a pubsub topic."""++ name: str+ flush_interval: float = field(default=FLUSH_INTERVAL_SECONDS)+ last_flush: float = field(default_factory=time.monotonic)+ samples: dict[str, list[float]] = field(default_factory=dict)++ def record(self, stage: str, elapsed_ms: float) -> None:+ if stage not in self.samples:+ self.samples[stage] = []+ self.samples[stage].append(elapsed_ms)++ def maybe_flush(+ self,+ *,+ publication_queue: TopicPublicationQueue,+ node_kind: str,+ camera_id: str | None = None,+ ) -> None:+ from freemocap.pubsub.pubsub_topics import PipelineTimingMessage++ now = time.perf_counter()+ if now - self.last_flush < self.flush_interval:+ return+ self.last_flush = now+ if not self.samples:+ return++ batch = {stage: list(values) for stage, values in self.samples.items() if values}+ for values in self.samples.values():+ values.clear()+ if not batch:+ return++ msg = PipelineTimingMessage(+ node_kind=node_kind,+ node_label=self.name,+ camera_id=camera_id,+ samples=batch,+ )+ try:+ publication_queue.put_nowait(msg)+ except Full:+ # Timing is best-effort; drop the batch rather than blocking the pipeline.+ passdiff --git a/freemocap/core/pipeline/pipeline_timing_reporter.py b/freemocap/core/pipeline/pipeline_timing_reporter.pynew file mode 100644index 00000000..42c047f6--- /dev/null+++ b/freemocap/core/pipeline/pipeline_timing_reporter.py@@ -0,0 +1,291 @@+"""+PipelineTimingReporter: a daemon thread (run inside the aggregator subprocess)+that subscribes to PipelineTimingTopic, maintains rolling per-stage buffers,+and periodically prints one consolidated report.++Camera-node samples for the same stage collapse across cameras into ensemble+statistics so adding cameras doesn't multiply log volume. A `cam-spread`+column surfaces straggler cameras (max - min of per-camera means).+"""+import collections+import logging+import threading+import time+from dataclasses import dataclass, field+from queue import Empty++import numpy as np+from skellycam.core.types.type_overloads import TopicSubscriptionQueue+from tabulate import tabulate++from freemocap.core.pipeline.pipeline_stage_timer import ROLLING_WINDOW_FRAMES++logger = logging.getLogger(__name__)++REPORT_INTERVAL_SECONDS: float = 30.0+SEPARATOR_WIDTH: int = 100+PRECISION: int = 2++# Per node-kind classification of which stage names contribute to the wrapper+# (their medians sum to ~the wrapper's median; the % column is meaningful),+# vs. framing/derived stats that share the table but are not sub-stages of+# the wrapper (% column shows "-" for these).+@dataclass(frozen=True)+class _SectionLayout:+ substages: tuple[str, ...]+ wrapper: str | None+ framing: tuple[str, ...] = ()+++SECTION_LAYOUTS: dict[str, _SectionLayout] = {+ "aggregator": _SectionLayout(+ substages=(+ "skeleton_triangulation",+ "charuco_triangulation",+ "keypoint_filter",+ "velocity_gate",+ "skeleton_filter",+ ),+ wrapper="full_frame_processing",+ framing=("frame_collection_wait", "loop_time"),+ ),+ "skeleton_inference": _SectionLayout(+ substages=("frame_read", "predict_batch"),+ wrapper=None,+ framing=("predict_per_camera", "dropped_frames"),+ ),+ "camera": _SectionLayout(+ substages=("skeleton_detection", "charuco_detection"),+ wrapper="total_camera_node",+ ),+}+++@dataclass+class PipelineTimingReporter:+ """Subscribes to PipelineTimingTopic and emits a consolidated report periodically."""++ name: str+ timing_sub: TopicSubscriptionQueue+ stop_event: threading.Event+ expected_camera_count: int = 0+ report_interval: float = REPORT_INTERVAL_SECONDS++ # Per-camera buffers: (camera_id, stage) -> deque+ _camera_samples: dict[tuple[str, str], collections.deque] = field(default_factory=dict)+ # Non-camera node buffers: (node_kind, stage) -> deque+ _node_samples: dict[tuple[str, str], collections.deque] = field(default_factory=dict)+ # Track the most recent label seen per node_kind for nicer section headers+ _node_labels: dict[str, str] = field(default_factory=dict)++ _thread: threading.Thread | None = None+ _new_data_since_last_report: bool = False++ def start(self) -> None:+ if self._thread is not None:+ return+ self._thread = threading.Thread(+ target=self._run,+ name=f"PipelineTimingReporter-{self.name}",+ daemon=True,+ )+ self._thread.start()++ def join(self, timeout: float | None = None) -> None:+ if self._thread is not None:+ self._thread.join(timeout=timeout)++ def _run(self) -> None:+ from freemocap.pubsub.pubsub_topics import PipelineTimingMessage++ last_report = time.perf_counter()+ try:+ while not self.stop_event.is_set():+ try:+ msg: PipelineTimingMessage = self.timing_sub.get(timeout=0.5)+ except Empty:+ msg = None+ if msg is not None:+ self._ingest(msg)++ now = time.perf_counter()+ if now - last_report >= self.report_interval:+ last_report = now+ if self._new_data_since_last_report:+ self._new_data_since_last_report = False+ self._print_report()+ except Exception as e:+ logger.error(f"PipelineTimingReporter [{self.name}] crashed: {e}", exc_info=True)++ def _ingest(self, msg) -> None:+ self._new_data_since_last_report = True+ if msg.node_label:+ self._node_labels[msg.node_kind] = msg.node_label+ if msg.node_kind == "camera" and msg.camera_id is not None:+ for stage, values in msg.samples.items():+ key = (msg.camera_id, stage)+ if key not in self._camera_samples:+ self._camera_samples[key] = collections.deque(maxlen=ROLLING_WINDOW_FRAMES)+ self._camera_samples[key].extend(values)+ else:+ for stage, values in msg.samples.items():+ key = (msg.node_kind, stage)+ if key not in self._node_samples:+ self._node_samples[key] = collections.deque(maxlen=ROLLING_WINDOW_FRAMES)+ self._node_samples[key].extend(values)++ def _print_report(self) -> None:+ if not self._camera_samples and not self._node_samples:+ return++ sep = "─" * SEPARATOR_WIDTH+ sections: list[str] = [sep, f"Pipeline Timing Report — {self.name}", ""]++ for kind in ("aggregator", "skeleton_inference"):+ stage_to_arr = {+ stage: np.array(self._node_samples[(k, stage)])+ for (k, stage) in self._node_samples.keys()+ if k == kind+ }+ if not stage_to_arr:+ continue+ label = self._node_labels.get(kind, kind)+ table = _build_table(+ stage_to_samples=stage_to_arr,+ layout=SECTION_LAYOUTS.get(kind),+ )+ sections.append("")+ sections.append(f"[ {label} ]")+ sections.append(table)++ # Camera ensemble: collapse across camera_id for each stage+ if self._camera_samples:+ cam_ids = sorted({cam for (cam, _) in self._camera_samples.keys()})+ stages = sorted({stage for (_, stage) in self._camera_samples.keys()})+ stage_to_pooled: dict[str, np.ndarray] = {}+ stage_to_cam_spread: dict[str, float] = {}+ for stage in stages:+ samples_per_cam = [+ np.array(self._camera_samples[(cam, stage)])+ for cam in cam_ids+ if (cam, stage) in self._camera_samples+ and len(self._camera_samples[(cam, stage)]) > 0+ ]+ if not samples_per_cam:+ continue+ stage_to_pooled[stage] = np.concatenate(samples_per_cam)+ per_cam_means = [float(np.mean(s)) for s in samples_per_cam]+ stage_to_cam_spread[stage] = (+ max(per_cam_means) - min(per_cam_means) if len(per_cam_means) > 1 else 0.0+ )++ if stage_to_pooled:+ table = _build_table(+ stage_to_samples=stage_to_pooled,+ layout=SECTION_LAYOUTS.get("camera"),+ cam_spread_by_stage=stage_to_cam_spread,+ )+ seen = len(cam_ids)+ if self.expected_camera_count and self.expected_camera_count != seen:+ cam_header = (+ f"[ Camera ensemble — {seen}/{self.expected_camera_count} "+ f"cameras reporting (pooled samples) ]"+ )+ else:+ total = self.expected_camera_count or seen+ cam_header = f"[ Camera ensemble — {total} cameras (pooled samples) ]"+ sections.append("")+ sections.append(cam_header)+ sections.append(table)++ sections.append(sep)+ logger.info("\n" + "\n".join(sections))+++def _build_table(+ *,+ stage_to_samples: dict[str, np.ndarray],+ layout: _SectionLayout | None,+ cam_spread_by_stage: dict[str, float] | None = None,+) -> str:+ """Build a tabulated stage-statistics table for one section.++ `layout` defines which stage names are sub-stages (their medians roll up+ into the wrapper, and the % column is computed against the wrapper or+ against the substage-median sum). Framing/derived stages share the table+ but show "-" in the % column.+ """+ p = PRECISION+ headers = ["Stage", "n", "Median", "Mean", "Std", "Q1", "Q3", "% of Total"]+ if cam_spread_by_stage is not None:+ headers.append("Cam-spread")++ if layout is None:+ layout = _SectionLayout(+ substages=tuple(sorted(stage_to_samples.keys())),+ wrapper=None,+ framing=(),+ )++ present_substages = [s for s in layout.substages if s in stage_to_samples]+ present_framing = [s for s in layout.framing if s in stage_to_samples]+ wrapper = layout.wrapper if layout.wrapper in stage_to_samples else None+ # Surface anything we didn't classify so a new stage doesn't silently vanish.+ classified = set(present_substages) | set(present_framing) | ({wrapper} if wrapper else set())+ extras = sorted(s for s in stage_to_samples.keys() if s not in classified)++ if wrapper is not None:+ denominator = float(np.median(stage_to_samples[wrapper]))+ else:+ denominator = sum(float(np.median(stage_to_samples[s])) for s in present_substages)++ def _row(stage: str, samples: np.ndarray, *, show_pct: bool) -> list[str]:+ if len(samples) == 0:+ row = [stage, "0", "-", "-", "-", "-", "-", "-"]+ if cam_spread_by_stage is not None:+ row.append("-")+ return row+ median = float(np.median(samples))+ pct_str = (+ f"{(median / denominator * 100.0):.1f}%"+ if (show_pct and denominator > 0)+ else "-"+ )+ row = [+ stage,+ str(len(samples)),+ f"{median:.{p}f}",+ f"{np.mean(samples):.{p}f}",+ f"{np.std(samples):.{p}f}",+ f"{np.percentile(samples, 25):.{p}f}",+ f"{np.percentile(samples, 75):.{p}f}",+ pct_str,+ ]+ if cam_spread_by_stage is not None:+ row.append(f"{cam_spread_by_stage.get(stage, 0.0):.{p}f}")+ return row++ rows: list[list[str]] = []+ blank_row = [""] * len(headers)++ for stage in present_substages:+ rows.append(_row(stage, stage_to_samples[stage], show_pct=True))++ if wrapper is not None:+ wrapper_row = _row(wrapper, stage_to_samples[wrapper], show_pct=True)+ wrapper_row[0] = f"TOTAL: {wrapper}"+ rows.append(wrapper_row)++ if present_framing or extras:+ rows.append(blank_row)+ for stage in present_framing + extras:+ rows.append(_row(stage, stage_to_samples[stage], show_pct=False))++ return tabulate(+ rows,+ headers=headers,+ tablefmt="simple",+ stralign="left",+ numalign="right",+ disable_numparse=True,+ )diff --git a/freemocap/core/pipeline/posthoc/pipeline_phases.py b/freemocap/core/pipeline/posthoc/pipeline_phases.pynew file mode 100644index 00000000..d65a1ac9--- /dev/null+++ b/freemocap/core/pipeline/posthoc/pipeline_phases.py@@ -0,0 +1,53 @@+"""+Enum definitions for all posthoc pipeline phase strings.++These values are sent over the WebSocket to the frontend as-is, so the string+values must stay in sync with the BACKEND_PHASE_MAP in ServerContextProvider.tsx.+"""+from enum import Enum+++class _StrValueEnum(str, Enum):+ """Base that makes str() return the value, not 'ClassName.MEMBER'."""+ def __str__(self) -> str:+ return self.value+++class VideoNodePhase(_StrValueEnum):+ """Phases emitted by individual video processing nodes."""+ SETTING_UP = "setting_up"+ PROCESSING_IMAGES = "processing_images"+ COMPLETE = "complete"+ FAILED = "failed"+++class AggregatorPhase(_StrValueEnum):+ """Phases emitted by the posthoc aggregation node itself."""+ COLLECTING_CAMERA_OUTPUT = "collecting_camera_output"+ COMPLETE = "complete"+ FAILED = "failed"+++class MocapStage(_StrValueEnum):+ """Stages within the posthoc mocap task function."""+ BUILDING_RECORDERS = "building_recorders"+ TRIANGULATING = "triangulating"+ EXPORTING_BLENDER = "exporting_blender"+++class CalibrationStage(_StrValueEnum):+ """Stages within the posthoc calibration task function."""+ VALIDATING_OBSERVATIONS = "validating_observations"+ RUNNING_SOLVER = "running_solver"+ SAVING_CALIBRATION = "saving_calibration"+++class PosthocPipelineType(_StrValueEnum):+ """Identifies what kind of posthoc pipeline is running.++ Sent over the WebSocket in every progress message so the frontend can+ route updates to the correct Redux slice without guessing from phase names.+ Must stay in sync with PipelineType in pipelines-slice.ts.+ """+ CALIBRATION = "calibration"+ MOCAP = "mocap"diff --git a/freemocap/core/pipeline/posthoc/posthoc_aggregation_node.py b/freemocap/core/pipeline/posthoc/posthoc_aggregation_node.pyindex 49ac8d38..f8505431 100644--- a/freemocap/core/pipeline/posthoc/posthoc_aggregation_node.py+++ b/freemocap/core/pipeline/posthoc/posthoc_aggregation_node.py@@ -9,36 +9,40 @@ The task function signature must be:def my_task(*,- frame_observations: list[dict[VideoIdString, BaseObservation]],+ frame_observations: list[dict[CameraIdString, BaseObservation]],recording_info: RecordingInfo,- video_metadata: dict[VideoIdString, VideoMetadata],- report_progress: Callable[[str, float], None],+ video_metadata: dict[CameraIdString, VideoMetadata],+ reporter: TaskProgressReporter | None = None,) -> None:Additional task-specific kwargs are pre-bound via functools.partial."""import loggingimport multiprocessing-from collections.abc import Callablefrom dataclasses import dataclassfrom multiprocessing.sharedctypes import Synchronized+from pathlib import Path+from typing import Callablefrom skellycam.core.ipc.process_management.worker_registry import WorkerRegistryfrom skellycam.core.recorders.videos.recording_info import RecordingInfo-from skellycam.core.types.type_overloads import TopicSubscriptionQueue+from skellycam.core.types.type_overloads import CameraIdString, TopicSubscriptionQueuefrom freemocap.core.pipeline.abcs.aggregator_node_abc import AggregatorNodefrom freemocap.core.pipeline.abcs.pipeline_ipc import PipelineIPC+from freemocap.core.pipeline.posthoc.pipeline_phases import AggregatorPhase, PosthocPipelineType+from freemocap.core.pipeline.posthoc.task_progress_reporter import TaskProgressReporterfrom freemocap.core.pipeline.posthoc.video_group_helper import VideoMetadata-from freemocap.core.types.type_overloads import PipelineIdString, FrameNumberInt, VideoIdString, TopicPublicationQueue+from freemocap.core.types.type_overloads import PipelineIdString, FrameNumberInt, TopicPublicationQueuefrom freemocap.pubsub.pubsub_manager import PubSubTopicManager+from freemocap.core.pipeline.posthoc.progress_messages import AggregatorNodeProgressMessage, PipelineProgressMessagefrom freemocap.pubsub.pubsub_topics import (VideoNodeOutputMessage,VideoNodeOutputTopic,- AggregatorNodeProgressTopic,- AggregatorNodeProgressMessage, PipelineProgressMessage,)-from freemocap.utilities.wait_functions import wait_1ms+from tqdm import tqdm++from queue import Emptylogger = logging.getLogger(__name__)@@ -54,13 +58,15 @@ class PosthocAggregationNode(AggregatorNode):cls,*,aggregation_task_fn: PosthocAggregationNodeTaskFn,- video_metadata: dict[VideoIdString, VideoMetadata],+ video_metadata: dict[CameraIdString, VideoMetadata],pipeline_id: PipelineIdString,+ pipeline_type: PosthocPipelineType,recording_info: RecordingInfo,worker_registry: WorkerRegistry,ipc: PipelineIPC,pubsub: PubSubTopicManager,) -> "PosthocAggregationNode":+ _progress_queue: multiprocessing.queues.Queue = multiprocessing.Queue()shutdown_self_flag, worker = cls._create_worker(target=cls._run,name=f"Pipeline-{pipeline_id}-PosthocAggregationNode",@@ -69,22 +75,19 @@ class PosthocAggregationNode(AggregatorNode):kwargs=dict(aggregation_task_fn=aggregation_task_fn,pipeline_id=pipeline_id,+ pipeline_type=pipeline_type,recording_info=recording_info,video_metadata=video_metadata,ipc=ipc,- aggregator_progress_pub=pubsub.get_publication_queue(- AggregatorNodeProgressTopic- ),+ aggregator_progress_pub=_progress_queue,video_node_output_subscription=pubsub.get_subscription(VideoNodeOutputTopic,),),-)return cls(shutdown_self_flag=shutdown_self_flag,- progress_subscription=pubsub.get_subscription(- AggregatorNodeProgressTopic,),+ progress_subscription=_progress_queue,worker=worker,)@@ -93,14 +96,19 @@ class PosthocAggregationNode(AggregatorNode):*,aggregation_task_fn: PosthocAggregationNodeTaskFn,pipeline_id: PipelineIdString,+ pipeline_type: PosthocPipelineType,recording_info: RecordingInfo,- video_metadata: dict[VideoIdString, VideoMetadata],+ video_metadata: dict[CameraIdString, VideoMetadata],ipc: PipelineIPC,shutdown_self_flag: Synchronized,video_node_output_subscription: TopicSubscriptionQueue,aggregator_progress_pub: TopicPublicationQueue,) -> None:+ rec_path = Path(recording_info.full_recording_path)+ rec_name = rec_path.name+ rec_path_str = str(rec_path)+start_frames = set(vm.start_frame for vm in video_metadata.values())end_frames = set(vm.end_frame for vm in video_metadata.values())if len(start_frames) != 1 or len(end_frames) != 1:@@ -111,56 +119,81 @@ class PosthocAggregationNode(AggregatorNode):start_frame = start_frames.pop()end_frame = end_frames.pop()frame_numbers = list(range(start_frame, end_frame))- video_ids = list(video_metadata.keys())- total_expected = len(frame_numbers) * len(video_ids)-- progress_message = AggregatorNodeProgressMessage(pipeline_id=pipeline_id,- frame_count=total_expected)- aggregator_progress_pub.put(progress_message)+ camera_ids = list(video_metadata.keys())+ total_expected = len(frame_numbers) * len(camera_ids)++ aggregator_progress_pub.put(AggregatorNodeProgressMessage(+ pipeline_id=pipeline_id,+ pipeline_type=str(pipeline_type),+ phase=AggregatorPhase.COLLECTING_CAMERA_OUTPUT,+ progress_fraction=0.0,+ detail=f"Collecting observations from {len(camera_ids)} cameras ({total_expected} total)",+ recording_name=rec_name,+ recording_path=rec_path_str,+ ))logger.debug(f"PosthocAggregationNode [{pipeline_id}] starting — "- f"expecting {len(frame_numbers)} frames × {len(video_ids)} videos "+ f"expecting {len(frame_numbers)} frames × {len(camera_ids)} cameras "f"= {total_expected} outputs")- video_outputs_by_frame: dict[FrameNumberInt, dict[VideoIdString, VideoNodeOutputMessage | None]] = {- frame_number: {vid: None for vid in video_ids}+ video_outputs_by_frame: dict[FrameNumberInt, dict[CameraIdString, VideoNodeOutputMessage | None]] = {+ frame_number: {cam: None for cam in camera_ids}for frame_number in frame_numbers}got_all_by_frame: dict[FrameNumberInt, bool] = {frame_number: False for frame_number in frame_numbers}received_count: int = 0+ _error_occurred = True # pessimistic; cleared to False only on clean completiontry:- while not shutdown_self_flag.value and ipc.should_continue:- wait_1ms()-- if video_node_output_subscription.empty():- continue-- msg: VideoNodeOutputMessage = video_node_output_subscription.get()-- if msg.video_id not in video_ids:- raise ValueError(- f"Unexpected video ID '{msg.video_id}' — "- f"expected one of {video_ids}"- )- if msg.frame_number not in video_outputs_by_frame:- raise ValueError(- f"Unexpected frame number {msg.frame_number} — "- f"expected range [{start_frame}, {end_frame})"- )-- video_outputs_by_frame[msg.frame_number][msg.video_id] = msg- received_count += 1-- if all(- isinstance(v, VideoNodeOutputMessage)- for v in video_outputs_by_frame[msg.frame_number].values()- ):- got_all_by_frame[msg.frame_number] = True+ with tqdm(+ total=total_expected,+ desc=f"[{pipeline_id}] collecting",+ unit="obs",+ leave=True,+ dynamic_ncols=True,+ ) as pbar:+ while not shutdown_self_flag.value and ipc.should_continue:+ try:+ msg: VideoNodeOutputMessage = video_node_output_subscription.get(timeout=0.001)+ except Empty:+ continue++ if msg.camera_id not in camera_ids:+ raise ValueError(+ f"Unexpected camera ID '{msg.camera_id}' — "+ f"expected one of {camera_ids}"+ )+ if msg.frame_number not in video_outputs_by_frame:+ raise ValueError(+ f"Unexpected frame number {msg.frame_number} — "+ f"expected range [{start_frame}, {end_frame})"+ )- if all(got_all_by_frame.values()):- break+ video_outputs_by_frame[msg.frame_number][msg.camera_id] = msg+ received_count += 1+ pbar.update(1)++ update_interval = max(1, total_expected // 50)+ if received_count % update_interval == 0:+ aggregator_progress_pub.put(AggregatorNodeProgressMessage(+ pipeline_id=pipeline_id,+ pipeline_type=str(pipeline_type),+ phase=AggregatorPhase.COLLECTING_CAMERA_OUTPUT,+ progress_fraction=received_count / total_expected,+ detail=f"Collecting observations {received_count}/{total_expected}",+ recording_name=rec_name,+ recording_path=rec_path_str,+ ))++ if all(+ isinstance(v, VideoNodeOutputMessage)+ for v in video_outputs_by_frame[msg.frame_number].values()+ ):+ got_all_by_frame[msg.frame_number] = True++ if all(got_all_by_frame.values()):+ breakmissing_frames = [frame_number for frame_number, complete in got_all_by_frame.items() if not complete]if missing_frames:@@ -172,55 +205,82 @@ class PosthocAggregationNode(AggregatorNode):logger.info(f"PosthocAggregationNode [{pipeline_id}] — all frames collected")- observations_by_frame: list[dict[VideoIdString, object]] = []+ observations_by_frame: list[dict[CameraIdString, object]] = []for frame_number in frame_numbers:frame_data = video_outputs_by_frame[frame_number]observations = {}- for vid_id, output_msg in frame_data.items():+ for cam_id, output_msg in frame_data.items():if not isinstance(output_msg, VideoNodeOutputMessage):raise RuntimeError(- f"Missing output for video {vid_id} frame {frame_number}"+ f"Missing output for camera {cam_id} frame {frame_number}")- observations[vid_id] = output_msg.observation+ observations[cam_id] = output_msg.observationobservations_by_frame.append(observations)- progress_message.running_aggregation_task = True- aggregator_progress_pub.put(progress_message)+ reporter = TaskProgressReporter(+ callback=lambda stage, detail, fraction: aggregator_progress_pub.put(+ AggregatorNodeProgressMessage(+ pipeline_id=pipeline_id,+ pipeline_type=str(pipeline_type),+ phase=stage,+ progress_fraction=fraction,+ detail=detail,+ recording_name=rec_name,+ recording_path=rec_path_str,+ )+ )+ )aggregation_task_fn(frame_observations=observations_by_frame,recording_info=recording_info,video_metadata=video_metadata,-+ reporter=reporter,)- progress_message.running_aggregation_task = False- aggregator_progress_pub.put(progress_message)logger.info(f"PosthocAggregationNode [{pipeline_id}] — task completed")+ _error_occurred = Falseexcept Exception as e:logger.error(f"Exception in PosthocAggregationNode [{pipeline_id}]: {e}",exc_info=True,)- progress_message.error = True- progress_message.error_message = f"{type(e).__name__}: {e}"- progress_message.running_aggregation_task = False- aggregator_progress_pub.put(progress_message)+ _error_occurred = True+ aggregator_progress_pub.put(AggregatorNodeProgressMessage(+ pipeline_id=pipeline_id,+ pipeline_type=str(pipeline_type),+ phase=AggregatorPhase.FAILED,+ progress_fraction=0.0,+ detail=f"{type(e).__name__}: {e}",+ recording_name=rec_name,+ recording_path=rec_path_str,+ ))ipc.shutdown_pipeline()# Do NOT re-raise: an unhandled exception here kills the worker, and the WorkerRegistry# child monitor treats that as a fatal failure and shuts down the parent server.- # The error has already been surfaced via the progress message (error=True, error_message=...)- # so the frontend can display a meaningful message to the user.+ # The error has already been surfaced via the progress message so the frontend can+ # display a meaningful message to the user.finally:- progress_message.complete = True- aggregator_progress_pub.put(progress_message)+ if not _error_occurred:+ aggregator_progress_pub.put(AggregatorNodeProgressMessage(+ pipeline_id=pipeline_id,+ pipeline_type=str(pipeline_type),+ phase=AggregatorPhase.COMPLETE,+ progress_fraction=1.0,+ recording_name=rec_name,+ recording_path=rec_path_str,+ ))logger.debug(f"PosthocAggregationNode [{pipeline_id}] exiting")def get_progress_messages(self) -> list[PipelineProgressMessage]:+ from queue import Emptymessages: list[AggregatorNodeProgressMessage] = []- while not self.progress_subscription.empty():- messages.append(self.progress_subscription.get())+ while True:+ try:+ messages.append(self.progress_subscription.get_nowait())+ except Empty:+ breakreturn messagesdiff --git a/freemocap/core/pipeline/posthoc/posthoc_pipeline.py b/freemocap/core/pipeline/posthoc/posthoc_pipeline.pyindex 2e51336f..04ed0bbf 100644--- a/freemocap/core/pipeline/posthoc/posthoc_pipeline.py+++ b/freemocap/core/pipeline/posthoc/posthoc_pipeline.py@@ -22,13 +22,16 @@ from skellytracker.trackers.base_tracker.base_tracker_abcs import BaseDetectorCofrom freemocap.core.pipeline.abcs.pipeline_abc import PipelineABCfrom freemocap.core.pipeline.abcs.pipeline_ipc import PipelineIPC+from skellycam.core.types.type_overloads import CameraIdString++from freemocap.core.pipeline.posthoc.pipeline_phases import PosthocPipelineTypefrom freemocap.core.pipeline.posthoc.posthoc_aggregation_node import PosthocAggregationNode, \PosthocAggregationNodeTaskFnfrom freemocap.core.pipeline.posthoc.video_group_helper import VideoGroupHelperfrom freemocap.core.pipeline.posthoc.video_node import VideoNode-from freemocap.core.types.type_overloads import PipelineIdString, VideoIdString+from freemocap.core.types.type_overloads import PipelineIdStringfrom freemocap.pubsub.pubsub_manager import PubSubTopicManager-from freemocap.pubsub.pubsub_topics import PipelineProgressMessage+from freemocap.core.pipeline.posthoc.progress_messages import PipelineProgressMessagelogger = logging.getLogger(__name__)@@ -42,12 +45,14 @@ class PosthocPipeline(PipelineABC):still running, or subscribe to PosthocProgressTopic for status updates."""id: PipelineIdString+ pipeline_type: PosthocPipelineTyperecording_info: RecordingInfo- video_nodes: dict[VideoIdString, VideoNode]+ video_nodes: dict[CameraIdString, VideoNode]aggregation_node: PosthocAggregationNodeipc: PipelineIPCpubsub: PubSubTopicManagerstarted: bool = False+ queued_progress_message: PipelineProgressMessage | None = None@propertydef alive(self) -> bool:@@ -58,7 +63,7 @@ class PosthocPipeline(PipelineABC):return any_alive or self.aggregation_node.is_alive@property- def video_ids(self) -> list[VideoIdString]:+ def camera_ids(self) -> list[CameraIdString]:return list(self.video_nodes.keys())@classmethod@@ -68,6 +73,7 @@ class PosthocPipeline(PipelineABC):recording_info: RecordingInfo,detector_config: BaseDetectorConfig,aggregation_task_fn: PosthocAggregationNodeTaskFn,+ pipeline_type: PosthocPipelineType,worker_registry: WorkerRegistry,global_kill_flag: Synchronized,save_annotated_video: bool = True,@@ -103,10 +109,10 @@ class PosthocPipeline(PipelineABC):global_kill_flag=global_kill_flag,)- video_nodes: dict[VideoIdString, VideoNode] = {}- for video_id, video_helper in video_group.videos.items():- video_nodes[video_id] = VideoNode.create(- video_id=video_id,+ video_nodes: dict[CameraIdString, VideoNode] = {}+ for camera_id, video_helper in video_group.videos.items():+ video_nodes[camera_id] = VideoNode.create(+ camera_id=camera_id,video_path=video_helper.video_path,detector_config=detector_config,worker_registry=worker_registry,@@ -115,12 +121,14 @@ class PosthocPipeline(PipelineABC):recording_path=recording_path,save_annotated_video=save_annotated_video,pipeline_id=pipeline_id,+ pipeline_type=pipeline_type,)aggregation_node = PosthocAggregationNode.create(aggregation_task_fn=aggregation_task_fn,video_metadata=video_group.video_metadata_by_id,pipeline_id=pipeline_id,+ pipeline_type=pipeline_type,recording_info=recording_info,worker_registry=worker_registry,ipc=ipc,@@ -131,6 +139,7 @@ class PosthocPipeline(PipelineABC):return cls(id=pipeline_id,+ pipeline_type=pipeline_type,recording_info=recording_info,video_nodes=video_nodes,aggregation_node=aggregation_node,@@ -173,7 +182,21 @@ class PosthocPipeline(PipelineABC):def get_progress_messages(self) -> list[PipelineProgressMessage]:progress_messages: list[PipelineProgressMessage] = []+ if self.queued_progress_message is not None:+ progress_messages.append(self.queued_progress_message)+ self.queued_progress_message = Nonefor node in list(self.video_nodes.values()):progress_messages.extend(node.get_progress_messages())progress_messages.extend(self.aggregation_node.get_progress_messages())return progress_messages++ def drain_and_get_messages(self) -> list[PipelineProgressMessage]:+ """Flush the relay (pub→sub) then drain all subscription queues.++ Call this instead of get_progress_messages() when the pipeline workers+ have already exited — the relay may not have had a chance to move+ the terminal COMPLETE/FAILED message from the publication queue to+ the subscription queue yet.+ """+ self.pubsub.drain()+ return self.get_progress_messages()diff --git a/freemocap/core/pipeline/posthoc/posthoc_pipeline_manager.py b/freemocap/core/pipeline/posthoc/posthoc_pipeline_manager.pyindex cfe5d3af..1479f7cf 100644--- a/freemocap/core/pipeline/posthoc/posthoc_pipeline_manager.py+++ b/freemocap/core/pipeline/posthoc/posthoc_pipeline_manager.py@@ -19,13 +19,14 @@ from skellycam.core.ipc.process_management.worker_registry import WorkerRegistryfrom skellycam.core.recorders.videos.recording_info import RecordingInfofrom freemocap.core.pipeline.abcs.pipeline_manager_abc import PipelineManagerABC+from freemocap.core.pipeline.posthoc.pipeline_phases import PosthocPipelineTypefrom freemocap.core.pipeline.posthoc.posthoc_pipeline import PosthocPipelinefrom freemocap.core.tasks.calibration.calibration_task_config import PosthocCalibrationPipelineConfigfrom freemocap.core.tasks.calibration.posthoc_calibration_task import run_posthoc_calibration_taskfrom freemocap.core.tasks.mocap.mocap_task_config import PosthocMocapPipelineConfigfrom freemocap.core.tasks.mocap.posthoc_mocap_task import run_posthoc_mocap_aggregator_taskfrom freemocap.core.types.type_overloads import PipelineIdString-from freemocap.pubsub.pubsub_topics import PipelineProgressMessage+from freemocap.core.pipeline.posthoc.progress_messages import PipelineProgressMessagelogger = logging.getLogger(__name__)@@ -49,34 +50,44 @@ class PosthocPipelineManager(PipelineManagerABC):# Lazy cleanup# ------------------------------------------------------------------- def _evict_dead(self) -> None:+ def _evict_dead(self) -> list[PipelineProgressMessage]:"""Remove pipelines whose processes have all exited. Caller must hold self.lock.- Calls shutdown() on each dead pipeline to release PubSub resources- (relay thread, multiprocessing.Queue instances, OS pipes).+ Drains any remaining progress messages BEFORE closing pubsub so that+ terminal COMPLETE/FAILED messages emitted just before worker exit are+ not lost. Returns those final messages."""dead_ids: list[PipelineIdString] = [pid for pid, pipeline in self.pipelines.items()if pipeline.started and not pipeline.alive]+ final_messages: list[PipelineProgressMessage] = []for pid in dead_ids:pipeline = self.pipelines.pop(pid)+ # Flush relay (pub→sub) THEN drain subscription queues so the+ # terminal COMPLETE/FAILED message emitted just before worker exit+ # is not missed. Without the flush, the relay may not have had a+ # chance to move the message from the publication queue before we+ # read the subscription queue.+ final_messages.extend(pipeline.drain_and_get_messages())pipeline.shutdown()logger.debug(f"Evicted completed PosthocPipeline [{pid}] "f"for '{pipeline.recording_info.recording_name}'")+ return final_messages- def evict_completed(self) -> None:+ def evict_completed(self) -> list[PipelineProgressMessage]:"""Clean up any posthoc pipelines that have finished running.+ Returns any final progress messages drained from dead pipelines.Safe to call frequently — skips lock acquisition when there are nopipelines to check."""if not self.pipelines:- return+ return []with self.lock:- self._evict_dead()+ return self._evict_dead()# ------------------------------------------------------------------# Pipeline creation@@ -96,9 +107,19 @@ class PosthocPipelineManager(PipelineManagerABC):recording_info=recording_info,detector_config=calibration_config.detector_config,aggregation_task_fn=calibration_aggregation_task_fn,+ pipeline_type=PosthocPipelineType.CALIBRATION,worker_registry=self.worker_registry,global_kill_flag=self.global_kill_flag,)+ pipeline.queued_progress_message = PipelineProgressMessage(+ pipeline_id=pipeline.id,+ pipeline_type=str(PosthocPipelineType.CALIBRATION),+ phase="queued",+ progress_fraction=0.0,+ detail="Pipeline queued, starting workers...",+ recording_name=recording_info.recording_name,+ recording_path=str(recording_info.full_recording_path),+ )pipeline.start()with self.lock:self._evict_dead()@@ -124,9 +145,19 @@ class PosthocPipelineManager(PipelineManagerABC):recording_info=recording_info,detector_config=mocap_config.skeleton_detector_config,aggregation_task_fn=mocap_task_fn,+ pipeline_type=PosthocPipelineType.MOCAP,worker_registry=self.worker_registry,global_kill_flag=self.global_kill_flag,)+ pipeline.queued_progress_message = PipelineProgressMessage(+ pipeline_id=pipeline.id,+ pipeline_type=str(PosthocPipelineType.MOCAP),+ phase="queued",+ progress_fraction=0.0,+ detail="Pipeline queued, starting workers...",+ recording_name=recording_info.recording_name,+ recording_path=str(recording_info.full_recording_path),+ )if start_pipeline:pipeline.start()with self.lock:@@ -142,6 +173,26 @@ class PosthocPipelineManager(PipelineManagerABC):# Lifecycle# ------------------------------------------------------------------+ def stop_pipeline(self, pipeline_id: PipelineIdString) -> bool:+ """Shutdown a single pipeline by ID. Returns True if found, False if not."""+ with self.lock:+ pipeline = self.pipelines.pop(pipeline_id, None)+ if pipeline is None:+ logger.warning(f"stop_pipeline: pipeline [{pipeline_id}] not found")+ return False+ pipeline.shutdown()+ logger.info(f"Stopped posthoc pipeline [{pipeline_id}]")+ return True++ def stop_all_pipelines(self) -> None:+ """Shutdown all active posthoc pipelines."""+ with self.lock:+ pipelines = list(self.pipelines.values())+ self.pipelines.clear()+ for pipeline in pipelines:+ pipeline.shutdown()+ logger.info(f"Stopped {len(pipelines)} posthoc pipeline(s)")+def shutdown(self) -> None:"""Force-shutdown all posthoc pipelines (running or completed).diff --git a/freemocap/core/pipeline/posthoc/progress_messages.py b/freemocap/core/pipeline/posthoc/progress_messages.pynew file mode 100644index 00000000..865afa2e--- /dev/null+++ b/freemocap/core/pipeline/posthoc/progress_messages.py@@ -0,0 +1,25 @@+from dataclasses import dataclass++from skellycam.core.types.type_overloads import CameraIdString+++@dataclass+class PipelineProgressMessage:+ message_type: str = "posthoc_progress"+ pipeline_id: str = ""+ pipeline_type: str = ""+ phase: str = ""+ progress_fraction: float = 0.0+ detail: str = ""+ recording_name: str = ""+ recording_path: str = ""+++@dataclass+class VideoNodeProgressMessage(PipelineProgressMessage):+ camera_id: CameraIdString = ""+++@dataclass+class AggregatorNodeProgressMessage(PipelineProgressMessage):+ passdiff --git a/freemocap/core/pipeline/posthoc/task_progress_reporter.py b/freemocap/core/pipeline/posthoc/task_progress_reporter.pynew file mode 100644index 00000000..cb3fa173--- /dev/null+++ b/freemocap/core/pipeline/posthoc/task_progress_reporter.py@@ -0,0 +1,50 @@+"""+TaskProgressReporter: typed progress-reporting interface for task functions.++Task functions receive a TaskProgressReporter instead of a bare Callable.+Call reporter.report(stage=SomeStage.FOO) at each meaningful step.++Use TaskProgressReporter.noop() when no reporting is needed (e.g. in tests+or when the aggregation node has no WebSocket queue available).+"""+from __future__ import annotations++from collections.abc import Callable+++class TaskProgressReporter:+ """+ Wraps the underlying progress callback with a named, keyword-only interface.++ Args:+ callback: receives (stage: str, detail: str, fraction: float).+ Pass a pipeline_phases enum value for stage; its string+ representation is forwarded to the callback automatically.+ """++ def __init__(self, callback: Callable[[str, str, float], None]) -> None:+ self._callback = callback++ def report(+ self,+ *,+ stage: str,+ detail: str = "",+ fraction: float = 0.0,+ ) -> None:+ """Emit a progress update.++ Args:+ stage: A phase/stage enum value (or plain string as fallback).+ All enums in pipeline_phases stringify to their value.+ detail: Human-readable description shown in the UI.+ fraction: Completion fraction in [0.0, 1.0]. Most named stages+ leave this at 0.0 (indeterminate bar); use it only when+ you have a genuine measured fraction.+ """+ self._callback(str(stage), detail, fraction)++ @classmethod+ def noop(cls) -> TaskProgressReporter:+ """Returns a silent reporter that discards all progress updates."""+ return cls(callback=lambda *_: None)diff --git a/freemocap/core/pipeline/posthoc/video_group_helper.py b/freemocap/core/pipeline/posthoc/video_group_helper.pyindex d4c711c1..f015a3a5 100644--- a/freemocap/core/pipeline/posthoc/video_group_helper.py+++ b/freemocap/core/pipeline/posthoc/video_group_helper.py@@ -3,6 +3,8 @@ Simplified VideoHelper with OpenCV best practices.Includes smart frame reading and caching."""+import json+import loggingfrom collections import OrderedDictfrom pathlib import Path@@ -10,8 +12,10 @@ import cv2import numpy as npfrom pydantic import BaseModel, Field, ConfigDict, model_validator-from freemocap.core.tasks.calibration.shared.camera_to_video_identity_matcher import camera_ids_from_video_paths-from freemocap.core.types.type_overloads import VideoIdString+from skellycam.core.recorders.videos.parse_video_filename import ParsedVideoFilename, VIDEO_EXTENSIONS+from skellycam.core.types.type_overloads import CameraIdString, CameraIndexInt++logger = logging.getLogger(__name__)# Module level constantsDEFAULT_CACHE_SIZE_MB = 500@@ -20,6 +24,7 @@ SEQUENTIAL_READ_THRESHOLD = 5 # If reading within 5 frames ahead, use sequentiaclass VideoMetadata(BaseModel):"""Video metadata container"""+ file_path: Pathwidth: intheight: intfps: float@@ -46,6 +51,21 @@ class VideoMetadata(BaseModel):)return values+ @property+ def parsed_filename(self) -> ParsedVideoFilename:+ return ParsedVideoFilename.from_path(self.file_path)++ @property+ def recording_name(self) -> str:+ return self.parsed_filename.recording_name++ @property+ def camera_id(self) -> CameraIdString:+ return self.parsed_filename.camera_id+ @property+ def camera_index(self) -> CameraIndexInt:+ return self.parsed_filename.camera_index+class FrameCache(BaseModel):@@ -104,6 +124,7 @@ class VideoHelper(BaseModel):# Reading optimization statelast_read_frame: int = Field(default=-1)sequential_threshold: int = Field(default=SEQUENTIAL_READ_THRESHOLD)+@propertydef has_frames(self) -> bool:"""Check if video has frames."""@@ -145,6 +166,7 @@ class VideoHelper(BaseModel):duration_seconds = frame_count / fps if fps > 0 else 0.0metadata = VideoMetadata(+ file_path = video_path,width=width,height=height,fps=fps,@@ -215,10 +237,10 @@ class VideoHelper(BaseModel):"""Check if sequential reading would be more efficient."""if self.last_read_frame < 0:return False-- # If we're reading nearby frames forward, use sequential- distance = frame_number - self.last_read_frame- return 0 < distance <= self.sequential_threshold+ return True # Always use sequential read when not wrapping around to avoid frame slippage+ # # If we're reading nearby frames forward, use sequential+ # distance = frame_number - self.last_read_frame+ # return 0 < distance <= self.sequential_thresholddef _read_sequential(self, frame_number: int) -> np.ndarray:"""Read frame using sequential access (grab/retrieve)."""@@ -333,11 +355,18 @@ class VideoGroupHelper(BaseModel):extra="forbid",frozen=True)- videos: dict[VideoIdString, VideoHelper]- video_metadata_by_id: dict[VideoIdString, VideoMetadata]+ videos: dict[CameraIdString, VideoHelper]+ video_metadata_by_id: dict[CameraIdString, VideoMetadata]+ # True if camera_id keys came from the recording manifest (authoritative).+ # False if they came from filename parsing (best-effort).+ keyed_from_manifest: bool = False+ # True if filename parsing had to fall back to alphabetical reindex+ # because indices were missing or colliding. Operator should verify+ # the camera assignment is correct. Always False when keyed_from_manifest.+ filename_reindex_applied: bool = False@property- def video_ids(self) -> list[VideoIdString]:+ def camera_ids(self) -> list[CameraIdString]:return list(self.videos.keys())@model_validator(mode="after")@@ -349,23 +378,69 @@ class VideoGroupHelper(BaseModel):return self@classmethod- def from_video_paths(cls, video_paths: list[str], close_videos: bool = True) -> "VideoGroupHelper":+ def from_video_paths(cls, video_paths: list[str | Path], close_videos: bool = True) -> "VideoGroupHelper":"""Create VideoGroupHelper from a list of video file paths.- Camera IDs are extracted from video filenames when possible.- Falls back to sorted positional indices if extraction fails.+ Camera IDs and indices are extracted via ParsedVideoFilename.from_path(),+ which tries the canonical SkellyCam format first then falls back to+ heuristic extraction (cam-prefix, trailing-int, alphabetical ordering)."""- id_to_path = camera_ids_from_video_paths(- video_paths=[Path(p) for p in video_paths],+ paths = sorted(Path(p) for p in video_paths)+ parsed_list = [ParsedVideoFilename.from_path(p) for p in paths]++ # Detect collisions or unknown indices (-1 sentinel) and re-assign+ indices = [pv.camera_index for pv in parsed_list]+ reindex_applied = -1 in indices or len(set(indices)) < len(indices)+ if reindex_applied:+ logger.warning(+ f"Camera indices are ambiguous or colliding ({indices}); "+ f"re-assigning by alphabetical filename order. "+ f"Verify the camera_id → video mapping is correct."+ )+ for i, pv in enumerate(parsed_list):+ pv.camera_index = i++ # Sort by camera_index and build VideoHelper map keyed by camera_id+ pairs = sorted(zip(parsed_list, paths), key=lambda x: x[0].camera_index)++ videos: dict[CameraIdString, VideoHelper] = {}+ for pv, path in pairs:+ videos[pv.camera_id] = VideoHelper.from_video_path(path)++ instance = cls(+ videos=videos,+ video_metadata_by_id={vid_id: vid.metadata for vid_id, vid in videos.items()},+ keyed_from_manifest=False,+ filename_reindex_applied=reindex_applied,)+ if close_videos:+ instance.close()+ return instance- videos: dict[VideoIdString, VideoHelper] = {}- for camera_id, video_path in id_to_path.items():+ @classmethod+ def from_manifest_videos(+ cls,+ *,+ manifest_videos: dict[str, str],+ videos_dir: Path,+ close_videos: bool = True,+ ) -> "VideoGroupHelper":+ """Build from an authoritative camera_id → relative-filename mapping."""+ videos: dict[CameraIdString, VideoHelper] = {}+ for camera_id, filename in manifest_videos.items():+ video_path = videos_dir / filename+ if not video_path.exists():+ raise FileNotFoundError(+ f"Manifest references video '{filename}' for camera '{camera_id}' "+ f"but the file does not exist at {video_path}"+ )videos[camera_id] = VideoHelper.from_video_path(video_path)instance = cls(videos=videos,video_metadata_by_id={vid_id: vid.metadata for vid_id, vid in videos.items()},+ keyed_from_manifest=True,+ filename_reindex_applied=False,)if close_videos:instance.close()@@ -373,20 +448,64 @@ class VideoGroupHelper(BaseModel):@classmethoddef from_video_folder_path(cls, video_folder_path: Path) -> "VideoGroupHelper":- video_paths = sorted(- [str(p) for p in video_folder_path.iterdir() if p.suffix.lower() in {'.mp4', '.avi', '.mov', '.mkv'}])-- return cls.from_video_paths(video_paths)+ paths = sorted(+ p for p in video_folder_path.glob("*")+ if p.is_file() and p.suffix.lower() in VIDEO_EXTENSIONS+ )+ if not paths:+ raise FileNotFoundError(f"No video files found in {video_folder_path}")+ return cls.from_video_paths(paths)@classmethoddef from_recording_path(cls, recording_path: str,video_subfolder_name: str = 'synchronized_videos') -> "VideoGroupHelper":- return cls.from_video_folder_path(Path(recording_path) / video_subfolder_name)+ """Build a VideoGroup for a recording.++ Prefers the manifest's `videos` map (camera_id → filename) when+ present; falls back to filename parsing of the synchronized-videos+ folder when the manifest is missing or has no videos map.+ """+ recording_path_obj = Path(recording_path)+ videos_dir = recording_path_obj / video_subfolder_name++ manifest_videos = _load_manifest_videos(recording_path_obj)+ if manifest_videos:+ return cls.from_manifest_videos(+ manifest_videos=manifest_videos,+ videos_dir=videos_dir,+ )+ return cls.from_video_folder_path(videos_dir)def close(self):for video in self.videos.values():video.close()++def _load_manifest_videos(recording_path: Path) -> dict[str, str] | None:+ """Return the manifest's `videos` map if present, else None.++ The manifest is `{recording_name}_recording_info.json` (or the legacy+ `{recording_name}_info.json` from SkellyCam). A missing or unreadable+ manifest, or a manifest without a populated `videos` field, returns None.+ """+ candidates = [+ recording_path / f"{recording_path.name}_recording_info.json",+ recording_path / f"{recording_path.name}_info.json",+ ]+ for path in candidates:+ if not path.exists():+ continue+ try:+ with open(path, "r") as f:+ data = json.load(f)+ except (json.JSONDecodeError, OSError) as e:+ logger.warning(f"Failed to read recording manifest at {path}: {e}")+ continue+ videos = data.get("videos")+ if isinstance(videos, dict) and videos:+ return {str(k): str(v) for k, v in videos.items()}+ return None+# Example usageif __name__ == "__main__":video_path = Path(r"C:\Users\jonma\Downloads\2025-07-01_ferret_757_EyeCameras_P33_EO5_1m_20s-2m_20s(2).mp4")diff --git a/freemocap/core/pipeline/posthoc/video_node.py b/freemocap/core/pipeline/posthoc/video_node.pyindex 2c9a57fe..6fcf60ef 100644--- a/freemocap/core/pipeline/posthoc/video_node.py+++ b/freemocap/core/pipeline/posthoc/video_node.py@@ -16,6 +16,7 @@ from multiprocessing.sharedctypes import Synchronizedfrom pathlib import Pathimport cv2+from tqdm import tqdmfrom skellycam.core.ipc.process_management.worker_registry import WorkerRegistryfrom skellytracker.trackers.base_tracker.base_tracker_abcs import BaseDetectorConfigfrom skellytracker.trackers.base_tracker.detector_helpers import create_detector_from_config, \@@ -23,11 +24,14 @@ from skellytracker.trackers.base_tracker.detector_helpers import create_detectorfrom freemocap.core.pipeline.abcs.pipeline_ipc import PipelineIPCfrom freemocap.core.pipeline.abcs.source_node_abc import SourceNode-from freemocap.core.types.type_overloads import VideoIdString, TopicPublicationQueue, PipelineIdString, \+from skellycam.core.types.type_overloads import CameraIdString++from freemocap.core.pipeline.posthoc.pipeline_phases import VideoNodePhase, PosthocPipelineType+from freemocap.core.pipeline.posthoc.progress_messages import VideoNodeProgressMessage, PipelineProgressMessage+from freemocap.core.types.type_overloads import TopicPublicationQueue, PipelineIdString, \TopicSubscriptionQueuefrom freemocap.pubsub.pubsub_manager import PubSubTopicManager-from freemocap.pubsub.pubsub_topics import VideoNodeOutputTopic, VideoNodeOutputMessage, VideoNodeProgressTopic, \- VideoNodeProgressMessage, PipelineProgressMessage+from freemocap.pubsub.pubsub_topics import VideoNodeOutputTopic, VideoNodeOutputMessagefrom freemocap.system.default_paths import ANNOTATED_VIDEOS_FOLDER_NAMElogger = logging.getLogger(__name__)@@ -36,7 +40,7 @@ logger = logging.getLogger(__name__)@dataclassclass VideoNode(SourceNode):- video_id: VideoIdString+ camera_id: CameraIdStringvideo_path: Pathprogress_subscription: TopicSubscriptionQueue@@ -44,43 +48,44 @@ class VideoNode(SourceNode):def create(cls,*,- video_id: VideoIdString,+ camera_id: CameraIdString,video_path: Path,detector_config: BaseDetectorConfig,worker_registry: WorkerRegistry,ipc: PipelineIPC,pubsub: PubSubTopicManager,recording_path: Path,+ pipeline_type: PosthocPipelineType,save_annotated_video: bool = True,pipeline_id: PipelineIdString | None = None,) -> "VideoNode":+ _progress_queue: multiprocessing.queues.Queue = multiprocessing.Queue()shutdown_self_flag, worker = cls._create_worker(target=cls._run,name=f"VideoNode-{video_path.stem}",worker_registry=worker_registry,log_queue=ipc.ws_queue,kwargs=dict(- video_id=video_id,+ camera_id=camera_id,video_path=video_path,detector_config=detector_config,ipc=ipc,video_output_pub=pubsub.get_publication_queue(VideoNodeOutputTopic,),- video_progress_pub = pubsub.get_publication_queue(- VideoNodeProgressTopic- ),+ video_progress_pub=_progress_queue,recording_path=recording_path,save_annotated_video=save_annotated_video,pipeline_id=pipeline_id,+ pipeline_type=pipeline_type,),)return cls(- video_id=video_id,+ camera_id=camera_id,video_path=video_path,shutdown_self_flag=shutdown_self_flag,worker=worker,- progress_subscription=pubsub.get_subscription(VideoNodeProgressTopic)+ progress_subscription=_progress_queue,)@staticmethod@@ -124,7 +129,7 @@ class VideoNode(SourceNode):@staticmethoddef _run(*,- video_id: VideoIdString,+ camera_id: CameraIdString,video_path: Path,detector_config: BaseDetectorConfig,ipc: PipelineIPC,@@ -134,16 +139,36 @@ class VideoNode(SourceNode):recording_path: Path,save_annotated_video: bool,pipeline_id: PipelineIdString,+ pipeline_type: PosthocPipelineType,) -> None:+ # Compound pipeline_id groups this camera node under the base pipeline on the frontend.+ node_pipeline_id = f"{pipeline_id}:{camera_id}"+ # Emit immediately so the frontend shows the pipeline before the (potentially slow) model load.+ video_progress_pub.put(VideoNodeProgressMessage(+ camera_id=camera_id,+ pipeline_id=node_pipeline_id,+ pipeline_type=str(pipeline_type),+ phase=VideoNodePhase.SETTING_UP,+ progress_fraction=0.0,+ detail="Loading detector...",+ recording_name=recording_path.name,+ recording_path=str(recording_path),+ ))detector = create_detector_from_config(detector_config)video_reader = cv2.VideoCapture(str(video_path), cv2.CAP_FFMPEG)if not video_reader.isOpened():raise RuntimeError(f"Failed to open video file: {video_path}")frame_count: int = int(video_reader.get(cv2.CAP_PROP_FRAME_COUNT))- progress_message = VideoNodeProgressMessage(video_id=video_id,- pipeline_id=pipeline_id,- frame_count=frame_count,)- video_progress_pub.put(progress_message)+ video_progress_pub.put(VideoNodeProgressMessage(+ camera_id=camera_id,+ pipeline_id=node_pipeline_id,+ pipeline_type=str(pipeline_type),+ phase=VideoNodePhase.SETTING_UP,+ progress_fraction=0.0,+ detail=f"Preparing {frame_count} frames",+ recording_name=recording_path.name,+ recording_path=str(recording_path),+ ))# Set up annotation pipeline if requestedannotator = None@@ -151,90 +176,101 @@ class VideoNode(SourceNode):base_reader: cv2.VideoCapture | None = Noneprev_annotated_path: Path | None = None--- if save_annotated_video:- annotator = create_annotator_from_config(detector_config)- annotated_output_path, prev_annotated_path = VideoNode._resolve_annotated_video_paths(- recording_path=recording_path,- video_path=video_path,- )-- # Open base reader if we have a previous annotated video to layer on- if prev_annotated_path is not None:- base_reader = cv2.VideoCapture(str(prev_annotated_path), cv2.CAP_FFMPEG)- if not base_reader.isOpened():- logger.warning(- f"Failed to open previous annotated video for {video_path.stem} — "- f"will annotate from source frames instead"- )- base_reader = None-- # Create video writer matching source video properties- fps = video_reader.get(cv2.CAP_PROP_FPS)- width = int(video_reader.get(cv2.CAP_PROP_FRAME_WIDTH))- height = int(video_reader.get(cv2.CAP_PROP_FRAME_HEIGHT))- fourcc = cv2.VideoWriter_fourcc(*"mp4v")- video_writer = cv2.VideoWriter(- str(annotated_output_path), fourcc, fps, (width, height)- )- if not video_writer.isOpened():- raise RuntimeError(- f"Failed to create video writer for: {annotated_output_path}"- )-- logger.info(- f"VideoNode started for {video_path.stem}"- f"{' (with annotation)' if save_annotated_video else ''}"- )-frame_number: int = 0+ _error_occurred = Falsetry:-- success, image = video_reader.read()- while success and not shutdown_self_flag.value and ipc.should_continue:- observation = detector.detect(- frame_number=frame_number,- image=image,- )- video_output_pub.put(- VideoNodeOutputMessage(- video_id=video_id,- frame_number=frame_number,- observation=observation,- ),+ if save_annotated_video:+ annotator = create_annotator_from_config(detector_config)+ annotated_output_path, prev_annotated_path = VideoNode._resolve_annotated_video_paths(+ recording_path=recording_path,+ video_path=video_path,)+ # Open base reader if we have a previous annotated video to layer on+ if prev_annotated_path is not None:+ base_reader = cv2.VideoCapture(str(prev_annotated_path), cv2.CAP_FFMPEG)+ if not base_reader.isOpened():+ logger.warning(+ f"Failed to open previous annotated video for {video_path.stem} — "+ f"will annotate from source frames instead"+ )+ base_reader = None++ # Create video writer matching source video properties+ fps = video_reader.get(cv2.CAP_PROP_FPS)+ width = int(video_reader.get(cv2.CAP_PROP_FRAME_WIDTH))+ height = int(video_reader.get(cv2.CAP_PROP_FRAME_HEIGHT))+ fourcc = cv2.VideoWriter_fourcc(*"mp4v")+ video_writer = cv2.VideoWriter(+ str(annotated_output_path), fourcc, fps, (width, height)+ )+ if not video_writer.isOpened():+ raise RuntimeError(+ f"Failed to create video writer for: {annotated_output_path}"+ )+ logger.info(+ f"VideoNode started for {video_path.stem}"+ f"{' (with annotation)' if save_annotated_video else ''}"+ )+ with tqdm(+ total=frame_count,+ desc=video_path.stem,+ unit="frame",+ leave=True,+ dynamic_ncols=True,+ ) as pbar:+ success, image = video_reader.read()+ while success and not shutdown_self_flag.value and ipc.should_continue:+ observation = detector.detect(+ frame_number=frame_number,+ image=image,+ )+ video_output_pub.put(+ VideoNodeOutputMessage(+ camera_id=camera_id,+ frame_number=frame_number,+ observation=observation,+ ),+ )-- # Annotate and write frame if enabled- if annotator is not None and video_writer is not None:- # Use previous annotated frame as base if available, else source frame- if base_reader is not None:- base_ok, base_frame = base_reader.read()- if not base_ok or base_frame is None:- logger.warning(- f"Previous annotated video ran out of frames at frame {frame_number} "- f"for {video_path.stem} — falling back to source frames"- )- base_reader.release()- base_reader = None- annotation_base = image+ # Annotate and write frame if enabled+ if annotator is not None and video_writer is not None:+ # Use previous annotated frame as base if available, else source frame+ if base_reader is not None:+ base_ok, base_frame = base_reader.read()+ if not base_ok or base_frame is None:+ logger.warning(+ f"Previous annotated video ran out of frames at frame {frame_number} "+ f"for {video_path.stem} — falling back to source frames"+ )+ base_reader.release()+ base_reader = None+ annotation_base = image+ else:+ annotation_base = base_frameelse:- annotation_base = base_frame- else:- annotation_base = image-- annotated_frame = annotator.annotate_image(- image=annotation_base,- observation=observation,- )- video_writer.write(annotated_frame)+ annotation_base = image- success, image = video_reader.read()- frame_number += 1- video_progress_pub.put(progress_message.increment())+ annotated_frame = annotator.annotate_image(+ image=annotation_base,+ observation=observation,+ )+ video_writer.write(annotated_frame)++ success, image = video_reader.read()+ frame_number += 1+ video_progress_pub.put(VideoNodeProgressMessage(+ camera_id=camera_id,+ pipeline_id=node_pipeline_id,+ pipeline_type=str(pipeline_type),+ phase=VideoNodePhase.PROCESSING_IMAGES,+ progress_fraction=frame_number / frame_count,+ detail=f"Camera {camera_id}: {frame_number}/{frame_count} frames",+ recording_name=recording_path.name,+ recording_path=str(recording_path),+ ))+ pbar.update(1)logger.info(f"VideoNode for {video_path.stem} finished reading "@@ -245,17 +281,33 @@ class VideoNode(SourceNode):logger.exception(f"Exception in VideoNode for {video_path.stem}: {e}")- progress_message.error = True- progress_message.error_message = f"{type(e).__name__}: {e}"- video_progress_pub.put(progress_message)+ _error_occurred = True+ video_progress_pub.put(VideoNodeProgressMessage(+ camera_id=camera_id,+ pipeline_id=node_pipeline_id,+ pipeline_type=str(pipeline_type),+ phase=VideoNodePhase.FAILED,+ progress_fraction=frame_number / frame_count if frame_count > 0 else 0.0,+ detail=f"{type(e).__name__}: {e}",+ recording_name=recording_path.name,+ recording_path=str(recording_path),+ ))ipc.shutdown_pipeline()# Do NOT re-raise: unhandled exceptions here kill the worker, and the WorkerRegistry# child monitor escalates that to a parent-process shutdown (exit code 15).# The error is surfaced via the progress message so the frontend can report it.finally:video_reader.release()- progress_message.complete = True- video_progress_pub.put(progress_message)+ if not _error_occurred:+ video_progress_pub.put(VideoNodeProgressMessage(+ camera_id=camera_id,+ pipeline_id=node_pipeline_id,+ pipeline_type=str(pipeline_type),+ phase=VideoNodePhase.COMPLETE,+ progress_fraction=1.0,+ recording_name=recording_path.name,+ recording_path=str(recording_path),+ ))if video_writer is not None:video_writer.release()if base_reader is not None:@@ -266,7 +318,11 @@ class VideoNode(SourceNode):logger.debug(f"VideoNode for {video_path.stem} exiting")def get_progress_messages(self) -> list[PipelineProgressMessage]:+ from queue import Emptymessages: list[VideoNodeProgressMessage] = []- while not self.progress_subscription.empty():- messages.append(self.progress_subscription.get())+ while True:+ try:+ messages.append(self.progress_subscription.get_nowait())+ except Empty:+ breakreturn messagesdiff --git a/freemocap/core/pipeline/realtime/camera_node.py b/freemocap/core/pipeline/realtime/camera_node.pyindex 8943d83c..3a83e5b3 100644--- a/freemocap/core/pipeline/realtime/camera_node.py+++ b/freemocap/core/pipeline/realtime/camera_node.py@@ -6,22 +6,22 @@ Runs indefinitely until shutdown. Responds to pipeline config updates(toggling detectors, changing charuco board params, etc)."""import logging-import multiprocessing+import queue+import timefrom dataclasses import dataclassfrom multiprocessing.sharedctypes import Synchronized-from typing import TYPE_CHECKINGfrom skellycam.core.ipc.process_management.worker_registry import WorkerRegistryfrom skellycam.core.ipc.shared_memory.camera_shared_memory_ring_buffer import CameraSharedMemoryRingBufferfrom skellycam.core.ipc.shared_memory.ring_buffer_shared_memory import SharedMemoryRingBufferDTOfrom skellycam.core.types.type_overloads import CameraIdString, TopicSubscriptionQueue-from skellycam.utilities.wait_functions import wait_1ms# from skellytracker.trackers.legacy_mediapipe_tracker.legacy_mediapipe_detector import LegacyMediapipeDetectorfrom freemocap.core.pipeline.abcs.pipeline_ipc import PipelineIPCfrom freemocap.core.pipeline.abcs.source_node_abc import SourceNodefrom freemocap.core.pipeline.realtime.camera_node_config import CameraNodeConfigfrom freemocap.core.types.type_overloads import TopicPublicationQueue+from freemocap.core.pipeline.pipeline_stage_timer import PipelineStageTimerfrom freemocap.pubsub.pubsub_manager import PubSubTopicManagerfrom freemocap.pubsub.pubsub_topics import (ProcessFrameNumberTopic,@@ -30,6 +30,7 @@ from freemocap.pubsub.pubsub_topics import (PipelineConfigUpdateMessage,ProcessFrameNumberMessage,CameraNodeOutputMessage,+ PipelineTimingTopic,)import numpy as np@@ -40,18 +41,20 @@ logger = logging.getLogger(__name__)@dataclassclass CameraNode(SourceNode):- camera_id:CameraIdString+ camera_id: CameraIdString@classmethoddef create(- cls,- *,- camera_id: CameraIdString,- camera_shm_dto: SharedMemoryRingBufferDTO,- worker_registry: WorkerRegistry,- config: CameraNodeConfig,- ipc: PipelineIPC,- pubsub: PubSubTopicManager,+ cls,+ *,+ camera_id: CameraIdString,+ camera_shm_dto: SharedMemoryRingBufferDTO,+ worker_registry: WorkerRegistry,+ config: CameraNodeConfig,+ ipc: PipelineIPC,+ pubsub: PubSubTopicManager,+ skeleton_inference_centralized: bool = False,+ log_pipeline_times: bool = False,) -> "CameraNode":shutdown_self_flag, worker = cls._create_worker(target=cls._run,@@ -63,6 +66,8 @@ class CameraNode(SourceNode):ipc=ipc,config=config,camera_shm_dto=camera_shm_dto,+ skeleton_inference_centralized=skeleton_inference_centralized,+ log_pipeline_times=log_pipeline_times,process_frame_number_sub=pubsub.get_subscription(ProcessFrameNumberTopic,),@@ -72,6 +77,9 @@ class CameraNode(SourceNode):camera_output_pub=pubsub.get_publication_queue(CameraNodeOutputTopic,),+ timing_pub=pubsub.get_publication_queue(+ PipelineTimingTopic,+ ),),)return cls(@@ -82,15 +90,18 @@ class CameraNode(SourceNode):@staticmethoddef _run(- *,- camera_id: CameraIdString,- ipc: PipelineIPC,- config: CameraNodeConfig,- process_frame_number_sub: TopicSubscriptionQueue,- pipeline_config_sub: TopicSubscriptionQueue,- camera_output_pub: TopicPublicationQueue,- shutdown_self_flag: Synchronized,- camera_shm_dto: SharedMemoryRingBufferDTO,+ *,+ camera_id: CameraIdString,+ ipc: PipelineIPC,+ config: CameraNodeConfig,+ process_frame_number_sub: TopicSubscriptionQueue,+ pipeline_config_sub: TopicSubscriptionQueue,+ camera_output_pub: TopicPublicationQueue,+ timing_pub: TopicPublicationQueue,+ shutdown_self_flag: Synchronized,+ camera_shm_dto: SharedMemoryRingBufferDTO,+ skeleton_inference_centralized: bool = False,+ log_pipeline_times: bool = False,) -> None:import cv2from skellytracker.trackers.charuco_tracker.charuco_detector import CharucoDetector@@ -102,32 +113,44 @@ class CameraNode(SourceNode):)charuco_detector: CharucoDetector | None = None- skeleton_detector: RTMPoseDetector | None = None+ skeleton_detector: RTMPoseDetector | None = None# skeleton_detector: LegacyMediapipeDetector | None = Noneif config.charuco_tracking_enabled and config.charuco_detector_config is not None:charuco_detector = CharucoDetector.create(config=config.charuco_detector_config,)- if config.skeleton_tracking_enabled and config.skeleton_detector_config is not None:+ if (+ config.skeleton_tracking_enabled+ and config.skeleton_detector_config is not None+ and not skeleton_inference_centralized+ ):+ # In centralized GPU mode, the dedicated SkeletonInferenceNode owns+ # the ONNX session and serves all cameras via batched inference.+ # Skipping per-camera construction here is what avoids spawning+ # N independent CUDA contexts on a single GPU.# skeleton_detector = LegacyMediapipeDetector.create(# config=config.skeleton_detector_config ,# )skeleton_detector = RTMPoseDetector.create(- config=config.skeleton_detector_config ,+ config=config.skeleton_detector_config,)frame_recarray: np.recarray | None = None+ timer = None+ if log_pipeline_times:+ timer = PipelineStageTimer(name=f"CameraNode-{camera_id}")try:logger.debug(f"RealtimeCameraNode [{camera_id}] entering main loop")while ipc.should_continue and not shutdown_self_flag.value:- wait_1ms()-# ---- Handle config updates ----- while not pipeline_config_sub.empty():- update_msg: PipelineConfigUpdateMessage = pipeline_config_sub.get()- new_config:CameraNodeConfig = update_msg.pipeline_config.camera_node_config+ while True:+ try:+ update_msg: PipelineConfigUpdateMessage = pipeline_config_sub.get_nowait()+ except queue.Empty:+ break+ new_config: CameraNodeConfig = update_msg.pipeline_config.camera_node_configlogger.debug(f"RealtimeCameraNode [{camera_id}] received config update")if new_config.charuco_tracking_enabled and new_config.charuco_detector_config is not None:@@ -137,14 +160,15 @@ class CameraNode(SourceNode):elif not new_config.charuco_tracking_enabled:charuco_detector = None- if new_config.skeleton_tracking_enabled and new_config.skeleton_detector_config is not None:- # skeleton_detector = LegacyMediapipeDetector.create(- # config=new_config.skeleton_detector_config,- # )+ if (+ new_config.skeleton_tracking_enabled+ and new_config.skeleton_detector_config is not None+ and not skeleton_inference_centralized+ ):skeleton_detector = RTMPoseDetector.create(config=new_config.skeleton_detector_config,)- elif not new_config.skeleton_tracking_enabled:+ elif not new_config.skeleton_tracking_enabled or skeleton_inference_centralized:skeleton_detector = Noneconfig = new_config@@ -157,11 +181,13 @@ class CameraNode(SourceNode):)break- # ---- Process frames ----- if process_frame_number_sub.empty():+ # ---- Block until a frame request arrives (up to 5ms) ----+ # Replaces the busy-poll (empty() check + 1ms sleep) with an+ # efficient OS-level wait, cutting latency and CPU waste.+ try:+ frame_msg: ProcessFrameNumberMessage = process_frame_number_sub.get(timeout=0.005)+ except queue.Empty:continue-- frame_msg: ProcessFrameNumberMessage = process_frame_number_sub.get()frame_recarray = camera_shm.get_data_by_index(index=frame_msg.frame_number,rec_array=frame_recarray,@@ -176,10 +202,11 @@ class CameraNode(SourceNode):else:image = frame_recarray.image[0]- actual_frame_number:int = int(frame_recarray.frame_metadata.frame_number[0])+ actual_frame_number: int = int(frame_recarray.frame_metadata.frame_number[0])actual_camera_id: CameraIdString = frame_recarray.frame_metadata.camera_info.camera_id[0]if actual_camera_id != camera_id:- raise RuntimeError(f"RealtimeCameraNode [{camera_id}]: expected camera ID {camera_id} but got frame with camera ID {actual_camera_id}")+ raise RuntimeError(+ f"RealtimeCameraNode [{camera_id}]: expected camera ID {camera_id} but got frame with camera ID {actual_camera_id}")if actual_frame_number != frame_msg.frame_number:logger.warning(f"RealtimeCameraNode [{camera_id}]: requested frame {frame_msg.frame_number} "@@ -187,25 +214,40 @@ class CameraNode(SourceNode):)skeleton_observation = Nonecharuco_observation = None+ t_frame_start = time.perf_counter() if timer is not None else 0.0if skeleton_detector is not None:+ t0 = time.perf_counter() if timer is not None else 0.0skeleton_observation = skeleton_detector.detect(frame_number=actual_frame_number,image=image,)+ if timer is not None:+ timer.record("skeleton_detection", (time.perf_counter() - t0) * 1e3)if charuco_detector is not None:+ t0 = time.perf_counter() if timer is not None else 0.0charuco_observation = charuco_detector.detect(frame_number=actual_frame_number,image=image,)+ if timer is not None:+ timer.record("charuco_detection", (time.perf_counter() - t0) * 1e3)+ if timer is not None:+ timer.record("total_camera_node", (time.perf_counter() - t_frame_start) * 1e3)camera_output_pub.put(CameraNodeOutputMessage(camera_id=actual_camera_id,frame_number=actual_frame_number,charuco_observation=charuco_observation,- skeleton_observation= skeleton_observation+ skeleton_observation=skeleton_observation,),)+ if timer is not None:+ timer.maybe_flush(+ publication_queue=timing_pub,+ node_kind="camera",+ camera_id=camera_id,+ )except Exception as e:logger.exception(f"Exception in RealtimeCameraNode [{camera_id}]: {e}")diff --git a/freemocap/core/pipeline/realtime/camera_node_config.py b/freemocap/core/pipeline/realtime/camera_node_config.pyindex 80d6ae37..766499be 100644--- a/freemocap/core/pipeline/realtime/camera_node_config.py+++ b/freemocap/core/pipeline/realtime/camera_node_config.py@@ -1,14 +1,16 @@from pydantic import BaseModel, Field+from skellycam.core.ipc.process_management.managed_worker import WorkerModefrom skellytracker.trackers.base_tracker.detector_helpers import SkeletonDetectorConfigfrom skellytracker.trackers.charuco_tracker.charuco_tracker_config import CharucoDetectorConfigfrom skellytracker.trackers.rtmpose_tracker.rtmpose_detector import RTMPoseDetectorConfigclass CameraNodeConfig(BaseModel):+ worker_mode: WorkerMode = WorkerMode.PROCESScharuco_tracking_enabled: bool = Trueskeleton_tracking_enabled: bool = Truecharuco_detector_config: CharucoDetectorConfig|None = Field(default_factory=CharucoDetectorConfig)- skeleton_detector_config: SkeletonDetectorConfig|None = Field(default_factory=lambda: RTMPoseDetectorConfig(mode="lightweight",+ skeleton_detector_config: SkeletonDetectorConfig|None = Field(default_factory=lambda: RTMPoseDetectorConfig(mode="balanced",confidence_threshold=5))# skeleton_detector_config: LegacyMediapipeDetectorConfig|None = Field(default_factory=LegacyMediapipeDetectorConfig)diff --git a/freemocap/core/pipeline/realtime/realtime_aggregator_node.py b/freemocap/core/pipeline/realtime/realtime_aggregator_node.pyindex b43e8228..5e57addf 100644--- a/freemocap/core/pipeline/realtime/realtime_aggregator_node.py+++ b/freemocap/core/pipeline/realtime/realtime_aggregator_node.py@@ -18,11 +18,13 @@ blended with an anthropometric prior. The filter resets on calibration reloadsince the coordinate frame may change."""import logging-import multiprocessing+import multiprocessing.synchronize+import os+import queue+import threadingimport timefrom dataclasses import dataclassfrom multiprocessing.sharedctypes import Synchronized-from typing import Iterableimport numpy as npfrom skellycam.core.ipc.process_management.worker_registry import WorkerRegistry@@ -31,13 +33,13 @@ from skellycam.core.ipc.shared_memory.camera_group_shared_memory import (CameraGroupSharedMemoryDTO,)from skellycam.core.types.type_overloads import CameraGroupIdString, CameraIdString, TopicSubscriptionQueue-from skellycam.utilities.wait_functions import wait_1msfrom skellyforge.data_models.trajectory_3d import Point3dfrom freemocap.core.pipeline.abcs.aggregator_node_abc import AggregatorNodefrom freemocap.core.pipeline.abcs.pipeline_ipc import PipelineIPC-from freemocap.core.pipeline.realtime.realtime_aggregator_node_config import RealtimeAggregatorNodeConfigfrom freemocap.core.pipeline.realtime.realtime_pipeline_config import RealtimePipelineConfig+from freemocap.core.pipeline.pipeline_stage_timer import PipelineStageTimer+from freemocap.core.pipeline.pipeline_timing_reporter import PipelineTimingReporterfrom freemocap.core.tasks.calibration.shared.calibration_state import CalibrationStateTrackerfrom freemocap.core.tasks.mocap.skeleton_dewiggler.dewiggling_methods.bone_length_estimator import AnthropometricPriorfrom freemocap.core.tasks.mocap.skeleton_dewiggler.dewiggling_methods.mediapipe_skeleton_config import \@@ -47,6 +49,7 @@ from freemocap.core.tasks.mocap.skeleton_dewiggler.dewiggling_methods.realtime_pfrom freemocap.core.tasks.mocap.skeleton_dewiggler.dewiggling_methods.rigid_body_estimator import RigidBodyPosefrom freemocap.core.tasks.mocap.skeleton_dewiggler.realtime_skeleton_filter import RealtimeFilterConfig, \RealtimeSkeletonFilter, FilterResult+from freemocap.core.pipeline.realtime.realtime_keypoint_filter import SimpleRealtimeKeypointFilterfrom freemocap.core.types.type_overloads import TopicPublicationQueuefrom freemocap.pubsub.pubsub_manager import PubSubTopicManagerfrom freemocap.pubsub.pubsub_topics import (@@ -58,13 +61,26 @@ from freemocap.pubsub.pubsub_topics import (AggregationNodeOutputMessage,AggregationNodeOutputTopic,PipelineConfigUpdateMessage,+ SkeletonInferenceResultMessage,+ SkeletonInferenceResultTopic,+ PipelineTimingTopic,)+# Cap on how many pending skeleton-inference results we hold while waiting for+# camera-node charuco outputs to arrive. Prevents unbounded memory growth if+# camera nodes lag (e.g. one camera unplugged). Older entries get dropped.+_MAX_PENDING_SKELETON_RESULTS: int = 2+logger = logging.getLogger(__name__)# How often (seconds) to poll the calibration file for changesCALIBRATION_POLL_INTERVAL_SECONDS: float = 1.0+# Skip Point3d Pydantic object creation when the binary keypoints path is+# active — the aggregator runs in a subprocess so it reads the env var here+# at import time, matching the flag check in realtime_pipeline.py.+_BINARY_KEYPOINTS_ENABLED: bool = os.environ.get("FREEMOCAP_BINARY_KEYPOINTS", "0") == "1"+def _merge_triangulated_arrays(*,@@ -158,11 +174,13 @@ class RealtimeAggregatorNode(AggregatorNode):*,config: RealtimePipelineConfig,camera_group_id: CameraGroupIdString,- camera_ids: list[CameraGroupIdString],+ camera_ids: list[CameraIdString],worker_registry: WorkerRegistry,camera_group_shm_dto: CameraGroupSharedMemoryDTO,ipc: PipelineIPC,pubsub: PubSubTopicManager,+ result_ready_event: multiprocessing.synchronize.Event,+ result_consumed_event: multiprocessing.synchronize.Event,) -> "RealtimeAggregatorNode":shutdown_self_flag, worker = cls._create_worker(target=cls._run,@@ -178,6 +196,9 @@ class RealtimeAggregatorNode(AggregatorNode):camera_node_sub=pubsub.get_subscription(CameraNodeOutputTopic,),+ skeleton_inference_sub=pubsub.get_subscription(+ SkeletonInferenceResultTopic,+ ),pipeline_config_sub=pubsub.get_subscription(PipelineConfigUpdateTopic,),@@ -187,6 +208,14 @@ class RealtimeAggregatorNode(AggregatorNode):aggregation_output_pub=pubsub.get_publication_queue(AggregationNodeOutputTopic,),+ timing_pub=pubsub.get_publication_queue(+ PipelineTimingTopic,+ ),+ timing_sub=pubsub.get_subscription(+ PipelineTimingTopic,+ ) if config.log_pipeline_times else None,+ result_ready_event=result_ready_event,+ result_consumed_event=result_consumed_event,),)return cls(@@ -199,14 +228,19 @@ class RealtimeAggregatorNode(AggregatorNode):*,pipeline_config: RealtimePipelineConfig,camera_group_id: CameraGroupIdString,- camera_ids: list[CameraGroupIdString],+ camera_ids: list[CameraIdString],ipc: PipelineIPC,shutdown_self_flag: Synchronized,camera_group_shm_dto: CameraGroupSharedMemoryDTO,camera_node_sub: TopicSubscriptionQueue,+ skeleton_inference_sub: TopicSubscriptionQueue,pipeline_config_sub: TopicSubscriptionQueue,process_frame_number_pub: TopicPublicationQueue,aggregation_output_pub: TopicPublicationQueue,+ timing_pub: TopicPublicationQueue,+ timing_sub: TopicSubscriptionQueue | None,+ result_ready_event: multiprocessing.synchronize.Event,+ result_consumed_event: multiprocessing.synchronize.Event,) -> None:logger.debug(f"RealtimeAggregationNode [{camera_group_id}] initializing")aggregator_config = pipeline_config.aggregator_config@@ -236,23 +270,52 @@ class RealtimeAggregatorNode(AggregatorNode):max_rejected_streak=filter_config.max_rejected_streak,)+ # Lightweight One Euro filter: smooths raw keypoints and gap-fills brief occlusions+ keypoint_filter = SimpleRealtimeKeypointFilter(+ min_cutoff=filter_config.min_cutoff,+ beta=filter_config.beta,+ )+camera_node_outputs: dict[CameraIdString, CameraNodeOutputMessage | None] = {cam_id: None for cam_id in camera_ids}+ # Pending skeleton inference results keyed by frame_number. Populated+ # by the centralized SkeletonInferenceNode (when GPU mode is on);+ # consumed when the matching camera outputs arrive for that frame.+ pending_skeleton_results: dict[int, dict[CameraIdString, object | None]] = {}latest_requested_frame: int = -1last_received_frame: int = -1- last_calibration_poll: float = time.monotonic()-+ last_calibration_poll: float = time.perf_counter()+ log_pipeline_times = pipeline_config.log_pipeline_times+ timer = PipelineStageTimer(name=f"AggregatorNode-{camera_group_id}") if log_pipeline_times else None+ t_frame_requested: float = time.perf_counter() if timer is not None else 0.0+ # Skip the first frame_collection_wait / loop_time samples — those+ # measure aggregator-startup → first-frame-arrival, which is dominated+ # by camera warmup (~5-7s) and is not a steady-state metric.+ recorded_first_frame: bool = False++ timing_reporter: PipelineTimingReporter | None = None+ timing_reporter_stop: threading.Event | None = None+ if log_pipeline_times and timing_sub is not None:+ timing_reporter_stop = threading.Event()+ timing_reporter = PipelineTimingReporter(+ name=str(camera_group_id),+ timing_sub=timing_sub,+ stop_event=timing_reporter_stop,+ expected_camera_count=len(camera_ids),+ )+ timing_reporter.start()try:- previous_tik = time.perf_counter()+ previous_loop_tik = time.perf_counter() if timer is not None else 0.0logger.debug(f"RealtimeAggregationNode [{camera_group_id}] entering main loop")while ipc.should_continue and not shutdown_self_flag.value:- wait_1ms()-# ---- Handle config updates ----- while not pipeline_config_sub.empty():- msg: PipelineConfigUpdateMessage = pipeline_config_sub.get()+ while True:+ try:+ msg: PipelineConfigUpdateMessage = pipeline_config_sub.get_nowait()+ except queue.Empty:+ breakpipeline_config = msg.pipeline_configaggregator_config = pipeline_config.aggregator_configfilter_config = aggregator_config.realtime_filter_config@@ -261,7 +324,7 @@ class RealtimeAggregatorNode(AggregatorNode):)# ---- Periodically check if calibration file changed on disk ----- now = time.monotonic()+ now = time.perf_counter()if now - last_calibration_poll >= CALIBRATION_POLL_INTERVAL_SECONDS:last_calibration_poll = nowif calibration.check_for_update():@@ -270,6 +333,7 @@ class RealtimeAggregatorNode(AggregatorNode):f"hot-reloaded calibration from {calibration.calibration_path}")# Coordinate frame may have changed — reset filter + gate+ keypoint_filter.reset()skeleton_filter.reset()point_gate.reset()@@ -281,33 +345,91 @@ class RealtimeAggregatorNode(AggregatorNode):)breakcurrent_multiframe_number = camera_group_shm.latest_multiframe_number+ # First-frame bootstrap and fallback. Normally, subsequent frames are+ # requested optimistically after camera collection completes (below).+ # This block handles startup (latest_requested_frame == -1) and the+ # rare case where the shm hadn't advanced at the optimistic-request point.if (current_multiframe_number > latest_requested_frame- and last_received_frame >= latest_requested_frame):+ and last_received_frame >= latest_requested_frame+ and result_consumed_event.is_set()):process_frame_number_pub.put(ProcessFrameNumberMessage(frame_number=current_multiframe_number,),)latest_requested_frame = current_multiframe_number+ t_frame_requested = time.perf_counter() if timer is not None else 0.0++ # ---- Collect skeleton inference results (GPU mode) ----+ # Drained on every iteration so they're available whenever the+ # corresponding camera-node charuco outputs finish arriving.+ while True:+ try:+ skel_msg: SkeletonInferenceResultMessage = skeleton_inference_sub.get_nowait()+ except queue.Empty:+ break+ pending_skeleton_results[skel_msg.frame_number] = skel_msg.per_camera_skeleton+ # Bound the pending dict so a lagging camera can't grow it forever.+ if len(pending_skeleton_results) > _MAX_PENDING_SKELETON_RESULTS:+ oldest = sorted(pending_skeleton_results.keys())[+ :len(pending_skeleton_results) - _MAX_PENDING_SKELETON_RESULTS]+ for k in oldest:+ pending_skeleton_results.pop(k, None)# ---- Collect camera node outputs ----- if camera_node_sub.empty():- continue-- cam_output: CameraNodeOutputMessage = camera_node_sub.get()- if cam_output.camera_id not in camera_ids:- raise ValueError(- f"Camera ID {cam_output.camera_id} not in "- f"camera IDs {list(camera_ids)}"- )- camera_node_outputs[cam_output.camera_id] = cam_output-- # ---- Check if all cameras reported for this frame ----- if not all(- isinstance(v, CameraNodeOutputMessage)- for v in camera_node_outputs.values()- ):- continue+ # If camera outputs are already complete (we looped back waiting+ # for the skeleton inference result), skip collection — the+ # existing entries are still valid and we just need the skeleton.+ all_cam_ready = all(+ isinstance(v, CameraNodeOutputMessage)+ for v in camera_node_outputs.values()+ )+ if not all_cam_ready:+ # Block up to 5ms for the next camera output instead of+ # busy-polling with empty() + 1ms sleep — cuts CPU waste+ # and removes polling overhead from the critical path.+ try:+ cam_output: CameraNodeOutputMessage = camera_node_sub.get(timeout=0.005)+ except queue.Empty:+ continue+ if cam_output.camera_id not in camera_ids:+ raise ValueError(+ f"Camera ID {cam_output.camera_id} not in "+ f"camera IDs {list(camera_ids)}"+ )+ if cam_output.frame_number != latest_requested_frame:+ raise RuntimeError(+ f"WRONG FRAME from camera {cam_output.camera_id}: "+ f"received frame {cam_output.frame_number} but expected "+ f"{latest_requested_frame} (last_received={last_received_frame}). "+ f"Camera processed the wrong frame — same frame sent twice?"+ )+ camera_node_outputs[cam_output.camera_id] = cam_output++ if not all(+ isinstance(v, CameraNodeOutputMessage)+ for v in camera_node_outputs.values()+ ):+ continue++ # ---- In GPU mode, also wait for the skeleton inference result ----+ if (pipeline_config.use_centralized_gpu_inference+ and pipeline_config.camera_node_config.skeleton_tracking_enabled):+ expected_frame = next(iter(camera_node_outputs.values())).frame_number+ if expected_frame not in pending_skeleton_results:+ # Camera outputs are ready but skeleton inference hasn't+ # caught up yet. Loop again — `camera_node_outputs` stays+ # populated, and the skeleton result will land in the+ # `skeleton_inference_sub` drain at the top of the next+ # iteration.+ continue+ # Splice the per-camera skeletons into each CameraNodeOutputMessage+ # so downstream triangulation code (which reads+ # `output.skeleton_observation`) needs no changes.+ skeleton_per_camera = pending_skeleton_results.pop(expected_frame)+ for cam_id, output_msg in camera_node_outputs.items():+ if output_msg is not None:+ output_msg.skeleton_observation = skeleton_per_camera.get(cam_id)frame_numbers = [msg.frame_number@@ -321,6 +443,29 @@ class RealtimeAggregatorNode(AggregatorNode):)last_received_frame = latest_requested_frame+ t_frame_start = time.perf_counter() if timer is not None else 0.0+ if timer is not None and recorded_first_frame:+ timer.record("frame_collection_wait", (t_frame_start - t_frame_requested) * 1e3)++ # ---- Optimistically request next frame before aggregating ----+ # result_consumed_event is guaranteed set at this point: we checked it+ # before requesting this frame and haven't published a result yet.+ # Camera nodes start detecting frame N+1 while we triangulate/filter N.+ frame_n_outputs = camera_node_outputs+ camera_node_outputs = {cam_id: None for cam_id in camera_ids}+ latest_shm_frame = camera_group_shm.latest_multiframe_number+ if latest_shm_frame > latest_requested_frame:+ process_frame_number_pub.put(+ ProcessFrameNumberMessage(frame_number=latest_shm_frame)+ )+ latest_requested_frame = latest_shm_frame+ t_frame_requested = time.perf_counter() if timer is not None else 0.0+ elif latest_shm_frame < latest_requested_frame:+ raise RuntimeError(+ f"SHM frame counter went backwards: latest_shm_frame={latest_shm_frame} "+ f"< latest_requested_frame={latest_requested_frame}. "+ f"Ring buffer should be monotonically increasing."+ )# ---- Triangulate and process if calibration is valid ----# All processing stays in dict[str, ndarray] until final@@ -331,58 +476,82 @@ class RealtimeAggregatorNode(AggregatorNode):rigid_body_poses: dict[str, RigidBodyPose] = {}if calibration.is_valid and aggregator_config.triangulation_enabled:# Triangulate mediapipe observations- mediapipe_observations_by_camera = {+ skeleton_observations_by_camera = {cam_id: output.skeleton_observation- for cam_id, output in camera_node_outputs.items()+ for cam_id, output in frame_n_outputs.items()if isinstance(output, CameraNodeOutputMessage)and output.skeleton_observation is not None}- if mediapipe_observations_by_camera:+ if skeleton_observations_by_camera:+ t0 = time.perf_counter() if timer is not None else 0.0_merge_triangulated_arrays(- triangulated=calibration.try_triangulate(- frame_number=latest_requested_frame,- frame_observations_by_camera=mediapipe_observations_by_camera,+ triangulated=calibration.try_angulate(+ frame_number=last_received_frame,+ frame_observations_by_camera=skeleton_observations_by_camera,max_reprojection_error_px=filter_config.max_reprojection_error_px,+ triangulation_config=aggregator_config.triangulation_config,),into=raw_keypoints,)+ if timer is not None:+ timer.record("skeleton_triangulation", (time.perf_counter() - t0) * 1e3)# Triangulate charuco observationscharuco_observations_by_camera = {cam_id: output.charuco_observation- for cam_id, output in camera_node_outputs.items()+ for cam_id, output in frame_n_outputs.items()if isinstance(output, CameraNodeOutputMessage)and output.charuco_observation is not None}if charuco_observations_by_camera:+ t0 = time.perf_counter() if timer is not None else 0.0_merge_triangulated_arrays(- triangulated=calibration.try_triangulate(- frame_number=latest_requested_frame,+ triangulated=calibration.try_angulate(+ frame_number=last_received_frame,frame_observations_by_camera=charuco_observations_by_camera,max_reprojection_error_px=filter_config.max_reprojection_error_px,+ triangulation_config=aggregator_config.triangulation_config,),into=raw_keypoints,)+ if timer is not None:+ timer.record("charuco_triangulation", (time.perf_counter() - t0) * 1e3)++ # One Euro filter: smooth raw keypoints and gap-fill brief occlusions+ if raw_keypoints:+ t0 = time.perf_counter() if timer is not None else 0.0+ filtered_keypoints = keypoint_filter.filter(+ t=time.perf_counter(),+ raw_keypoints=raw_keypoints,+ )+ if timer is not None:+ timer.record("keypoint_filter", (time.perf_counter() - t0) * 1e3)# Velocity gate: reject teleportation spikesif aggregator_config.filter_enabled:if raw_keypoints:+ t0 = time.perf_counter() if timer is not None else 0.0gate_result: GateResult = point_gate.gate(- t=time.monotonic(),+ t=time.perf_counter(),points=raw_keypoints,)_merge_triangulated_arrays(triangulated=gate_result.positions,into=filtered_keypoints,)-- # # Filter + constrain skeleton keypoints- # if filtered_keypoints and config.skeleton_enabled:- # filtered_keypoints = _filter_skeleton_arrays(- # point_arrays=filtered_keypoints,- # skeleton_filter=skeleton_filter,- # t=time.monotonic(),- # )+ if timer is not None:+ timer.record("velocity_gate", (time.perf_counter() - t0) * 1e3)++ # Filter + constrain skeleton keypoints+ if filtered_keypoints and aggregator_config.skeleton_enabled:+ t0 = time.perf_counter() if timer is not None else 0.0+ filtered_keypoints = _filter_skeleton_arrays(+ point_arrays=filtered_keypoints,+ skeleton_filter=skeleton_filter,+ t=time.perf_counter(),+ )+ if timer is not None:+ timer.record("skeleton_filter", (time.perf_counter() - t0) * 1e3)# # Estimate rigid body segment poses# if filtered_keypoints and config.skeleton_enabled and skeleton_filter.current_bone_lengths:@@ -393,27 +562,47 @@ class RealtimeAggregatorNode(AggregatorNode):# )# Convert to Point3d once at the end for the output message-- now = time.perf_counter()- loop_time = now - previous_tik- previous_tik = now- # logger.trace(f"RealtimeAggregationNode [{camera_group_id}] loop time: {loop_time*1e3:.3f} ms")+ if timer is not None:+ timer.record("full_frame_processing", (time.perf_counter() - t_frame_start) * 1e3)+ now = time.perf_counter()+ if recorded_first_frame:+ timer.record("loop_time", (now - previous_loop_tik) * 1e3)+ previous_loop_tik = now+ recorded_first_frame = True+ timer.maybe_flush(+ publication_queue=timing_pub,+ node_kind="aggregator",+ )# ---- Publish aggregated output ----aggregation_output_pub.put(AggregationNodeOutputMessage(- frame_number=latest_requested_frame,+ frame_number=last_received_frame,pipeline_id=ipc.pipeline_id,pipeline_config=pipeline_config,camera_group_id=camera_group_id,- camera_node_outputs=camera_node_outputs,- keypoints_raw=_arrays_to_point3d(raw_keypoints),- keypoints_filtered=_arrays_to_point3d(filtered_keypoints),+ camera_node_outputs=frame_n_outputs,+ # When the binary path is active, skip the per-point+ # Pydantic object creation — the raw arrays field is+ # what the serializer actually reads.+ keypoints_raw=(+ {} if _BINARY_KEYPOINTS_ENABLED+ else _arrays_to_point3d(raw_keypoints)+ ),+ keypoints_filtered=(+ {} if _BINARY_KEYPOINTS_ENABLED+ else _arrays_to_point3d(filtered_keypoints)+ ),+ keypoints_raw_arrays=raw_keypoints,+ keypoints_filtered_arrays=filtered_keypoints,# rigid_body_poses=rigid_body_poses,),)-- camera_node_outputs = {cam_id: None for cam_id in camera_ids}+ # Mark the slot as full and not-yet-consumed; the consumer+ # (websocket relay via RealtimePipeline.get_latest_frontend_payload)+ # flips these in the opposite order on grab.+ result_consumed_event.clear()+ result_ready_event.set()except Exception as e:logger.error(@@ -423,4 +612,8 @@ class RealtimeAggregatorNode(AggregatorNode):ipc.kill_everything()raisefinally:+ if timing_reporter_stop is not None:+ timing_reporter_stop.set()+ if timing_reporter is not None:+ timing_reporter.join(timeout=2.0)logger.debug(f"RealtimeAggregationNode [{camera_group_id}] exiting")diff --git a/freemocap/core/pipeline/realtime/realtime_aggregator_node_config.py b/freemocap/core/pipeline/realtime/realtime_aggregator_node_config.pyindex c8a674b8..37905985 100644--- a/freemocap/core/pipeline/realtime/realtime_aggregator_node_config.py+++ b/freemocap/core/pipeline/realtime/realtime_aggregator_node_config.py@@ -2,6 +2,7 @@ from pydantic import BaseModel, Fieldfrom freemocap.core.tasks.calibration.calibration_task_config import CalibrationSourcefrom freemocap.core.tasks.mocap.skeleton_dewiggler.realtime_skeleton_filter import RealtimeFilterConfig+from freemocap.core.tasks.triangulation.helpers.triangulation_config import TriangulationConfigclass RealtimeAggregatorNodeConfig(BaseModel):@@ -20,3 +21,4 @@ class RealtimeAggregatorNodeConfig(BaseModel):skeleton_enabled: bool = Truerealtime_filter_config: RealtimeFilterConfig = Field(default_factory=RealtimeFilterConfig)+ triangulation_config: TriangulationConfig = Field(default_factory=TriangulationConfig)diff --git a/freemocap/core/pipeline/realtime/realtime_keypoint_filter.py b/freemocap/core/pipeline/realtime/realtime_keypoint_filter.pynew file mode 100644index 00000000..a362fb37--- /dev/null+++ b/freemocap/core/pipeline/realtime/realtime_keypoint_filter.py@@ -0,0 +1,101 @@+"""+SimpleRealtimeKeypointFilter: lightweight One Euro filter wrapper for the realtime pipeline.++Applies per-keypoint One Euro smoothing to triangulated 3D positions and+predicts (extrapolates) positions for keypoints that temporarily disappear,+so the output stream doesn't blink when tracking is lost for a few frames.++Gap filling:+ When a keypoint is absent from raw_keypoints the filter calls predict()+ using its stored velocity, decaying that velocity each frame so the+ extrapolated point slows to a stop. After max_prediction_frames+ consecutive misses the keypoint is dropped from the output entirely.++NaN handling:+ The One Euro filter has no NaN guards. This is safe here because+ _merge_triangulated_arrays() in the aggregator already drops any+ NaN-containing triangulated points before they reach this filter —+ missing keypoints show up as absent dict keys, not NaN values.+"""++import logging+from dataclasses import dataclass, field++import numpy as np++from freemocap.core.tasks.mocap.skeleton_dewiggler.dewiggling_methods.one_euro_filter import OneEuroFilter3D++logger = logging.getLogger(__name__)+++@dataclass+class SimpleRealtimeKeypointFilter:+ """One Euro filter applied per-keypoint with velocity-decay gap filling."""++ min_cutoff: float = 0.005+ beta: float = 0.3+ d_cutoff: float = 1.0+ max_prediction_frames: int = 3+ prediction_velocity_decay: float = 0.5++ _filters: dict[str, OneEuroFilter3D] = field(default_factory=dict, init=False, repr=False)+ _prediction_counts: dict[str, int] = field(default_factory=dict, init=False, repr=False)+ _last_t: float | None = field(default=None, init=False, repr=False)++ def filter(self, *, t: float, raw_keypoints: dict[str, np.ndarray]) -> dict[str, np.ndarray]:+ """Return smoothed + gap-filled keypoints.++ Args:+ t: Monotonic timestamp in seconds (must be strictly increasing across calls).+ raw_keypoints: Triangulated 3D positions, keyed by point name.+ NaN-free — caller is responsible for pre-filtering.++ Returns:+ dict mapping point name → filtered (3,) ndarray.+ Includes predictions for recently-seen keypoints absent this frame.+ """+ if self._last_t is not None and t <= self._last_t:+ # TODO: Fix root cause — the aggregator is processing the same frame twice causing the filter to receive identical timestamps for consecutive frames. Until the data-flow bug is resolved, skip filtering this frame to avoid crashing the pipeline.+ logger.error(+ f"Non-monotonic timestamp passed to keypoint filter: "+ f"t={t} <= last_t={self._last_t} (dt={t - self._last_t}). "+ f"The aggregator processed the same frame twice, or the clock went backwards. "+ f"Skipping filter for this frame."+ )+ return raw_keypoints+ self._last_t = t++ result: dict[str, np.ndarray] = {}++ # Process keypoints present this frame+ for name, pos in raw_keypoints.items():+ if name not in self._filters:+ self._filters[name] = OneEuroFilter3D(+ t0=t,+ x0=pos.astype(float),+ min_cutoff=self.min_cutoff,+ beta=self.beta,+ d_cutoff=self.d_cutoff,+ )+ self._prediction_counts[name] = 0+ result[name] = pos+ else:+ self._prediction_counts[name] = 0+ result[name] = self._filters[name](t=t, x=pos.astype(float))++ # Predict keypoints absent this frame (gap filling)+ for name, filt in self._filters.items():+ if name in raw_keypoints:+ continue+ count = self._prediction_counts.get(name, 0)+ if count < self.max_prediction_frames:+ result[name] = filt.predict(t=t, velocity_decay=self.prediction_velocity_decay)+ self._prediction_counts[name] = count + 1++ return result++ def reset(self) -> None:+ """Clear all filter state. Call when the calibration/coordinate frame changes."""+ self._filters.clear()+ self._prediction_counts.clear()+ self._last_t = Nonediff --git a/freemocap/core/pipeline/realtime/realtime_pipeline.py b/freemocap/core/pipeline/realtime/realtime_pipeline.pyindex 67f1f734..d0027900 100644--- a/freemocap/core/pipeline/realtime/realtime_pipeline.py+++ b/freemocap/core/pipeline/realtime/realtime_pipeline.py@@ -8,13 +8,20 @@ published through the pubsub system.Calibration or Kinematic reconstructions-specific orchestration (start/stop recording, triggering posthoccalibration) is NOT here — it belongs in the PipelineManager or route handlers."""+import asyncioimport logging+import multiprocessing+import multiprocessing.synchronize+import osimport uuidfrom dataclasses import dataclass+from queue import Emptyfrom pydantic import BaseModel, ConfigDict+from skellytracker.trackers.rtmpose_tracker.names_and_connections import RTMPOSE_WHOLEBODY_DEFINITIONfrom skellycam.core.camera.config.camera_config import CameraConfigsfrom skellycam.core.camera_group.camera_group import CameraGroup+from skellycam.core.ipc.process_management.managed_worker import WorkerModefrom skellycam.core.ipc.process_management.worker_registry import WorkerRegistryfrom skellycam.core.types.type_overloads import CameraIdString, CameraGroupIdString@@ -22,7 +29,11 @@ from freemocap.core.pipeline.abcs.pipeline_ipc import PipelineIPCfrom freemocap.core.pipeline.realtime.camera_node import CameraNodefrom freemocap.core.pipeline.realtime.realtime_aggregator_node import RealtimeAggregatorNodefrom freemocap.core.pipeline.realtime.realtime_pipeline_config import RealtimePipelineConfig+from freemocap.core.pipeline.realtime.realtime_skeleton_inference_node import (+ RealtimeSkeletonInferenceNode,+)from freemocap.core.types.type_overloads import PipelineIdString, TopicSubscriptionQueue, FrameNumberInt+from freemocap.core.viz.frontend_keypoints_serializer import build_keypoints_payloadfrom freemocap.core.viz.frontend_payload import FrontendPayload, FrontendImagePacketfrom freemocap.pubsub.pubsub_manager import PubSubTopicManagerfrom freemocap.pubsub.pubsub_topics import (@@ -35,6 +46,12 @@ from freemocap.pubsub.pubsub_topics import (logger = logging.getLogger(__name__)+# Step 1 of the JSON→binary keypoints refactor is gated behind this env var so+# the JSON path stays the default until both ends are validated end-to-end.+# Set FREEMOCAP_BINARY_KEYPOINTS=1 to enable.+_BINARY_KEYPOINTS_ENABLED: bool = os.environ.get("FREEMOCAP_BINARY_KEYPOINTS", "0") == "1"++class RealtimePipelineState(BaseModel):"""Serializable snapshot of pipeline state (for API responses)."""model_config = ConfigDict(validate_assignment=True, frozen=True)@@ -51,19 +68,26 @@ class RealtimePipeline:config: RealtimePipelineConfigcamera_nodes: dict[CameraIdString, CameraNode]aggregation_node: RealtimeAggregatorNode+ skeleton_inference_node: RealtimeSkeletonInferenceNode | Noneaggregation_output_subscription: TopicSubscriptionQueue+ result_ready_event: multiprocessing.synchronize.Event+ result_consumed_event: multiprocessing.synchronize.Eventipc: PipelineIPCpubsub: PubSubTopicManager+ worker_registry: WorkerRegistrystarted: bool = False@propertydef alive(self) -> bool:if not self.started:return False- return (+ nodes_alive = (all(node.is_alive for node in self.camera_nodes.values())and self.aggregation_node.is_alive)+ if self.skeleton_inference_node is not None:+ nodes_alive = nodes_alive and self.skeleton_inference_node.is_alive+ return nodes_alive@propertydef camera_group_id(self) -> CameraGroupIdString:@@ -84,6 +108,7 @@ class RealtimePipeline:camera_group: CameraGroup,worker_registry: WorkerRegistry,pipeline_config: RealtimePipelineConfig,+ realtime_camera_ids: list[CameraIdString] | None = None,) -> "RealtimePipeline":global_kill_flag = camera_group.ipc.global_kill_flag@@ -95,27 +120,70 @@ class RealtimePipeline:global_kill_flag=global_kill_flag,)+ camera_registry = worker_registry+ if pipeline_config.camera_node_config.worker_mode == WorkerMode.THREAD:+ camera_registry = WorkerRegistry(+ global_kill_flag=global_kill_flag,+ worker_mode=WorkerMode.THREAD,+ )++ # Use the realtime subset if provided, otherwise all cameras in the group.+ # The camera group is always started with all selected cameras so their+ # shared memory exists; we just choose which ones feed the pipeline nodes.+ pipeline_camera_ids: list[CameraIdString] = (+ [cid for cid in camera_group.configs.keys() if cid in realtime_camera_ids]+ if realtime_camera_ids is not None+ else list(camera_group.configs.keys())+ )+camera_nodes = {camera_id: CameraNode.create(camera_id=camera_id,- worker_registry=worker_registry,+ worker_registry=camera_registry,camera_shm_dto=camera_group.shm.to_dto().camera_shm_dtos[camera_id],config=pipeline_config.camera_node_config,ipc=ipc,pubsub=pubsub,-+ skeleton_inference_centralized=pipeline_config.use_centralized_gpu_inference,+ log_pipeline_times=pipeline_config.log_pipeline_times,)- for camera_id in camera_group.configs.keys()+ for camera_id in pipeline_camera_ids}+ skeleton_inference_node: RealtimeSkeletonInferenceNode | None = None+ if (pipeline_config.use_centralized_gpu_inference+ and pipeline_config.camera_node_config.skeleton_tracking_enabled):+ skeleton_inference_node = RealtimeSkeletonInferenceNode.create(+ camera_group_id=camera_group.id,+ camera_ids=pipeline_camera_ids,+ worker_registry=worker_registry,+ camera_group_shm_dto=camera_group.shm.to_dto(),+ config=pipeline_config,+ ipc=ipc,+ pubsub=pubsub,+ )++ # Backpressure events between the aggregator and the websocket consumer.+ # The aggregator processes one frame, publishes the result, clears+ # `result_consumed_event`, and sets `result_ready_event`. The consumer+ # waits on `result_ready_event`, grabs the result, then flips the events+ # in the opposite order — releasing the aggregator to start the next+ # frame. Initial state: nothing is ready, but the slot is "consumed"+ # (free), so the aggregator can produce its first frame immediately.+ result_ready_event = multiprocessing.Event()+ result_consumed_event = multiprocessing.Event()+ result_consumed_event.set()+aggregation_node = RealtimeAggregatorNode.create(camera_group_id=camera_group.id,- camera_ids=camera_group.camera_ids,+ camera_ids=pipeline_camera_ids,worker_registry=worker_registry,camera_group_shm_dto=camera_group.shm.to_dto(),config=pipeline_config,ipc=ipc,pubsub=pubsub,+ result_ready_event=result_ready_event,+ result_consumed_event=result_consumed_event,)aggregation_output_subscription = pubsub.get_subscription(@@ -128,9 +196,13 @@ class RealtimePipeline:config=pipeline_config,camera_nodes=camera_nodes,aggregation_node=aggregation_node,+ skeleton_inference_node=skeleton_inference_node,aggregation_output_subscription=aggregation_output_subscription,+ result_ready_event=result_ready_event,+ result_consumed_event=result_consumed_event,ipc=ipc,pubsub=pubsub,+ worker_registry=worker_registry,)def start(self) -> None:@@ -149,6 +221,17 @@ class RealtimePipeline:self.aggregation_node.start()+ # Start the centralized GPU inference node before camera nodes so its+ # session (including any TRT engine compilation) is ready by the time+ # the first frame request lands. First-run TRT compile can take 1–3+ # minutes; subsequent runs are cache-hits.+ if self.skeleton_inference_node is not None:+ logger.info(+ f"Starting centralized SkeletonInferenceNode for pipeline [{self.id}] — "+ f"first run may pause for ~1-3 minutes while TensorRT compiles engines."+ )+ self.skeleton_inference_node.start()+for camera_id, node in self.camera_nodes.items():node.start()@@ -163,17 +246,28 @@ class RealtimePipeline:for node in self.camera_nodes.values():node.worker._intentionally_terminated = Trueself.aggregation_node.worker._intentionally_terminated = True+ if self.skeleton_inference_node is not None:+ self.skeleton_inference_node.worker._intentionally_terminated = Trueself.pubsub.close()for node in self.camera_nodes.values():if node.is_alive:node.shutdown()+ if self.skeleton_inference_node is not None and self.skeleton_inference_node.is_alive:+ self.skeleton_inference_node.shutdown()if self.aggregation_node.is_alive:self.aggregation_node.shutdown()logger.debug(f"RealtimePipeline [{self.id}] shut down")def update_config(self, new_config: RealtimePipelineConfig) -> None:- """Push a config update to all pipeline workers via pubsub."""+ """Push a config update to all pipeline workers via pubsub.++ Also manages SkeletonInferenceNode lifecycle when skeleton_tracking_enabled+ transitions between True and False.+ """+ old_skeleton = self.config.camera_node_config.skeleton_tracking_enabled+ new_skeleton = new_config.camera_node_config.skeleton_tracking_enabled+self.config = new_configlogger.trace(f"Pushing new config to realtime pipeline: {self.id} \n {new_config.model_dump_json(indent=4)}")self.pubsub.publish(@@ -181,11 +275,44 @@ class RealtimePipeline:message=PipelineConfigUpdateMessage(pipeline_config=new_config),)+ if old_skeleton and not new_skeleton:+ # Skeleton tracking disabled: shut down the centralized inference node.+ if self.skeleton_inference_node is not None and self.skeleton_inference_node.is_alive:+ logger.info(f"RealtimePipeline [{self.id}]: skeleton tracking disabled — shutting down SkeletonInferenceNode")+ self.skeleton_inference_node.shutdown()+ self.skeleton_inference_node = None++ elif not old_skeleton and new_skeleton and new_config.use_centralized_gpu_inference:+ # Skeleton tracking re-enabled: create and start a fresh inference node.+ logger.info(+ f"Starting centralized SkeletonInferenceNode for pipeline [{self.id}] — "+ f"first run may pause for ~1-3 minutes while TensorRT compiles engines."+ )+ self.skeleton_inference_node = RealtimeSkeletonInferenceNode.create(+ camera_group_id=self.camera_group.id,+ camera_ids=self.camera_group.camera_ids,+ worker_registry=self.worker_registry,+ camera_group_shm_dto=self.camera_group.shm.to_dto(),+ config=new_config,+ ipc=self.ipc,+ pubsub=self.pubsub,+ )+ self.skeleton_inference_node.start()+async def update_camera_configs(self, camera_configs: CameraConfigs) -> CameraConfigs:return await self.camera_group.update_camera_settings(requested_configs=camera_configs,)+ async def wait_for_result_ready(self, timeout: float) -> bool:+ """Block (off the event loop) until the aggregator has a result ready.++ Returns True if a result became available within `timeout`, False on+ timeout. Used by the websocket relay to avoid spinning on a polling+ loop while the aggregator is processing the next frame.+ """+ return await asyncio.to_thread(self.result_ready_event.wait, timeout)+def get_latest_frontend_payload(self, if_newer_than: FrameNumberInt, ) -> FrontendImagePacket | None:if not self.alive:if self.camera_group.alive:@@ -204,20 +331,41 @@ class RealtimePipeline:return Noneaggregation_output: AggregationNodeOutputMessage | None = None- while not self.aggregation_output_subscription.empty():- aggregation_output = self.aggregation_output_subscription.get()+ while True:+ try:+ aggregation_output = self.aggregation_output_subscription.get_nowait()+ except Empty:+ breakif aggregation_output is None:return None+ # Flip the backpressure events: clear "ready" (we just took it) and+ # set "consumed" (the aggregator can now process the next frame).+ # The aggregator should already be idling on the consumed-gate, so+ # this signal is what kicks off the next pass — in parallel with+ # the websocket sending this packet to the frontend.+ self.result_ready_event.clear()+ self.result_consumed_event.set()+payload = self.camera_group.get_frontend_payload_by_frame_number(frame_number=aggregation_output.frame_number,)if payload is not None:frames_bytearray, mf_timestamp = payload+ keypoints_binary_payload: bytearray | None = None+ if _BINARY_KEYPOINTS_ENABLED:+ keypoints_binary_payload = build_keypoints_payload(+ frame_number=aggregation_output.frame_number,+ tracker_id=RTMPOSE_WHOLEBODY_DEFINITION.name,+ point_names=RTMPOSE_WHOLEBODY_DEFINITION.tracked_points,+ keypoints_raw_arrays=aggregation_output.keypoints_raw_arrays,+ keypoints_filtered_arrays=aggregation_output.keypoints_filtered_arrays,+ )return FrontendImagePacket(images_bytearray=frames_bytearray,multiframe_timestamp=mf_timestamp,frontend_payload=FrontendPayload.from_aggregation_output(aggregation_output),+ keypoints_binary_payload=keypoints_binary_payload,)return Nonediff --git a/freemocap/core/pipeline/realtime/realtime_pipeline_config.py b/freemocap/core/pipeline/realtime/realtime_pipeline_config.pyindex a3d4b86b..652b81e6 100644--- a/freemocap/core/pipeline/realtime/realtime_pipeline_config.py+++ b/freemocap/core/pipeline/realtime/realtime_pipeline_config.py@@ -4,6 +4,9 @@ from skellycam.core.types.type_overloads import CameraIdStringfrom freemocap.core.pipeline.realtime.camera_node_config import CameraNodeConfigfrom freemocap.core.pipeline.realtime.realtime_aggregator_node_config import RealtimeAggregatorNodeConfig+from freemocap.core.pipeline.realtime.realtime_skeleton_inference_node_config import (+ RealtimeSkeletonInferenceNodeConfig,+)class RealtimePipelineConfig(BaseModel):@@ -13,3 +16,13 @@ class RealtimePipelineConfig(BaseModel):aggregator_config: RealtimeAggregatorNodeConfig = Field(default_factory=RealtimeAggregatorNodeConfig,)+ # When True, skeleton inference runs in a single dedicated worker process+ # that batches frames from all cameras (one CUDA context, one ONNX session).+ # When False, each camera node runs its own RTMPoseDetector inline (legacy+ # behavior; suitable for CPU-only machines or for A/B comparison).+ use_centralized_gpu_inference: bool = True+ log_pipeline_times: bool = True++ skeleton_inference_node_config: RealtimeSkeletonInferenceNodeConfig = Field(+ default_factory=RealtimeSkeletonInferenceNodeConfig,+ )diff --git a/freemocap/core/pipeline/realtime/realtime_pipeline_manager.py b/freemocap/core/pipeline/realtime/realtime_pipeline_manager.pyindex e6ac4f1f..07700e52 100644--- a/freemocap/core/pipeline/realtime/realtime_pipeline_manager.py+++ b/freemocap/core/pipeline/realtime/realtime_pipeline_manager.py@@ -11,6 +11,7 @@ Responsibilities:- Recording orchestration (start/stop across all pipelines)- Orderly shutdown"""+import asyncioimport loggingimport multiprocessingimport multiprocessing.synchronize@@ -52,6 +53,7 @@ class RealtimePipelineManager(PipelineManagerABC):*,camera_group: CameraGroup,pipeline_config: RealtimePipelineConfig,+ realtime_camera_ids: list[CameraIdString] | None = None,) -> RealtimePipeline:with self.lock:# Return existing pipeline for this camera set (with updated config)@@ -68,6 +70,7 @@ class RealtimePipelineManager(PipelineManagerABC):pipeline_config=pipeline_config,camera_group=camera_group,worker_registry=self.worker_registry,+ realtime_camera_ids=realtime_camera_ids,)pipeline.start()self.pipelines[pipeline.id] = pipeline@@ -104,6 +107,25 @@ class RealtimePipelineManager(PipelineManagerABC):# Frontend payload streaming# ------------------------------------------------------------------+ async def wait_for_any_result_ready(self, timeout: float = 0.5) -> None:+ """Wait until at least one active pipeline has a processed frame ready.++ Returns as soon as any pipeline signals its result_ready_event, or+ after `timeout` seconds if none does. Falls back to a short sleep when+ there are no alive pipelines (camera-only or idle mode) so callers+ don't busy-spin while waiting for a pipeline to start.+ """+ with self.lock:+ alive = [p for p in self.pipelines.values() if p.alive]+ if not alive:+ await asyncio.sleep(0.01)+ return+ # Wait on all alive pipelines concurrently; return on the first hit.+ tasks = [asyncio.create_task(p.wait_for_result_ready(timeout)) for p in alive]+ _done, pending = await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)+ for t in pending:+ t.cancel()+def get_latest_frontend_payloads(self,if_newer_than: FrameNumberInt,diff --git a/freemocap/core/pipeline/realtime/realtime_skeleton_inference_node.py b/freemocap/core/pipeline/realtime/realtime_skeleton_inference_node.pynew file mode 100644index 00000000..0b8fceca--- /dev/null+++ b/freemocap/core/pipeline/realtime/realtime_skeleton_inference_node.py@@ -0,0 +1,422 @@+"""+RealtimeSkeletonInferenceNode: dedicated GPU worker that owns one ONNX session+for skeleton detection and serves all cameras via batched inference.++Why this exists:+ Per-camera RTMPoseDetector construction (the legacy path) creates one CUDA+ context per camera process. On consumer Windows GPUs there is no cooperative+ context scheduling (no MPS), so N processes hammering one GPU serialize+ kernel-by-kernel and pay per-context overhead. This node centralizes+ inference: one CUDA context, one batched ONNX call per multi-camera frame.++Topology:+ - Subscribes to ProcessFrameNumberTopic (the same topic the camera nodes+ use as their "process frame N" trigger).+ - Reads frame N's image directly from each camera's shared-memory ring buffer+ (the same DTO the aggregator already gets).+ - Calls RTMPoseSession.predict_batch(images) — one session.run for all cameras.+ - Publishes a single SkeletonInferenceResultMessage per frame, keyed by+ frame_number, with per-camera RTMPoseObservation.+ - The aggregator merges this with per-camera CameraNodeOutputMessage+ (charuco-only in GPU mode) by frame_number.++Backpressure:+ Drains ProcessFrameNumberTopic to the latest message every iteration; older+ messages are dropped rather than queued. If the GPU falls behind the camera+ group's frame rate, we lose frames instead of accumulating lag.+"""+import gc+import logging+import time+from dataclasses import dataclass+from multiprocessing.sharedctypes import Synchronized+from queue import Empty++import cv2+import numpy as np+from numpy.typing import NDArray+from skellycam.core.ipc.process_management.worker_registry import WorkerRegistry+from skellycam.core.ipc.shared_memory.camera_group_shared_memory import (+ CameraGroupSharedMemory,+ CameraGroupSharedMemoryDTO,+)+from skellycam.core.ipc.shared_memory.camera_shared_memory_ring_buffer import (+ CameraSharedMemoryRingBuffer,+)+from skellycam.core.types.type_overloads import (+ CameraGroupIdString,+ CameraIdString,+ TopicSubscriptionQueue,+)+from skellycam.utilities.wait_functions import wait_1ms+from skellytracker.trackers.base_tracker.base_tracker_abcs import BaseObservation+from skellytracker.trackers.rtmpose_tracker.rtmpose_detector import RTMPoseDetectorConfig+from skellytracker.trackers.rtmpose_tracker.rtmpose_observation import RTMPoseObservation+from skellytracker.trackers.rtmpose_tracker.rtmpose_session import (+ RTMPoseSession,+ RTMPoseSessionConfig,+)++from freemocap.core.pipeline.abcs.pipeline_ipc import PipelineIPC+from freemocap.core.pipeline.abcs.source_node_abc import SourceNode+from freemocap.core.pipeline.realtime.realtime_pipeline_config import RealtimePipelineConfig+from freemocap.core.pipeline.pipeline_stage_timer import PipelineStageTimer+from freemocap.core.types.type_overloads import TopicPublicationQueue+from freemocap.pubsub.pubsub_manager import PubSubTopicManager+from freemocap.pubsub.pubsub_topics import (+ PipelineConfigUpdateMessage,+ PipelineConfigUpdateTopic,+ ProcessFrameNumberMessage,+ ProcessFrameNumberTopic,+ SkeletonInferenceResultMessage,+ SkeletonInferenceResultTopic,+ PipelineTimingTopic,+)++logger = logging.getLogger(__name__)+++@dataclass+class RealtimeSkeletonInferenceNode(SourceNode):+ """Worker node that hosts one batched RTMPoseSession for all cameras."""++ @classmethod+ def create(+ cls,+ *,+ camera_group_id: CameraGroupIdString,+ camera_ids: list[CameraIdString],+ worker_registry: WorkerRegistry,+ camera_group_shm_dto: CameraGroupSharedMemoryDTO,+ config: RealtimePipelineConfig,+ ipc: PipelineIPC,+ pubsub: PubSubTopicManager,+ ) -> "RealtimeSkeletonInferenceNode":+ shutdown_self_flag, worker = cls._create_worker(+ target=cls._run,+ name=f"CameraGroup-{camera_group_id}-SkeletonInferenceNode",+ worker_registry=worker_registry,+ log_queue=ipc.ws_queue,+ kwargs=dict(+ camera_group_id=camera_group_id,+ camera_ids=camera_ids,+ pipeline_config=config,+ ipc=ipc,+ camera_group_shm_dto=camera_group_shm_dto,+ process_frame_number_sub=pubsub.get_subscription(ProcessFrameNumberTopic),+ pipeline_config_sub=pubsub.get_subscription(PipelineConfigUpdateTopic),+ skeleton_result_pub=pubsub.get_publication_queue(SkeletonInferenceResultTopic),+ timing_pub=pubsub.get_publication_queue(PipelineTimingTopic),+ ),+ )+ return cls(+ shutdown_self_flag=shutdown_self_flag,+ worker=worker,+ )++ @staticmethod+ def _run(+ *,+ camera_group_id: CameraGroupIdString,+ camera_ids: list[CameraIdString],+ pipeline_config: RealtimePipelineConfig,+ ipc: PipelineIPC,+ shutdown_self_flag: Synchronized,+ camera_group_shm_dto: CameraGroupSharedMemoryDTO,+ process_frame_number_sub: TopicSubscriptionQueue,+ pipeline_config_sub: TopicSubscriptionQueue,+ skeleton_result_pub: TopicPublicationQueue,+ timing_pub: TopicPublicationQueue,+ ) -> None:+ logger.debug(f"RealtimeSkeletonInferenceNode [{camera_group_id}] initializing")++ camera_group_shm = CameraGroupSharedMemory.recreate(+ shm_dto=camera_group_shm_dto,+ read_only=True,+ )+ # Per-camera ring buffer handles for direct image reads. We mirror+ # `camera_node.py`'s recreate call but read-only since this worker+ # never writes frames.+ camera_shms: dict[CameraIdString, CameraSharedMemoryRingBuffer] = {+ camera_id: CameraSharedMemoryRingBuffer.recreate(+ dto=camera_group_shm_dto.camera_shm_dtos[camera_id],+ read_only=True,+ )+ for camera_id in camera_ids+ }++ session = _build_session(pipeline_config)+ if session is None:+ logger.error(+ f"RealtimeSkeletonInferenceNode [{camera_group_id}] could not "+ f"construct RTMPoseSession; exiting."+ )+ ipc.kill_everything()+ return++ log_pipeline_times = pipeline_config.log_pipeline_times+ timer = PipelineStageTimer(name=f"SkeletonInferenceNode-{camera_group_id}") if log_pipeline_times else None+ _MAX_SESSION_RESTARTS = 3+ session_restart_count = 0+ # Per-camera scratch recarrays (avoids reallocating each frame).+ frame_recarrays: dict[CameraIdString, np.recarray | None] = {+ cam_id: None for cam_id in camera_ids+ }++ try:+ logger.debug(+ f"RealtimeSkeletonInferenceNode [{camera_group_id}] entering main loop "+ f"(active_provider={session.active_provider!r})"+ )+ while ipc.should_continue and not shutdown_self_flag.value:+ wait_1ms()++ # ---- Handle config updates (only act on flips that change session shape) ----+ while True:+ try:+ msg: PipelineConfigUpdateMessage = pipeline_config_sub.get_nowait()+ except Empty:+ break+ pipeline_config = msg.pipeline_config+ logger.debug(+ f"RealtimeSkeletonInferenceNode [{camera_group_id}] "+ f"received config update (no hot-reload of session; "+ f"changes to detector mode require a pipeline restart)"+ )++ # ---- Drain to latest frame number (drop stale) ----+ latest_frame_msg: ProcessFrameNumberMessage | None = None+ dropped_count = 0+ while True:+ try:+ candidate = process_frame_number_sub.get_nowait()+ except Empty:+ break+ if latest_frame_msg is not None:+ dropped_count += 1+ latest_frame_msg = candidate+ if latest_frame_msg is None:+ continue+ if dropped_count and timer is not None:+ timer.record("dropped_frames", float(dropped_count))++ if not camera_group_shm.valid:+ logger.debug(+ f"RealtimeSkeletonInferenceNode [{camera_group_id}] "+ f"shared memory invalidated, exiting"+ )+ break++ requested_frame_number = latest_frame_msg.frame_number++ # ---- Read N images from per-camera ring buffers ----+ t_read = time.perf_counter() if timer is not None else 0.0+ images, ordered_camera_ids = _read_frames(+ camera_ids=camera_ids,+ camera_shms=camera_shms,+ frame_recarrays=frame_recarrays,+ requested_frame_number=requested_frame_number,+ )+ if timer is not None:+ timer.record("frame_read", (time.perf_counter() - t_read) * 1e3)++ if not images:+ # Ring buffer didn't have the frame for any camera; skip.+ continue++ # ---- Batched skeleton inference ----+ t_inf = time.perf_counter() if timer is not None else 0.0+ try:+ batch_results = session.predict_batch(images)+ except Exception as mem_err:+ # Catch Python MemoryError (raised by rtmpose_session when it+ # detects a BFC Arena OOM) and any ONNX RuntimeException that+ # slips through with an OOM message — both indicate GPU VRAM+ # exhaustion and should trigger the session restart below.+ if not (isinstance(mem_err, MemoryError)+ or "BFCArena" in str(mem_err)+ or "Available memory" in str(mem_err)):+ raise+ logger.error(+ f"RealtimeSkeletonInferenceNode [{camera_group_id}] GPU OOM during "+ f"inference (restart {session_restart_count + 1}/{_MAX_SESSION_RESTARTS}): "+ f"{mem_err}"+ )+ if session_restart_count >= _MAX_SESSION_RESTARTS:+ logger.error(+ f"RealtimeSkeletonInferenceNode [{camera_group_id}] exceeded max "+ f"session restarts — giving up."+ )+ ipc.kill_everything()+ return+ del session+ gc.collect()+ session = _build_session(pipeline_config)+ if session is None:+ logger.error(+ f"RealtimeSkeletonInferenceNode [{camera_group_id}] failed to rebuild "+ f"session after MemoryError — giving up."+ )+ ipc.kill_everything()+ return+ session_restart_count += 1+ logger.info(+ f"RealtimeSkeletonInferenceNode [{camera_group_id}] session rebuilt "+ f"successfully after MemoryError."+ )+ continue # skip this frame, resume on next+ if timer is not None:+ inf_ms = (time.perf_counter() - t_inf) * 1e3+ timer.record("predict_batch", inf_ms)+ # Per-camera-equivalent latency, for comparing with the legacy+ # per-camera `skeleton_detection` timer in camera_node logs.+ timer.record("predict_per_camera", inf_ms / max(len(images), 1))++ # ---- Build per-camera observations ----+ per_camera_skeleton: dict[CameraIdString, BaseObservation | None] = {}+ for camera_id, image, (keypoints, scores) in zip(+ ordered_camera_ids, images, batch_results,+ ):+ per_camera_skeleton[camera_id] = RTMPoseObservation.from_detection_results(+ frame_number=requested_frame_number,+ keypoints=keypoints,+ scores=scores,+ image_size=(int(image.shape[0]), int(image.shape[1])),+ )+ # Cameras whose frame we couldn't read get None — aggregator+ # treats this as "no skeleton this frame for this camera"+ # (same semantics as today's missing-detection path).+ for camera_id in camera_ids:+ per_camera_skeleton.setdefault(camera_id, None)++ skeleton_result_pub.put(+ SkeletonInferenceResultMessage(+ frame_number=requested_frame_number,+ per_camera_skeleton=per_camera_skeleton,+ ),+ )+ if timer is not None:+ timer.maybe_flush(+ publication_queue=timing_pub,+ node_kind="skeleton_inference",+ )++ except Exception as e:+ logger.error(+ f"Exception in RealtimeSkeletonInferenceNode [{camera_group_id}]: {e}",+ exc_info=True,+ )+ ipc.kill_everything()+ raise+ finally:+ logger.debug(f"RealtimeSkeletonInferenceNode [{camera_group_id}] exiting")+++# ---------------------------------------------------------------------------+# Helpers+# ---------------------------------------------------------------------------+++def _build_session(pipeline_config: RealtimePipelineConfig) -> RTMPoseSession | None:+ """Construct the centralized RTMPoseSession from the pipeline config.++ Reads model size / mode from `camera_node_config.skeleton_detector_config`+ so a single source of truth governs which model is used in either pipeline+ mode. Reads provider / cache settings from `skeleton_inference_node_config`.+ Returns None if the skeleton detector isn't an RTMPose config (caller+ should treat this as a fatal misconfiguration in GPU mode).+ """+ skel_config = pipeline_config.camera_node_config.skeleton_detector_config+ if not isinstance(skel_config, RTMPoseDetectorConfig):+ logger.warning(+ f"Centralized GPU inference is enabled but the skeleton detector "+ f"config is not RTMPoseDetectorConfig (got {type(skel_config).__name__}). "+ f"Falling back to legacy per-camera inference."+ )+ return None++ inf_config = pipeline_config.skeleton_inference_node_config+ #TODO - this is dumb, I think? WE should be able to just use the inference node config directly without this nonsense?++ # Pick mode safely. RTMPoseSessionConfig accepts a Literal of three values;+ # other strings (e.g. legacy values) get coerced to "balanced" rather than+ # failing pydantic validation — keeps the pipeline alive on weird configs.+ mode = skel_config.mode if skel_config.mode in ("performance", "lightweight", "balanced") else "balanced"++ session_config = RTMPoseSessionConfig(+ mode=mode,+ execution_provider=inf_config.execution_provider,+ engine_cache_dir=inf_config.engine_cache_dir,+ max_batch_size=inf_config.max_batch_size,+ on_provider_missing="fallback" if inf_config.fallback_on_missing_provider else "raise",+ )++ try:+ return RTMPoseSession.create(session_config)+ except Exception as e:+ logger.error(+ f"Failed to construct RTMPoseSession with provider={inf_config.execution_provider!r}: {e!r}",+ exc_info=True,+ )+ return None+++def _read_frames(+ *,+ camera_ids: list[CameraIdString],+ camera_shms: dict[CameraIdString, CameraSharedMemoryRingBuffer],+ frame_recarrays: dict[CameraIdString, np.recarray | None],+ requested_frame_number: int,+) -> tuple[list[NDArray[np.uint8]], list[CameraIdString]]:+ """Read frame `requested_frame_number` from each camera's ring buffer.++ Returns parallel lists `(images, camera_ids)` for the cameras whose ring+ buffer actually contained the requested frame. Cameras whose buffer was+ overwritten or whose frame metadata mismatched are silently skipped (the+ aggregator already tolerates missing per-camera observations on a frame).++ Mirrors the rotation-handling logic from `camera_node.py:171-178` so the+ image fed to ONNX is identical to what the legacy per-camera path would+ have inferred over.+ """+ images: list[NDArray[np.uint8]] = []+ ordered_camera_ids: list[CameraIdString] = []++ for camera_id in camera_ids:+ camera_shm = camera_shms[camera_id]+ try:+ frame_recarray = camera_shm.get_data_by_index(+ index=requested_frame_number,+ rec_array=frame_recarrays[camera_id],+ )+ except Exception as e:+ logger.debug(+ f"Could not read frame {requested_frame_number} from camera "+ f"{camera_id}: {e!r}"+ )+ continue+ frame_recarrays[camera_id] = frame_recarray++ actual_frame_number = int(frame_recarray.frame_metadata.frame_number[0])+ if actual_frame_number != requested_frame_number:+ # Ring buffer has moved on — use the frame that's actually there+ # rather than dropping the camera entirely.+ logger.warning(+ f"SkeletonInferenceNode: requested frame {requested_frame_number} "+ f"from camera {camera_id} but got {actual_frame_number} — "+ f"ring buffer advanced; using available frame."+ )++ rotation = frame_recarray.frame_metadata.camera_info.rotation+ if rotation != -1:+ image = cv2.rotate(+ src=frame_recarray.image[0],+ rotateCode=rotation[0],+ )+ else:+ image = frame_recarray.image[0]++ images.append(image)+ ordered_camera_ids.append(camera_id)++ return images, ordered_camera_idsdiff --git a/freemocap/core/pipeline/realtime/realtime_skeleton_inference_node_config.py b/freemocap/core/pipeline/realtime/realtime_skeleton_inference_node_config.pynew file mode 100644index 00000000..e8f0fdea--- /dev/null+++ b/freemocap/core/pipeline/realtime/realtime_skeleton_inference_node_config.py@@ -0,0 +1,36 @@+"""Config for the centralized RealtimeSkeletonInferenceNode.++Kept separate from CameraNodeConfig so it can be toggled / tuned independently+of the per-camera detector knobs. The node-level skeleton detector config+(mode, model size, etc.) is still read from `CameraNodeConfig.skeleton_detector_config`+so a single source of truth governs which model is used in either pipeline mode."""+from pathlib import Path++from pydantic import BaseModel, Field+from skellytracker.trackers.rtmpose_tracker.rtmpose_session import ExecutionProviderName+++def _default_engine_cache_dir() -> Path:+ return Path.home() / ".cache" / "skellytracker" / "trt_engines"+++class RealtimeSkeletonInferenceNodeConfig(BaseModel):+ # Upper bound on batch size. The node uses min(num_cameras, max_batch_size)+ # at runtime. Set to 1 to disable batching across cameras while keeping the+ # single-CUDA-context win.+ max_batch_size: int = 8++ # Where TensorRT engine + timing caches live. First TRT run compiles to here+ # (slow, 1-5 minutes); subsequent runs are a cache hit and load instantly.+ engine_cache_dir: Path = Field(default_factory=_default_engine_cache_dir)++ # If the requested execution provider isn't available, fall back automatically+ # (trt -> cuda -> cpu) instead of raising.+ fallback_on_missing_provider: bool = True++ # "trt": TensorRT EP — 2-5x faster than CUDA EP, requires NVIDIA GPU ++ # `pip install tensorrt`. Compiles engines on first run (1-5 min),+ # cached to engine_cache_dir on all subsequent runs.+ # "cuda": CUDA EP — requires NVIDIA GPU + onnxruntime-gpu, no extra install.+ # "cpu": CPU EP — no GPU required, slowest.+ execution_provider: ExecutionProviderName = "cuda"diff --git a/freemocap/core/tasks/calibration/anipose_calibration/anipose_adapters.py b/freemocap/core/tasks/calibration/anipose_calibration/anipose_adapters.pydeleted file mode 100644index 30887976..00000000--- a/freemocap/core/tasks/calibration/anipose_calibration/anipose_adapters.py+++ /dev/null@@ -1,81 +0,0 @@-"""Adapter functions between shared Pydantic models and anipose-specific types.--These let the anipose solver keep its internal AniposeCameraGroup/AniposeCamera-classes while the rest of the system speaks CameraModel/CalibrationResult.-"""-from freemocap.core.tasks.calibration.anipose_calibration.helpers.freemocap_anipose import AniposeCharucoBoard, \- AniposeCameraGroup, AniposeCamera-from freemocap.core.tasks.calibration.shared.calibration_models import CharucoBoardDefinition, CameraModel, CameraIntrinsics, \- CameraExtrinsics---def create_anipose_board(board: CharucoBoardDefinition) -> AniposeCharucoBoard:- """Create an AniposeCharucoBoard from the shared board definition.-- The anipose solver needs AniposeCharucoBoard because it inherits- detect_image / estimate_pose_rows / get_all_calibration_points- from aniposelib.boards.CharucoBoard.- """- return AniposeCharucoBoard(- squaresX=board.squares_x,- squaresY=board.squares_y,- square_length=board.square_length_mm,- marker_length=board.aruco_marker_length_mm,- marker_bits=board.marker_bits,- dict_size=board.dict_size,- )---def camera_models_to_anipose_group(cameras: list[CameraModel]) -> AniposeCameraGroup:- """Build an AniposeCameraGroup from unified CameraModel objects.-- Used when downstream code (e.g. triangulation) requires the anipose API.- """- anipose_cameras: list[AniposeCamera] = []- for cam in cameras:- ac = AniposeCamera(- matrix=cam.intrinsics.to_camera_matrix(),- dist=cam.intrinsics.to_dist_coeffs_5(),- size=cam.image_size,- rvec=cam.extrinsics.rodrigues_vector,- tvec=cam.extrinsics.translation,- name=cam.name,- world_orientation=cam.extrinsics.world_orientation,- world_position=cam.extrinsics.world_position,- )- anipose_cameras.append(ac)-- return AniposeCameraGroup(cameras=anipose_cameras)---def anipose_group_to_camera_models(group: AniposeCameraGroup) -> list[CameraModel]:- """Extract a list of CameraModel from an AniposeCameraGroup.-- Used after anipose calibration completes to produce a CalibrationResult.- """- cameras: list[CameraModel] = []- for ac in group.cameras:- intrinsics = CameraIntrinsics.from_camera_matrix_and_dist(- camera_matrix=ac.get_camera_matrix(),- dist_coeffs=ac.get_distortions(),- )-- extrinsics = CameraExtrinsics.from_rodrigues(- rvec=ac.get_rotation(),- tvec=ac.get_translation(),- )-- size = ac.get_size()- if size is None:- raise ValueError(f"AniposeCamera '{ac.get_name()}' has no image size set")-- cameras.append(- CameraModel(- name=ac.get_name(),- image_size=(int(size[0]), int(size[1])),- intrinsics=intrinsics,- extrinsics=extrinsics,- )- )-- return camerasdiff --git a/freemocap/core/tasks/calibration/anipose_calibration/helpers/anipose_calibration_helpers.py b/freemocap/core/tasks/calibration/anipose_calibration/helpers/anipose_calibration_helpers.pynew file mode 100644index 00000000..f9fe06fb--- /dev/null+++ b/freemocap/core/tasks/calibration/anipose_calibration/helpers/anipose_calibration_helpers.py@@ -0,0 +1,189 @@+"""Anipose calibration post-processing helpers.++Pin camera 0 to origin, charuco groundplane alignment,+real-world camera position computation — all operating on list[CameraModel].+"""++import logging+from pathlib import Path++import cv2+import numpy as np+from skellycam.core.types.type_overloads import CameraIdString+from skellytracker.trackers.base_tracker.base_tracker_abcs import BaseRecorder+from skellytracker.trackers.charuco_tracker.charuco_observation import CharucoObservation++from freemocap.core.tasks.calibration.anipose_calibration.helpers.camera_model_solver_ops import (+ apply_extrinsics,+ stack_rodrigues,+ stack_translations,+)+from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinition+from freemocap.core.tasks.calibration.shared.groundplane_alignment import GroundPlaneResult+from freemocap.core.tasks.calibration.shared.groundplane_math import (+ CharucoVelocityError,+ CharucoVisibilityError,+ compute_board_basis_vectors,+ find_still_charuco_frame,+)+from freemocap.core.tasks.calibration.shared.interpolate_trajectories import interpolate_trajectory_data++logger = logging.getLogger(__name__)++CharucoObservations = dict[CameraIdString, CharucoObservation | None]+++class GroundPlaneSuccess:+ def __init__(self, success: bool, error: str | None = None):+ self.success = success+ self.error = error+++def pin_camera_zero_to_origin(cameras: list[CameraModel]) -> list[CameraModel]:+ """Re-express all camera extrinsics relative to camera 0.++ Camera 0 ends up with identity rotation and zero translation.+ All other cameras are expressed relative to camera 0.+ """+ rvecs = stack_rodrigues(cameras)+ tvecs = stack_translations(cameras)++ R0, _ = cv2.Rodrigues(rvecs[0])+ rvecs_new = np.empty_like(rvecs)+ for i in range(rvecs.shape[0]):+ Ri, _ = cv2.Rodrigues(rvecs[i])+ Ri_new, _ = cv2.Rodrigues(Ri @ R0.T)+ rvecs_new[i] = Ri_new.flatten()++ # Use R0_new (identity for camera 0 after alignment) — not original R0+ R0_new, _ = cv2.Rodrigues(rvecs_new[0])+ delta_to_origin_world = -R0_new.T @ tvecs[0, :]+ tvecs_new = np.zeros_like(tvecs)+ for cam_i in range(tvecs.shape[0]):+ Ri, _ = cv2.Rodrigues(rvecs_new[cam_i])+ delta_to_origin_camera_i = Ri @ delta_to_origin_world+ tvecs_new[cam_i, :] = tvecs[cam_i, :] + delta_to_origin_camera_i++ apply_extrinsics(cameras, rvecs_new, tvecs_new)+ return cameras+++def set_charuco_board_as_groundplane(+ *,+ observation_recorders: dict[CameraIdString, BaseRecorder],+ cameras: list[CameraModel],+ board: CharucoBoardDefinition,+ recording_folder_path: "Path | None" = None,+) -> tuple[list[CameraModel], GroundPlaneSuccess, GroundPlaneResult | None]:+ """Set the charuco board plane as the world groundplane."""+ from freemocap.core.tasks.calibration.anipose_calibration.helpers.bundle_adjust import triangulate++ logger.info("Getting 2D Charuco data")+ data2d_by_camera: dict[CameraIdString, np.ndarray] = {}+ if len(observation_recorders) == 0:+ raise ValueError("No observation recorders provided to process.")++ for camera_id, recorder in observation_recorders.items():+ if not all(isinstance(observation, CharucoObservation) for observation in recorder.observations):+ raise TypeError(f"Recorder for camera ID {camera_id} contains non-Charuco observations.")+ data2d_fr_id_xyc = recorder.to_array.copy()+ logger.info(f"Processing camera ID: {camera_id} with 2D data shape: {data2d_fr_id_xyc.shape}")+ data2d_by_camera[camera_id] = data2d_fr_id_xyc[..., :2]++ charuco2d_cam_fr_id_xy = np.stack(list(data2d_by_camera.values()), axis=0)+ logger.info(+ f"Charuco 2d data retrieved with shape (cams, frames, markers, XY): {charuco2d_cam_fr_id_xy.shape}"+ )+ charuco2d_cam_fr_id_xy = charuco2d_cam_fr_id_xy.astype(np.float64)+ num_cameras, num_frames, num_tracked_points, _ = charuco2d_cam_fr_id_xy.shape+ charuco_2d_flat = charuco2d_cam_fr_id_xy.reshape(num_cameras, -1, 2)++ logger.info("Getting 3d Charuco data")+ charuco_3d_flat = triangulate(cameras, charuco_2d_flat)+ charuco3d_fr_id_xyz = charuco_3d_flat.reshape(num_frames, num_tracked_points, 3)+ logger.info(f"Charuco 3d data reconstructed with shape: {charuco3d_fr_id_xyz.shape}")++ charuco_3d_xyz_interpolated = interpolate_trajectory_data(trajectory_data=charuco3d_fr_id_xyz)++ try:+ charuco_still_frame_idx = find_still_charuco_frame(+ charuco_3d=charuco3d_fr_id_xyz,+ squares_x=board.squares_x,+ squares_y=board.squares_y,+ )+ except CharucoVisibilityError as e:+ logger.warning("Ground-plane alignment skipped — reverting to original calibration: %s", e, exc_info=True)+ return cameras, GroundPlaneSuccess(success=False, error=str(e)), None+ except CharucoVelocityError as e:+ logger.warning("Ground-plane alignment skipped — reverting to original calibration: %s", e, exc_info=True)+ return cameras, GroundPlaneSuccess(success=False, error=str(e)), None++ charuco_frame = charuco_3d_xyz_interpolated[charuco_still_frame_idx]++ x_hat, y_hat, z_hat = compute_board_basis_vectors(+ charuco_frame=charuco_frame,+ squares_x=board.squares_x,+ squares_y=board.squares_y,+ )++ charuco_origin_in_world = charuco_frame[0]+ rmat_charuco_to_world = np.column_stack([x_hat, y_hat, z_hat])++ ground_plane_result = GroundPlaneResult(+ origin=charuco_origin_in_world,+ rotation_matrix=rmat_charuco_to_world,+ method="charuco",+ )++ rvecs_new, tvecs_new = _adjust_world_reference_frame_to_charuco(+ cameras=cameras,+ charuco_origin_in_world=charuco_origin_in_world,+ rmat_charuco_to_world=rmat_charuco_to_world,+ )+ apply_extrinsics(cameras, rvecs_new, tvecs_new)++ logger.info("Camera calibration adjusted to set charuco board as ground plane")++ charuco_3d_flat = triangulate(cameras, charuco_2d_flat)+ charuco3d_fr_id_xyz = charuco_3d_flat.reshape(num_frames, num_tracked_points, 3)+ charuco_3d_xyz_interpolated = interpolate_trajectory_data(trajectory_data=charuco3d_fr_id_xyz)++ if recording_folder_path is not None:+ charuco_save_path = Path(recording_folder_path) / "output_data" / "charuco_3d_xyz.npy"+ charuco_save_path.parent.mkdir(parents=True, exist_ok=True)+ np.save(charuco_save_path, charuco_3d_xyz_interpolated)+ logger.info(f"Charuco 3d data saved to {charuco_save_path}")++ return cameras, GroundPlaneSuccess(success=True), ground_plane_result+++def _adjust_world_reference_frame_to_charuco(+ *,+ cameras: list[CameraModel],+ charuco_origin_in_world: np.ndarray,+ rmat_charuco_to_world: np.ndarray,+) -> tuple[np.ndarray, np.ndarray]:+ """Adjust camera extrinsics to use charuco board as world reference frame."""+ rvecs = stack_rodrigues(cameras)+ tvecs = stack_translations(cameras)++ tvecs_new = np.zeros_like(tvecs)+ rvecs_new = np.zeros_like(rvecs)++ for i in range(tvecs.shape[0]):+ rmat_world_to_cam_i, _ = cv2.Rodrigues(rvecs[i])+ t_delta = rmat_world_to_cam_i @ charuco_origin_in_world+ tvecs_new[i] = t_delta + tvecs[i]++ new_rmat = rmat_world_to_cam_i @ rmat_charuco_to_world+ new_rvec, _ = cv2.Rodrigues(new_rmat)+ rvecs_new[i] = new_rvec.flatten()++ return rvecs_new, tvecs_new+++# Keep old names as aliases for backward compatibility within this module.+# (run_anipose_calibration.py is updated separately.)+anipose_pin_camera_zero_to_origin = pin_camera_zero_to_origin+set_charuco_board_as_groundplane_anipose = set_charuco_board_as_groundplanediff --git a/freemocap/core/tasks/calibration/anipose_calibration/helpers/bundle_adjust.py b/freemocap/core/tasks/calibration/anipose_calibration/helpers/bundle_adjust.pynew file mode 100644index 00000000..ebecea83--- /dev/null+++ b/freemocap/core/tasks/calibration/anipose_calibration/helpers/bundle_adjust.py@@ -0,0 +1,586 @@+"""Bundle-adjustment solver operating directly on list[CameraModel].++Free-function port of what was AniposeCameraGroup. The optimizer mutates+the supplied cameras list in place: each iteration replaces extrinsics+and overwrites intrinsics fields per `camera_model_solver_ops`.+"""+from __future__ import annotations++import logging+import multiprocessing.synchronize+from typing import Any++import cv2+import numpy as np+from freemocap.core.tasks.calibration.shared.transform_math import build_transformation_matrix, get_rtvec+from numpy.typing import NDArray+from scipy import optimize+from scipy.sparse import dok_matrix+from skellycam.core.types.type_overloads import CameraIdString++from freemocap.core.tasks.calibration.charuco_board import charuco_board_ops+from freemocap.core.tasks.calibration.anipose_calibration.helpers.camera_model_solver_ops import (+ PARAMS_PER_CAMERA,+ apply_camera_params,+ apply_extrinsics,+ pack_camera_params,+)+from freemocap.core.tasks.calibration.anipose_calibration.helpers.freemocap_anipose import (+ extract_points,+ extract_roration_translation_vectors,+ get_connections,+ get_error_dict,+ get_initial_extrinsics,+ merge_rows,+ remap_ids,+ resample_points,+ subset_extra,+ transform_points, BoardObservations,+)+from freemocap.core.tasks.calibration.shared.camera_extrinsics import CameraExtrinsics+from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinition++logger = logging.getLogger(__name__)++def camera_ids_from_camera_models(cameras: list[CameraModel]) -> list[CameraIdString]:+ return [CameraIdString(cam.id) for cam in cameras]+++# =============================================================================+# TRIANGULATION / REPROJECTION (delegate to shared Triangulator)+# =============================================================================+++def _make_triangulator(cameras: list[CameraModel]):+ """Build a Triangulator from the current (in-flight) camera state.++ Solver iterations mutate camera intrinsics/extrinsics, so this rebuilds+ on every call. Construction cost is microseconds; solver iterations+ take seconds.+ """+ from freemocap.core.tasks.triangulation.triangulator import Triangulator+ return Triangulator(cameras=cameras)+++def triangulate(+ cameras: list[CameraModel],+ points: NDArray[np.float64],+ undistort: bool = True,+ use_outlier_rejection: bool = True,+ kill_event: multiprocessing.synchronize.Event | None = None,+) -> NDArray[np.float64] | None:+ """Triangulate a (num_cameras, N, 2) image-point array to (N, 3) world points."""+ from freemocap.core.tasks.triangulation.helpers.triangulation_config import TriangulationConfig++ if points.shape[0] != len(cameras):+ raise ValueError(+ f"First dim should equal number of cameras ({len(cameras)}), "+ f"but shape is {points.shape}"+ )++ one_point = False+ if len(points.shape) == 2:+ points = points.reshape(-1, 1, 2)+ one_point = True++ if kill_event is not None and kill_event.is_set():+ return None++ triangulator = _make_triangulator(cameras)+ result = triangulator.triangulate(+ data2d=points,+ config=TriangulationConfig(use_outlier_rejection=use_outlier_rejection),+ assume_undistorted_normalized=not undistort,+ )+ out = result.points_3d+ if one_point:+ out = out[0]+ return out+++def reprojection_error(+ cameras: list[CameraModel],+ points_3d: NDArray[np.float64],+ points_2d: NDArray[np.float64],+ mean: bool = False,+) -> NDArray[np.float64] | float:+ """Reprojection error between 3-D points and 2-D observations."""+ one_point = False+ if len(points_3d.shape) == 1 and len(points_2d.shape) == 2:+ points_3d = points_3d.reshape(1, 3)+ points_2d = points_2d.reshape(-1, 1, 2)+ one_point = True++ num_cameras, num_points, _ = points_2d.shape+ if points_3d.shape != (num_points, 3):+ raise ValueError(+ f"2D/3D shape mismatch: 2D={points_2d.shape}, 3D={points_3d.shape}"+ )++ triangulator = _make_triangulator(cameras)+ if mean:+ errors = triangulator.mean_reprojection_error(+ points_3d=points_3d, points_2d_pixel=points_2d,+ )+ else:+ errors = triangulator.signed_reprojection_error(+ points_3d=points_3d, points_2d_pixel=points_2d,+ )++ if one_point:+ errors = float(errors[0]) if mean else errors.reshape(-1, 2)+ return errors+++def average_error(+ cameras: list[CameraModel],+ points_2d: NDArray[np.float64],+ median: bool = False,+) -> float:+ points_3d = triangulate(cameras, points_2d)+ errors = reprojection_error(cameras, points_3d, points_2d, mean=True)+ return float(np.median(errors)) if median else float(np.mean(errors))+++# =============================================================================+# BUNDLE ADJUSTMENT+# =============================================================================+++def iterative_bundle_adjustment(+ cameras: list[CameraModel],+ points_2d: NDArray[np.float64],+ board_observations: BoardObservations,+ num_iterations: int = 10,+ damping_start: float = 15,+ damping_end: float = 1,+ max_nfev: int = 200,+ ftol: float = 1e-4,+ num_samples_per_iteration: int = 100,+ num_samples_full: int = 1000,+ error_threshold: float = 0.3,+) -> float:+ """Iterative bundle adjustment with a decaying outlier-rejection schedule.++ Mutates `cameras` in place. Returns the final median reprojection error.+ """+ if points_2d.shape[0] != len(cameras):+ raise ValueError(+ f"First dim should equal number of cameras ({len(cameras)}), "+ f"but shape is {points_2d.shape}"+ )++ points_2d_full = points_2d+ board_observations_full = board_observations++ points_2d, board_observations = resample_points(+ points_2d_full, board_observations_full, num_samples=num_samples_full+ )+ error = average_error(cameras, points_2d, median=True)++ logger.info(f"Reprojection error before bundle adjustment: {error:.4f} pixels ")++ mus = np.exp(np.linspace(np.log(damping_start), np.log(damping_end), num=num_iterations))++ for iteration in range(num_iterations):+ points_2d, board_observations = resample_points(+ points_2d_full, board_observations_full, num_samples=num_samples_full+ )+ points_3d = triangulate(cameras, points_2d)+ errors_full = reprojection_error(cameras, points_3d, points_2d, mean=False)+ errors_norm = reprojection_error(cameras, points_3d, points_2d, mean=True)++ error_dict = get_error_dict(errors_full)+ max_error = 0+ min_error = 0+ for k, v in error_dict.items():+ num, percents = v+ max_error = max(percents[-1], max_error)+ min_error = max(percents[0], min_error)+ mu = max(min(max_error, mus[iteration]), min_error)++ good = errors_norm < mu+ board_observations_good = subset_extra(board_observations, good)+ points_2d_samp, board_observations_samp = resample_points(+ points_2d[:, good], board_observations_good, num_samples=num_samples_per_iteration+ )++ error = float(np.median(errors_norm))++ if error < error_threshold:+ break++ logger.info(+ f"Iteration {iteration + 1}/{num_iterations}: error={error:.4f}, mu={mu:.2f}, inliers={np.sum(good)}/{len(good)}")++ bundle_adjust(+ cameras,+ points_2d_samp,+ board_observations_samp,+ loss="linear",+ ftol=ftol,+ max_nfev=max_nfev,+ )++ points_2d, board_observations = resample_points(+ points_2d_full, board_observations_full, num_samples=num_samples_full+ )+ points_3d = triangulate(cameras, points_2d)+ errors_full = reprojection_error(cameras, points_3d, points_2d, mean=False)+ errors_norm = reprojection_error(cameras, points_3d, points_2d, mean=True)+ error_dict = get_error_dict(errors_full)++ max_error = 0+ min_error = 0+ for k, v in error_dict.items():+ num, percents = v+ max_error = max(percents[-1], max_error)+ min_error = max(percents[0], min_error)+ mu = max(max(max_error, damping_end), min_error)++ good = errors_norm < mu+ board_observations_good = subset_extra(board_observations, good)+ bundle_adjust(+ cameras,+ points_2d[:, good],+ board_observations_good,+ loss="linear",+ ftol=ftol,+ max_nfev=max(200, max_nfev),+ )++ return average_error(cameras, points_2d, median=True)+++def bundle_adjust(+ cameras: list[CameraModel],+ points_2d: NDArray[np.float64],+ board_observations: BoardObservations,+ loss: str = "linear",+ threshold: float = 50,+ ftol: float = 1e-4,+ max_nfev: int = 1000,+ start_params: NDArray[np.float64] | None = None,+) -> float:+ """Single scipy.least_squares bundle-adjust pass; mutates cameras in place."""+ if points_2d.shape[0] != len(cameras):+ raise ValueError(+ f"First dim should equal number of cameras ({len(cameras)}), "+ f"but shape is {points_2d.shape}"+ )++ board_observations.corner_ids_map = remap_ids(board_observations.corner_ids)++ x0, num_camera_params = _initialize_params_bundle(cameras, points_2d, board_observations)++ if start_params is not None:+ x0 = start_params+ num_camera_params = PARAMS_PER_CAMERA++ jac_sparse = _jac_sparsity_bundle(cameras, points_2d, num_camera_params, board_observations)++ opt = optimize.least_squares(+ _error_fun_bundle,+ x0,+ jac_sparsity=jac_sparse,+ f_scale=threshold,+ x_scale="jac",+ loss=loss,+ ftol=ftol,+ method="trf",+ tr_solver="lsmr",+ verbose=2,+ max_nfev=max_nfev,+ args=(cameras, points_2d, num_camera_params, board_observations),+ )++ for camera_index, cam in enumerate(cameras):+ param_start = camera_index * num_camera_params+ param_end = (camera_index + 1) * num_camera_params+ apply_camera_params(cam, opt.x[param_start:param_end])++ return average_error(cameras, points_2d)+++def _error_fun_bundle(+ params: NDArray[np.float64],+ cameras: list[CameraModel],+ points_2d: NDArray[np.float64],+ num_camera_params: int,+ board_observations: BoardObservations,+) -> NDArray[np.float64]:+ """Residual function for scipy.least_squares bundle adjustment.++ Previously decorated with ``@jit(parallel=True, forceobj=True)`` which+ forced Numba into *object mode* — it cannot compile functions that+ mutate Python objects (CameraModel) or call arbitrary Python functions+ (reprojection_error → Triangulator). Object-mode Numba provides zero+ speed benefit and emitted a type-inference warning on every run.++ Instead, we now inline the two hot-path operations:++ 1. **apply_camera_params** — directly set camera attributes from the+ param slice, avoiding the function-call / object-construction+ overhead of ``CameraExtrinsics.from_rodrigues`` inside the old+ helper.+ 2. **reprojection_error** — directly call ``cv2.projectPoints`` per+ camera instead of building a full ``Triangulator`` object on every+ solver iteration.+ """+ good = ~np.isnan(points_2d)+ num_cameras = len(cameras)+ num_points = points_2d.shape[1]++ # -- Inline apply_camera_params: mutate cameras directly from params --+ for camera_index in range(num_cameras):+ param_start = camera_index * num_camera_params+ p = params[param_start: param_start + num_camera_params]+ cam = cameras[camera_index]+ focal = float(p[6])+ cam.intrinsics.fx = focal+ cam.intrinsics.fy = focal+ cam.intrinsics.k1 = float(p[7])+ cam.intrinsics.k2 = 0.0+ cam.intrinsics.p1 = 0.0+ cam.intrinsics.p2 = 0.0+ cam.extrinsics = CameraExtrinsics.from_rodrigues(+ rvec=np.asarray(p[0:3], dtype=np.float64),+ tvec=np.asarray(p[3:6], dtype=np.float64),+ )++ # -- Extract 3D points from param vector --+ total_cam_params = num_camera_params * num_cameras+ num_3d_params = num_points * 3+ points_3d_test = params[total_cam_params: total_cam_params + num_3d_params].reshape(-1, 3)++ # -- Inline reprojection error (avoids Triangulator construction) --+ nan_mask = np.isnan(points_3d_test).any(axis=1)+ valid_pts = points_3d_test[~nan_mask].reshape(-1, 1, 3)+ projected_all = np.empty((num_cameras, num_points, 2), dtype=np.float64)+ for cam_idx, cam in enumerate(cameras):+ if valid_pts.shape[0] == 0:+ projected_all[cam_idx] = np.nan+ continue+ proj, _ = cv2.projectPoints(+ valid_pts,+ cam.extrinsics.rodrigues_vector,+ cam.extrinsics.translation,+ cam.intrinsics.to_camera_matrix(),+ cam.intrinsics.to_dist_coeffs(),+ )+ full = np.full((num_points, 2), np.nan, dtype=np.float64)+ full[~nan_mask] = proj.reshape(-1, 2)+ projected_all[cam_idx] = full++ signed_errors = points_2d - projected_all # (num_cameras, num_points, 2)+ errors_reproj = signed_errors[good]++ # -- Board-object constraint residuals (unchanged logic) --+ ids = board_observations.corner_ids_map+ objp = board_observations.object_points+ min_scale = np.min(objp[objp > 0])+ num_boards = int(np.max(ids)) + 1+ board_param_start = total_cam_params + num_3d_params+ rvecs = params[board_param_start: board_param_start + num_boards * 3].reshape(-1, 3)+ tvecs = params[board_param_start + num_boards * 3: board_param_start + num_boards * 6].reshape(-1, 3)+ expected = transform_points(objp, rvecs[ids], tvecs[ids])+ errors_obj = 2 * (points_3d_test - expected).ravel() / min_scale++ return np.hstack([errors_reproj, errors_obj])+++def _jac_sparsity_bundle(+ cameras: list[CameraModel],+ points_2d: NDArray[np.float64],+ num_camera_params: int,+ board_observations: BoardObservations,+) -> dok_matrix:+ point_indices = np.zeros(points_2d.shape, dtype="int32")+ cam_indices = np.zeros(points_2d.shape, dtype="int32")++ for point_index in range(points_2d.shape[1]):+ point_indices[:, point_index] = point_index+ for camera_index in range(points_2d.shape[0]):+ cam_indices[camera_index] = camera_index++ good = ~np.isnan(points_2d)++ ids = board_observations.corner_ids_map+ num_boards = int(np.max(ids)) + 1+ total_board_params = num_boards * 6++ num_cameras = points_2d.shape[0]+ num_points = points_2d.shape[1]+ total_params_reproj = num_cameras * num_camera_params + num_points * 3+ num_params = total_params_reproj + total_board_params++ num_good_values = np.sum(good)+ num_errors = num_good_values + (num_points * 3 if board_observations is not None else 0)++ A_sparse = dok_matrix((num_errors, num_params), dtype="int16")++ cam_indices_good = cam_indices[good]+ point_indices_good = point_indices[good]+ ix = np.arange(num_good_values)++ for param_offset in range(num_camera_params):+ A_sparse[ix, cam_indices_good * num_camera_params + param_offset] = 1+ for coord in range(3):+ A_sparse[ix, num_cameras * num_camera_params + point_indices_good * 3 + coord] = 1++ if board_observations is not None:+ point_ix = np.arange(num_points)+ for i in range(3):+ for j in range(3):+ A_sparse[num_good_values + point_ix * 3 + i, total_params_reproj + ids * 3 + j] = 1+ A_sparse[+ num_good_values + point_ix * 3 + i,+ total_params_reproj + num_boards * 3 + ids * 3 + j,+ ] = 1+ for i in range(3):+ A_sparse[+ num_good_values + point_ix * 3 + i,+ num_cameras * num_camera_params + point_ix * 3 + i,+ ] = 1++ return A_sparse+++def _initialize_params_bundle(+ cameras: list[CameraModel],+ points_2d: NDArray[np.float64],+ board_observations: BoardObservations,+) -> tuple[NDArray[np.float64], int]:+ """Build the initial parameter vector for bundle adjustment.++ Layout: [camera_params... | 3d_points... | board_rvecs... | board_tvecs...]+ """++ cam_params = np.hstack([pack_camera_params(cam) for cam in cameras])+ num_camera_params = len(cam_params) // len(cameras)+ total_cam_params = len(cam_params)++ num_cameras, num_points, _ = points_2d.shape+ if num_cameras != len(cameras):+ raise ValueError("Camera count mismatch between cameras and 2D points")++ points_3d = triangulate(cameras, points_2d)++ ids = board_observations.corner_ids_map+ num_boards = int(np.max(ids[~np.isnan(ids)])) + 1+ total_board_params = num_boards * 6++ rvecs = np.zeros((num_boards, 3), dtype="float64")+ tvecs = np.zeros((num_boards, 3), dtype="float64")++ if board_observations.rotation_vectors is not None and board_observations.translation_vectors is not None:+ rvecs_all = board_observations.rotation_vectors+ tvecs_all = board_observations.translation_vectors+ for board_num in range(num_boards):+ point_id = np.where(ids == board_num)[0][0]+ cam_ids_possible = np.where(~np.isnan(points_2d[:, point_id, 0]))[0]+ cam_id = np.random.choice(cam_ids_possible)+ M_cam = build_transformation_matrix(+ cameras[cam_id].extrinsics.rodrigues_vector,+ cameras[cam_id].extrinsics.translation,+ )+ M_board_cam = build_transformation_matrix(rvecs_all[cam_id, point_id], tvecs_all[cam_id, point_id])+ M_board = np.linalg.inv(M_cam) @ M_board_cam+ rvec, tvec = get_rtvec(M_board)+ rvecs[board_num] = rvec+ tvecs[board_num] = tvec++ x0 = np.zeros(total_cam_params + points_3d.size + total_board_params)+ x0[:total_cam_params] = cam_params+ x0[total_cam_params: total_cam_params + points_3d.size] = points_3d.ravel()++ if board_observations is not None:+ board_start = total_cam_params + points_3d.size+ x0[board_start: board_start + num_boards * 3] = rvecs.ravel()+ x0[board_start + num_boards * 3: board_start + num_boards * 6] = tvecs.ravel()++ return x0, num_camera_params+++# =============================================================================+# CALIBRATION ENTRY POINT (replaces AniposeCameraGroup.calibrate_rows)+# =============================================================================+++def calibrate_cameras_from_rows(+ cameras: list[CameraModel],+ all_rows: list[list[dict[str, Any]]],+ board: CharucoBoardDefinition,+) -> tuple[float, list, list]:+ """Calibrate cameras from charuco board observation rows.++ Mutates `cameras` in place. Returns (reprojection_error, merged_rows,+ charuco_frame_numbers).+ """+ num_cameras = len(cameras)+ if len(all_rows) != num_cameras:+ raise ValueError(+ f"Detection count ({len(all_rows)}) != camera count ({num_cameras})"+ )++ logger.info(f"Calibrating {num_cameras} cameras")+ for cam_idx, (rows, camera) in enumerate(zip(all_rows, cameras)):+ logger.info(f"Camera {cam_idx} ({camera.id}): {len(rows)} frames with detections")+ if camera.image_size is None:+ raise ValueError(f"Camera '{camera.id}' has no image size")++ logger.info("Initializing camera intrinsics...")+ for cam_idx, (rows, camera) in enumerate(zip(all_rows, cameras)):+ objp, imgp = charuco_board_ops.get_all_calibration_points(board, rows)+ mixed = [(o, i) for (o, i) in zip(objp, imgp) if len(o) >= 7]+ if len(mixed) == 0:+ raise ValueError(f"No valid calibration points for camera {cam_idx} (need >= 7)")+ logger.info(f" Camera {cam_idx}: {len(mixed)} usable frames")+ objp, imgp = zip(*mixed)+ matrix = cv2.initCameraMatrix2D(objp, imgp, tuple(camera.image_size))+ camera.intrinsics.fx = float(matrix[0, 0])+ camera.intrinsics.fy = float(matrix[1, 1])+ camera.intrinsics.cx = float(matrix[0, 2])+ camera.intrinsics.cy = float(matrix[1, 2])++ logger.info("Estimating board poses...")+ for i, (row, cam) in enumerate(zip(all_rows, cameras)):+ all_rows[i] = charuco_board_ops.estimate_pose_rows(board, cam, row)++ for cam_idx, (rows, camera) in enumerate(zip(all_rows, cameras)):+ valid_poses = sum(1 for r in rows if r.get("rvec") is not None and r.get("tvec") is not None)+ if valid_poses == 0:+ raise ValueError(+ f"Camera {cam_idx} ({camera.id}) has no frames with enough charuco corners "+ f"for pose estimation (need >= 6 per frame). "+ f"Ensure the charuco board is clearly visible and well-lit in every camera's view, "+ f"and that the correct board dimensions are configured."+ )+ logger.info(f" Camera {cam_idx} ({camera.id}): {valid_poses}/{len(rows)} frames have valid board pose")++ charuco_frames = [f["framenum"][1] for f in all_rows[0]]++ logger.info("Merging observations across cameras...")+ cam_ids = camera_ids_from_camera_models(cameras)+ merged = merge_rows(all_rows=all_rows, camera_ids=cam_ids)++ image_points, board_observations = extract_points(merged, board, camera_ids=cam_ids, min_cameras=2)+ logger.info(f"Extracted points: shape={image_points.shape}")++ logger.info("Initializing camera extrinsics...")+ rtvecs = extract_roration_translation_vectors(merged, camera_ids=cam_ids)++ connections = get_connections(rtvecs, cam_ids)+ for (cam_a, cam_b), count in sorted(connections.items()):+ if cam_a < cam_b:+ logger.info(f" {cam_a} <-> {cam_b}: {count} shared frames")++ rvecs, tvecs = get_initial_extrinsics(rtvecs, camera_ids=cam_ids)+ apply_extrinsics(cameras, rvecs, tvecs)++ logger.info("Starting iterative bundle adjustment...")+ error = iterative_bundle_adjustment(cameras, image_points, board_observations, error_threshold=1.0)+ logger.info(f"Calibration complete — final error: {error:.4f}")++ return error, merged, charuco_framesdiff --git a/freemocap/core/tasks/calibration/anipose_calibration/helpers/calibration_helpers.py b/freemocap/core/tasks/calibration/anipose_calibration/helpers/calibration_helpers.pydeleted file mode 100644index b5223556..00000000--- a/freemocap/core/tasks/calibration/anipose_calibration/helpers/calibration_helpers.py+++ /dev/null@@ -1,242 +0,0 @@-"""Anipose calibration post-processing helpers.--Pin camera 0 to origin, charuco groundplane alignment,-real-world camera position computation.-"""--import logging-from pathlib import Path--import cv2-import numpy as np-import pandas as pd-from skellycam.core.types.type_overloads import CameraIdString-from skellytracker.trackers.base_tracker.base_tracker_abcs import BaseRecorder-from skellytracker.trackers.charuco_tracker.charuco_observation import CharucoObservation--from freemocap.core.tasks.calibration.anipose_calibration.helpers.freemocap_anipose import AniposeCameraGroup, \- AniposeCharucoBoard-from freemocap.core.tasks.calibration.shared.groundplane_alignment import GroundPlaneResult-from freemocap.core.tasks.calibration.shared.groundplane_math import find_still_charuco_frame, CharucoVisibilityError, \- CharucoVelocityError, compute_board_basis_vectors-from freemocap.core.types.type_overloads import VideoIdString--logger = logging.getLogger(__name__)--CharucoObservations = dict[CameraIdString, CharucoObservation | None]---class GroundPlaneSuccess:- def __init__(self, success: bool, error: str | None = None):- self.success = success- self.error = error---def interpolate_skeleton_data(skeleton_data: np.ndarray, method_to_use: str = "linear", order: int = 3) -> np.ndarray:- """Interpolate missing NaN values in a 3D skeleton/charuco numpy array.-- Args:- skeleton_data: (n_frames, n_markers, 3) array with possible NaN gaps.- method_to_use: Pandas interpolation method (e.g. 'linear', 'polynomial').- order: Order for polynomial/spline interpolation methods.-- Returns:- Interpolated array with same shape, NaN gaps filled.- """- num_frames = skeleton_data.shape[0]- num_markers = skeleton_data.shape[1]- interpolated = np.empty((num_frames, num_markers, 3))-- for marker in range(num_markers):- marker_data = skeleton_data[:, marker, :]- df = pd.DataFrame(marker_data)- df_interpolated = df.interpolate(method=method_to_use, axis=0, order=order)- marker_array = np.array(df_interpolated)- # Fill remaining NaNs (e.g. at recording start) with column mean- marker_array = np.where(- np.isfinite(marker_array),- marker_array,- np.nanmean(marker_array),- )- interpolated[:, marker, :] = marker_array-- return interpolated---def anipose_pin_camera_zero_to_origin(camera_group: AniposeCameraGroup) -> AniposeCameraGroup:- """Re-express all camera extrinsics relative to camera 0.-- Camera 0 ends up with identity rotation and zero translation.- All other cameras are expressed relative to camera 0.- """- rvecs_new = _align_rotations_to_cam0(camera_group=camera_group)- camera_group.set_rotations(rvecs_new)- tvecs_new = _shift_origin_to_cam0(camera_group=camera_group)- camera_group.set_translations(tvecs_new)- return camera_group---def _align_rotations_to_cam0(camera_group: AniposeCameraGroup) -> np.ndarray:- """Align all camera rotations to camera 0's coordinate frame."""- rvecs = camera_group.get_rotations()- R0, _ = cv2.Rodrigues(rvecs[0])-- rvecs_new = np.empty_like(rvecs)- for i in range(rvecs.shape[0]):- Ri, _ = cv2.Rodrigues(rvecs[i])- Ri_new, _ = cv2.Rodrigues(Ri @ R0.T)- rvecs_new[i] = Ri_new.flatten()- return rvecs_new---def _shift_origin_to_cam0(camera_group: AniposeCameraGroup) -> np.ndarray:- """Shift world origin to camera 0's position."""- tvecs = camera_group.get_translations()- rvecs = camera_group.get_rotations()-- R0, _ = cv2.Rodrigues(rvecs[0, :])- delta_to_origin_world = -R0.T @ tvecs[0, :]-- new_tvecs = np.zeros_like(tvecs)- for cam_i in range(tvecs.shape[0]):- Ri, _ = cv2.Rodrigues(rvecs[cam_i, :])- delta_to_origin_camera_i = Ri @ delta_to_origin_world- new_tvecs[cam_i, :] = tvecs[cam_i, :] + delta_to_origin_camera_i- return new_tvecs---def set_charuco_board_as_groundplane(- *,- observation_recorders: dict[VideoIdString, BaseRecorder],- anipose_camera_group: AniposeCameraGroup,- anipose_charuco_board: AniposeCharucoBoard,- recording_folder_path: "Path | None" = None,-) -> tuple[AniposeCameraGroup, GroundPlaneSuccess, GroundPlaneResult | None]:- """Set the charuco board plane as the world groundplane."""- logger.info("Getting 2D Charuco data")- data2d_by_video: dict[VideoIdString, np.ndarray] = {}- if len(observation_recorders) == 0:- raise ValueError("No observation recorders provided to process.")-- for video_id, recorder in observation_recorders.items():- if not all(isinstance(observation, CharucoObservation) for observation in recorder.observations):- raise TypeError(f"Recorder for video ID {video_id} contains non-Charuco observations.")- data2d_fr_id_xyc = recorder.to_array.copy()- logger.info(f"Processing video ID: {video_id} with 2D data shape: {data2d_fr_id_xyc.shape}")- data2d_by_video[video_id] = data2d_fr_id_xyc[..., :2]-- charuco2d_cam_fr_id_xy = np.stack(list(data2d_by_video.values()), axis=0)- logger.info(- f"Charuco 2d data retrieved with shape (cams, frames, markers, XY): {charuco2d_cam_fr_id_xy.shape}"- )- charuco2d_cam_fr_id_xy = charuco2d_cam_fr_id_xy.astype(np.float64)- num_cameras, num_frames, num_tracked_points, _ = charuco2d_cam_fr_id_xy.shape- charuco_2d_flat = charuco2d_cam_fr_id_xy.reshape(num_cameras, -1, 2)-- logger.info("Getting 3d Charuco data")- charuco_3d_flat = anipose_camera_group.triangulate(charuco_2d_flat)- charuco3d_fr_id_xyz = charuco_3d_flat.reshape(num_frames, num_tracked_points, 3)- logger.info(f"Charuco 3d data reconstructed with shape: {charuco3d_fr_id_xyz.shape}")-- charuco_3d_xyz_interpolated = interpolate_skeleton_data(skeleton_data=charuco3d_fr_id_xyz)-- try:- charuco_still_frame_idx = find_still_charuco_frame(- charuco_3d=charuco3d_fr_id_xyz,- squares_x=anipose_charuco_board.squaresX,- squares_y=anipose_charuco_board.squaresY,- )- except CharucoVisibilityError as e:- logger.warning("Ground-plane alignment skipped — reverting to original calibration: %s", e, exc_info=True)- return anipose_camera_group, GroundPlaneSuccess(success=False, error=str(e)), None- except CharucoVelocityError as e:- logger.warning("Ground-plane alignment skipped — reverting to original calibration: %s", e, exc_info=True)- return anipose_camera_group, GroundPlaneSuccess(success=False, error=str(e)), None-- charuco_frame = charuco_3d_xyz_interpolated[charuco_still_frame_idx]-- x_hat, y_hat, z_hat = compute_board_basis_vectors(- charuco_frame=charuco_frame,- squares_x=anipose_charuco_board.squaresX,- squares_y=anipose_charuco_board.squaresY,- )-- charuco_origin_in_world = charuco_frame[0]- rmat_charuco_to_world = np.column_stack([x_hat, y_hat, z_hat])-- ground_plane_result = GroundPlaneResult(- origin=charuco_origin_in_world,- rotation_matrix=rmat_charuco_to_world,- method="charuco",- )-- rvecs_new, tvecs_new = _adjust_world_reference_frame_to_charuco(- camera_group=anipose_camera_group,- charuco_origin_in_world=charuco_origin_in_world,- rmat_charuco_to_world=rmat_charuco_to_world,- )-- anipose_camera_group.set_rotations(rvecs_new)- anipose_camera_group.set_translations(tvecs_new)-- logger.info("Anipose camera calibration data adjusted to set charuco board as ground plane")-- # Recalculate 3D charuco data in new coordinate system- charuco_3d_flat = anipose_camera_group.triangulate(charuco_2d_flat)- charuco3d_fr_id_xyz = charuco_3d_flat.reshape(num_frames, num_tracked_points, 3)- charuco_3d_xyz_interpolated = interpolate_skeleton_data(skeleton_data=charuco3d_fr_id_xyz)-- if recording_folder_path is not None:- charuco_save_path = Path(recording_folder_path) / "output_data" / "charuco_3d_xyz.npy"- charuco_save_path.parent.mkdir(parents=True, exist_ok=True)- np.save(charuco_save_path, charuco_3d_xyz_interpolated)- logger.info(f"Charuco 3d data saved to {charuco_save_path}")-- return anipose_camera_group, GroundPlaneSuccess(success=True), ground_plane_result---def _adjust_world_reference_frame_to_charuco(- *,- camera_group: AniposeCameraGroup,- charuco_origin_in_world: np.ndarray,- rmat_charuco_to_world: np.ndarray,-) -> tuple[np.ndarray, np.ndarray]:- """Adjust camera extrinsics to use charuco board as world reference frame."""- tvecs = camera_group.get_translations()- rvecs = camera_group.get_rotations()-- tvecs_new = np.zeros_like(tvecs)- rvecs_new = np.zeros_like(rvecs)-- for i in range(tvecs.shape[0]):- rmat_world_to_cam_i, _ = cv2.Rodrigues(rvecs[i])- t_delta = rmat_world_to_cam_i @ charuco_origin_in_world- tvecs_new[i] = t_delta + tvecs[i]-- new_rmat = rmat_world_to_cam_i @ rmat_charuco_to_world- new_rvec, _ = cv2.Rodrigues(new_rmat)- rvecs_new[i] = new_rvec.flatten()-- return rvecs_new, tvecs_new---def get_real_world_matrices(camera_group: AniposeCameraGroup) -> tuple[list, list]:- """Calculate real-world positions and orientations of cameras."""- rvecs = camera_group.get_rotations()- tvecs = camera_group.get_translations()-- positions = []- orientations = []-- for i in range(tvecs.shape[0]):- rmat_world_to_cam_i, _ = cv2.Rodrigues(rvecs[i])- rmat_cam_to_world = rmat_world_to_cam_i.T- t_world = -rmat_cam_to_world @ tvecs[i]-- positions.append(t_world.astype(float).tolist())- orientations.append(rmat_cam_to_world.astype(float).tolist())-- camera_group.set_world_positions(positions)- camera_group.set_world_orientations(orientations)-- return positions, orientationsdiff --git a/freemocap/core/tasks/calibration/anipose_calibration/helpers/camera_model_solver_ops.py b/freemocap/core/tasks/calibration/anipose_calibration/helpers/camera_model_solver_ops.pynew file mode 100644index 00000000..f49c4a41--- /dev/null+++ b/freemocap/core/tasks/calibration/anipose_calibration/helpers/camera_model_solver_ops.py@@ -0,0 +1,85 @@+"""Solver-only operations on CameraModel for bundle adjustment.++These were previously methods on AniposeCamera/AniposeCameraGroup. Free+functions here keep the shared CameraModel free of solver concerns.+"""+from __future__ import annotations++import numpy as np+from numpy.typing import NDArray++from freemocap.core.tasks.calibration.shared.camera_extrinsics import CameraExtrinsics+from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+++# Parameter layout per camera: [rvec(3), tvec(3), focal(1), dist0(1)] = 8 floats.+# Matches the original AniposeCamera.get_params/set_params layout (extra_dist=False).+PARAMS_PER_CAMERA = 8+++def pack_camera_params(camera: CameraModel) -> NDArray[np.float64]:+ """Pack a camera's optimisable parameters into an 8-element array.++ Layout: [rvec(3), tvec(3), focal(1), dist0(1)].+ Focal is the average of fx/fy.+ """+ intr = camera.intrinsics+ extr = camera.extrinsics+ focal = 0.5 * (intr.fx + intr.fy)+ params = np.zeros(PARAMS_PER_CAMERA, dtype=np.float64)+ params[0:3] = extr.rodrigues_vector+ params[3:6] = extr.translation+ params[6] = focal+ params[7] = intr.k1+ return params+++def apply_camera_params(camera: CameraModel, params: NDArray[np.float64]) -> None:+ """Mutate a CameraModel in place from an 8-element parameter array.++ fx/fy are both set to the focal value. cx/cy are preserved. k1 is set+ from params[7]; k2/p1/p2 are zeroed (matches the original AniposeCamera+ behavior, which only optimised k1).+ """+ focal = float(params[6])+ camera.intrinsics.fx = focal+ camera.intrinsics.fy = focal+ camera.intrinsics.k1 = float(params[7])+ camera.intrinsics.k2 = 0.0+ camera.intrinsics.p1 = 0.0+ camera.intrinsics.p2 = 0.0+ camera.extrinsics = CameraExtrinsics.from_rodrigues(+ rvec=np.asarray(params[0:3], dtype=np.float64),+ tvec=np.asarray(params[3:6], dtype=np.float64),+ )+++# ----- Bulk accessors (replace AniposeCameraGroup.rotations / .translations) -----+++def stack_rodrigues(cameras: list[CameraModel]) -> NDArray[np.float64]:+ """(num_cameras, 3) Rodrigues rotation vectors."""+ return np.array([cam.extrinsics.rodrigues_vector for cam in cameras], dtype=np.float64)+++def stack_translations(cameras: list[CameraModel]) -> NDArray[np.float64]:+ """(num_cameras, 3) translation vectors."""+ return np.array([cam.extrinsics.translation for cam in cameras], dtype=np.float64)+++def apply_extrinsics(+ cameras: list[CameraModel],+ rvecs: NDArray[np.float64],+ tvecs: NDArray[np.float64],+) -> None:+ """Replace each camera's extrinsics in place from Rodrigues + translation arrays."""+ if len(rvecs) != len(cameras) or len(tvecs) != len(cameras):+ raise ValueError(+ f"extrinsics length mismatch: cameras={len(cameras)}, "+ f"rvecs={len(rvecs)}, tvecs={len(tvecs)}"+ )+ for cam, rvec, tvec in zip(cameras, rvecs, tvecs):+ cam.extrinsics = CameraExtrinsics.from_rodrigues(+ rvec=np.asarray(rvec, dtype=np.float64),+ tvec=np.asarray(tvec, dtype=np.float64),+ )diff --git a/freemocap/core/tasks/calibration/anipose_calibration/helpers/freemocap_anipose.py b/freemocap/core/tasks/calibration/anipose_calibration/helpers/freemocap_anipose.pyindex a42b3463..411e698a 100644--- a/freemocap/core/tasks/calibration/anipose_calibration/helpers/freemocap_anipose.py+++ b/freemocap/core/tasks/calibration/anipose_calibration/helpers/freemocap_anipose.py@@ -3,47 +3,40 @@# More info on Anipose: https://anipose.readthedocs.io/en/latest/import logging-import multiprocessing-import multiprocessing.synchronizefrom collections import defaultdict-from copy import copy-from pathlib import Path+from dataclasses import dataclass+from typing import Any-import cv2import numpy as np-import toml-from aniposelib.boards import extract_points, extract_rtvecs, merge_rows, CharucoBoard-from numba import jit-from scipy import optimize-from scipy.sparse import dok_matrix-from tqdm import trange--from freemocap.core.tasks.calibration.shared.transform_math import build_maximum_spanning_tree, make_M, \+from freemocap.core.tasks.calibration.charuco_board.charuco_board_ops import get_empty_detection, \+ get_object_points+from numpy.typing import NDArray+from skellycam.core.types.type_overloads import CameraIdString++from skellytracker.trackers.charuco_tracker import CharucoBoardDefinition+from freemocap.core.tasks.calibration.shared.transform_math import build_maximum_spanning_tree, build_transformation_matrix, \robust_average_transforms, find_spanning_tree_pairs, get_rtvec-numba_logger = logging.getLogger("numba")-numba_logger.setLevel(logging.WARNING)logger = logging.getLogger(__name__)-ARUCO_DICTS = {- (4, 50): cv2.aruco.DICT_4X4_50,- (5, 50): cv2.aruco.DICT_5X5_50,- (6, 50): cv2.aruco.DICT_6X6_50,- (7, 50): cv2.aruco.DICT_7X7_50,- (4, 100): cv2.aruco.DICT_4X4_100,- (5, 100): cv2.aruco.DICT_5X5_100,- (6, 100): cv2.aruco.DICT_6X6_100,- (7, 100): cv2.aruco.DICT_7X7_100,- (4, 250): cv2.aruco.DICT_4X4_250,- (5, 250): cv2.aruco.DICT_5X5_250,- (6, 250): cv2.aruco.DICT_6X6_250,- (7, 250): cv2.aruco.DICT_7X7_250,- (4, 1000): cv2.aruco.DICT_4X4_1000,- (5, 1000): cv2.aruco.DICT_5X5_1000,- (6, 1000): cv2.aruco.DICT_6X6_1000,- (7, 1000): cv2.aruco.DICT_7X7_1000,-}++# =============================================================================+# SHARED TYPES+# =============================================================================+++@dataclass+class BoardObservations:+ """Per-frame charuco board data for the bundle adjustment solver."""++ object_points: NDArray[np.float64] # (N, 3) board-frame 3-D corner positions+ corner_ids: NDArray[np.int32] # (N,) board frame indices per point row+ rotation_vectors: NDArray[np.float64] # (num_cameras, N, 3) per-camera rvecs from solvePnP+ translation_vectors: NDArray[np.float64] # (num_cameras, N, 3) per-camera tvecs from solvePnP+ corner_ids_map: NDArray[np.int32] | None = None # contiguous 0-based remapping; set by bundle_adjust++# =============================================================================@@ -51,30 +44,25 @@ ARUCO_DICTS = {# =============================================================================-def triangulate_simple(points: np.ndarray, camera_mats: np.ndarray) -> np.ndarray:- """Triangulate a single 3D point from 2D observations via DLT."""- num_cams = len(camera_mats)- A = np.zeros((num_cams * 2, 4))- for i in range(num_cams):- x, y = points[i]- mat = camera_mats[i]- A[(i * 2): (i * 2 + 1)] = x * mat[2] - mat[0]- A[(i * 2 + 1): (i * 2 + 2)] = y * mat[2] - mat[1]- u, s, vh = np.linalg.svd(A, full_matrices=True)- p3d = vh[-1]- p3d = p3d[:3] / p3d[3]- return p3d---def get_error_dict(errors_full: np.ndarray, min_points: int = 10) -> dict:- """Compute pairwise reprojection error statistics across cameras."""- n_cams = errors_full.shape[0]+def get_error_dict(errors_full: np.ndarray, min_points: int = 10) -> dict[tuple[int, int], tuple[int, np.ndarray]]:+ """Compute pairwise reprojection error statistics across cameras.++ Args:+ errors_full: (num_cameras, N, 2) signed reprojection errors.+ min_points: Minimum shared observations required to include a pair.++ Returns:+ Dict mapping (cam_i, cam_j) → (num_shared_points, percentile_array)+ where percentile_array contains the [15th, 75th] percentiles of the+ mean pairwise error magnitude.+ """+ num_cameras = errors_full.shape[0]errors_norm = np.linalg.norm(errors_full, axis=2)good = ~np.isnan(errors_full[:, :, 0])- error_dict = dict()+ error_dict: dict[tuple[int, int], tuple[int, np.ndarray]] = {}- for i in range(n_cams):- for j in range(i + 1, n_cams):+ for i in range(num_cameras):+ for j in range(i + 1, num_cameras):subset = good[i] & good[j]err_subset = errors_norm[:, subset][[i, j]]err_subset_mean = np.mean(err_subset, axis=0)@@ -84,68 +72,100 @@ def get_error_dict(errors_full: np.ndarray, min_points: int = 10) -> dict:return error_dict-def subset_extra(extra: dict | None, ixs: np.ndarray) -> dict | None:- """Subset the extra data dict (board IDs, object points, etc.) by indices."""- if extra is None:- return None- return {- "objp": extra["objp"][ixs],- "ids": extra["ids"][ixs],- "rvecs": extra["rvecs"][:, ixs],- "tvecs": extra["tvecs"][:, ixs],- }+def subset_extra(board_observations: BoardObservations, ixs: np.ndarray) -> BoardObservations:+ """Subset a BoardObservations to the given point indices."""+ corner_ids_map = (+ board_observations.corner_ids_map[ixs]+ if board_observations.corner_ids_map is not None+ else None+ )+ return BoardObservations(+ object_points=board_observations.object_points[ixs],+ corner_ids=board_observations.corner_ids[ixs],+ rotation_vectors=board_observations.rotation_vectors[:, ixs],+ translation_vectors=board_observations.translation_vectors[:, ixs],+ corner_ids_map=corner_ids_map,+ )def resample_points(- imgp: np.ndarray,- extra: dict | None = None,- n_samp: int = 25,-) -> tuple[np.ndarray, dict | None]:- """Subsample 2D points for bundle adjustment, prioritizing multi-camera coverage."""- n_cams = imgp.shape[0]- good = ~np.isnan(imgp[:, :, 0])- ixs = np.arange(imgp.shape[1])- num_cams = np.sum(~np.isnan(imgp[:, :, 0]), axis=0)+ image_points: np.ndarray,+ board_observations: BoardObservations,+ num_samples: int = 25,+) -> tuple[np.ndarray, BoardObservations]:+ """Subsample 2-D image points for bundle adjustment, prioritizing multi-camera coverage.++ For each pair of cameras that share observations, picks up to ``num_samples``+ points weighted toward those seen by more cameras.++ Args:+ image_points: (num_cameras, N, 2) array; NaN where a camera has no observation.+ board_observations: Optional board data to subset in parallel with points.+ num_samples: Maximum points to sample per camera pair.++ Returns:+ Tuple of (subsetted image_points, subsetted board_observations).+ """+ num_cameras = image_points.shape[0]+ good = ~np.isnan(image_points[:, :, 0])+ ixs = np.arange(image_points.shape[1])+ num_cams_per_point = np.sum(~np.isnan(image_points[:, :, 0]), axis=0)include: set[int] = set()- for i in range(n_cams):- for j in range(i + 1, n_cams):+ for i in range(num_cameras):+ for j in range(i + 1, num_cameras):subset = good[i] & good[j]n_good = np.sum(subset)if n_good > 0:- arr = np.copy(num_cams[subset]).astype("float64")+ arr = np.copy(num_cams_per_point[subset]).astype("float64")arr += np.random.random(size=arr.shape)- picked_ix = np.argsort(-arr)[:n_samp]+ picked_ix = np.argsort(-arr)[:num_samples]picked = ixs[subset][picked_ix]include.update(picked)final_ixs = sorted(include)- newp = imgp[:, final_ixs]- extra = subset_extra(extra, np.asarray(final_ixs))- return newp, extra+ newp = image_points[:, final_ixs]+ board_observations = subset_extra(board_observations, np.asarray(final_ixs))+ return newp, board_observationsdef transform_points(- points: np.ndarray,- rvecs: np.ndarray,- tvecs: np.ndarray,+ points: np.ndarray,+ rotation_vectors: np.ndarray,+ translation_vectors: np.ndarray,) -> np.ndarray:- """Rotate points by Rodrigues vectors and translate."""- theta = np.linalg.norm(rvecs, axis=1)[:, np.newaxis]+ """Rotate points by Rodrigues vectors and translate.++ Args:+ points: (N, 3) array of 3-D points.+ rotation_vectors: (N, 3) Rodrigues rotation vectors, one per point.+ translation_vectors: (N, 3) translation vectors, one per point.++ Returns:+ (N, 3) rotated and translated points.+ """+ theta = np.linalg.norm(rotation_vectors, axis=1)[:, np.newaxis]with np.errstate(invalid="ignore"):- v = rvecs / theta+ v = rotation_vectors / thetav = np.nan_to_num(v)dot = np.sum(points * v, axis=1)[:, np.newaxis]cos_theta = np.cos(theta)sin_theta = np.sin(theta)rotated = cos_theta * points + sin_theta * np.cross(v, points) + dot * (1 - cos_theta) * v- return rotated + tvecs+ return rotated + translation_vectorsdef remap_ids(ids: np.ndarray) -> np.ndarray:- """Remap arbitrary board IDs to contiguous 0-based indices."""+ """Remap arbitrary board IDs to contiguous 0-based indices.++ Args:+ ids: (N,) integer array of board frame indices.++ Returns:+ (N,) integer array with values remapped to [0, num_unique).+ """unique_ids = np.unique(ids)ids_out = np.copy(ids)for i, num in enumerate(unique_ids):@@ -159,27 +179,30 @@ def remap_ids(ids: np.ndarray) -> np.ndarray:def get_connections(- xs: np.ndarray,- cam_names: list|np.ndarray | None = None,- both: bool = True,-) -> dict[tuple, int]:- """Count shared observation pairs between cameras."""- n_cams = xs.shape[0]- n_points = xs.shape[1]-- if cam_names is None:- # TODO - This is wrong!! we should use camera ID in the dict, NOT the INDEX!- cam_names = [str(i) for i in range(n_cams)]-- connections = {}-- for rnum in range(n_points):- ixs = np.where(~np.isnan(xs[:, rnum, 0]))[0]- keys = [int(cam_names[ix]) for ix in ixs]+ rotation_translation_vectors: np.ndarray,+ camera_ids: list[CameraIdString],+ both: bool = True,+) -> dict[tuple[CameraIdString, CameraIdString], int]:+ """Count shared observation pairs between cameras.++ Args:+ rotation_translation_vectors: (num_cameras, N, 6) array; NaN rows indicate no observation.+ camera_ids: Ordered list of camera ID strings.+ both: If True, populate (a, b) and (b, a); otherwise only (a, b).++ Returns:+ Dict mapping (camera_id_a, camera_id_b) → shared frame count.+ """+ num_points = rotation_translation_vectors.shape[1]+ connections: dict[tuple[CameraIdString, CameraIdString], int] = {}++ for point_index in range(num_points):+ ixs = np.where(~np.isnan(rotation_translation_vectors[:, point_index, 0]))[0]+ keys = [camera_ids[ix] for ix in ixs]for i in range(len(keys)):+ a = CameraIdString(keys[i])for j in range(i + 1, len(keys)):- a = keys[i]- b = keys[j]+ b = CameraIdString(keys[j])connections[(a, b)] = connections.get((a, b), 0) + 1if both:connections[(b, a)] = connections.get((b, a), 0) + 1@@ -187,37 +210,49 @@ def get_connections(def get_calibration_graph(- rtvecs: np.ndarray,- cam_names: np.ndarray | list | None = None,-) -> dict[int, list[int]]:- """Build a maximum spanning tree of camera connections from shared observations."""- n_cams = rtvecs.shape[0]- if cam_names is None:- cam_names = np.arange(n_cams)+ rotation_translation_vectors: np.ndarray,+ camera_ids: list[CameraIdString],+) -> dict[CameraIdString, list[CameraIdString]]:+ """Build a maximum spanning tree of camera connections from shared observations.- connections = get_connections(rtvecs, np.arange(n_cams))+ Args:+ rotation_translation_vectors: (num_cameras, N, 6) board pose array.+ camera_ids: Ordered list of camera ID strings.+ Returns:+ Adjacency dict representing the maximum spanning tree.+ """+ num_cameras = rotation_translation_vectors.shape[0]+ connections = get_connections(rotation_translation_vectors, camera_ids)return build_maximum_spanning_tree(connection_counts=connections,- n_nodes=n_cams,- node_labels=[str(cn) for cn in cam_names],+ n_nodes=num_cameras,+ node_ids=camera_ids,)-def _get_pairwise_transform(rtvecs: np.ndarray, left: int, right: int) -> np.ndarray:+def _get_pairwise_transform(rotation_translation_vectors: np.ndarray, left: int, right: int) -> np.ndarray:"""Compute the robust average transform between two cameras from shared observations.- For each frame where both cameras observe the board, computes M_left @ inv(M_right)- and robustly averages the results.+ For each frame where both cameras observe the board, computes+ ``M_left @ inv(M_right)`` and robustly averages the results.++ Args:+ rotation_translation_vectors: (num_cameras, N, 6) board pose array.+ left: Index of the left (source) camera.+ right: Index of the right (target) camera.++ Returns:+ (4, 4) average extrinsics transform from right to left."""transforms: list[np.ndarray] = []- for dix in range(rtvecs.shape[1]):- d = rtvecs[:, dix]+ for detection_index in range(rotation_translation_vectors.shape[1]):+ d = rotation_translation_vectors[:, detection_index]good = ~np.isnan(d[:, 0])if good[left] and good[right]:- M_left = make_M(d[left, 0:3], d[left, 3:6])- M_right = make_M(d[right, 0:3], d[right, 3:6])+ M_left = build_transformation_matrix(d[left, 0:3], d[left, 3:6])+ M_right = build_transformation_matrix(d[right, 0:3], d[right, 3:6])transforms.append(M_left @ np.linalg.inv(M_right))if len(transforms) == 0:@@ -228,69 +263,86 @@ def _get_pairwise_transform(rtvecs: np.ndarray, left: int, right: int) -> np.ndadef compute_camera_matrices(- rtvecs: np.ndarray,- pairs: list[tuple[int, int]],-) -> dict[int, np.ndarray]:+ rotation_translation_vectors: np.ndarray,+ pairs: list[tuple[CameraIdString, CameraIdString]],+ camera_ids: list[CameraIdString],+) -> dict[CameraIdString, np.ndarray]:"""Compute camera extrinsics by chaining pairwise transforms along spanning tree pairs.Camera at pairs[0][0] is the root (identity transform).++ Args:+ rotation_translation_vectors: (num_cameras, N, 6) board pose array.+ pairs: Ordered list of (parent, child) camera ID pairs from the spanning tree.+ camera_ids: Ordered list of all camera ID strings.++ Returns:+ Dict mapping each camera ID to its (4, 4) extrinsics matrix."""- extrinsics: dict[int, np.ndarray] = {}+ extrinsics: dict[CameraIdString, np.ndarray] = {}source = pairs[0][0]extrinsics[source] = np.identity(4)+ id_to_index: dict[CameraIdString, int] = {camera_id: idx for idx, camera_id in enumerate(camera_ids)}+for a, b in pairs:if a not in extrinsics:raise ValueError(f"Camera {a} must be computed before camera {b}")- ext = _get_pairwise_transform(rtvecs, b, a)+ ext = _get_pairwise_transform(rotation_translation_vectors, id_to_index[b], id_to_index[a])extrinsics[b] = ext @ extrinsics[a]return extrinsicsdef get_initial_extrinsics(- rtvecs: np.ndarray,- cam_names: list | None = None,+ rotation_translation_vectors: np.ndarray,+ camera_ids: list[CameraIdString],) -> tuple[np.ndarray, np.ndarray]:"""Compute initial camera extrinsics from board pose observations.- Builds a spanning tree from shared observation counts, computes pairwise- transforms, and chains them from camera 0 (the root).+ Builds a maximum spanning tree from shared observation counts, computes+ pairwise transforms along the tree, and chains them from camera 0 (root).++ Args:+ rotation_translation_vectors: (num_cameras, N, 6) array of [rvec | tvec] board poses; NaN where unobserved.+ camera_ids: Ordered list of camera ID strings matching the first axis of ``rtvecs``.Returns:- Tuple of (rvecs, tvecs) arrays, each shape (n_cams, 3).+ Tuple of (rvecs_array, tvecs_array), each shape (num_cameras, 3)."""- n_cams = rtvecs.shape[0]- n_frames = rtvecs.shape[1]- logger.info(f"Computing initial extrinsics for {n_cams} cameras from {n_frames} frames")-- for cam_idx in range(n_cams):- valid_obs = np.sum(~np.isnan(rtvecs[cam_idx, :, 0]))- cam_name = cam_names[cam_idx] if cam_names else str(cam_idx)- logger.info(f"Camera {cam_name}: {valid_obs}/{n_frames} valid observations ({100 * valid_obs / n_frames:.1f}%)")+ num_cameras = rotation_translation_vectors.shape[0]+ num_frames = rotation_translation_vectors.shape[1]+ logger.info(f"Computing initial extrinsics for {num_cameras} cameras from {num_frames} frames")++ for camera_index, camera_id in enumerate(camera_ids):+ valid_obs = np.sum(~np.isnan(rotation_translation_vectors[camera_index, :, 0]))+ logger.info(+ f"Camera {camera_id}: {valid_obs}/{num_frames} valid observations "+ f"({100 * valid_obs / num_frames:.1f}%)"+ )- graph = get_calibration_graph(rtvecs, cam_names)+ graph = get_calibration_graph(rotation_translation_vectors, camera_ids)logger.info(f"Calibration graph: {dict(graph)}")- pairs = find_spanning_tree_pairs(graph, root=0)+ pairs = find_spanning_tree_pairs(graph)logger.info(f"Calibration pairs: {pairs}")- if len(pairs) != n_cams - 1:- raise ValueError(f"Expected {n_cams - 1} pairs, got {len(pairs)}. Graph may be disconnected!")+ if len(pairs) != num_cameras - 1:+ raise ValueError(f"Expected {num_cameras - 1} pairs, got {len(pairs)}. Graph may be disconnected!")- extrinsics = compute_camera_matrices(rtvecs, pairs)+ extrinsics = compute_camera_matrices(rotation_translation_vectors=rotation_translation_vectors, pairs=pairs, camera_ids=camera_ids)- rvecs = []- tvecs = []- for cnum in range(n_cams):- if cnum not in extrinsics:- raise ValueError(f"Missing extrinsics for camera {cnum}")- rvec, tvec = get_rtvec(extrinsics[cnum])- rvecs.append(rvec)- tvecs.append(tvec)+ rvecs_list: list[np.ndarray] = []+ tvecs_list: list[np.ndarray] = []+ for camera_index, camera_id in enumerate(camera_ids):+ if camera_id not in extrinsics:+ raise ValueError(f"Missing extrinsics for camera#{camera_index}, id: {camera_id}")+ rvec, tvec = get_rtvec(extrinsics[camera_id])+ rvecs_list.append(rvec)+ tvecs_list.append(tvec)- rvecs_arr = np.array(rvecs)- tvecs_arr = np.array(tvecs)+ rvecs_arr = np.array(rvecs_list)+ tvecs_arr = np.array(tvecs_list)logger.info(f"Rotation magnitudes: {np.linalg.norm(rvecs_arr, axis=1)}")logger.info(f"Translation magnitudes: {np.linalg.norm(tvecs_arr, axis=1)}")@@ -298,855 +350,201 @@ def get_initial_extrinsics(return rvecs_arr, tvecs_arr-# =============================================================================-# CAMERA MODEL-# =============================================================================+def extract_roration_translation_vectors(+ merged: list[dict[CameraIdString, dict[str, Any]]],+ camera_ids: list[CameraIdString],+ min_cameras: int = 1,+ board=None,+ cameras: list | None = None,+) -> np.ndarray:+ """Extract per-camera board pose vectors from merged detection rows.+ ``board.estimate_pose_rows`` should have been called on each camera's rows+ before merging. If not, pass ``board`` and ``cameras`` so poses can be+ estimated on the fly.-class AniposeCamera:- def __init__(- self,- matrix=np.eye(3),- dist=np.zeros(5),- size=None,- rvec=np.zeros(3),- tvec=np.zeros(3),- world_orientation=np.eye(3),- world_position=np.zeros(3),- name=None,- extra_dist=False,- ):- self.set_camera_matrix(matrix)- self.set_distortions(dist)- self.set_size(size)- self.set_rotation(rvec)- self.set_translation(tvec)- self.set_world_orientation(world_orientation)- self.set_world_position(world_position)- self.set_name(name)- self.extra_dist = extra_dist-- def get_dict(self) -> dict:- return {- "name": self.get_name(),- "size": list(self.get_size()),- "matrix": self.get_camera_matrix().tolist(),- "distortions": self.get_distortions().tolist(),- "rotation": self.get_rotation().tolist(),- "translation": self.get_translation().tolist(),- "world_orientation": self.get_world_orientation().tolist(),- "world_position": self.get_world_position().tolist(),- }-- def load_dict(self, d: dict) -> None:- self.set_camera_matrix(d["matrix"])- self.set_rotation(d["rotation"])- self.set_translation(d["translation"])- self.set_distortions(d["distortions"])- self.set_name(d["name"])- self.set_size(d["size"])- self.set_world_orientation(d.get("world_orientation", np.eye(3)))- self.set_world_position(d.get("world_position", np.zeros(3)))-- @staticmethod- def from_dict(d: dict) -> "AniposeCamera":- cam = AniposeCamera()- cam.load_dict(d)- return cam-- def get_camera_matrix(self) -> np.ndarray:- return self.matrix-- def get_distortions(self) -> np.ndarray:- return self.dist-- def set_camera_matrix(self, matrix) -> None:- self.matrix = np.array(matrix, dtype="float64")-- def set_focal_length(self, fx: float, fy: float | None = None) -> None:- if fy is None:- fy = fx- self.matrix[0, 0] = fx- self.matrix[1, 1] = fy-- def get_focal_length(self, both: bool = False) -> float | tuple[float, float]:- fx = self.matrix[0, 0]- fy = self.matrix[1, 1]- if both:- return (fx, fy)- else:- return (fx + fy) / 2.0-- def set_distortions(self, dist) -> None:- self.dist = np.array(dist, dtype="float64").ravel()-- def set_rotation(self, rvec) -> None:- self.rvec = np.array(rvec, dtype="float64").ravel()-- def get_rotation(self) -> np.ndarray:- return self.rvec-- def set_translation(self, tvec) -> None:- self.tvec = np.array(tvec, dtype="float64").ravel()-- def get_translation(self) -> np.ndarray:- return self.tvec-- def set_world_orientation(self, world_orientation) -> None:- self.world_orientation = np.asarray(world_orientation, dtype="float64").reshape(3, 3)-- def get_world_orientation(self) -> np.ndarray:- return self.world_orientation-- def set_world_position(self, world_position) -> None:- self.world_position = np.array(world_position, dtype="float64").ravel()-- def get_world_position(self) -> np.ndarray:- return self.world_position-- def get_extrinsics_mat(self) -> np.ndarray:- return make_M(self.rvec, self.tvec)-- def get_name(self) -> str:- return self.name-- def set_name(self, name) -> None:- self.name = str(name)-- def set_size(self, size) -> None:- """Set size as (width, height)."""- self.size = size-- def get_size(self):- """Get size as (width, height)."""- return self.size-- def get_params(self) -> np.ndarray:- params = np.zeros(8 + self.extra_dist, dtype="float64")- params[0:3] = self.get_rotation()- params[3:6] = self.get_translation()- params[6] = self.get_focal_length()- dist = self.get_distortions()- params[7] = dist[0]- if self.extra_dist:- params[8] = dist[1]- return params-- def set_params(self, params: np.ndarray) -> None:- self.set_rotation(params[0:3])- self.set_translation(params[3:6])- self.set_focal_length(params[6])-- dist = np.zeros(5, dtype="float64")- dist[0] = params[7]- if self.extra_dist:- dist[1] = params[8]- self.set_distortions(dist)-- def distort_points(self, points: np.ndarray) -> np.ndarray:- shape = points.shape- points = points.reshape(-1, 1, 2)- new_points = np.dstack([points, np.ones((points.shape[0], 1, 1))])- out, _ = cv2.projectPoints(- new_points, np.zeros(3), np.zeros(3),- self.matrix.astype("float64"), self.dist.astype("float64"),- )- return out.reshape(shape)-- def undistort_points(self, points: np.ndarray) -> np.ndarray:- shape = points.shape- points = points.reshape(-1, 1, 2)- out = cv2.undistortPoints(points, self.matrix.astype("float64"), self.dist.astype("float64"))- return out.reshape(shape)-- def project(self, points: np.ndarray) -> np.ndarray:- points = points.reshape(-1, 1, 3)- out, _ = cv2.projectPoints(- points, self.rvec, self.tvec,- self.matrix.astype("float64"), self.dist.astype("float64"),- )- return out-- def single_camera_reprojection_error(self, p3d: np.ndarray, p2d: np.ndarray) -> np.ndarray:- projected = self.project(p3d).reshape(p2d.shape)- return p2d - projected-- def copy(self) -> "AniposeCamera":- return AniposeCamera(- matrix=self.get_camera_matrix().copy(),- dist=self.get_distortions().copy(),- size=self.get_size(),- rvec=self.get_rotation().copy(),- tvec=self.get_translation().copy(),- name=self.get_name(),- extra_dist=self.extra_dist,- world_orientation=self.get_world_orientation().copy(),- world_position=self.get_world_position().copy(),- )+ Args:+ merged: List of per-frame dicts mapping camera_id → detection dict+ (keys: ``corners``, ``ids``, ``rvec``, ``tvec``, ``framenum``).+ camera_ids: Ordered camera IDs determining axis order of the output.+ If ``None``, inferred from the union of row keys (sorted).+ min_cameras: Drop frames seen by fewer than this many cameras.+ board: CharucoBoardDefinition; required if poses are not pre-estimated.+ cameras: List of cameras; required alongside ``board`` if poses are not pre-estimated.+ Returns:+ (num_cameras, num_detections, 6) float64 array of [rvec | tvec] concatenated.+ Entries are NaN where a camera did not observe the board in that frame.+ """-# =============================================================================-# CAMERA GROUP-# =============================================================================+ num_cameras = len(camera_ids)+ num_detections = len(merged)-class AniposeCameraGroup:- def __init__(self, cameras: list[AniposeCamera], metadata: dict | None = None):- self.cameras = cameras- self.metadata = metadata if metadata is not None else {}-- def subset_cameras(self, indices: list[int]) -> "AniposeCameraGroup":- cams = [self.cameras[ix].copy() for ix in indices]- return AniposeCameraGroup(cams, self.metadata)-- def subset_cameras_names(self, names: list[str]) -> "AniposeCameraGroup":- cur_names = self.get_names()- cur_names_dict = dict(zip(cur_names, range(len(cur_names))))- indices = []- for name in names:- if name not in cur_names_dict:- raise IndexError(f"name {name} not part of camera names: {cur_names}")- indices.append(cur_names_dict[name])- return self.subset_cameras(indices)-- def project(self, points: np.ndarray) -> np.ndarray:- """Given Nx3 points, returns CxNx2 projected 2D points."""- points = points.reshape(-1, 1, 3)- n_points = points.shape[0]- n_cams = len(self.cameras)-- out = np.empty((n_cams, n_points, 2), dtype="float64")- for cnum, cam in enumerate(self.cameras):- out[cnum] = cam.project(points).reshape(n_points, 2)- return out-- def triangulate(- self,- points: np.ndarray,- undistort: bool = True,- progress: bool = False,- kill_event: multiprocessing.synchronize.Event | None = None,- ) -> np.ndarray | None:- """Given CxNx2 points, returns Nx3 triangulated 3D points."""- assert points.shape[0] == len(self.cameras), (- f"First dim should equal number of cameras ({len(self.cameras)}), "- f"but shape is {points.shape}"- )+ rtvecs = np.empty((num_cameras, num_detections, 6), dtype="float64")+ rtvecs[:] = np.nan- one_point = False- if len(points.shape) == 2:- points = points.reshape(-1, 1, 2)- one_point = True-- if undistort:- new_points = np.empty(points.shape)- for cnum, cam in enumerate(self.cameras):- sub = np.copy(points[cnum])- new_points[cnum] = cam.undistort_points(sub)- points = new_points-- n_cams, n_points, _ = points.shape- out = np.empty((n_points, 3))- out[:] = np.nan-- cam_mats = np.array([cam.get_extrinsics_mat() for cam in self.cameras])- iterator = trange(n_points, ncols=70) if progress else range(n_points)-- for ip in iterator:- subp = points[:, ip, :]- good = ~np.isnan(subp[:, 0])- if np.sum(good) >= 2:- out[ip] = triangulate_simple(subp[good], cam_mats[good])- if kill_event is not None and kill_event.is_set():- return None-- if one_point:- out = out[0]- return out-- @jit(parallel=True, forceobj=True)- def reprojection_error(self, points_3d: np.ndarray, points_2d: np.ndarray, mean: bool = False):- """Compute reprojection error. Returns CxNx2, or Nx1 if mean=True."""- one_point = False- if len(points_3d.shape) == 1 and len(points_2d.shape) == 2:- points_3d = points_3d.reshape(1, 3)- points_2d = points_2d.reshape(-1, 1, 2)- one_point = True-- n_cams, n_points, _ = points_2d.shape- assert points_3d.shape == (n_points, 3), (- f"2D/3D shape mismatch: 2D={points_2d.shape}, 3D={points_3d.shape}"- )+ for row_index, row in enumerate(merged):+ for camera_index, camera_id in enumerate(camera_ids):+ if camera_id in row:+ r = row[camera_id]+ if "rvec" not in r or "tvec" not in r:+ if board is None:+ raise ValueError(+ "rvec or tvec not found in rows. "+ "estimate_pose_rows should have been run before merging, "+ "or pass board and cameras as arguments."+ )+ from freemocap.core.tasks.calibration.charuco_board.charuco_board_ops import estimate_pose_points+ rvec, tvec = estimate_pose_points(board, cameras[camera_index], r["corners"], r["ids"])+ r["rvec"] = rvec+ r["tvec"] = tvec- errors = np.empty((n_cams, n_points, 2))- for camera_number, cam in enumerate(self.cameras):- errors[camera_number] = cam.single_camera_reprojection_error(points_3d, points_2d[camera_number])-- if mean:- errors_norm = np.linalg.norm(errors, axis=2)- good = ~np.isnan(errors_norm)- errors_norm[~good] = 0- denom = np.sum(good, axis=0).astype("float64")- denom[denom < 1.5] = np.nan- errors = np.sum(errors_norm, axis=0) / denom-- if one_point:- errors = float(errors[0]) if mean else errors.reshape(-1, 2)- return errors-- # ------------------------------------------------------------------ # BUNDLE ADJUSTMENT- # ------------------------------------------------------------------- def bundle_adjust_iter(- self,- p2ds,- extra=None,- n_iters=10,- start_mu=15,- end_mu=1,- max_nfev=200,- ftol=1e-4,- n_samp_iter=100,- n_samp_full=1000,- error_threshold=0.3,- verbose=False,- ) -> float:- """Iterative bundle adjustment with outlier-reducing weight schedule."""- error_list = []-- assert p2ds.shape[0] == len(self.cameras), (- f"First dim should equal number of cameras ({len(self.cameras)}), but shape is {p2ds.shape}"- )+ if r["rvec"] is None or r["tvec"] is None:+ continue- p2ds_full = p2ds- extra_full = extra-- p2ds, extra = resample_points(p2ds_full, extra_full, n_samp=n_samp_full)- error = self.average_error(p2ds, median=True)-- if verbose:- print("error: ", error)-- mus = np.exp(np.linspace(np.log(start_mu), np.log(end_mu), num=n_iters))-- for i in range(n_iters):- p2ds, extra = resample_points(p2ds_full, extra_full, n_samp=n_samp_full)- p3ds = self.triangulate(p2ds)- errors_full = self.reprojection_error(p3ds, p2ds, mean=False)- errors_norm = self.reprojection_error(p3ds, p2ds, mean=True)-- error_dict = get_error_dict(errors_full)- max_error = 0- min_error = 0- for k, v in error_dict.items():- num, percents = v- max_error = max(percents[-1], max_error)- min_error = max(percents[0], min_error)- mu = max(min(max_error, mus[i]), min_error)-- good = errors_norm < mu- extra_good = subset_extra(extra, good)- p2ds_samp, extra_samp = resample_points(p2ds[:, good], extra_good, n_samp=n_samp_iter)-- error = np.median(errors_norm)- error_list.append(error)-- if error < error_threshold:- break-- if verbose:- print(error_dict)- print("error: {:.2f}, mu: {:.1f}, ratio: {:.3f}".format(error, mu, np.mean(good)))-- self.bundle_adjust(- p2ds_samp, extra_samp, loss="linear", ftol=ftol, max_nfev=max_nfev, verbose=verbose,- )-- # Final pass with relaxed threshold- p2ds, extra = resample_points(p2ds_full, extra_full, n_samp=n_samp_full)- p3ds = self.triangulate(p2ds)- errors_full = self.reprojection_error(p3ds, p2ds, mean=False)- errors_norm = self.reprojection_error(p3ds, p2ds, mean=True)- error_dict = get_error_dict(errors_full)-- max_error = 0- min_error = 0- for k, v in error_dict.items():- num, percents = v- max_error = max(percents[-1], max_error)- min_error = max(percents[0], min_error)- mu = max(max(max_error, end_mu), min_error)-- good = errors_norm < mu- extra_good = subset_extra(extra, good)- self.bundle_adjust(- p2ds[:, good], extra_good, loss="linear", ftol=ftol,- max_nfev=max(200, max_nfev), verbose=verbose,- )+ rtvec = np.hstack([r["rvec"].ravel(), r["tvec"].ravel()])+ rtvecs[camera_index, row_index] = rtvec- return self.average_error(p2ds, median=True)-- def bundle_adjust(- self,- p2ds,- extra=None,- loss="linear",- threshold=50,- ftol=1e-4,- max_nfev=1000,- weights=None,- start_params=None,- verbose=True,- ) -> float:- """Fine-tune camera parameters via scipy least_squares bundle adjustment."""- assert p2ds.shape[0] == len(self.cameras), (- f"First dim should equal number of cameras ({len(self.cameras)}), but shape is {p2ds.shape}"- )+ num_good = np.sum(~np.isnan(rtvecs), axis=0)[:, 0]+ rtvecs = rtvecs[:, num_good >= min_cameras]- if extra is not None:- extra["ids_map"] = remap_ids(extra["ids"])-- x0, n_cam_params = self._initialize_params_bundle(p2ds, extra)-- if start_params is not None:- x0 = start_params- n_cam_params = len(self.cameras[0].get_params())-- jac_sparse = self._jac_sparsity_bundle(p2ds, n_cam_params, extra)-- opt = optimize.least_squares(- self._error_fun_bundle,- x0,- jac_sparsity=jac_sparse,- f_scale=threshold,- x_scale="jac",- loss=loss,- ftol=ftol,- method="trf",- tr_solver="lsmr",- verbose=2 * verbose,- max_nfev=max_nfev,- args=(p2ds, n_cam_params, extra),- )+ return rtvecs- for i, cam in enumerate(self.cameras):- a = i * n_cam_params- b = (i + 1) * n_cam_params- cam.set_params(opt.x[a:b])-- return self.average_error(p2ds)-- @jit(parallel=True, forceobj=True)- def _error_fun_bundle(self, params, p2ds, n_cam_params, extra):- """Error function for bundle adjustment."""- good = ~np.isnan(p2ds)- n_cams = len(self.cameras)-- for i in range(n_cams):- a = i * n_cam_params- b = (i + 1) * n_cam_params- self.cameras[i].set_params(params[a:b])-- sub = n_cam_params * n_cams- n3d = p2ds.shape[1] * 3- p3ds_test = params[sub: sub + n3d].reshape(-1, 3)- errors_reproj = self.reprojection_error(p3ds_test, p2ds)[good]-- if extra is not None:- ids = extra["ids_map"]- objp = extra["objp"]- min_scale = np.min(objp[objp > 0])- n_boards = int(np.max(ids)) + 1- a = sub + n3d- rvecs = params[a: a + n_boards * 3].reshape(-1, 3)- tvecs = params[a + n_boards * 3: a + n_boards * 6].reshape(-1, 3)- expected = transform_points(objp, rvecs[ids], tvecs[ids])- errors_obj = 2 * (p3ds_test - expected).ravel() / min_scale- else:- errors_obj = np.array([])-- return np.hstack([errors_reproj, errors_obj])-- def _jac_sparsity_bundle(self, p2ds, n_cam_params, extra):- """Compute the sparsity structure of the Jacobian for bundle adjustment."""- point_indices = np.zeros(p2ds.shape, dtype="int32")- cam_indices = np.zeros(p2ds.shape, dtype="int32")-- for i in range(p2ds.shape[1]):- point_indices[:, i] = i- for j in range(p2ds.shape[0]):- cam_indices[j] = j-- good = ~np.isnan(p2ds)-- if extra is not None:- ids = extra["ids_map"]- n_boards = int(np.max(ids)) + 1- total_board_params = n_boards * 6- else:- n_boards = 0- total_board_params = 0-- n_cams = p2ds.shape[0]- n_points = p2ds.shape[1]- total_params_reproj = n_cams * n_cam_params + n_points * 3- n_params = total_params_reproj + total_board_params-- n_good_values = np.sum(good)- n_errors = n_good_values + (n_points * 3 if extra is not None else 0)-- A_sparse = dok_matrix((n_errors, n_params), dtype="int16")-- cam_indices_good = cam_indices[good]- point_indices_good = point_indices[good]- ix = np.arange(n_good_values)-- for i in range(n_cam_params):- A_sparse[ix, cam_indices_good * n_cam_params + i] = 1- for i in range(3):- A_sparse[ix, n_cams * n_cam_params + point_indices_good * 3 + i] = 1-- if extra is not None:- point_ix = np.arange(n_points)- for i in range(3):- for j in range(3):- A_sparse[n_good_values + point_ix * 3 + i, total_params_reproj + ids * 3 + j] = 1- A_sparse[n_good_values + point_ix * 3 + i, total_params_reproj + n_boards * 3 + ids * 3 + j] = 1- for i in range(3):- A_sparse[n_good_values + point_ix * 3 + i, n_cams * n_cam_params + point_ix * 3 + i] = 1-- return A_sparse-- def _initialize_params_bundle(self, p2ds, extra):- """Initialize parameter vector for bundle adjustment."""- cam_params = np.hstack([cam.get_params() for cam in self.cameras])- n_cam_params = len(cam_params) // len(self.cameras)- total_cam_params = len(cam_params)-- n_cams, n_points, _ = p2ds.shape- assert n_cams == len(self.cameras), "Camera count mismatch between group and 2D points"-- p3ds = self.triangulate(p2ds)-- if extra is not None:- ids = extra["ids_map"]- n_boards = int(np.max(ids[~np.isnan(ids)])) + 1- total_board_params = n_boards * 6-- rvecs = np.zeros((n_boards, 3), dtype="float64")- tvecs = np.zeros((n_boards, 3), dtype="float64")-- if "rvecs" in extra and "tvecs" in extra:- rvecs_all = extra["rvecs"]- tvecs_all = extra["tvecs"]- for board_num in range(n_boards):- point_id = np.where(ids == board_num)[0][0]- cam_ids_possible = np.where(~np.isnan(p2ds[:, point_id, 0]))[0]- cam_id = np.random.choice(cam_ids_possible)- M_cam = self.cameras[cam_id].get_extrinsics_mat()- M_board_cam = make_M(rvecs_all[cam_id, point_id], tvecs_all[cam_id, point_id])- M_board = np.linalg.inv(M_cam) @ M_board_cam- rvec, tvec = get_rtvec(M_board)- rvecs[board_num] = rvec- tvecs[board_num] = tvec- else:- total_board_params = 0-- x0 = np.zeros(total_cam_params + p3ds.size + total_board_params)- x0[:total_cam_params] = cam_params- x0[total_cam_params: total_cam_params + p3ds.size] = p3ds.ravel()-- if extra is not None:- start_board = total_cam_params + p3ds.size- x0[start_board: start_board + n_boards * 3] = rvecs.ravel()- x0[start_board + n_boards * 3: start_board + n_boards * 6] = tvecs.ravel()-- return x0, n_cam_params-- # ------------------------------------------------------------------ # ACCESSORS & SERIALIZATION- # ------------------------------------------------------------------- def average_error(self, p2ds: np.ndarray, median: bool = False) -> float:- p3ds = self.triangulate(p2ds)- errors = self.reprojection_error(p3ds, p2ds, mean=True)- return np.median(errors) if median else np.mean(errors)-- def set_rotations(self, rvecs: np.ndarray) -> None:- for cam, rvec in zip(self.cameras, rvecs):- cam.set_rotation(rvec)-- def set_translations(self, tvecs: np.ndarray) -> None:- for cam, tvec in zip(self.cameras, tvecs):- cam.set_translation(tvec)-- def set_world_positions(self, positions: list) -> None:- for cam, position in zip(self.cameras, positions):- cam.set_world_position(position)-- def set_world_orientations(self, orientations: list) -> None:- for cam, orientation in zip(self.cameras, orientations):- cam.set_world_orientation(orientation)-- def get_world_positions(self) -> np.ndarray:- return np.stack([cam.get_world_position() for cam in self.cameras])-- def get_world_orientations(self) -> np.ndarray:- return np.stack([cam.get_world_orientation() for cam in self.cameras])-- def get_rotations(self) -> np.ndarray:- return np.array([cam.get_rotation() for cam in self.cameras])-- def get_translations(self) -> np.ndarray:- return np.array([cam.get_translation() for cam in self.cameras])-- def get_names(self) -> list[str]:- return [cam.get_name() for cam in self.cameras]-- def set_names(self, names: list[str]) -> None:- for cam, name in zip(self.cameras, names):- cam.set_name(name)-- def copy(self) -> "AniposeCameraGroup":- cameras = [cam.copy() for cam in self.cameras]- metadata = copy(self.metadata)- return AniposeCameraGroup(cameras, metadata)-- def get_dicts(self) -> list[dict]:- return [cam.get_dict() for cam in self.cameras]-- @staticmethod- def from_dicts(cameras_dicts: list[dict]) -> "AniposeCameraGroup":- cameras = [AniposeCamera.from_dict(d) for d in cameras_dicts]- return AniposeCameraGroup(cameras)-- @staticmethod- def from_names(names: list[str]) -> "AniposeCameraGroup":- cameras = [AniposeCamera(name=name) for name in names]- return AniposeCameraGroup(cameras)-- def load_dicts(self, arr: list[dict]) -> None:- for cam, d in zip(self.cameras, arr):- cam.load_dict(d)-- def dump(self, fname: str | Path) -> None:- dicts = self.get_dicts()- names = [camera_dict["name"] for camera_dict in dicts]- master_dict = dict(zip(names, dicts))- master_dict["metadata"] = self.metadata- with open(fname, "w") as f:- toml.dump(master_dict, f)-- @staticmethod- def load(fname: str | Path) -> "AniposeCameraGroup":- if not Path(fname).is_file():- raise FileNotFoundError(f"File {fname} not found.")- master_dict = toml.load(fname)- keys = sorted(master_dict.keys())- items = [master_dict[k] for k in keys if k != "metadata"]- cgroup = AniposeCameraGroup.from_dicts(items)- if "metadata" in master_dict:- cgroup.metadata = master_dict["metadata"]- return cgroup-- # ------------------------------------------------------------------ # CALIBRATION- # ------------------------------------------------------------------- def calibrate_rows(- self,- all_rows: list[list[dict]],- board,- init_intrinsics: bool = True,- init_extrinsics: bool = True,- verbose: bool = True,- ) -> tuple[float, list, list]:- """Calibrate cameras from charuco board observation rows.-- Returns:- Tuple of (reprojection_error, merged_rows, charuco_frame_numbers).- """- n_cameras = len(self.cameras)- assert len(all_rows) == n_cameras, (- f"Detection count ({len(all_rows)}) != camera count ({n_cameras})"- )- logger.info(f"Calibrating {n_cameras} cameras")- for cam_idx, (rows, camera) in enumerate(zip(all_rows, self.cameras)):- logger.info(f"Camera {cam_idx} ({camera.get_name()}): {len(rows)} frames with detections")- assert camera.get_size() is not None, f"Camera '{camera.get_name()}' has no frame size"-- if init_intrinsics:- logger.info("Initializing camera intrinsics...")- for cam_idx, (rows, camera) in enumerate(zip(all_rows, self.cameras)):- objp, imgp = board.get_all_calibration_points(rows)- mixed = [(o, i) for (o, i) in zip(objp, imgp) if len(o) >= 7]- if len(mixed) == 0:- raise ValueError(f"No valid calibration points for camera {cam_idx} (need >= 7)")- logger.info(f" Camera {cam_idx}: {len(mixed)} usable frames")- objp, imgp = zip(*mixed)- matrix = cv2.initCameraMatrix2D(objp, imgp, tuple(camera.get_size()))- camera.set_camera_matrix(matrix)-- logger.info("Estimating board poses...")- for i, (row, cam) in enumerate(zip(all_rows, self.cameras)):- all_rows[i] = board.estimate_pose_rows(cam, row)-- # Verify each camera has at least some frames with a successfully estimated board pose.- # solvePnP needs >= 6 charuco corners per frame; if a camera never saw that many, calibration cannot proceed.- for cam_idx, (rows, camera) in enumerate(zip(all_rows, self.cameras)):- valid_poses = sum(1 for r in rows if r.get("rvec") is not None and r.get("tvec") is not None)- if valid_poses == 0:- raise ValueError(- f"Camera {cam_idx} ({camera.get_name()}) has no frames with enough charuco corners "- f"for pose estimation (need >= 6 per frame). "- f"Ensure the charuco board is clearly visible and well-lit in every camera's view, "- f"and that the correct board dimensions are configured."- )- logger.info(f" Camera {cam_idx} ({camera.get_name()}): {valid_poses}/{len(rows)} frames have valid board pose")-- charuco_frames = [f["framenum"][1] for f in all_rows[0]]-- logger.info("Merging observations across cameras...")- merged = merge_rows(all_rows)-- imgp, extra = extract_points(merged, board, min_cameras=2)- logger.info(f"Extracted points: shape={imgp.shape}")-- if init_extrinsics:- logger.info("Initializing camera extrinsics...")- rtvecs = extract_rtvecs(merged)-- if verbose:- connections = get_connections(rtvecs, self.get_names())- for (cam_a, cam_b), count in sorted(connections.items()):- if cam_a < cam_b:- logger.info(f" {cam_a} <-> {cam_b}: {count} shared frames")-- rvecs, tvecs = get_initial_extrinsics(rtvecs, cam_names=self.get_names())- self.set_rotations(rvecs)- self.set_translations(tvecs)-- logger.info("Starting iterative bundle adjustment...")- error = self.bundle_adjust_iter(imgp, extra, verbose=verbose, error_threshold=1)- logger.info(f"Calibration complete — final error: {error:.4f}")-- return error, merged, charuco_frames+def merge_rows(+ all_rows: list[list[dict[str, Any]]],+ camera_ids: list[CameraIdString],+) -> list[dict[CameraIdString, dict[str, Any]]]:+ """Merge per-camera detection rows by frame number.+ Args:+ all_rows: One list of detection dicts per camera. Each dict must have+ a ``framenum`` key used to align frames across cameras.+ camera_ids: IDs to assign to each entry in ``all_rows``. If ``None``,+ uses integer indices (0, 1, 2, ...).-# =============================================================================-# CHARUCO BOARD-# =============================================================================+ Returns:+ List of dicts, one per unique frame number, mapping camera_id →+ that camera's detection dict for that frame (absent if not detected).+ """+ assert camera_ids is None or len(all_rows) == len(camera_ids), \+ "number of rows does not match the number of camera IDs"++++ rows_dict: dict[Any, dict[Any, dict[str, Any]]] = defaultdict(dict)+ framenums: set = set()++ for camera_id, rows in zip(camera_ids, all_rows):+ for r in rows:+ num = r["framenum"]+ rows_dict[camera_id][num] = r+ framenums.add(num)++ merged = []+ for num in sorted(framenums):+ d = {}+ for camera_id in camera_ids:+ if num in rows_dict[camera_id]:+ d[camera_id] = rows_dict[camera_id][num]+ merged.append(d)++ return merged+++def extract_points(+ merged: list[dict[CameraIdString, dict[str, Any]]],+ board: CharucoBoardDefinition,+ camera_ids: list[CameraIdString],+ min_cameras: int = 1,+ min_points: int = 4,+ check_rtvecs: bool = True,+) -> tuple[np.ndarray, BoardObservations]:+ """Extract 2-D image points and board metadata from merged detection rows.++ Args:+ merged: Output of ``merge_rows`` — list of per-frame dicts mapping+ camera_id → detection dict.+ board: Calibration board definition.+ camera_ids: Ordered camera IDs. If ``None``, inferred from row keys (sorted).+ min_cameras: Drop points seen by fewer than this many cameras.+ min_points: Minimum valid corners required in a single camera-frame.+ check_rtvecs: If True, skip frames where ``rvec``/``tvec`` are missing.++ Returns:+ Tuple of:+ image_points -- (num_cameras, N, 2) float64; NaN where unobserved.+ board_observations -- BoardObservations dict with keys:+ ``objp`` (N, 3): object points in board space,+ ``ids`` (N,): board frame indices,+ ``rvecs`` (num_cameras, N, 3): per-camera rotation vectors,+ ``tvecs`` (num_cameras, N, 3): per-camera translation vectors.+ """-class AniposeCharucoBoard(CharucoBoard):- def __init__(- self,- squaresX: int = 5,- squaresY: int = 7,- square_length: float = 1.0,- marker_length: float = 0.8,- marker_bits: int = 4,- dict_size: int = 250,- ):- super().__init__(squaresX, squaresY, square_length, marker_length, marker_bits, dict_size)- self.squaresX = squaresX- self.squaresY = squaresY- self.square_length = square_length- self.marker_length = marker_length- self.marker_bits = marker_bits- self.dict_size = dict_size-- dkey = (marker_bits, dict_size)- self.dictionary = cv2.aruco.getPredefinedDictionary(ARUCO_DICTS[dkey])-- self.board = cv2.aruco.CharucoBoard(- size=[squaresX, squaresY],- squareLength=square_length,- markerLength=marker_length,- dictionary=self.dictionary,- )- total_size = (squaresX - 1) * (squaresY - 1)- objp = np.zeros((total_size, 3), np.float64)- objp[:, :2] = np.mgrid[0: (squaresX - 1), 0: (squaresY - 1)].T.reshape(-1, 2)- objp *= square_length- self.objPoints = objp- self.empty_detection = np.zeros((total_size, 1, 2)) * np.nan- self.total_size = total_size-- def detect_markers(self, image: np.ndarray, camera=None, refine: bool = True):- gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) if len(image.shape) == 3 else image-- params = cv2.aruco.DetectorParameters()- params.cornerRefinementMethod = cv2.aruco.CORNER_REFINE_CONTOUR- params.adaptiveThreshWinSizeMin = 100- params.adaptiveThreshWinSizeMax = 700- params.adaptiveThreshWinSizeStep = 50- params.adaptiveThreshConstant = 0-- try:- corners, ids, rejectedImgPoints = cv2.aruco.detectMarkers(gray, self.dictionary, parameters=params)- except Exception:- ids = None-- if ids is None:- return [], []-- K = D = None- if camera is not None:- K = camera.get_camera_matrix()- D = camera.get_distortions()-- if refine:- detectedCorners, detectedIds, _, _ = cv2.aruco.refineDetectedMarkers(- gray, self.board, corners, ids, rejectedImgPoints, K, D, parameters=params- )- else:- detectedCorners, detectedIds = corners, ids-- return detectedCorners, detectedIds-- def detect_image(self, image: np.ndarray, camera=None):- gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) if len(image.shape) == 3 else image-- corners, ids = self.detect_markers(image, camera, refine=True)- if len(corners) > 0:- ret, detectedCorners, detectedIds = cv2.aruco.interpolateCornersCharuco(- corners, ids, gray, self.board- )- if detectedIds is None:- detectedCorners = detectedIds = np.float64([])- else:- detectedCorners = detectedIds = np.float64([])-- return detectedCorners, detectedIds-- def estimate_pose_points(- self,- camera: AniposeCamera,- corners: np.ndarray | None,- ids: np.ndarray | None,- ) -> tuple[np.ndarray | None, np.ndarray | None]:- """Estimate board pose via solvePnP using detected charuco corner positions and their known 3D locations."""- # cv2.solvePnP's DLT algorithm requires >= 6 point correspondences; skip frames below that.- if corners is None or ids is None or len(corners) < 6:- return None, None-- flat_ids = ids.flatten()- obj_points = self.objPoints[flat_ids].astype(np.float64)- img_points = corners.reshape(-1, 1, 2).astype(np.float64)-- K = camera.get_camera_matrix()- D = camera.get_distortions()-- ret, rvec, tvec = cv2.solvePnP(- objectPoints=obj_points,- imagePoints=img_points,- cameraMatrix=K,- distCoeffs=D,- )- if not ret:- return None, None- return rvec, tvec+ test = get_empty_detection(board).reshape(-1, 2)+ num_cameras = len(camera_ids)+ num_points_per_detection = test.shape[0]+ num_detections = len(merged)++ objp_template = get_object_points(board).reshape(-1, 3)++ image_points = np.full(+ (num_cameras, num_detections, num_points_per_detection, 2), np.nan, dtype="float64"+ )+ rvecs = np.full(+ (num_cameras, num_detections, num_points_per_detection, 3), np.nan, dtype="float64"+ )+ tvecs = np.full(+ (num_cameras, num_detections, num_points_per_detection, 3), np.nan, dtype="float64"+ )+ objp = np.empty((num_detections, num_points_per_detection, 3), dtype="float64")+ board_ids = np.empty((num_detections, num_points_per_detection), dtype="int32")++ for row_index, row in enumerate(merged):+ objp[row_index] = np.copy(objp_template)+ board_ids[row_index] = row_index++ for camera_index, camera_id in enumerate(camera_ids):+ if camera_id in row:+ filled = row[camera_id]["filled"].reshape(-1, 2)+ bad = np.any(np.isnan(filled), axis=1)+ num_good = np.sum(~bad)+ if num_good < min_points:+ continue++ if row[camera_id].get("rvec") is None or row[camera_id].get("tvec") is None:+ if check_rtvecs:+ continue+ row[camera_id]["rvec"] = np.full(3, np.nan, dtype="float64")+ row[camera_id]["tvec"] = np.full(3, np.nan, dtype="float64")++ image_points[camera_index, row_index] = filled+ rvecs[camera_index, row_index, ~bad] = row[camera_id]["rvec"].ravel()+ tvecs[camera_index, row_index, ~bad] = row[camera_id]["tvec"].ravel()++ image_points = np.reshape(image_points, (num_cameras, -1, 2))+ rvecs = np.reshape(rvecs, (num_cameras, -1, 3))+ tvecs = np.reshape(tvecs, (num_cameras, -1, 3))+ objp = np.reshape(objp, (-1, 3))+ board_ids = np.reshape(board_ids, (-1,))++ num_good = np.sum(~np.isnan(image_points), axis=0)[:, 0]+ good = num_good >= min_cameras++ image_points = image_points[:, good]+ rvecs = rvecs[:, good]+ tvecs = tvecs[:, good]+ objp = objp[good]+ board_ids = board_ids[good]++ board_observations = BoardObservations(+ object_points=objp,+ corner_ids=board_ids,+ rotation_vectors=rvecs,+ translation_vectors=tvecs,+ )++ return image_points, board_observationsdiff --git a/freemocap/core/tasks/calibration/anipose_calibration/run_anipose_calibration.py b/freemocap/core/tasks/calibration/anipose_calibration/run_anipose_calibration.pyindex e24b7c3f..2e3c9417 100644--- a/freemocap/core/tasks/calibration/anipose_calibration/run_anipose_calibration.py+++ b/freemocap/core/tasks/calibration/anipose_calibration/run_anipose_calibration.py@@ -1,7 +1,6 @@-"""Run anipose-based camera calibration (legacy solver).+"""Run anipose-based camera calibration using shared CameraModel types throughout.-Accepts the shared CharucoBoardDefinition and returns a CalibrationResult,-so both solver paths produce the same output type.+Accepts the shared CharucoBoardDefinition and returns a CalibrationResult."""import logging@@ -14,17 +13,20 @@ from skellytracker.trackers.base_tracker.base_tracker_abcs import BaseRecorderfrom skellytracker.trackers.charuco_tracker.charuco_observation import CharucoObservationfrom freemocap.core.pipeline.posthoc.video_group_helper import VideoMetadata-from freemocap.core.tasks.calibration.anipose_calibration.anipose_adapters import create_anipose_board, \- anipose_group_to_camera_models-from freemocap.core.tasks.calibration.anipose_calibration.helpers.calibration_helpers import \- anipose_pin_camera_zero_to_origin, \- set_charuco_board_as_groundplane, get_real_world_matrices-from freemocap.core.tasks.calibration.anipose_calibration.helpers.freemocap_anipose import AniposeCamera, \- AniposeCameraGroup-from freemocap.core.tasks.calibration.shared.calibration_models import CharucoBoardDefinition, CalibrationResult-from freemocap.core.tasks.calibration.shared.charuco_observation_aggregator import CharucoObservationAggregator+from freemocap.core.tasks.calibration.anipose_calibration.helpers.anipose_calibration_helpers import (+ pin_camera_zero_to_origin,+ set_charuco_board_as_groundplane,+)+from freemocap.core.tasks.calibration.anipose_calibration.helpers.bundle_adjust import (+ calibrate_cameras_from_rows,+)+from freemocap.core.tasks.calibration.shared.camera_intrinsics import CameraIntrinsics+from freemocap.core.tasks.calibration.shared.camera_extrinsics import CameraExtrinsics+from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from freemocap.core.tasks.calibration.shared.calibration_result import CalibrationResult+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinition+from freemocap.core.tasks.calibration.charuco_board.charuco_observation_aggregator import CharucoObservationAggregatorfrom freemocap.core.tasks.calibration.shared.groundplane_alignment import GroundPlaneResult-from freemocap.core.types.type_overloads import VideoIdStringlogger = logging.getLogger(__name__)@@ -33,42 +35,41 @@ def run_anipose_calibration(*,charuco_observations_by_frame: list[dict[CameraIdString, CharucoObservation]],board: CharucoBoardDefinition,- video_metadata: dict[VideoIdString, VideoMetadata],+ video_metadata: dict[CameraIdString, VideoMetadata],recording_info: RecordingInfo,pin_camera_0_to_origin: bool = True,- use_charuco_as_groundplane: bool = False,- init_intrinsics: bool = True,- init_extrinsics: bool = True,- verbose: bool = True,+ use_charuco_as_groundplane: bool = True,) -> tuple[CalibrationResult, GroundPlaneResult | None]:"""Run anipose calibration from charuco observations.Returns a CalibrationResult with optimized camera models."""- t_start = time.monotonic()-- anipose_cameras: list[AniposeCamera] = [- AniposeCamera(- name=video_id,- size=(video_meta.width, video_meta.height),+ t_start = time.perf_counter()++ cameras: list[CameraModel] = [+ CameraModel(+ id=camera_id,+ index=video_meta.camera_index,+ image_size=(video_meta.width, video_meta.height),+ intrinsics=CameraIntrinsics.from_image_size(+ width=video_meta.width, height=video_meta.height+ ),+ extrinsics=CameraExtrinsics.identity(),)- for video_id, video_meta in video_metadata.items()+ for camera_id, video_meta in video_metadata.items()]- anipose_camera_group = AniposeCameraGroup(cameras=anipose_cameras)- anipose_charuco_board = create_anipose_board(board=board)logger.info(f"Starting Anipose calibration with "f"{len(charuco_observations_by_frame)} frames of charuco observations")- # Aggregate all observations into anipose row formatcharuco_observation_aggregator: CharucoObservationAggregator | None = Nonefor charuco_observations_by_camera in charuco_observations_by_frame:if charuco_observation_aggregator is None:charuco_observation_aggregator = CharucoObservationAggregator.from_charuco_observation_payload(charuco_observations_by_camera=charuco_observations_by_camera,- anipose_camera_ordering=[camera.name for camera in anipose_camera_group.cameras],+ anipose_camera_ordering=[cam.id for cam in cameras],)else:charuco_observation_aggregator.add_observations(charuco_observations_by_camera)@@ -76,33 +77,25 @@ def run_anipose_calibration(if charuco_observation_aggregator is None:raise ValueError("No charuco observations were provided for calibration")- # Run anipose bundle adjustment- all_camera_rows = charuco_observation_aggregator.all_camera_rows+ all_camera_rows = charuco_observation_aggregator.to_anipose_rows(n_corners=board.n_corners)logger.info(f"Aggregated charuco observations for {len(all_camera_rows)} cameras")- error, merged, charuco_frame_numbers = anipose_camera_group.calibrate_rows(- all_camera_rows,- anipose_charuco_board,- init_intrinsics=init_intrinsics,- init_extrinsics=init_extrinsics,- verbose=verbose,++ error, merged, charuco_frame_numbers = calibrate_cameras_from_rows(+ cameras=cameras,+ all_rows=all_camera_rows,+ board=board,)logger.info(f"Anipose calibration completed — error: {error}")- # Add metadata- anipose_camera_group.metadata["groundplane_calibration"] = False- anipose_camera_group.metadata["recording_info"] = recording_info.model_dump()-- # Pin camera 0 to originif pin_camera_0_to_origin:- anipose_camera_group = anipose_pin_camera_zero_to_origin(camera_group=anipose_camera_group)+ cameras = pin_camera_zero_to_origin(cameras)logger.info("Pinned camera 0 to origin")- # Ground plane correctionground_plane_result: GroundPlaneResult | None = Noneif use_charuco_as_groundplane:- observation_recorders_by_video: dict[VideoIdString, BaseRecorder] = {- video_id: BaseRecorder() for video_id in charuco_observations_by_frame[0].keys()+ observation_recorders_by_camera: dict[CameraIdString, BaseRecorder] = {+ camera_id: BaseRecorder() for camera_id in charuco_observations_by_frame[0].keys()}for frame_number, charuco_observations_by_camera in enumerate(charuco_observations_by_frame):if not all(@@ -111,38 +104,31 @@ def run_anipose_calibration(raise ValueError(f"Non-CharucoObservation found in frame {frame_number} observations")- for video_id, recorder in observation_recorders_by_video.items():- recorder.add_observation(observation=charuco_observations_by_camera[video_id])+ for camera_id, recorder in observation_recorders_by_camera.items():+ recorder.add_observation(observation=charuco_observations_by_camera[camera_id])- anipose_camera_group, groundplane_success, ground_plane_result = set_charuco_board_as_groundplane(- observation_recorders=observation_recorders_by_video,- anipose_camera_group=anipose_camera_group,- anipose_charuco_board=anipose_charuco_board,+ cameras, groundplane_success, ground_plane_result = set_charuco_board_as_groundplane(+ observation_recorders=observation_recorders_by_camera,+ cameras=cameras,+ board=board,recording_folder_path=Path(recording_info.full_recording_path),)if groundplane_success.success:- anipose_camera_group.metadata["groundplane_calibration"] = Truelogger.info("Successfully set charuco board as groundplane")else:logger.warning(f"Failed to set groundplane: {groundplane_success.error}")- # Compute real-world camera positions and orientations- get_real_world_matrices(camera_group=anipose_camera_group)-- # Convert anipose results to shared CameraModel types- camera_models = anipose_group_to_camera_models(group=anipose_camera_group)-- elapsed = time.monotonic() - t_start+ elapsed = time.perf_counter() - t_startresult = CalibrationResult(- cameras=camera_models,+ cameras=cameras,board=board,reprojection_error_px=float(error),initial_cost=0.0,final_cost=float(error),n_iterations=0,time_seconds=elapsed,- n_observations_used=len(charuco_frame_numbers) * len(camera_models),+ n_observations_used=len(charuco_frame_numbers) * len(cameras),n_observations_rejected=0,)return result, ground_plane_resultdiff --git a/freemocap/core/tasks/calibration/calibration_task_config.py b/freemocap/core/tasks/calibration/calibration_task_config.pyindex c4170c63..e7b342b3 100644--- a/freemocap/core/tasks/calibration/calibration_task_config.py+++ b/freemocap/core/tasks/calibration/calibration_task_config.py@@ -4,7 +4,8 @@ from pydantic import BaseModel, ConfigDict, Fieldfrom skellytracker.trackers.charuco_tracker.charuco_tracker_config import CharucoDetectorConfigfrom freemocap.core.tasks.calibration.pyceres_calibration.helpers.models import PyceresCalibrationSolverConfig-from freemocap.core.tasks.calibration.shared.calibration_models import CharucoBoardDefinition+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinition+from freemocap.core.tasks.triangulation.helpers.triangulation_config import TriangulationConfigclass CalibrationSolverMethod(str, Enum):@@ -47,10 +48,15 @@ class PosthocCalibrationPipelineConfig(BaseModel):description="Align world frame to charuco board plane after calibration.",)+ triangulation_config: TriangulationConfig = Field(+ default_factory=TriangulationConfig,+ alias="triangulationConfig",+ description=(+ "Configuration for the post-calibration triangulator: simple DLT "+ "vs. subset-ensemble outlier rejection, plus the outlier-rejection knobs."+ ),+ )+@propertydef detector_config(self) -> CharucoDetectorConfig:- return CharucoDetectorConfig(- squares_x=self.charuco_board.squares_x,- squares_y=self.charuco_board.squares_y,- square_length=self.charuco_board.square_length_mm,- )+ return CharucoDetectorConfig(board=self.charuco_board)diff --git a/freemocap/core/tasks/calibration/charuco_board/__init__.py b/freemocap/core/tasks/calibration/charuco_board/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/freemocap/core/tasks/calibration/charuco_board/charuco_board_ops.py b/freemocap/core/tasks/calibration/charuco_board/charuco_board_ops.pynew file mode 100644index 00000000..a5c25385--- /dev/null+++ b/freemocap/core/tasks/calibration/charuco_board/charuco_board_ops.py@@ -0,0 +1,157 @@+"""Charuco board operations driven by CharucoBoardDefinition.++These were previously methods on AniposeCharucoBoard. Free functions here+let the bundle-adjustment solver operate directly on the shared board+definition without a parallel board class.++Detection (`detect_image` / `detect_markers` from the old AniposeCharucoBoard)+is intentionally not ported: charuco detection is performed upstream by+skellytracker, and the calibration solver only needs the geometry ++solvePnP pose-estimation half.+"""+from __future__ import annotations++from dataclasses import dataclass+from functools import lru_cache+from typing import Any++import cv2+import numpy as np+from numpy.typing import NDArray++# Integer array — ids may arrive as int32 or int64; use plain np.ndarray to+# avoid beartype rejecting a valid but narrower dtype.+IntArray = np.ndarray++from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinition++++@dataclass(frozen=True)+class _BoardCv2State:+ object_points: NDArray[np.float64]+ empty_detection: NDArray[np.float64]+ n_corners: int+++@lru_cache(maxsize=8)+def _build_state(+ squares_x: int,+ squares_y: int,+ square_length_mm: float,+) -> _BoardCv2State:+ cols = squares_x - 1+ rows = squares_y - 1+ n_corners = cols * rows+ objp = np.zeros((n_corners, 3), dtype=np.float64)+ objp[:, :2] = np.mgrid[0:cols, 0:rows].T.reshape(-1, 2)+ objp *= square_length_mm+ empty = np.full((n_corners, 1, 2), np.nan, dtype=np.float64)+ return _BoardCv2State(object_points=objp, empty_detection=empty, n_corners=n_corners)+++def _state(board: CharucoBoardDefinition) -> _BoardCv2State:+ return _build_state(board.squares_x, board.squares_y, board.square_length_mm)+++def get_object_points(board: CharucoBoardDefinition) -> NDArray[np.float64]:+ """(n_corners, 3) board-frame corner positions, Z=0 plane."""+ return _state(board).object_points+++def get_empty_detection(board: CharucoBoardDefinition) -> NDArray[np.float64]:+ """(n_corners, 1, 2) NaN-filled detection template."""+ return np.copy(_state(board).empty_detection)+++def fill_points(+ board: CharucoBoardDefinition,+ corners: np.ndarray | None,+ ids: IntArray | None,+) -> NDArray[np.float64]:+ """Scatter detected corners into a (n_corners, 1, 2) array indexed by corner id."""+ out = get_empty_detection(board)+ if corners is None or len(corners) == 0 or ids is None:+ return out+ flat_ids = ids.ravel()+ for i, cxs in zip(flat_ids, corners):+ out[i] = cxs+ return out+++def estimate_pose_points(+ board: CharucoBoardDefinition,+ camera: CameraModel,+ corners: np.ndarray | None,+ ids: IntArray | None,+) -> tuple[np.ndarray | None, np.ndarray | None]:+ """solvePnP-based board pose estimate. Returns (rvec, tvec) or (None, None).++ Requires >= 6 charuco corner correspondences (cv2.solvePnP DLT minimum).+ """+ if corners is None or ids is None or len(corners) < 6:+ return None, None++ flat_ids = ids.flatten()+ obj_points = get_object_points(board)[flat_ids].astype(np.float64)+ img_points = corners.reshape(-1, 1, 2).astype(np.float64)++ K = camera.intrinsics.to_camera_matrix()+ D = camera.intrinsics.to_dist_coeffs_5()++ ret, rvec, tvec = cv2.solvePnP(+ objectPoints=obj_points,+ imagePoints=img_points,+ cameraMatrix=K,+ distCoeffs=D,+ )+ if not ret:+ return None, None+ return rvec, tvec+++def estimate_pose_rows(+ board: CharucoBoardDefinition,+ camera: CameraModel,+ rows: list[dict[str, Any]],+) -> list[dict[str, Any]]:+ """Annotate each detection row with rvec/tvec from solvePnP."""+ for row in rows:+ rvec, tvec = estimate_pose_points(board, camera, row["corners"], row["ids"])+ row["rvec"] = rvec+ row["tvec"] = tvec+ return rows+++def fill_points_rows(+ board: CharucoBoardDefinition,+ rows: list[dict[str, Any]],+) -> list[dict[str, Any]]:+ """Annotate each detection row with a 'filled' (n_corners, 1, 2) array."""+ for row in rows:+ row["filled"] = fill_points(board, row["corners"], row["ids"])+ return rows+++def get_all_calibration_points(+ board: CharucoBoardDefinition,+ rows: list[dict[str, Any]],+ min_points: int = 5,+) -> tuple[list[NDArray[np.float32]], list[NDArray[np.float32]]]:+ """Return (object_points_per_frame, image_points_per_frame) for cv2.initCameraMatrix2D."""+ rows = fill_points_rows(board, rows)++ objpoints = get_object_points(board).reshape(-1, 3)++ all_obj: list[NDArray[np.float32]] = []+ all_img: list[NDArray[np.float32]] = []++ for row in rows:+ filled = row["filled"].reshape(-1, 2)+ good = np.all(~np.isnan(filled), axis=1)+ if np.sum(good) >= min_points:+ all_obj.append(np.float32(objpoints[good]))+ all_img.append(np.float32(filled[good]))++ return all_obj, all_imgdiff --git a/freemocap/core/tasks/calibration/charuco_board/charuco_corners.py b/freemocap/core/tasks/calibration/charuco_board/charuco_corners.pynew file mode 100644index 00000000..e75b8712--- /dev/null+++ b/freemocap/core/tasks/calibration/charuco_board/charuco_corners.py@@ -0,0 +1,38 @@+import numpy as np+from numpy._typing import NDArray+from pydantic import BaseModel, ConfigDict, field_validator+++class CornerObservation(BaseModel):+ """A single detected charuco corner in pixel coordinates."""++ model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)++ corner_id: int+ pixel_xy: NDArray[np.float64]++ @field_validator("pixel_xy", mode="before")+ @classmethod+ def validate_pixel(cls, v: NDArray[np.float64] | list | tuple) -> NDArray[np.float64]:+ arr = np.asarray(v, dtype=np.float64).ravel()+ if arr.shape != (2,):+ raise ValueError(f"pixel_xy must have shape (2,), got {arr.shape}")+ return arr+++class CharucoCornersObservation(BaseModel):+ """All charuco corners detected by one camera in one frame."""++ model_config = ConfigDict(extra="forbid")++ camera_name: str+ frame_index: int+ corners: list[CornerObservation]++ @property+ def n_corners(self) -> int:+ return len(self.corners)++ @property+ def corner_ids(self) -> list[int]:+ return [c.corner_id for c in self.corners]diff --git a/freemocap/core/tasks/calibration/charuco_board/charuco_observation_aggregator.py b/freemocap/core/tasks/calibration/charuco_board/charuco_observation_aggregator.pynew file mode 100644index 00000000..516277ee--- /dev/null+++ b/freemocap/core/tasks/calibration/charuco_board/charuco_observation_aggregator.py@@ -0,0 +1,66 @@+"""Aggregates charuco observations for the anipose calibration path.++Collects CharucoObservation objects from skellytracker and converts them+directly to anipose row dicts via CharucoObservation.to_anipose_camera_row().+"""++from pydantic import BaseModel, Field, ConfigDict, Extra+from skellycam.core.types.type_overloads import CameraIdString+from skellytracker.trackers.charuco_tracker.charuco_observation import CharucoObservation++CharucoObservations = dict[CameraIdString, CharucoObservation | None]+++class CharucoObservationAggregator(BaseModel):+ """Collects CharucoObservation objects across frames per camera."""+ model_config = ConfigDict(+ arbitrary_types_allowed=True,+ extra="forbid",+ )+ anipose_camera_ordering: list[CameraIdString]+ individual_camera_observations: dict[CameraIdString, list[CharucoObservation]] = Field(+ default_factory=dict+ )++ @classmethod+ def from_charuco_observation_payload(+ cls,+ charuco_observations_by_camera: CharucoObservations,+ anipose_camera_ordering: list[CameraIdString],+ ) -> "CharucoObservationAggregator":+ if set(charuco_observations_by_camera.keys()) != set(anipose_camera_ordering):+ raise ValueError("charuco_observations_by_camera and anipose_camera_ordering must have the same camera ids")++ camera_observations: dict[CameraIdString, list[CharucoObservation]] = {}+ for camera_id, obs in charuco_observations_by_camera.items():+ if obs is None:+ raise ValueError(+ "Cannot create CharucoObservationAggregator from payload with None observations "+ "— use nan-filled CharucoObservation instead"+ )+ camera_observations[camera_id] = [obs]++ return cls(+ individual_camera_observations=camera_observations,+ anipose_camera_ordering=anipose_camera_ordering,+ )++ @property+ def all_observations_by_camera(self) -> dict[CameraIdString, list[CharucoObservation]]:+ return {cam_id: self.individual_camera_observations[cam_id] for cam_id in self.anipose_camera_ordering}++ def to_anipose_rows(self, n_corners: int) -> list[list[dict]]:+ """Convert stored observations to anipose row dicts for calibrate_rows()."""+ return [+ [obs.to_anipose_camera_row() for obs in self.individual_camera_observations[cam_id]]+ for cam_id in self.anipose_camera_ordering+ ]++ def add_observations(self, charuco_observations_by_camera: CharucoObservations) -> None:+ for camera_id, obs in charuco_observations_by_camera.items():+ if obs is None:+ raise ValueError(+ "Cannot add None observations to CharucoObservationAggregator "+ "— use nan-filled CharucoObservation instead"+ )+ self.individual_camera_observations[camera_id].append(obs)diff --git a/freemocap/core/tasks/calibration/posthoc_calibration_task.py b/freemocap/core/tasks/calibration/posthoc_calibration_task.pyindex 601e41d2..82a574aa 100644--- a/freemocap/core/tasks/calibration/posthoc_calibration_task.py+++ b/freemocap/core/tasks/calibration/posthoc_calibration_task.py@@ -14,29 +14,29 @@ Pre-bind task_config via functools.partial when creating the pipeline.import jsonimport logging-from collections.abc import Callablefrom pathlib import Pathimport numpy as npfrom skellycam.core.recorders.videos.recording_info import RecordingInfo+from skellycam.core.types.type_overloads import CameraIdStringfrom skellytracker.trackers.base_tracker.base_tracker_abcs import BaseRecorderfrom skellytracker.trackers.charuco_tracker.charuco_observation import CharucoObservation+from freemocap.core.pipeline.posthoc.pipeline_phases import CalibrationStage+from freemocap.core.pipeline.posthoc.task_progress_reporter import TaskProgressReporterfrom freemocap.core.pipeline.posthoc.video_group_helper import VideoMetadatafrom freemocap.core.tasks.calibration.anipose_calibration.run_anipose_calibration import run_anipose_calibrationfrom freemocap.core.tasks.calibration.calibration_task_config import PosthocCalibrationPipelineConfig, \CalibrationSolverMethodfrom freemocap.core.tasks.calibration.pyceres_calibration.pyceres_calibration_pipeline import run_pyceres_calibration-from freemocap.core.tasks.calibration.shared.calibration_models import CharucoBoardDefinition, \- CharucoCornersObservation, \- CornerObservation, CalibrationResult+from freemocap.core.tasks.calibration.shared.calibration_result import CalibrationResult+from freemocap.core.tasks.calibration.charuco_board.charuco_corners import CornerObservation, CharucoCornersObservation+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinitionfrom freemocap.core.tasks.calibration.shared.calibration_paths import get_last_successful_calibration_toml_pathfrom freemocap.core.tasks.calibration.shared.calibration_save import save_calibration_copiesfrom freemocap.core.tasks.calibration.shared.compare_calibrations import compute_calibration_health-from freemocap.core.tasks.calibration.shared.groundplane_alignment import GroundPlaneResult, groundplane_metadata+from freemocap.core.tasks.calibration.shared.groundplane_alignment import GroundPlaneResultfrom freemocap.core.tasks.mocap.mocap_helpers.charuco_model_from_observations import charuco_model_from_observations-from freemocap.core.types.type_overloads import VideoIdString, TopicPublicationQueue-from freemocap.pubsub.pubsub_topics import AggregatorNodeProgressMessagefrom freemocap.utilities.toml_mixin import numpy_to_pythonlogger = logging.getLogger(__name__)@@ -62,10 +62,10 @@ def _create_board(task_config: PosthocCalibrationPipelineConfig) -> CharucoBoarddef _charuco_observation_to_frame_observation(- *,- charuco_obs: CharucoObservation,- camera_name: str,- frame_index: int,+ *,+ charuco_obs: CharucoObservation,+ camera_name: str,+ frame_index: int,) -> CharucoCornersObservation:"""Convert a skellytracker CharucoObservation to a CharucoCornersObservation.@@ -94,8 +94,8 @@ def _charuco_observation_to_frame_observation(def _convert_all_observations(- *,- charuco_observations_by_frame: list[dict[VideoIdString, CharucoObservation]],+ *,+ charuco_observations_by_frame: list[dict[CameraIdString, CharucoObservation]],) -> list[CharucoCornersObservation]:"""Convert all charuco observations to CharucoCornersObservation models."""all_frame_obs: list[CharucoCornersObservation] = []@@ -119,11 +119,11 @@ def _convert_all_observations(def _save_result(- *,- result: CalibrationResult,- recording_info: RecordingInfo,- solver_method: str,- ground_plane: GroundPlaneResult | None = None,+ *,+ result: CalibrationResult,+ recording_info: RecordingInfo,+ solver_method: str,+ ground_plane: GroundPlaneResult | None = None,) -> Path:"""Save CalibrationResult to all standard locations via anipose-compatible TOML."""metadata: dict = {@@ -131,7 +131,13 @@ def _save_result("recording_info": recording_info.model_dump(),}if ground_plane is not None:- metadata.update(groundplane_metadata(ground_plane, recording_info.recording_name))+ groundplane_metadata = {+ "groundplane_applied": True,+ "groundplane_method": ground_plane.method,+ "groundplane_recording_id": recording_info.recording_name,+ "groundplane_result": ground_plane.to_dict()+ }+ metadata.update(groundplane_metadata)recording_toml = save_calibration_copies(save_fn=lambda path: result.dump_anipose_toml(path=path, metadata=metadata),@@ -148,27 +154,27 @@ def _save_result(def _run_pyceres_path(- *,- all_observations: list[CharucoCornersObservation],- board: CharucoBoardDefinition,- task_config: PosthocCalibrationPipelineConfig,- video_metadata: dict[VideoIdString, VideoMetadata],+ *,+ all_observations: list[CharucoCornersObservation],+ board: CharucoBoardDefinition,+ task_config: PosthocCalibrationPipelineConfig,+ video_metadata: dict[CameraIdString, VideoMetadata],) -> tuple[CalibrationResult, GroundPlaneResult | None]:"""Run calibration using the pyceres bundle adjustment solver."""if len(all_observations) == 0:raise ValueError("No valid charuco observations found")- camera_names = list(video_metadata.keys())+ camera_ids = list(video_metadata.keys())image_sizes: dict[str, tuple[int, int]] = {- vid_id: (vm.width, vm.height)- for vid_id, vm in video_metadata.items()+ camera_id: (vm.width, vm.height)+ for camera_id, vm in video_metadata.items()}result, ground_plane = run_pyceres_calibration(board=board,all_observations=all_observations,image_sizes=image_sizes,- camera_names=camera_names,+ camera_ids=camera_ids,config=task_config.pyceres_solver_config,use_groundplane=task_config.use_groundplane,)@@ -187,12 +193,12 @@ def _run_pyceres_path(def _run_anipose_path(- *,- charuco_observations_by_frame: list[dict[VideoIdString, CharucoObservation]],- board: CharucoBoardDefinition,- task_config: PosthocCalibrationPipelineConfig,- recording_info: RecordingInfo,- video_metadata: dict[VideoIdString, VideoMetadata],+ *,+ charuco_observations_by_frame: list[dict[CameraIdString, CharucoObservation]],+ board: CharucoBoardDefinition,+ task_config: PosthocCalibrationPipelineConfig,+ recording_info: RecordingInfo,+ video_metadata: dict[CameraIdString, VideoMetadata],) -> tuple[CalibrationResult, GroundPlaneResult | None]:"""Run calibration using the legacy anipose solver."""logger.info("Starting anipose calibration...")@@ -218,11 +224,12 @@ def _run_anipose_path(def run_posthoc_calibration_task(- *,- frame_observations: list[dict[VideoIdString, CharucoObservation]],- recording_info: RecordingInfo,- video_metadata: dict[VideoIdString, VideoMetadata],- task_config: PosthocCalibrationPipelineConfig,+ *,+ frame_observations: list[dict[CameraIdString, CharucoObservation]],+ recording_info: RecordingInfo,+ video_metadata: dict[CameraIdString, VideoMetadata],+ task_config: PosthocCalibrationPipelineConfig,+ reporter: TaskProgressReporter | None = None,) -> None:"""Run posthoc calibration on collected charuco observations.@@ -231,21 +238,24 @@ def run_posthoc_calibration_task(that is saved via the same anipose-compatible TOML format."""- video_ids = list(video_metadata.keys())+ _reporter = reporter or TaskProgressReporter.noop()+ camera_ids = list(video_metadata.keys())++ _reporter.report(stage=CalibrationStage.VALIDATING_OBSERVATIONS, detail="Validating charuco observations")# ---- Validate all observations are CharucoObservation ----- charuco_observations_by_frame: list[dict[VideoIdString, CharucoObservation]] = []+ charuco_observations_by_frame: list[dict[CameraIdString, CharucoObservation]] = []for frame_idx, frame_obs in enumerate(frame_observations):- frame_charuco: dict[VideoIdString, CharucoObservation] = {}- for vid_id, obs in frame_obs.items():+ frame_charuco: dict[CameraIdString, CharucoObservation] = {}+ for camera_id, obs in frame_obs.items():if not isinstance(obs, CharucoObservation):raise TypeError(- f"Expected CharucoObservation for video {vid_id} frame {frame_idx}, "+ f"Expected CharucoObservation for video {camera_id} frame {frame_idx}, "f"got {type(obs).__name__}")- frame_charuco[vid_id] = obs+ frame_charuco[camera_id] = obscharuco_observations_by_frame.append(frame_charuco)- views_per_camera = {vid_id: len(charuco_observations_by_frame) for vid_id in video_ids}+ views_per_camera = {camera_id: len(charuco_observations_by_frame) for camera_id in camera_ids}logger.debug(f"Received (video id: charuco observation count): {views_per_camera}")# ---- Create shared board definition ----@@ -257,13 +267,15 @@ def run_posthoc_calibration_task()# Save observations so comparison tools can run board reconstruction tests- observations_json_path = Path(recording_info.full_recording_path) / "output_data"/"charuco_observations.json"+ observations_json_path = Path(recording_info.full_recording_path) / "output_data" / "charuco_observations.json"observations_json_path.parent.mkdir(parents=True, exist_ok=True)observations_json_path.write_text(json.dumps([numpy_to_python(obs.model_dump()) for obs in all_observations], indent=4))logger.info(f"Saved {len(all_observations)} charuco observations to {observations_json_path}")+ _reporter.report(stage=CalibrationStage.RUNNING_SOLVER, detail=f"Running {task_config.solver_method.value} solver")+# ---- Route to solver ----logger.info(f"Using calibration solver: {task_config.solver_method.value}")@@ -287,6 +299,7 @@ def run_posthoc_calibration_task(case _:raise ValueError(f"Unknown solver method: {task_config.solver_method}")+ _reporter.report(stage=CalibrationStage.SAVING_CALIBRATION, detail="Saving calibration result")# ---- Save calibration result (unified for both paths) ----_save_result(@@ -305,12 +318,12 @@ def run_posthoc_calibration_task(logger.info(f"\n{health.summary}")# ---- Build charuco board model from observations ----- observation_recorders_by_video: dict[VideoIdString, BaseRecorder] = {- vid_id: BaseRecorder() for vid_id in video_ids+ observation_recorders_by_video: dict[CameraIdString, BaseRecorder] = {+ camera_id: BaseRecorder() for camera_id in camera_ids}for charuco_obs_by_camera in charuco_observations_by_frame:- for vid_id, recorder in observation_recorders_by_video.items():- recorder.add_observation(observation=charuco_obs_by_camera[vid_id])+ for camera_id, recorder in observation_recorders_by_video.items():+ recorder.add_observation(observation=charuco_obs_by_camera[camera_id])charuco_model_from_observations(observation_recorders=observation_recorders_by_video,diff --git a/freemocap/core/tasks/calibration/pyceres_calibration/helpers/initialization.py b/freemocap/core/tasks/calibration/pyceres_calibration/helpers/initialization.pyindex 6f915790..a9ef111e 100644--- a/freemocap/core/tasks/calibration/pyceres_calibration/helpers/initialization.py+++ b/freemocap/core/tasks/calibration/pyceres_calibration/helpers/initialization.py@@ -17,9 +17,11 @@ from numpy.typing import NDArrayfrom scipy.linalg import inv as matrix_inversefrom scipy.spatial.transform import Rotation-from freemocap.core.tasks.calibration.shared.calibration_models import CharucoCornersObservation, CameraIntrinsics, \- CharucoBoardDefinition, CameraExtrinsics-from freemocap.core.tasks.calibration.shared.transform_math import make_M, robust_average_transforms, \+from freemocap.core.tasks.calibration.shared.camera_intrinsics import CameraIntrinsics+from freemocap.core.tasks.calibration.shared.camera_extrinsics import CameraExtrinsics+from freemocap.core.tasks.calibration.charuco_board.charuco_corners import CharucoCornersObservation+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinition+from freemocap.core.tasks.calibration.shared.transform_math import build_transformation_matrix, robust_average_transforms, \build_maximum_spanning_tree, find_spanning_tree_pairs, get_rtveclogger = logging.getLogger(__name__)@@ -170,7 +172,7 @@ def _estimate_board_poses(if not success:continue- poses[obs.frame_index] = make_M(rvec=rvec.ravel(), tvec=tvec.ravel())+ poses[obs.frame_index] = build_transformation_matrix(rvec=rvec.ravel(), tvec=tvec.ravel())return poses@@ -272,9 +274,9 @@ def initialize_extrinsics(graph = build_maximum_spanning_tree(connection_counts=connections,n_nodes=n_cams,- node_labels=camera_names,+ node_ids=camera_names,)- pairs = find_spanning_tree_pairs(graph=graph, root=0)+ pairs = find_spanning_tree_pairs(graph=graph)logger.info(f"Spanning tree pairs: {[(camera_names[a], camera_names[b]) for a, b in pairs]}")# Step 3: Chain pairwise transforms from root@@ -393,7 +395,7 @@ def initialize_board_poses(continue# Board pose in camera frame- T_cam_board = make_M(rvec=rvec.ravel(), tvec=tvec.ravel())+ T_cam_board = build_transformation_matrix(rvec=rvec.ravel(), tvec=tvec.ravel())# Camera extrinsics: T_cam_world (world → camera)ext = extrinsics[cam_name]diff --git a/freemocap/core/tasks/calibration/pyceres_calibration/helpers/models.py b/freemocap/core/tasks/calibration/pyceres_calibration/helpers/models.pyindex c1c669df..7af80af6 100644--- a/freemocap/core/tasks/calibration/pyceres_calibration/helpers/models.py+++ b/freemocap/core/tasks/calibration/pyceres_calibration/helpers/models.py@@ -63,6 +63,9 @@ class PyceresCalibrationSolverConfig(BaseModel):intrinsics_mode: IntrinsicsOptimizationMode = IntrinsicsOptimizationMode()intrinsics_prior_weight: float = 0.01pin_camera_0: bool = True+ # Which camera to pin at the origin during bundle adjustment. None means+ # "the first camera in the input list"+ pin_camera_id: str | None = Noneoutlier_rejection_iterations: int = 5initial_outlier_threshold_px: float = 15.0final_outlier_threshold_px: float = 2.0diff --git a/freemocap/core/tasks/calibration/pyceres_calibration/helpers/postprocessing.py b/freemocap/core/tasks/calibration/pyceres_calibration/helpers/postprocessing.pyindex e5254365..70623b89 100644--- a/freemocap/core/tasks/calibration/pyceres_calibration/helpers/postprocessing.py+++ b/freemocap/core/tasks/calibration/pyceres_calibration/helpers/postprocessing.py@@ -10,8 +10,11 @@ import numpy as npfrom numpy.typing import NDArrayfrom scipy.spatial.transform import Rotation-from freemocap.core.tasks.calibration.shared.calibration_models import CameraModel, CameraExtrinsics, \- CharucoCornersObservation, CharucoBoardDefinition+from freemocap.core.tasks.calibration.shared.camera_extrinsics import CameraExtrinsics+from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from freemocap.core.tasks.calibration.charuco_board.charuco_corners import CharucoCornersObservation+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinition+from freemocap.core.tasks.calibration.shared.camera_id_resolution import resolve_camera_id_or_raisefrom freemocap.core.tasks.calibration.shared.groundplane_alignment import GroundPlaneResult, \apply_groundplane_to_camerasfrom freemocap.core.tasks.calibration.shared.groundplane_math import find_still_charuco_frame, \@@ -28,7 +31,7 @@ logger = logging.getLogger(__name__)def pin_camera_to_origin(*,cameras: list[CameraModel],- camera_index: int = 0,+ camera_id: str,) -> list[CameraModel]:"""Re-express all camera extrinsics relative to the specified camera.@@ -37,17 +40,18 @@ def pin_camera_to_origin(Args:cameras: List of camera models with extrinsics.- camera_index: Index of the camera to place at the origin.+ camera_id: ID of the camera to place at the origin. Resolved against+ the camera list using the shared fallback ladder (exact id+ equality, then heuristic index match).Returns:New list of CameraModel with adjusted extrinsics."""- if camera_index < 0 or camera_index >= len(cameras):- raise IndexError(- f"camera_index {camera_index} out of range for {len(cameras)} cameras"- )-- ref_cam = cameras[camera_index]+ candidate_ids = [cam.id for cam in cameras]+ resolved_id = resolve_camera_id_or_raise(+ camera_id, candidate_ids, context="pin_camera_to_origin",+ )+ ref_cam = next(cam for cam in cameras if cam.id == resolved_id)R0 = ref_cam.extrinsics.rotation_matrixt0 = ref_cam.extrinsics.translation@@ -76,7 +80,7 @@ def pin_camera_to_origin(result.append(CameraModel(- name=cam.name,+ id=cam.id,image_size=cam.image_size,intrinsics=cam.intrinsics,extrinsics=new_extrinsics,@@ -84,7 +88,7 @@ def pin_camera_to_origin()logger.info(- f"Pinned camera '{cameras[camera_index].name}' to origin. "+ f"Pinned camera '{ref_cam.id}' to origin. "f"Adjusted {len(cameras)} camera extrinsics.")@@ -111,7 +115,7 @@ def _triangulate_charuco_corners((n_frames, n_corners, 3) array of triangulated 3D positions."""# Group observations by frame- cam_name_to_model = {cam.name: cam for cam in cameras}+ cam_name_to_model = {cam.id: cam for cam in cameras}frame_groups: dict[int, dict[str, CharucoCornersObservation]] = {}for obs in all_observations:if obs.frame_index not in frame_groups:diff --git a/freemocap/core/tasks/calibration/pyceres_calibration/helpers/solver.py b/freemocap/core/tasks/calibration/pyceres_calibration/helpers/solver.pyindex 60dcf071..8050580e 100644--- a/freemocap/core/tasks/calibration/pyceres_calibration/helpers/solver.py+++ b/freemocap/core/tasks/calibration/pyceres_calibration/helpers/solver.py@@ -16,8 +16,12 @@ from scipy.spatial.transform import Rotationfrom freemocap.core.tasks.calibration.pyceres_calibration.helpers.cost_functions import CharucoReprojectionCost, \IntrinsicsPriorCostfrom freemocap.core.tasks.calibration.pyceres_calibration.helpers.models import PyceresCalibrationSolverConfig-from freemocap.core.tasks.calibration.shared.calibration_models import CharucoBoardDefinition, CameraModel, \- CharucoCornersObservation, CalibrationResult, CameraIntrinsics, CameraExtrinsics+from freemocap.core.tasks.calibration.shared.camera_intrinsics import CameraIntrinsics+from freemocap.core.tasks.calibration.shared.camera_extrinsics import CameraExtrinsics+from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from freemocap.core.tasks.calibration.shared.calibration_result import CalibrationResult+from freemocap.core.tasks.calibration.charuco_board.charuco_corners import CharucoCornersObservation+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinitionlogger = logging.getLogger(__name__)@@ -132,8 +136,8 @@ def run_pyceres_bundle_adjustment(Returns:CalibrationResult with optimized camera models."""- t_start = time.monotonic()- camera_name_to_idx = {cam.name: idx for idx, cam in enumerate(cameras)}+ t_start = time.perf_counter()+ camera_name_to_idx = {cam.id: idx for idx, cam in enumerate(cameras)}board_pts_3d = board.corner_positions_board_frame# =========================================================================@@ -180,7 +184,7 @@ def run_pyceres_bundle_adjustment(for obs in obs_records:cam_obs_counts[obs.camera_name] += 1for cam in cameras:- logger.info(f" Camera '{cam.name}': {cam_obs_counts.get(cam.name, 0)} corner observations")+ logger.info(f" Camera '{cam.id}': {cam_obs_counts.get(cam.id, 0)} corner observations")# =========================================================================# ALLOCATE PARAMETER ARRAYS@@ -194,9 +198,9 @@ def run_pyceres_bundle_adjustment(cam_intrinsics_arrays: dict[str, NDArray[np.float64]] = {}for cam in cameras:- cam_quat_arrays[cam.name] = cam.extrinsics.quaternion_wxyz.copy()- cam_trans_arrays[cam.name] = cam.extrinsics.translation.copy()- cam_intrinsics_arrays[cam.name] = cam.intrinsics.to_param_array()+ cam_quat_arrays[cam.id] = cam.extrinsics.quaternion_wxyz.copy()+ cam_trans_arrays[cam.id] = cam.extrinsics.translation.copy()+ cam_intrinsics_arrays[cam.id] = cam.intrinsics.to_param_array()# Board pose parametersboard_quat_arrays: dict[int, NDArray[np.float64]] = {}@@ -213,7 +217,7 @@ def run_pyceres_bundle_adjustment(# Save initial intrinsics for prior costinitial_intrinsics: dict[str, NDArray[np.float64]] = {- cam.name: cam.intrinsics.to_param_array() for cam in cameras+ cam.id: cam.intrinsics.to_param_array() for cam in cameras}# =========================================================================@@ -258,9 +262,9 @@ def run_pyceres_bundle_adjustment(# Register camera parameter blocksfor cam in cameras:- q_arr = cam_quat_arrays[cam.name]- t_arr = cam_trans_arrays[cam.name]- i_arr = cam_intrinsics_arrays[cam.name]+ q_arr = cam_quat_arrays[cam.id]+ t_arr = cam_trans_arrays[cam.id]+ i_arr = cam_intrinsics_arrays[cam.id]problem.add_parameter_block(q_arr, 4)problem.set_manifold(q_arr, pyceres.QuaternionManifold())@@ -277,11 +281,24 @@ def run_pyceres_bundle_adjustment(pyceres.SubsetManifold(8, constant_indices),)- # Pin camera 0 extrinsics if configured+ # Pin one camera's extrinsics if configured. Defaults to the first+ # camera in the input list, but can be set explicitly via+ # config.pin_camera_id (resolved with the shared fallback ladder).if config.pin_camera_0:- cam0 = cameras[0]- problem.set_parameter_block_constant(cam_quat_arrays[cam0.name])- problem.set_parameter_block_constant(cam_trans_arrays[cam0.name])+ if config.pin_camera_id is None:+ pin_cam = cameras[0]+ else:+ from freemocap.core.tasks.calibration.shared.camera_id_resolution import (+ resolve_camera_id_or_raise,+ )+ resolved = resolve_camera_id_or_raise(+ config.pin_camera_id,+ [c.id for c in cameras],+ context="pyceres solver pin_camera_id",+ )+ pin_cam = next(c for c in cameras if c.id == resolved)+ problem.set_parameter_block_constant(cam_quat_arrays[pin_cam.id])+ problem.set_parameter_block_constant(cam_trans_arrays[pin_cam.id])# Register board pose parameter blocksfor frame_idx in sorted_frame_indices:@@ -316,13 +333,13 @@ def run_pyceres_bundle_adjustment(if config.intrinsics_prior_weight > 0:for cam in cameras:prior_cost = IntrinsicsPriorCost(- initial_intrinsics=initial_intrinsics[cam.name],+ initial_intrinsics=initial_intrinsics[cam.id],weight=config.intrinsics_prior_weight,)problem.add_residual_block(prior_cost,None,- [cam_intrinsics_arrays[cam.name]],+ [cam_intrinsics_arrays[cam.id]],)logger.info(f"Problem: {problem.num_residual_blocks()} residual blocks, "@@ -407,10 +424,10 @@ def run_pyceres_bundle_adjustment(# =========================================================================result_cameras: list[CameraModel] = []for cam in cameras:- new_intrinsics = CameraIntrinsics.from_param_array(cam_intrinsics_arrays[cam.name])+ new_intrinsics = CameraIntrinsics.from_param_array(cam_intrinsics_arrays[cam.id])- quat = cam_quat_arrays[cam.name]- trans = cam_trans_arrays[cam.name]+ quat = cam_quat_arrays[cam.id]+ trans = cam_trans_arrays[cam.id]new_extrinsics = CameraExtrinsics(quaternion_wxyz=quat.copy(),translation=trans.copy(),@@ -418,14 +435,14 @@ def run_pyceres_bundle_adjustment(result_cameras.append(CameraModel(- name=cam.name,+ id=cam.id,image_size=cam.image_size,intrinsics=new_intrinsics,extrinsics=new_extrinsics,))- elapsed = time.monotonic() - t_start+ elapsed = time.perf_counter() - t_startn_used = sum(1 for obs in obs_records if not obs.is_outlier)return CalibrationResult(diff --git a/freemocap/core/tasks/calibration/pyceres_calibration/pyceres_calibration_pipeline.py b/freemocap/core/tasks/calibration/pyceres_calibration/pyceres_calibration_pipeline.pyindex 34448f94..22820d96 100644--- a/freemocap/core/tasks/calibration/pyceres_calibration/pyceres_calibration_pipeline.py+++ b/freemocap/core/tasks/calibration/pyceres_calibration/pyceres_calibration_pipeline.py@@ -18,9 +18,10 @@ from freemocap.core.tasks.calibration.pyceres_calibration.helpers.models importfrom freemocap.core.tasks.calibration.pyceres_calibration.helpers.postprocessing import pin_camera_to_origin, \align_to_charuco_groundplanefrom freemocap.core.tasks.calibration.pyceres_calibration.helpers.solver import run_pyceres_bundle_adjustment-from freemocap.core.tasks.calibration.shared.calibration_models import CharucoBoardDefinition, \- CharucoCornersObservation, \- CalibrationResult, CameraModel+from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from freemocap.core.tasks.calibration.shared.calibration_result import CalibrationResult+from freemocap.core.tasks.calibration.charuco_board.charuco_corners import CharucoCornersObservation+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinitionfrom freemocap.core.tasks.calibration.shared.groundplane_alignment import GroundPlaneResultlogger = logging.getLogger(__name__)@@ -31,7 +32,7 @@ def run_pyceres_calibration(board: CharucoBoardDefinition,all_observations: list[CharucoCornersObservation],image_sizes: dict[str, tuple[int, int]],- camera_names: list[str],+ camera_ids: list[str],config: PyceresCalibrationSolverConfig,use_groundplane: bool = False,) -> tuple[CalibrationResult, GroundPlaneResult | None]:@@ -41,7 +42,7 @@ def run_pyceres_calibration(board: Charuco board definition.all_observations: All FrameObservation records across all cameras and frames.image_sizes: Per-camera image size as {name: (width, height)}.- camera_names: Ordered list of camera names. Camera 0 is the reference.+ camera_ids: Ordered list of camera names. Camera 0 is the reference.config: Solver configuration.use_groundplane: If True, align the world frame to the charuco board plane.@@ -51,33 +52,33 @@ def run_pyceres_calibration(# =========================================================================# VALIDATE INPUTS# =========================================================================- if len(camera_names) < 2:- raise ValueError(f"Need at least 2 cameras, got {len(camera_names)}")+ if len(camera_ids) < 2:+ raise ValueError(f"Need at least 2 cameras, got {len(camera_ids)}")if len(all_observations) == 0:raise ValueError("No observations provided")- for cam_name in camera_names:- if cam_name not in image_sizes:- raise KeyError(f"No image size for camera '{cam_name}'")+ for camera_id in camera_ids:+ if camera_id not in image_sizes:+ raise KeyError(f"No image size for camera '{camera_id}'")# Group observations by cameraobservations_by_camera: dict[str, list[CharucoCornersObservation]] = {- name: [] for name in camera_names+ name: [] for name in camera_ids}for obs in all_observations:if obs.camera_name not in observations_by_camera:raise ValueError(f"Observation references unknown camera '{obs.camera_name}'. "- f"Known cameras: {camera_names}"+ f"Known cameras: {camera_ids}")observations_by_camera[obs.camera_name].append(obs)- for cam_name in camera_names:- n_obs = len(observations_by_camera[cam_name])+ for camera_id in camera_ids:+ n_obs = len(observations_by_camera[camera_id])if n_obs == 0:- raise ValueError(f"Camera '{cam_name}' has zero observations")- logger.info(f"Camera '{cam_name}': {n_obs} frame observations")+ raise ValueError(f"Camera '{camera_id}' has zero observations")+ logger.info(f"Camera '{camera_id}': {n_obs} frame observations")# =========================================================================# STEP 1: INITIALIZE INTRINSICS@@ -103,20 +104,20 @@ def run_pyceres_calibration(board=board,observations_by_camera=observations_by_camera,intrinsics=intrinsics,- camera_names=camera_names,+ camera_names=camera_ids,)# =========================================================================# STEP 3: BUILD INITIAL CAMERA MODELS# =========================================================================initial_cameras: list[CameraModel] = []- for cam_name in camera_names:+ for camera_id in camera_ids:initial_cameras.append(CameraModel(- name=cam_name,- image_size=image_sizes[cam_name],- intrinsics=intrinsics[cam_name],- extrinsics=extrinsics[cam_name],+ id=camera_id,+ image_size=image_sizes[camera_id],+ intrinsics=intrinsics[camera_id],+ extrinsics=extrinsics[camera_id],))@@ -161,9 +162,10 @@ def run_pyceres_calibration(final_cameras = result.camerasif config.pin_camera_0:+ pin_camera_id = config.pin_camera_id or final_cameras[0].idfinal_cameras = pin_camera_to_origin(cameras=final_cameras,- camera_index=0,+ camera_id=pin_camera_id,)ground_plane_result: GroundPlaneResult | None = None@@ -203,7 +205,7 @@ def run_pyceres_calibration(for cam in result.cameras:pos = cam.extrinsics.world_positionlogger.info(- f" Camera '{cam.name}': "+ f" Camera '{cam.id}': "f"pos=({pos[0]:.1f}, {pos[1]:.1f}, {pos[2]:.1f})mm, "f"fx={cam.intrinsics.fx:.1f}, fy={cam.intrinsics.fy:.1f}")diff --git a/freemocap/core/tasks/calibration/shared/calibration_models.py b/freemocap/core/tasks/calibration/shared/calibration_models.pydeleted file mode 100644index 399e50a9..00000000--- a/freemocap/core/tasks/calibration/shared/calibration_models.py+++ /dev/null@@ -1,517 +0,0 @@-"""Shared Pydantic data models for camera calibration.--These models are the canonical representations used by both the anipose-and pyceres calibration paths. Each solver may have additional internal-models, but data flows through these shared types at the boundaries.-"""--from pathlib import Path--import cv2-import numpy as np-import toml-from numpy.typing import NDArray-from pydantic import BaseModel, ConfigDict, field_validator, model_validator, computed_field-from scipy.spatial.transform import Rotation--from freemocap.utilities.toml_mixin import TomlMixin, numpy_to_python---# =============================================================================-# BOARD DEFINITION-# =============================================================================---class CharucoBoardDefinition(BaseModel, TomlMixin):- """Known charuco board geometry — fixed, never optimized.-- Single source of truth for board parameters. Both solver paths- construct their solver-specific board representations from this.- """-- model_config = ConfigDict(extra="forbid")-- squares_x: int- squares_y: int- square_length_mm: float- marker_length_ratio: float = 0.8- marker_bits: int = 4- dict_size: int = 250-- @computed_field- @property- def aruco_marker_length_mm(self) -> float:- return self.marker_length_ratio * self.square_length_mm-- @model_validator(mode="after")- def validate_geometry(self) -> "CharucoBoardDefinition":- if self.aruco_marker_length_mm >= self.square_length_mm:- raise ValueError(- f"marker_length_mm ({self.aruco_marker_length_mm}) must be < "- f"square_length_mm ({self.square_length_mm})"- )- if self.squares_x < 2 or self.squares_y < 2:- raise ValueError(- f"Board must have at least 2x2 squares, "- f"got {self.squares_x}x{self.squares_y}"- )- return self-- @property- def n_corners(self) -> int:- """- Number of internal corners on the board, i.e. corners between- adjacent aruco markers. These are the points used as input to the calibrator- """- return (self.squares_x - 1) * (self.squares_y - 1)-- @property- def corner_positions_board_frame(self) -> NDArray[np.float64]:- """(n_corners, 3) corner positions in the board-local frame (Z=0 plane)."""- cols = self.squares_x - 1- rows = self.squares_y - 1- objp = np.zeros((cols * rows, 3), dtype=np.float64)- objp[:, :2] = np.mgrid[0:cols, 0:rows].T.reshape(-1, 2)- objp *= self.square_length_mm- return objp-- @classmethod- def create_test_data_7x5(cls) -> "CharucoBoardDefinition":- """Convenience method to create a standard 7x5 charuco board definition."""- return cls(- squares_x=7,- squares_y=5,- square_length_mm=58.0,- )-- @classmethod- def create_letter_size_5x3(cls) -> "CharucoBoardDefinition":- """Convenience method to create a standard 7x5 charuco board definition."""- return cls(- squares_x=5,- squares_y=3,- square_length_mm=54.0,- )--# =============================================================================-# INTRINSICS-# =============================================================================---class CameraIntrinsics(BaseModel, TomlMixin):- """Camera intrinsic parameters: focal length, principal point, distortion."""-- model_config = ConfigDict(extra="forbid")-- fx: float- fy: float- cx: float- cy: float- k1: float = 0.0- k2: float = 0.0- p1: float = 0.0- p2: float = 0.0-- def to_param_array(self) -> NDArray[np.float64]:- """Pack into 8-element array: [fx, fy, cx, cy, k1, k2, p1, p2]."""- return np.array(- [self.fx, self.fy, self.cx, self.cy, self.k1, self.k2, self.p1, self.p2],- dtype=np.float64,- )-- @classmethod- def from_param_array(cls, params: NDArray[np.float64]) -> "CameraIntrinsics":- """Unpack from 8-element array."""- if params.shape != (8,):- raise ValueError(f"Expected shape (8,), got {params.shape}")- return cls(- fx=float(params[0]),- fy=float(params[1]),- cx=float(params[2]),- cy=float(params[3]),- k1=float(params[4]),- k2=float(params[5]),- p1=float(params[6]),- p2=float(params[7]),- )-- def to_camera_matrix(self) -> NDArray[np.float64]:- """3x3 camera matrix K."""- return np.array(- [[self.fx, 0.0, self.cx],- [0.0, self.fy, self.cy],- [0.0, 0.0, 1.0]],- dtype=np.float64,- )-- def to_dist_coeffs(self) -> NDArray[np.float64]:- """OpenCV distortion coefficients (4-element): [k1, k2, p1, p2]."""- return np.array([self.k1, self.k2, self.p1, self.p2], dtype=np.float64)-- def to_dist_coeffs_5(self) -> NDArray[np.float64]:- """5-element distortion vector for anipose-compatible TOML: [k1, k2, p1, p2, 0]."""- return np.array([self.k1, self.k2, self.p1, self.p2, 0.0], dtype=np.float64)-- @classmethod- def from_image_size(cls, *, width: int, height: int) -> "CameraIntrinsics":- """Naive initial guess: focal length = image width, principal point = center."""- return cls(- fx=float(width),- fy=float(width),- cx=float(width) / 2.0,- cy=float(height) / 2.0,- )-- @classmethod- def from_camera_matrix_and_dist(- cls,- *,- camera_matrix: NDArray[np.float64],- dist_coeffs: NDArray[np.float64],- ) -> "CameraIntrinsics":- """Construct from a 3x3 camera matrix and distortion coefficients."""- if camera_matrix.shape != (3, 3):- raise ValueError(f"camera_matrix shape {camera_matrix.shape}, expected (3, 3)")- dist = dist_coeffs.ravel()- return cls(- fx=float(camera_matrix[0, 0]),- fy=float(camera_matrix[1, 1]),- cx=float(camera_matrix[0, 2]),- cy=float(camera_matrix[1, 2]),- k1=float(dist[0]) if len(dist) > 0 else 0.0,- k2=float(dist[1]) if len(dist) > 1 else 0.0,- p1=float(dist[2]) if len(dist) > 2 else 0.0,- p2=float(dist[3]) if len(dist) > 3 else 0.0,- )---# =============================================================================-# EXTRINSICS-# =============================================================================---class CameraExtrinsics(BaseModel, TomlMixin):- """Camera extrinsic parameters: orientation (quaternion wxyz) + translation."""-- model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)-- quaternion_wxyz: NDArray[np.float64]- translation: NDArray[np.float64]-- @field_validator("quaternion_wxyz", mode="before")- @classmethod- def validate_quaternion(cls, v: NDArray[np.float64] | list) -> NDArray[np.float64]:- arr = np.asarray(v, dtype=np.float64).ravel()- if arr.shape != (4,):- raise ValueError(f"Quaternion must have shape (4,), got {arr.shape}")- return arr-- @field_validator("translation", mode="before")- @classmethod- def validate_translation(cls, v: NDArray[np.float64] | list) -> NDArray[np.float64]:- arr = np.asarray(v, dtype=np.float64).ravel()- if arr.shape != (3,):- raise ValueError(f"Translation must have shape (3,), got {arr.shape}")- return arr-- @property- def rotation_matrix(self) -> NDArray[np.float64]:- """3x3 rotation matrix from quaternion."""- w, x, y, z = self.quaternion_wxyz- return Rotation.from_quat([x, y, z, w]).as_matrix()-- @property- def rodrigues_vector(self) -> NDArray[np.float64]:- """3-element Rodrigues rotation vector (for OpenCV compatibility)."""- rvec, _ = cv2.Rodrigues(self.rotation_matrix)- return rvec.ravel()-- @property- def world_position(self) -> NDArray[np.float64]:- """Camera position in world coordinates: -R^T @ t."""- return -self.rotation_matrix.T @ self.translation-- @property- def world_orientation(self) -> NDArray[np.float64]:- """Camera orientation as 3x3 rotation matrix (cam-to-world): R^T."""- return self.rotation_matrix.T-- @classmethod- def from_rodrigues(- cls,- *,- rvec: NDArray[np.float64],- tvec: NDArray[np.float64],- ) -> "CameraExtrinsics":- """Construct from Rodrigues rotation vector + translation."""- rmat, _ = cv2.Rodrigues(np.asarray(rvec, dtype=np.float64).ravel())- quat_xyzw = Rotation.from_matrix(rmat).as_quat()- quat_wxyz = np.array(- [quat_xyzw[3], quat_xyzw[0], quat_xyzw[1], quat_xyzw[2]],- )- return cls(- quaternion_wxyz=quat_wxyz,- translation=np.asarray(tvec, dtype=np.float64).ravel(),- )-- @classmethod- def identity(cls) -> "CameraExtrinsics":- """Identity transform (no rotation, no translation)."""- return cls(- quaternion_wxyz=np.array([1.0, 0.0, 0.0, 0.0]),- translation=np.zeros(3, dtype=np.float64),- )---# =============================================================================-# CAMERA MODEL-# =============================================================================---class CameraModel(BaseModel, TomlMixin):- """Complete camera model: intrinsics + extrinsics + metadata."""-- model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)-- name: str- image_size: tuple[int, int] # (width, height)- intrinsics: CameraIntrinsics- extrinsics: CameraExtrinsics-- @property- def projection_matrix(self) -> NDArray[np.float64]:- """Full 3x4 projection matrix P = K @ [R|t]."""- K = self.intrinsics.to_camera_matrix()- R = self.extrinsics.rotation_matrix- t = self.extrinsics.translation- Rt = np.zeros((3, 4), dtype=np.float64)- Rt[:, :3] = R- Rt[:, 3] = t- return K @ Rt---# =============================================================================-# OBSERVATIONS-# =============================================================================---class CornerObservation(BaseModel):- """A single detected charuco corner in pixel coordinates."""-- model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)-- corner_id: int- pixel_xy: NDArray[np.float64]-- @field_validator("pixel_xy", mode="before")- @classmethod- def validate_pixel(cls, v: NDArray[np.float64] | list | tuple) -> NDArray[np.float64]:- arr = np.asarray(v, dtype=np.float64).ravel()- if arr.shape != (2,):- raise ValueError(f"pixel_xy must have shape (2,), got {arr.shape}")- return arr---class CharucoCornersObservation(BaseModel):- """All charuco corners detected by one camera in one frame."""-- model_config = ConfigDict(extra="forbid")-- camera_name: str- frame_index: int- corners: list[CornerObservation]-- @property- def n_corners(self) -> int:- return len(self.corners)-- @property- def corner_ids(self) -> list[int]:- return [c.corner_id for c in self.corners]---# =============================================================================-# CALIBRATION RESULT-# =============================================================================----class CalibrationResult(BaseModel, TomlMixin):- """Output of either calibration pipeline.-- Both the anipose and pyceres paths produce this type. It can be- serialized to/from the anipose-compatible TOML format.-- Provides get_triangulator() and get_triangulator_for_cameras() to- build a Triangulator for downstream 3D reconstruction without any- anipose dependency.- """-- model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)-- cameras: list[CameraModel]- board: CharucoBoardDefinition- reprojection_error_px: float- initial_cost: float- final_cost: float- n_iterations: int- time_seconds: float- n_observations_used: int- n_observations_rejected: int-- @property- def camera_names(self) -> list[str]:- return [c.name for c in self.cameras]-- def get_camera(self, name: str) -> CameraModel:- """Look up a camera by name."""- for cam in self.cameras:- if cam.name == name:- return cam- raise KeyError(f"Camera '{name}' not found. Available: {self.camera_names}")-- # ---- Triangulator construction ------ def get_triangulator(self) -> "Triangulator":- """Build a Triangulator from this calibration's cameras.-- The Triangulator performs DLT triangulation directly from CameraModel- intrinsics/extrinsics with no anipose dependency.- """- from freemocap.core.tasks.calibration.shared.triangulator import Triangulator- return Triangulator.from_calibration_result(calibration=self)-- def get_triangulator_for_cameras(self, camera_ids: list[str]) -> "Triangulator":- """Build a Triangulator with cameras ordered to match the given IDs.-- Use this when the current session's cameras may be a subset of,- or in a different order than, the calibration's cameras.-- Raises:- KeyError: If any camera_id is not found in this calibration.- """- from freemocap.core.tasks.calibration.shared.triangulator import Triangulator-- return Triangulator.from_calibration_for_cameras(- calibration=self,- camera_ids=camera_ids,- )-- # ---- Anipose-compatible TOML (same as existing) ------ def dump_anipose_toml(- self,- path: Path,- metadata: dict | None = None,- ) -> None:- """Write anipose-compatible TOML."""- cameras_dict: dict[str, object] = {}-- for cam in self.cameras:- cameras_dict[cam.name] = {- "name": cam.name,- "size": list(cam.image_size),- "matrix": cam.intrinsics.to_camera_matrix().tolist(),- "distortions": cam.intrinsics.to_dist_coeffs_5().tolist(),- "rotation": cam.extrinsics.rodrigues_vector.tolist(),- "translation": cam.extrinsics.translation.tolist(),- "world_orientation": cam.extrinsics.world_orientation.tolist(),- "world_position": cam.extrinsics.world_position.tolist(),- }-- meta = metadata.copy() if metadata else {}- meta["reprojection_error_px"] = self.reprojection_error_px- meta["n_observations_used"] = self.n_observations_used- meta["n_observations_rejected"] = self.n_observations_rejected- meta["solver_time_seconds"] = self.time_seconds- meta["board"] = {- "squares_x": self.board.squares_x,- "squares_y": self.board.squares_y,- "square_length_mm": self.board.square_length_mm,- "marker_length_mm": self.board.aruco_marker_length_mm,- "marker_bits": self.board.marker_bits,- "dict_size": self.board.dict_size,- }- cameras_dict["metadata"] = numpy_to_python(meta)-- path = Path(path)- path.parent.mkdir(parents=True, exist_ok=True)- path.write_text(toml.dumps(cameras_dict))-- @classmethod- def load_anipose_toml(cls, path: Path) -> "CalibrationResult":- """Load from an anipose-compatible TOML calibration file."""- path = Path(path)- if not path.is_file():- raise FileNotFoundError(f"Calibration file not found: {path}")-- toml_data = toml.load(path)- metadata = toml_data.pop("metadata", {})-- cameras: list[CameraModel] = []- for key in sorted(toml_data.keys()):- d = toml_data[key]- if "name" not in d:- raise ValueError(f"TOML key '{key}' missing 'name' field")-- if "size" in d:- size = (int(d["size"][0]), int(d["size"][1]))- elif "image_size" in d:- size = (int(d["image_size"][0]), int(d["image_size"][1]))- else:- raise KeyError(f"Camera '{key}' missing 'size' or 'image_size'")-- K = np.array(d["matrix"], dtype=np.float64)- if K.shape != (3, 3):- raise ValueError(f"Camera '{key}': matrix shape {K.shape}, expected (3, 3)")-- dist = np.array(d["distortions"], dtype=np.float64).ravel()-- intrinsics = CameraIntrinsics(- fx=float(K[0, 0]),- fy=float(K[1, 1]),- cx=float(K[0, 2]),- cy=float(K[1, 2]),- k1=float(dist[0]) if len(dist) > 0 else 0.0,- k2=float(dist[1]) if len(dist) > 1 else 0.0,- p1=float(dist[2]) if len(dist) > 2 else 0.0,- p2=float(dist[3]) if len(dist) > 3 else 0.0,- )-- rvec = np.array(d["rotation"], dtype=np.float64).ravel()- tvec = np.array(d["translation"], dtype=np.float64).ravel()- extrinsics = CameraExtrinsics.from_rodrigues(rvec=rvec, tvec=tvec)-- cameras.append(- CameraModel(- name=str(d["name"]),- image_size=size,- intrinsics=intrinsics,- extrinsics=extrinsics,- )- )-- if len(cameras) == 0:- raise ValueError(f"No cameras found in {path}")-- board_meta = metadata.get("board", {})- board = CharucoBoardDefinition(- squares_x=board_meta.get("squares_x", 7),- squares_y=board_meta.get("squares_y", 5),- square_length_mm=board_meta.get("square_length_mm", 1.0),- # aruco_marker_length_mm=board_meta.get("marker_length_mm", 0.8),- marker_bits=board_meta.get("marker_bits", 4),- dict_size=board_meta.get("dict_size", 250),- )-- return cls(- cameras=cameras,- board=board,- reprojection_error_px=metadata.get("reprojection_error_px", 0.0),- initial_cost=metadata.get("initial_cost", 0.0),- final_cost=metadata.get("final_cost", 0.0),- n_iterations=metadata.get("n_iterations", 0),- time_seconds=metadata.get("solver_time_seconds", 0.0),- n_observations_used=metadata.get("n_observations_used", 0),- n_observations_rejected=metadata.get("n_observations_rejected", 0),- )diff --git a/freemocap/core/tasks/calibration/shared/calibration_result.py b/freemocap/core/tasks/calibration/shared/calibration_result.pynew file mode 100644index 00000000..b737c25e--- /dev/null+++ b/freemocap/core/tasks/calibration/shared/calibration_result.py@@ -0,0 +1,214 @@+from pathlib import Path++import numpy as np+import toml+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinition+from freemocap.core.tasks.calibration.shared.camera_intrinsics import CameraIntrinsics+from freemocap.core.tasks.calibration.shared.camera_extrinsics import CameraExtrinsics+from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from freemocap.utilities.toml_mixin import TomlMixin, numpy_to_python+from pydantic import BaseModel, ConfigDict+from skellycam.core.types.type_overloads import CameraIdString, CameraIndexInt+++class CalibrationResult(BaseModel, TomlMixin):+ """Output of either calibration pipeline.++ Both the anipose and pyceres paths produce this type. It can be+ serialized to/from the anipose-compatible TOML format.++ Provides get_triangulator() and get_triangulator_for_cameras() to+ build a Triangulator for downstream 3D reconstruction without any+ anipose dependency.+ """++ model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)++ cameras: list[CameraModel]+ board: CharucoBoardDefinition+ reprojection_error_px: float+ initial_cost: float+ final_cost: float+ n_iterations: int+ time_seconds: float+ n_observations_used: int+ n_observations_rejected: int+ groundplane_aligned: bool = False++ @property+ def camera_ids(self) -> list[str]:+ return [c.id for c in self.cameras]++ def get_camera(self, camera_id: str) -> CameraModel:+ """Look up a camera by name."""+ for cam in self.cameras:+ if cam.id == camera_id:+ return cam+ raise KeyError(f"Camera '{camera_id}' not found. Available: {self.camera_ids}")++ # ---- Triangulator construction ----++ def get_triangulator(self) -> "Triangulator":+ """Build a Triangulator from this calibration's cameras.++ The Triangulator performs DLT triangulation directly from CameraModel+ intrinsics/extrinsics with no anipose dependency.+ """+ from freemocap.core.tasks.triangulation.triangulator import Triangulator++ return Triangulator.from_calibration_result(calibration=self)++ def get_triangulator_for_cameras(self, camera_ids: list[str]) -> "Triangulator":+ """Build a Triangulator with cameras ordered to match the given IDs.++ Use this when the current session's cameras may be a subset of,+ or in a different order than, the calibration's cameras.++ Raises:+ KeyError: If any camera_id is not found in this calibration.+ """+ from freemocap.core.tasks.triangulation.triangulator import Triangulator++ return Triangulator.from_calibration_for_cameras(+ calibration=self,+ camera_ids=camera_ids,+ )++ # ---- Anipose-compatible TOML (same as existing) ----++ def dump_anipose_toml(+ self,+ path: Path,+ metadata: dict | None = None,+ ) -> None:+ """Write anipose-compatible TOML."""+ cameras_dict: dict[str, object] = {}++ for cam in self.cameras:+ cameras_dict[cam.id] = {+ "name": cam.id,+ "id": cam.id,+ "index": cam.index,+ "size": list(cam.image_size),+ "matrix": cam.intrinsics.to_camera_matrix().tolist(),+ "distortions": cam.intrinsics.to_dist_coeffs_5().tolist(),+ "rotation": cam.extrinsics.rodrigues_vector.tolist(),+ "translation": cam.extrinsics.translation.tolist(),+ "world_orientation": cam.extrinsics.world_orientation.tolist(),+ "world_position": cam.extrinsics.world_position.tolist(),+ }++ meta = metadata.copy() if metadata else {}+ meta["reprojection_error_px"] = self.reprojection_error_px+ meta["n_observations_used"] = self.n_observations_used+ meta["n_observations_rejected"] = self.n_observations_rejected+ meta["solver_time_seconds"] = self.time_seconds+ meta["board"] = {+ "squares_x": self.board.squares_x,+ "squares_y": self.board.squares_y,+ "square_length_mm": self.board.square_length_mm,+ "marker_length_mm": self.board.aruco_marker_length_mm,+ "aruco_dictionary_enum": self.board.aruco_dictionary_enum,+ }+ cameras_dict["metadata"] = numpy_to_python(meta)++ path = Path(path)+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(toml.dumps(cameras_dict))++ @classmethod+ def load_anipose_toml(cls, path: Path) -> "CalibrationResult":+ """Load from an anipose-compatible TOML calibration file."""+ path = Path(path)+ if not path.is_file():+ raise FileNotFoundError(f"Calibration file not found: {path}")++ toml_data = toml.load(path)+ metadata = toml_data.pop("metadata", {})++ cameras: list[CameraModel] = []+ for key in sorted(toml_data.keys()):+ d = toml_data[key]+ if "name" not in d:+ raise ValueError(f"TOML key '{key}' missing 'name' field")++ if "size" in d:+ size = (int(d["size"][0]), int(d["size"][1]))+ elif "image_size" in d:+ size = (int(d["image_size"][0]), int(d["image_size"][1]))+ else:+ raise KeyError(f"Camera '{key}' missing 'size' or 'image_size'")++ K = np.array(d["matrix"], dtype=np.float64)+ if K.shape != (3, 3):+ raise ValueError(f"Camera '{key}': matrix shape {K.shape}, expected (3, 3)")++ dist = np.array(d["distortions"], dtype=np.float64).ravel()++ intrinsics = CameraIntrinsics(+ fx=float(K[0, 0]),+ fy=float(K[1, 1]),+ cx=float(K[0, 2]),+ cy=float(K[1, 2]),+ k1=float(dist[0]) if len(dist) > 0 else 0.0,+ k2=float(dist[1]) if len(dist) > 1 else 0.0,+ p1=float(dist[2]) if len(dist) > 2 else 0.0,+ p2=float(dist[3]) if len(dist) > 3 else 0.0,+ )++ rvec = np.array(d["rotation"], dtype=np.float64).ravel()+ tvec = np.array(d["translation"], dtype=np.float64).ravel()+ extrinsics = CameraExtrinsics.from_rodrigues(rvec=rvec, tvec=tvec)++ camera_id = d.get("id", None)+ if camera_id is None:+ camera_id = d.get("name", None)++ cameras.append(+ CameraModel(+ id=CameraIdString(camera_id),+ index=CameraIndexInt(d["index"]),+ image_size=size,+ intrinsics=intrinsics,+ extrinsics=extrinsics,+ )+ )++ if len(cameras) == 0:+ raise ValueError(f"No cameras found in {path}")++ import cv2 as _cv2+ board_meta = metadata.get("board", {})+ # Backward compat: old TOMLs stored marker_bits + dict_size; new ones store aruco_dictionary_enum directly.+ _legacy_aruco_dicts = {+ (4, 50): _cv2.aruco.DICT_4X4_50, (4, 100): _cv2.aruco.DICT_4X4_100,+ (4, 250): _cv2.aruco.DICT_4X4_250, (4, 1000): _cv2.aruco.DICT_4X4_1000,+ (5, 50): _cv2.aruco.DICT_5X5_50, (5, 100): _cv2.aruco.DICT_5X5_100,+ (5, 250): _cv2.aruco.DICT_5X5_250, (5, 1000): _cv2.aruco.DICT_5X5_1000,+ }+ if "aruco_dictionary_enum" in board_meta:+ aruco_dict_enum = int(board_meta["aruco_dictionary_enum"])+ else:+ aruco_dict_enum = _legacy_aruco_dicts.get(+ (board_meta.get("marker_bits", 4), board_meta.get("dict_size", 250)),+ _cv2.aruco.DICT_4X4_250,+ )+ board = CharucoBoardDefinition(+ squares_x=board_meta.get("squares_x", 7),+ squares_y=board_meta.get("squares_y", 5),+ square_length_mm=board_meta.get("square_length_mm", 1.0),+ aruco_dictionary_enum=aruco_dict_enum,+ )++ return cls(+ cameras=cameras,+ board=board,+ reprojection_error_px=metadata.get("reprojection_error_px", 0.0),+ initial_cost=metadata.get("initial_cost", 0.0),+ final_cost=metadata.get("final_cost", 0.0),+ n_iterations=metadata.get("n_iterations", 0),+ time_seconds=metadata.get("solver_time_seconds", 0.0),+ n_observations_used=metadata.get("n_observations_used", 0),+ n_observations_rejected=metadata.get("n_observations_rejected", 0),+ groundplane_aligned=metadata.get("groundplane_applied", False),+ )diff --git a/freemocap/core/tasks/calibration/shared/calibration_state.py b/freemocap/core/tasks/calibration/shared/calibration_state.pyindex 5feba864..879fe140 100644--- a/freemocap/core/tasks/calibration/shared/calibration_state.py+++ b/freemocap/core/tasks/calibration/shared/calibration_state.py@@ -7,16 +7,21 @@ failure, and periodic file-change detection for hot-reloading.import loggingimport os+import timefrom pathlib import Path+from freemocap.core.pipeline.pipeline_stage_timer import PipelineStageTimer+import numpy as npfrom numpy.typing import NDArrayfrom skellycam.core.types.type_overloads import CameraIdStringfrom skellytracker.trackers.base_tracker.base_tracker_abcs import BaseObservation-from freemocap.core.tasks.calibration.shared.calibration_models import CalibrationResult+from freemocap.core.tasks.calibration.shared.calibration_result import CalibrationResultfrom freemocap.core.tasks.calibration.shared.calibration_paths import get_last_successful_calibration_toml_path-from freemocap.core.tasks.calibration.shared.triangulator import Triangulator+from freemocap.core.tasks.calibration.shared.camera_id_resolution import resolve_camera_id_or_raise+from freemocap.core.tasks.triangulation.helpers.triangulation_config import TriangulationConfig+from freemocap.core.tasks.triangulation.triangulator import Triangulatorlogger = logging.getLogger(__name__)@@ -47,6 +52,15 @@ class CalibrationStateTracker:self._consecutive_failure_count: int = 0self._calibration_path: Path | None = Noneself._calibration_file_mtime: float | None = None+ # Maps frozenset of active calibration-name strings -> pre-built sub-Triangulator.+ # Lazily populated on first frame with a given camera subset; reused thereafter.+ self._subset_triangulator_cache: dict[frozenset, Triangulator] = {}+ # Maps runtime CameraIdString -> resolved calibration camera name.+ # Lazily populated. Cleared when the incoming camera ID set changes.+ self._cam_id_name_cache: dict[str, str] = {}+ # Last seen frozenset of incoming camera IDs, for detecting camera set changes.+ self._last_incoming_cam_ids: frozenset | None = None+ # self._timer = PipelineStageTimer(name="CalibrationStateTracker")@classmethoddef create_and_try_load(cls) -> "CalibrationStateTracker":@@ -130,19 +144,23 @@ class CalibrationStateTracker:self._calibration_file_mtime = os.path.getmtime(path)logger.info(f"Loaded calibration from {path} with "- f"{len(cameras)} cameras: {[c.name for c in cameras]}"+ f"{len(cameras)} cameras: {[c.id for c in cameras]}")+ self._subset_triangulator_cache.clear()+ self._cam_id_name_cache.clear()+ self._last_incoming_cam_ids = Nonereturn Trueexcept Exception as e:logger.warning(f"Failed to load calibration from {path}: {e}", exc_info=True)return False- def try_triangulate(+ def try_angulate(self,*,frame_number: int,frame_observations_by_camera: dict[CameraIdString, BaseObservation],max_reprojection_error_px: float,+ triangulation_config: TriangulationConfig | None = None,) -> dict[str, NDArray[np.float64]] | None:"""Attempt triangulation with reprojection error gating.@@ -156,84 +174,147 @@ class CalibrationStateTracker:if not self.is_valid:return None+ if triangulation_config is None:+ triangulation_config = TriangulationConfig()+try:- calibration_camera_names = self._triangulator.camera_names+ calibration_camera_ids = self._triangulator.camera_ids- # Collect named 2D points per calibration camera- tracked_by_cam: dict[str, dict[str, NDArray[np.float64]]] = {}- for cam_id, obs in frame_observations_by_camera.items():- matched_name = _match_camera_name(- cam_id=cam_id,- calibration_camera_names=calibration_camera_names,- )- if matched_name is None:- continue- tracked_by_cam[matched_name] = {- name: np.asarray(pt, dtype=np.float64)[:2]- for name, pt in obs.to_tracked_points().items()- }+ # Detect when the incoming camera set changes (rare: reconnect, etc.)+ # and clear the name-resolution cache so stale entries don't linger.+ incoming_cam_ids: frozenset[str] = frozenset(frame_observations_by_camera.keys())+ if incoming_cam_ids != self._last_incoming_cam_ids:+ self._cam_id_name_cache.clear()+ self._last_incoming_cam_ids = incoming_cam_ids- if len(tracked_by_cam) < 2:+ # Resolve runtime cam_id -> calibration camera name once per cam.+ matched_obs_by_cam: dict[str, BaseObservation] = {}+ for cam_id, obs in frame_observations_by_camera.items():+ if cam_id not in self._cam_id_name_cache:+ self._cam_id_name_cache[cam_id] = _match_camera_name(+ cam_id=cam_id,+ calibration_camera_names=calibration_camera_ids,+ )+ matched_obs_by_cam[self._cam_id_name_cache[cam_id]] = obs++ if len(matched_obs_by_cam) < 2:return {}- # Build subset triangulator if we don't have all cameras- active_cam_names = sorted(tracked_by_cam.keys())- if set(active_cam_names) != set(calibration_camera_names):+ # Reuse a cached sub-triangulator for this camera subset; only build+ # a new one when we see a novel active-camera combination.+ active_cam_set: frozenset[str] = frozenset(matched_obs_by_cam.keys())+ if active_cam_set == frozenset(calibration_camera_ids):+ sub_triangulator = self._triangulator+ elif active_cam_set in self._subset_triangulator_cache:+ sub_triangulator = self._subset_triangulator_cache[active_cam_set]+ else:sub_triangulator = Triangulator(cameras=[cam for cam in self._triangulator.cameras- if cam.name in tracked_by_cam+ if cam.id in matched_obs_by_cam])- else:- sub_triangulator = self._triangulator- ordered_cam_names: list[str] = sub_triangulator.camera_names+ self._subset_triangulator_cache[active_cam_set] = sub_triangulator+ ordered_cam_names: list[str] = sub_triangulator.camera_idsn_cameras = len(ordered_cam_names)- # Find all point names and count how many cameras see each- all_point_names: set[str] = set()- for pts in tracked_by_cam.values():- all_point_names.update(pts.keys())-- # Keep only points visible in ≥2 cameras- point_names: list[str] = sorted(- name for name in all_point_names- if sum(1 for cam in ordered_cam_names if name in tracked_by_cam[cam]) >= 2+ # Fast path: when every observation type uses the canonical+ # PointCloud-only `to_tracked_points` (i.e. doesn't add any extra+ # named points beyond `obs.points`), and all cameras share the same+ # PointCloud names tuple, we can stack `xyz[:, :2]` arrays directly+ # and skip per-keypoint dict construction. RTMPose hits this path.+ ordered_obs: list[BaseObservation] = [+ matched_obs_by_cam[c] for c in ordered_cam_names+ ]+ first_obs = ordered_obs[0]+ canonical_names: tuple[str, ...] = first_obs.points.names+ fast_path = (+ type(first_obs).to_tracked_points is BaseObservation.to_tracked_points+ and all(+ type(o).to_tracked_points is BaseObservation.to_tracked_points+ and o.points.names == canonical_names+ for o in ordered_obs[1:]+ ))- if not point_names:- return {}-- n_points = len(point_names)-- # Build (n_cameras, n_points, 2) array with NaN for missing observations- stacked = np.full((n_cameras, n_points, 2), np.nan, dtype=np.float64)- for cam_idx, cam_name in enumerate(ordered_cam_names):- cam_points = tracked_by_cam[cam_name]- for pt_idx, pt_name in enumerate(point_names):- if pt_name in cam_points:- stacked[cam_idx, pt_idx, :] = cam_points[pt_name]-- # Triangulate: (n_cameras, 1, n_points, 2) → (1, n_points, 3)- triangulated = sub_triangulator.triangulate_array(- data2d=stacked[:, np.newaxis, :, :],+ _t0 = time.perf_counter()+ if fast_path:+ # Build (n_cameras, n_points, 2) by stacking xy slices.+ stacked = np.stack(+ [np.ascontiguousarray(o.points.xy, dtype=np.float64) for o in ordered_obs]+ )+ point_names_seq: tuple[str, ...] = canonical_names+ # Filter to points visible in ≥2 cameras+ visible_per_point = (~np.isnan(stacked[..., 0])).sum(axis=0)+ keep_mask = visible_per_point >= 2+ if not bool(keep_mask.any()):+ return {}+ if not bool(keep_mask.all()):+ stacked = stacked[:, keep_mask, :]+ point_names_seq = tuple(+ n for n, k in zip(canonical_names, keep_mask.tolist()) if k+ )+ else:+ # Fallback for observations whose `to_tracked_points` adds extra+ # named points (e.g. CharucoObservation injects per-aruco-corner+ # entries). Original dict-based assembly.+ tracked_by_cam: dict[str, dict[str, NDArray[np.float64]]] = {+ cam_name: {+ name: np.asarray(pt, dtype=np.float64)[:2]+ for name, pt in matched_obs_by_cam[cam_name].to_tracked_points().items()+ }+ for cam_name in ordered_cam_names+ }+ all_point_names: set[str] = set()+ for pts in tracked_by_cam.values():+ all_point_names.update(pts.keys())+ point_names_list: list[str] = sorted(+ name for name in all_point_names+ if sum(1 for cam in ordered_cam_names if name in tracked_by_cam[cam]) >= 2+ )+ if not point_names_list:+ return {}+ point_names_seq = tuple(point_names_list)+ stacked = np.full(+ (n_cameras, len(point_names_seq), 2), np.nan, dtype=np.float64+ )+ for cam_idx, cam_name in enumerate(ordered_cam_names):+ cam_points = tracked_by_cam[cam_name]+ for pt_idx, pt_name in enumerate(point_names_seq):+ if pt_name in cam_points:+ stacked[cam_idx, pt_idx, :] = cam_points[pt_name]+ # self._timer.record("build_stacked", (time.perf_counter() - _t0) * 1e3)++ # Triangulate the single frame+ _t0 = time.perf_counter()+ triangulation_result = sub_triangulator.triangulate(+ data2d=stacked,+ config=triangulation_config,)- points_3d = triangulated[0] # (n_points, 3)+ points_3d = triangulation_result.points_3d # (n_points, 3)+# self._timer.record("triangulate", (time.perf_counter() - _t0) * 1e3)- # Reprojection error gate+ # Reprojection error gate (in pixels, mean across valid cameras)+ _t0 = time.perf_counter()mean_reproj_error = sub_triangulator.mean_reprojection_error(points_3d=points_3d,- points_2d=stacked,+ points_2d_pixel=stacked,) # (n_points,)bad_mask = mean_reproj_error > max_reprojection_error_pxif np.any(bad_mask):points_3d[bad_mask] = np.nan+# self._timer.record("mean_reproj_error", (time.perf_counter() - _t0) * 1e3)# Build result dict, excluding NaN points- result: dict[str, NDArray[np.float64]] = {}- for i, name in enumerate(point_names):- if not np.isnan(points_3d[i]).any():- result[name] = points_3d[i]+ _t0 = time.perf_counter()+ valid_pt_mask = ~np.isnan(points_3d).any(axis=1)+ result: dict[str, NDArray[np.float64]] = {+ name: points_3d[i]+ for i, name in enumerate(point_names_seq)+ if valid_pt_mask[i]+ }+# self._timer.record("result_dict", (time.perf_counter() - _t0) * 1e3)+# self._timer.maybe_report()# Triangulation succeeded — reset failure counterself._consecutive_failure_count = 0@@ -260,6 +341,9 @@ class CalibrationStateTracker:self._triangulator = Noneself._calibration = Noneself._calibration_path = None+ self._subset_triangulator_cache.clear()+ self._cam_id_name_cache.clear()+ self._last_incoming_cam_ids = None# Preserve _calibration_file_mtime so we can detect when the file changes@@ -267,17 +351,17 @@ def _match_camera_name(*,cam_id: CameraIdString,calibration_camera_names: list[str],-) -> str | None:- """Match a runtime camera ID to a calibration camera name.-- Uses exact string matching only. Returns None (with a warning) if- no match is found.+) -> str:+ """Match a runtime camera_id to a calibration camera name.++ Uses exact equality first, then the same fallback ladder as the+ SkellyCam video filename parser (cam-prefix, trailing-int, opaque+ digit). Raises `CameraIdMismatchError` (a `KeyError`) on miss — the+ caller's existing exception handling treats this as a triangulation+ failure that increments the consecutive-failure counter."""- if cam_id in calibration_camera_names:- return cam_id-- logger.warning(- f"Camera '{cam_id}' has no exact match in calibration cameras "- f"{calibration_camera_names} — skipping this camera for triangulation"+ return resolve_camera_id_or_raise(+ cam_id,+ calibration_camera_names,+ context="runtime frame camera_id vs calibration TOML",)- return Nonediff --git a/freemocap/core/tasks/calibration/shared/camera_extrinsics.py b/freemocap/core/tasks/calibration/shared/camera_extrinsics.pynew file mode 100644index 00000000..ff40adfb--- /dev/null+++ b/freemocap/core/tasks/calibration/shared/camera_extrinsics.py@@ -0,0 +1,79 @@+import cv2+import numpy as np+from freemocap.utilities.toml_mixin import TomlMixin+from numpy._typing import NDArray+from pydantic import BaseModel, ConfigDict, field_validator+from scipy.spatial.transform import Rotation+++class CameraExtrinsics(BaseModel, TomlMixin):+ """Camera extrinsic parameters: orientation (quaternion wxyz) + translation."""++ model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)++ quaternion_wxyz: NDArray[np.float64]+ translation: NDArray[np.float64]++ @field_validator("quaternion_wxyz", mode="before")+ @classmethod+ def validate_quaternion(cls, v: NDArray[np.float64] | list) -> NDArray[np.float64]:+ arr = np.asarray(v, dtype=np.float64).ravel()+ if arr.shape != (4,):+ raise ValueError(f"Quaternion must have shape (4,), got {arr.shape}")+ return arr++ @field_validator("translation", mode="before")+ @classmethod+ def validate_translation(cls, v: NDArray[np.float64] | list) -> NDArray[np.float64]:+ arr = np.asarray(v, dtype=np.float64).ravel()+ if arr.shape != (3,):+ raise ValueError(f"Translation must have shape (3,), got {arr.shape}")+ return arr++ @property+ def rotation_matrix(self) -> NDArray[np.float64]:+ """3x3 rotation matrix from quaternion."""+ w, x, y, z = self.quaternion_wxyz+ return Rotation.from_quat([x, y, z, w]).as_matrix()++ @property+ def rodrigues_vector(self) -> NDArray[np.float64]:+ """3-element Rodrigues rotation vector (for OpenCV compatibility)."""+ rvec, _ = cv2.Rodrigues(self.rotation_matrix)+ return rvec.ravel()++ @property+ def world_position(self) -> NDArray[np.float64]:+ """Camera position in world coordinates: -R^T @ t."""+ return -self.rotation_matrix.T @ self.translation++ @property+ def world_orientation(self) -> NDArray[np.float64]:+ """Camera orientation as 3x3 rotation matrix (cam-to-world): R^T."""+ return self.rotation_matrix.T++ @classmethod+ def from_rodrigues(+ cls,+ *,+ rvec: NDArray[np.float64],+ tvec: NDArray[np.float64],+ ) -> "CameraExtrinsics":+ """Construct from Rodrigues rotation vector + translation."""+ rmat, _ = cv2.Rodrigues(np.asarray(rvec, dtype=np.float64).ravel())+ quat_xyzw = Rotation.from_matrix(rmat).as_quat()+ quat_wxyz = np.array(+ [quat_xyzw[3], quat_xyzw[0], quat_xyzw[1], quat_xyzw[2]],+ )+ return cls(+ quaternion_wxyz=quat_wxyz,+ translation=np.asarray(tvec, dtype=np.float64).ravel(),+ )++ @classmethod+ def identity(cls) -> "CameraExtrinsics":+ """Identity transform (no rotation, no translation)."""+ return cls(+ quaternion_wxyz=np.array([1.0, 0.0, 0.0, 0.0]),+ translation=np.zeros(3, dtype=np.float64),+ )diff --git a/freemocap/core/tasks/calibration/shared/camera_id_resolution.py b/freemocap/core/tasks/calibration/shared/camera_id_resolution.pynew file mode 100644index 00000000..aafaf39a--- /dev/null+++ b/freemocap/core/tasks/calibration/shared/camera_id_resolution.py@@ -0,0 +1,75 @@+"""Resolve a query camera_id against a candidate set with the same fallback+ladder used by SkellyCam's video filename parser.++Used wherever two camera-keyed surfaces have to agree (runtime frame metadata+vs calibration TOML, calibration TOML vs pin-target id, etc.). Exact-string+equality is the happy path; if that fails, both sides are run through the+heuristic index extractor (cam-prefix / trailing-int / digit) and matched on+the extracted index. If neither pass produces a hit, callers should treat that+as a hard error — silent skip is exactly the failure mode this module exists+to eliminate.+"""++from skellycam.core.recorders.videos.parse_video_filename import try_extract_camera_info+++class CameraIdMismatchError(KeyError):+ """A camera_id could not be resolved against the candidate set."""+++def _heuristic_index(camera_id: str) -> int | None:+ """Best-effort integer-index extraction from a camera_id string.++ Mirrors the SkellyCam filename parser's ladder: cam-prefix > trailing-int >+ opaque digit. Returns None when the string carries no recoverable index.+ """+ if camera_id.isdigit() and int(camera_id) <= 20:+ return int(camera_id)+ _, idx, _ = try_extract_camera_info(camera_id)+ return idx+++def resolve_camera_id(query: str, candidates: list[str]) -> str | None:+ """Match `query` to one of `candidates` using the fallback ladder.++ 1. Exact equality.+ 2. Heuristic index extraction on both sides; match by extracted index.++ Returns the matched candidate, or None if no match is found.+ """+ if query in candidates:+ return query++ query_idx = _heuristic_index(query)+ if query_idx is None:+ return None++ for cand in candidates:+ cand_idx = _heuristic_index(cand)+ if cand_idx is not None and cand_idx == query_idx:+ return cand+ return None+++def resolve_camera_id_or_raise(+ query: str,+ candidates: list[str],+ *,+ context: str = "",+) -> str:+ """Like `resolve_camera_id`, but raises `CameraIdMismatchError` on miss.++ `context` is interpolated into the error message to help the operator+ locate the mismatch (e.g. "runtime frame vs calibration TOML").+ """+ matched = resolve_camera_id(query, candidates)+ if matched is None:+ ctx = f" [{context}]" if context else ""+ raise CameraIdMismatchError(+ f"Could not resolve camera_id {query!r} against {candidates}{ctx}. "+ f"Tried exact match then heuristic index extraction "+ f"(cam-prefix / trailing-int / digit). Verify that the camera_ids "+ f"on both sides agree exactly, or share a common cam-prefix or "+ f"trailing-integer pattern."+ )+ return matcheddiff --git a/freemocap/core/tasks/calibration/shared/camera_intrinsics.py b/freemocap/core/tasks/calibration/shared/camera_intrinsics.pynew file mode 100644index 00000000..cb99961f--- /dev/null+++ b/freemocap/core/tasks/calibration/shared/camera_intrinsics.py@@ -0,0 +1,91 @@+import numpy as np+from freemocap.utilities.toml_mixin import TomlMixin+from numpy._typing import NDArray+from pydantic import BaseModel, ConfigDict+++class CameraIntrinsics(BaseModel, TomlMixin):+ """Camera intrinsic parameters: focal length, principal point, distortion."""++ model_config = ConfigDict(extra="forbid")++ fx: float+ fy: float+ cx: float+ cy: float+ k1: float = 0.0+ k2: float = 0.0+ p1: float = 0.0+ p2: float = 0.0++ def to_param_array(self) -> NDArray[np.float64]:+ """Pack into 8-element array: [fx, fy, cx, cy, k1, k2, p1, p2]."""+ return np.array(+ [self.fx, self.fy, self.cx, self.cy, self.k1, self.k2, self.p1, self.p2],+ dtype=np.float64,+ )++ @classmethod+ def from_param_array(cls, params: NDArray[np.float64]) -> "CameraIntrinsics":+ """Unpack from 8-element array."""+ if params.shape != (8,):+ raise ValueError(f"Expected shape (8,), got {params.shape}")+ return cls(+ fx=float(params[0]),+ fy=float(params[1]),+ cx=float(params[2]),+ cy=float(params[3]),+ k1=float(params[4]),+ k2=float(params[5]),+ p1=float(params[6]),+ p2=float(params[7]),+ )++ def to_camera_matrix(self) -> NDArray[np.float64]:+ """3x3 camera matrix K."""+ return np.array(+ [[self.fx, 0.0, self.cx],+ [0.0, self.fy, self.cy],+ [0.0, 0.0, 1.0]],+ dtype=np.float64,+ )++ def to_dist_coeffs(self) -> NDArray[np.float64]:+ """OpenCV distortion coefficients (4-element): [k1, k2, p1, p2]."""+ return np.array([self.k1, self.k2, self.p1, self.p2], dtype=np.float64)++ def to_dist_coeffs_5(self) -> NDArray[np.float64]:+ """5-element distortion vector for anipose-compatible TOML: [k1, k2, p1, p2, 0]."""+ return np.array([self.k1, self.k2, self.p1, self.p2, 0.0], dtype=np.float64)++ @classmethod+ def from_image_size(cls, *, width: int, height: int) -> "CameraIntrinsics":+ """Naive initial guess: focal length = image width, principal point = center."""+ return cls(+ fx=float(width),+ fy=float(width),+ cx=float(width) / 2.0,+ cy=float(height) / 2.0,+ )++ @classmethod+ def from_camera_matrix_and_dist(+ cls,+ *,+ camera_matrix: NDArray[np.float64],+ dist_coeffs: NDArray[np.float64],+ ) -> "CameraIntrinsics":+ """Construct from a 3x3 camera matrix and distortion coefficients."""+ if camera_matrix.shape != (3, 3):+ raise ValueError(f"camera_matrix shape {camera_matrix.shape}, expected (3, 3)")+ dist = dist_coeffs.ravel()+ return cls(+ fx=float(camera_matrix[0, 0]),+ fy=float(camera_matrix[1, 1]),+ cx=float(camera_matrix[0, 2]),+ cy=float(camera_matrix[1, 2]),+ k1=float(dist[0]) if len(dist) > 0 else 0.0,+ k2=float(dist[1]) if len(dist) > 1 else 0.0,+ p1=float(dist[2]) if len(dist) > 2 else 0.0,+ p2=float(dist[3]) if len(dist) > 3 else 0.0,+ )diff --git a/freemocap/core/tasks/calibration/shared/camera_model.py b/freemocap/core/tasks/calibration/shared/camera_model.pynew file mode 100644index 00000000..d8c35651--- /dev/null+++ b/freemocap/core/tasks/calibration/shared/camera_model.py@@ -0,0 +1,30 @@+import numpy as np+from freemocap.core.tasks.calibration.shared.camera_intrinsics import CameraIntrinsics+from freemocap.core.tasks.calibration.shared.camera_extrinsics import CameraExtrinsics+from freemocap.utilities.toml_mixin import TomlMixin+from numpy._typing import NDArray+from pydantic import BaseModel, ConfigDict+from skellycam.core.types.type_overloads import CameraIdString, CameraIndexInt+++class CameraModel(BaseModel, TomlMixin):+ """Complete camera model: intrinsics + extrinsics + metadata."""++ model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)++ id: CameraIdString+ index: CameraIndexInt+ image_size: tuple[int, int] # (width, height)+ intrinsics: CameraIntrinsics+ extrinsics: CameraExtrinsics++ @property+ def projection_matrix(self) -> NDArray[np.float64]:+ """Full 3x4 projection matrix P = K @ [R|t]."""+ K = self.intrinsics.to_camera_matrix()+ R = self.extrinsics.rotation_matrix+ t = self.extrinsics.translation+ Rt = np.zeros((3, 4), dtype=np.float64)+ Rt[:, :3] = R+ Rt[:, 3] = t+ return K @ Rtdiff --git a/freemocap/core/tasks/calibration/shared/camera_to_video_identity_matcher.py b/freemocap/core/tasks/calibration/shared/camera_to_video_identity_matcher.pydeleted file mode 100644index fe4cf4de..00000000--- a/freemocap/core/tasks/calibration/shared/camera_to_video_identity_matcher.py+++ /dev/null@@ -1,139 +0,0 @@-"""Camera identity: extract and match camera IDs across recordings.--Camera IDs are the stable link between calibration and future recordings.-They must survive the round-trip: hardware → video filename → calibration TOML → triangulation.--The canonical camera ID comes from CameraConfig.camera_id (a CameraIdString like "000").-Video filenames are expected to encode this ID in a parseable way.-"""--import logging-import re-from pathlib import Path--from pydantic import BaseModel, ConfigDict, model_validator--logger = logging.getLogger(__name__)--# Patterns to try, in priority order, when extracting a camera ID from a filename.-# Each pattern should have a single capture group for the camera ID.-_CAMERA_ID_PATTERNS: list[re.Pattern[str]] = [- # "rec1_camera_000.mp4" or "recording_camera_12.avi"- re.compile(r"camera[_\-](\d+)", re.IGNORECASE),- # "rec1_cam000.mp4"- re.compile(r"cam(\d+)", re.IGNORECASE),- # "000.mp4" — bare numeric filename- re.compile(r"^(\d+)\.[a-zA-Z0-9]+$"),-]---def extract_camera_id_from_filename(video_path: Path | str) -> str | None:- """Try to extract a camera ID from a video filename.-- Returns the extracted camera ID string, or None if no pattern matched.- """- filename = Path(video_path).name-- for pattern in _CAMERA_ID_PATTERNS:- match = pattern.search(filename)- if match:- return match.group(1)-- return None---def camera_ids_from_video_paths(- video_paths: list[Path | str],-) -> dict[str, Path]:- """Extract camera IDs from a list of video paths.-- Returns a dict mapping camera_id → video_path.-- If camera IDs can be extracted from filenames, those are used.- If extraction fails for ANY video, falls back to sorted positional- indices for ALL videos (to avoid mixing strategies).-- Raises:- ValueError: If extracted camera IDs have duplicates.- """- paths = [Path(p) for p in sorted(video_paths, key=lambda p: str(p))]-- # Try extracting IDs from filenames- extracted: list[str | None] = [- extract_camera_id_from_filename(p) for p in paths- ]-- if all(eid is not None for eid in extracted):- ids = [eid for eid in extracted if eid is not None] # appease type checker- if len(set(ids)) != len(ids):- raise ValueError(- f"Duplicate camera IDs extracted from filenames: {ids}"- )- logger.info(f"Extracted camera IDs from filenames: {ids}")- return {cam_id: path for cam_id, path in zip(ids, paths)}-- # Fallback: positional indices- logger.warning(- "Could not extract camera IDs from all video filenames. "- "Falling back to positional indices. "- f"Extraction results: {list(zip([p.name for p in paths], extracted))}"- )- return {str(i): path for i, path in enumerate(paths)}---class CameraGroupIdentity(BaseModel):- """Maps camera IDs to their calibrated camera models.-- Ensures a consistent, explicit mapping between the camera IDs used- in a recording session and the camera parameters from calibration.- """-- model_config = ConfigDict(extra="forbid", frozen=True)-- camera_ids: list[str]-- @model_validator(mode="after")- def _validate_unique(self) -> "CameraGroupIdentity":- if len(set(self.camera_ids)) != len(self.camera_ids):- raise ValueError(- f"Camera IDs must be unique, got: {self.camera_ids}"- )- if len(self.camera_ids) < 1:- raise ValueError("Must have at least one camera ID")- return self-- @property- def n_cameras(self) -> int:- return len(self.camera_ids)-- def index_of(self, camera_id: str) -> int:- """Get the index of a camera ID. Raises ValueError if not found."""- try:- return self.camera_ids.index(camera_id)- except ValueError:- raise ValueError(- f"Camera '{camera_id}' not in group. Known: {self.camera_ids}"- )-- def validate_against_calibration_names(- self,- calibration_camera_names: list[str],- ) -> None:- """Verify all our camera IDs exist in the calibration.-- Raises:- KeyError: If any camera ID is missing from the calibration.- """- cal_set = set(calibration_camera_names)- missing = [cid for cid in self.camera_ids if cid not in cal_set]- if missing:- raise KeyError(- f"Cameras {missing} not found in calibration. "- f"Calibration has: {calibration_camera_names}"- )-- @classmethod- def from_video_paths(cls, video_paths: list[Path | str]) -> "CameraGroupIdentity":- """Build a CameraGroupIdentity by extracting IDs from video filenames."""- id_to_path = camera_ids_from_video_paths(video_paths=video_paths)- return cls(camera_ids=list(id_to_path.keys()))diff --git a/freemocap/core/tasks/calibration/shared/charuco_observation_aggregator.py b/freemocap/core/tasks/calibration/shared/charuco_observation_aggregator.pydeleted file mode 100644index f76a8490..00000000--- a/freemocap/core/tasks/calibration/shared/charuco_observation_aggregator.py+++ /dev/null@@ -1,62 +0,0 @@-"""Aggregates charuco observations into anipose-compatible row format.--Used only by the anipose calibration path.-"""--from pydantic import BaseModel, Field-from skellycam.core.types.type_overloads import CameraIdString-from skellytracker.trackers.charuco_tracker.charuco_observation import CharucoObservation--CharucoObservations = dict[CameraIdString, CharucoObservation | None]---class CharucoObservationAggregator(BaseModel):- """Collects charuco observations across frames into anipose row format."""-- anipose_camera_ordering: list[CameraIdString]- individual_camera_rows: dict[CameraIdString, list] = Field(default_factory=dict)-- @classmethod- def from_charuco_observation_payload(- cls,- charuco_observations_by_camera: CharucoObservations,- anipose_camera_ordering: list[CameraIdString],- ) -> "CharucoObservationAggregator":- if set(charuco_observations_by_camera.keys()) != set(anipose_camera_ordering):- raise ValueError("individual_camera_rows and anipose_camera_ordering must have the same camera ids")-- camera_rows: dict[CameraIdString, list] = {}- for camera_id, charuco_observation in charuco_observations_by_camera.items():- if charuco_observation is None:- raise ValueError(- "Cannot create CharucoObservationAggregator from payload with None observations "- "— use nan-filled CharucoObservation instead"- )- anipose_camera_row = charuco_observation.to_anipose_camera_row()- if anipose_camera_row is None:- raise ValueError(- "Cannot create CharucoObservationAggregator from payload with None anipose row "- "— use nan-filled CharucoObservation instead"- )- camera_rows[camera_id] = [anipose_camera_row]-- return cls(individual_camera_rows=camera_rows, anipose_camera_ordering=anipose_camera_ordering)-- @property- def all_camera_rows(self) -> list[list]:- return [self.individual_camera_rows[cam_id] for cam_id in self.anipose_camera_ordering]-- def add_observations(self, charuco_observations_by_camera: CharucoObservations) -> None:- for camera_id, charuco_observation in charuco_observations_by_camera.items():- if charuco_observation is None:- raise ValueError(- "Cannot add None observations to CharucoObservationAggregator "- "— use nan-filled CharucoObservation instead"- )- anipose_camera_row = charuco_observation.to_anipose_camera_row()- if anipose_camera_row is None:- raise ValueError(- "Cannot add None anipose row to CharucoObservationAggregator "- "— use nan-filled CharucoObservation instead"- )- self.individual_camera_rows[camera_id].append(anipose_camera_row)diff --git a/freemocap/core/tasks/calibration/shared/compare_calibrations.py b/freemocap/core/tasks/calibration/shared/compare_calibrations.pyindex 30df2454..d9b11819 100644--- a/freemocap/core/tasks/calibration/shared/compare_calibrations.py+++ b/freemocap/core/tasks/calibration/shared/compare_calibrations.py@@ -11,8 +11,11 @@ import numpy as npfrom numpy.typing import NDArrayfrom pydantic import BaseModel, ConfigDict-from freemocap.core.tasks.calibration.shared.calibration_models import CharucoBoardDefinition, CameraModel, \- CharucoCornersObservation, CalibrationResult+from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from freemocap.core.tasks.calibration.shared.calibration_result import CalibrationResult+from freemocap.core.tasks.calibration.charuco_board.charuco_corners import CharucoCornersObservation+from skellytracker.trackers.charuco_tracker import CharucoBoardDefinition+from skellycam.core.types.type_overloads import CameraIdString, CameraIndexIntlogger = logging.getLogger(__name__)@@ -92,7 +95,7 @@ def _triangulate_board_frame(Returns:(n_corners, 3) array with NaN for corners that couldn't be triangulated."""- cam_by_name = {cam.name: cam for cam in cameras}+ cam_by_name = {cam.id: cam for cam in cameras}result = np.full((n_corners, 3), np.nan, dtype=np.float64)for corner_id in range(n_corners):@@ -167,7 +170,8 @@ class PerCameraHealth(BaseModel):model_config = ConfigDict(extra="forbid")- camera_name: str+ camera_id: CameraIdString+ camera_index: CameraIndexIntfx: floatfy: floatcx: float@@ -187,7 +191,7 @@ class PerCameraHealth(BaseModel):fl_flag = "✓" if self.focal_length_reasonable else "✗"pp_flag = "✓" if self.principal_point_reasonable else "✗"return (- f" {self.camera_name}:\n"+ f" Camera#{self.camera_index}: {self.camera_id}:\n"f" Focal length: fx={self.fx:.1f} fy={self.fy:.1f} "f"(fx/fy={self.fx_fy_ratio:.3f}) [{fl_flag}]\n"f" Principal point: cx={self.cx:.1f} cy={self.cy:.1f} "@@ -292,7 +296,8 @@ def compute_calibration_health(fx_fy_ratio = i.fx / i.fy if i.fy != 0 else float("inf")per_camera.append(PerCameraHealth(- camera_name=cam.name,+ camera_id=cam.id,+ camera_index = cam.index,fx=i.fx, fy=i.fy, cx=i.cx, cy=i.cy,k1=i.k1, k2=i.k2,image_width=w, image_height=h,@@ -345,8 +350,8 @@ class CameraComparisonResult(BaseModel):model_config = ConfigDict(extra="forbid")- camera_name: str-+ camera_id: CameraIdString+ camera_index: CameraIndexIntfx_a: floatfx_b: floatfy_a: float@@ -371,7 +376,7 @@ class CameraComparisonResult(BaseModel):@propertydef summary(self) -> str:return (- f" Camera '{self.camera_name}':\n"+ f" Camera #{self.camera_index}: '{self.camera_id}':\n"f" Focal length: A=({self.fx_a:.1f}, {self.fy_a:.1f}) "f"B=({self.fx_b:.1f}, {self.fy_b:.1f}) "f"Δ={self.focal_length_delta_px:.2f}px\n"@@ -474,7 +479,8 @@ def _compare_single_camera()return CameraComparisonResult(- camera_name=cam_a.name,+ camera_id=cam_a.id,+ camera_index=cam_a.index,fx_a=ia.fx, fx_b=ib.fx,fy_a=ia.fy, fy_b=ib.fy,cx_a=ia.cx, cx_b=ib.cx,@@ -510,8 +516,8 @@ def compare_calibration_results(all_observations: If provided, runs board reconstruction accuracytest for both calibrations using the same observations."""- names_a = set(result_a.camera_names)- names_b = set(result_b.camera_names)+ names_a = set(result_a.camera_ids)+ names_b = set(result_b.camera_ids)if names_a != names_b:raise ValueError(f"Camera name mismatch: {label_a} has {sorted(names_a)}, "diff --git a/freemocap/core/tasks/calibration/shared/feet_groundplane.py b/freemocap/core/tasks/calibration/shared/feet_groundplane.pydeleted file mode 100644index a14de8db..00000000--- a/freemocap/core/tasks/calibration/shared/feet_groundplane.py+++ /dev/null@@ -1,148 +0,0 @@-"""Estimate ground plane from person's foot marker positions.--Ported from skellyforge's Human.put_skeleton_on_ground() method.-Returns a GroundPlaneResult that can be applied to camera extrinsics-via apply_groundplane_to_cameras().-"""--import logging--import numpy as np-from numpy.typing import NDArray--from freemocap.core.tasks.calibration.shared.groundplane_alignment import GroundPlaneResult--logger = logging.getLogger(__name__)--REQUIRED_FOOT_MARKERS = [- "left_heel",- "right_heel",- "left_foot_index",- "right_foot_index",-]--UP_DIRECTION_MARKERS = [- "left_shoulder",- "right_shoulder",-]---def _find_still_frame(trajectories: NDArray[np.float64]) -> int:- """Find frame where foot markers are most stationary.-- Args:- trajectories: (n_frames, n_markers, 3) foot marker positions.-- Returns:- Frame index with minimum maximum velocity across markers.- """- velocity = np.linalg.norm(np.diff(trajectories, axis=0), axis=2)- visible_frames = ~np.isnan(velocity).any(axis=1)-- if not visible_frames.any():- raise ValueError("No frames with all foot markers visible")-- max_velocity_per_frame = np.nanmax(velocity[visible_frames], axis=1)- lowest_velocity_idx = int(np.nanargmin(max_velocity_per_frame))- return int(np.where(visible_frames)[0][lowest_velocity_idx])---def _get_unit_vector(vector: NDArray[np.float64]) -> NDArray[np.float64]:- norm = np.linalg.norm(vector)- if norm < 1e-10:- raise ValueError("Cannot normalize near-zero vector")- return vector / norm---def estimate_groundplane_from_feet(- skeleton_3d: NDArray[np.float64],- marker_name_to_index: dict[str, int],-) -> GroundPlaneResult | None:- """Estimate ground plane from foot marker positions.-- Uses the skellyforge approach: find still frame, compute basis vectors- from foot positions and shoulder midpoint (neck_center proxy).-- Args:- skeleton_3d: (n_frames, n_markers, 3) triangulated skeleton data.- marker_name_to_index: Mapping of marker names to indices in the- skeleton_3d array. Must contain left_heel, right_heel,- left_foot_index, right_foot_index, left_shoulder, right_shoulder.-- Returns:- GroundPlaneResult, or None if required markers are missing.- """- # Validate required markers- all_required = REQUIRED_FOOT_MARKERS + UP_DIRECTION_MARKERS- missing = [m for m in all_required if m not in marker_name_to_index]- if missing:- logger.warning(f"Missing markers for feet ground plane: {missing}")- return None-- # Extract foot trajectories: (n_frames, 4, 3)- foot_indices = [marker_name_to_index[m] for m in REQUIRED_FOOT_MARKERS]- foot_trajectories = skeleton_3d[:, foot_indices, :]-- # Find still frame- try:- still_frame = _find_still_frame(foot_trajectories)- except ValueError as e:- logger.warning(f"Could not find still frame for feet ground plane: {e}")- return None-- logger.info(f"Using frame {still_frame} for feet ground plane estimation")-- # Center = mean of 4 foot markers at still frame- center = np.mean(foot_trajectories[still_frame], axis=0)- if np.isnan(center).any():- logger.warning("Foot marker center contains NaN at still frame")- return None-- # Forward direction: center → midpoint of foot_index markers- left_foot_index_pos = skeleton_3d[still_frame, marker_name_to_index["left_foot_index"]]- right_foot_index_pos = skeleton_3d[still_frame, marker_name_to_index["right_foot_index"]]- mid_foot_index = (left_foot_index_pos + right_foot_index_pos) / 2-- # Up direction: center → neck_center (midpoint of shoulders)- left_shoulder = skeleton_3d[still_frame, marker_name_to_index["left_shoulder"]]- right_shoulder = skeleton_3d[still_frame, marker_name_to_index["right_shoulder"]]- neck_center = (left_shoulder + right_shoulder) / 2-- try:- forward = _get_unit_vector(mid_foot_index - center)- up = _get_unit_vector(neck_center - center)-- x_hat = _get_unit_vector(np.cross(forward, up))- y_hat = _get_unit_vector(np.cross(up, x_hat))- z_hat = _get_unit_vector(np.cross(x_hat, y_hat))- except ValueError as e:- logger.warning(f"Could not compute basis vectors for feet ground plane: {e}")- return None-- rotation_matrix = np.column_stack([x_hat, y_hat, z_hat])-- return GroundPlaneResult(- origin=center,- rotation_matrix=rotation_matrix,- method="feet",- )---def build_mediapipe_body_marker_name_to_index() -> dict[str, int]:- """Build marker name → index mapping for mediapipe body landmarks.-- The body landmarks are the first 33 markers in the mediapipe skeleton- array, in the order defined by mediapipe_model_info.yaml.- """- names = [- "nose", "left_eye_inner", "left_eye", "left_eye_outer",- "right_eye_inner", "right_eye", "right_eye_outer",- "left_ear", "right_ear", "mouth_left", "mouth_right",- "left_shoulder", "right_shoulder", "left_elbow", "right_elbow",- "left_wrist", "right_wrist", "left_pinky", "right_pinky",- "left_index", "right_index", "left_thumb", "right_thumb",- "left_hip", "right_hip", "left_knee", "right_knee",- "left_ankle", "right_ankle", "left_heel", "right_heel",- "left_foot_index", "right_foot_index",- ]- return {name: idx for idx, name in enumerate(names)}diff --git a/freemocap/core/tasks/calibration/shared/groundplane_alignment.py b/freemocap/core/tasks/calibration/shared/groundplane_alignment.pyindex e0e54e51..93c0f574 100644--- a/freemocap/core/tasks/calibration/shared/groundplane_alignment.py+++ b/freemocap/core/tasks/calibration/shared/groundplane_alignment.py@@ -14,10 +14,8 @@ import numpy as npfrom numpy.typing import NDArrayfrom scipy.spatial.transform import Rotation-from freemocap.core.tasks.calibration.shared.calibration_models import (- CameraExtrinsics,- CameraModel,-)+from freemocap.core.tasks.calibration.shared.camera_extrinsics import CameraExtrinsics+from freemocap.core.tasks.calibration.shared.camera_model import CameraModellogger = logging.getLogger(__name__)@@ -30,6 +28,13 @@ class GroundPlaneResult:rotation_matrix: NDArray[np.float64] # (3,3) [x_hat | y_hat | z_hat]method: str # "charuco" or "feet"+ def to_dict(self) -> dict:+ return {+ "origin": list(self.origin),+ "rotation_matrix": list(self.rotation_matrix),+ "method": self.method,+ }+def apply_groundplane_to_cameras(cameras: list[CameraModel],@@ -70,7 +75,7 @@ def apply_groundplane_to_cameras(result.append(CameraModel(- name=cam.name,+ id=cam.id,image_size=cam.image_size,intrinsics=cam.intrinsics,extrinsics=CameraExtrinsics(@@ -84,15 +89,3 @@ def apply_groundplane_to_cameras(f"Ground plane alignment complete (method: {ground_plane.method})")return result---def groundplane_metadata(- ground_plane: GroundPlaneResult,- recording_id: str,-) -> dict:- """Return metadata dict to merge into calibration TOML."""- return {- "groundplane_applied": True,- "groundplane_method": ground_plane.method,- "groundplane_recording_id": recording_id,- }diff --git a/freemocap/core/tasks/calibration/shared/groundplane_math.py b/freemocap/core/tasks/calibration/shared/groundplane_math.pyindex 9eb71830..b69a5961 100644--- a/freemocap/core/tasks/calibration/shared/groundplane_math.py+++ b/freemocap/core/tasks/calibration/shared/groundplane_math.py@@ -92,6 +92,8 @@ def find_still_charuco_frame(squares_y: int,search_start: int = 0,search_range: int = 120,+ max_allowed_velocity:float=1.0+) -> int:"""Find the frame where the charuco board is most stationary.@@ -133,10 +135,9 @@ def find_still_charuco_frame(max_velocity_per_frame = np.nanmax(velocity[visible], axis=1)- MAX_ALLOWED_VELOCITY = 1.0- if np.nanmin(max_velocity_per_frame) > MAX_ALLOWED_VELOCITY:+ if np.nanmin(max_velocity_per_frame) > max_allowed_velocity:raise CharucoVelocityError(- f"All frames have ChArUco corner velocity > {MAX_ALLOWED_VELOCITY:.2f} — "+ f"All frames have ChArUco corner velocity > {max_allowed_velocity:.2f} — "f"check that the board is stationary.")diff --git a/freemocap/core/tasks/calibration/shared/interpolate_trajectories.py b/freemocap/core/tasks/calibration/shared/interpolate_trajectories.pynew file mode 100644index 00000000..3f8a7dbf--- /dev/null+++ b/freemocap/core/tasks/calibration/shared/interpolate_trajectories.py@@ -0,0 +1,67 @@+import numpy as np+import scipy.interpolate+++def interpolate_trajectory_data(+ trajectory_data: np.ndarray,+ method_to_use: str = "linear",+ order: int = 3,+) -> np.ndarray:+ """Interpolate missing NaN values in a numpy array of shape (n_frames, n_markers, 3).++ Args:+ trajectory_data: (n_frames, n_markers, 3) array with possible NaN gaps.+ method_to_use: 'linear', 'polynomial', or 'cubic'.+ order: Polynomial order (only used when method_to_use='polynomial').++ Returns:+ Interpolated array of same shape with NaN gaps filled.+ """+ if trajectory_data.ndim != 3 or trajectory_data.shape[2] != 3:+ raise ValueError(f"Expected shape (n_frames, n_markers, 3), got {trajectory_data.shape}")++ if method_to_use not in ("linear", "polynomial", "cubic"):+ raise ValueError(+ f"Unknown interpolation method: {method_to_use!r}. Must be 'linear', 'polynomial', or 'cubic'.")++ n_frames, n_markers, n_dims = trajectory_data.shape+ interpolated = trajectory_data.copy()+ all_frames = np.arange(n_frames)++ for marker in range(n_markers):+ for dim in range(n_dims):+ series = trajectory_data[:, marker, dim]+ valid_mask = np.isfinite(series)++ if not np.any(valid_mask):+ raise ValueError(f"Marker {marker} dim {dim} is entirely NaN — cannot interpolate.")++ if np.all(valid_mask):+ continue++ valid_frames = all_frames[valid_mask]+ valid_values = series[valid_mask]+ nan_frames = all_frames[~valid_mask]++ if method_to_use == "linear":+ # np.interp clamps to edge values for out-of-bounds frames+ interpolated[nan_frames, marker, dim] = np.interp(nan_frames, valid_frames, valid_values)++ elif method_to_use == "polynomial":+ interp_fn = scipy.interpolate.interp1d(+ valid_frames,+ valid_values,+ kind=order,+ bounds_error=False,+ fill_value=(valid_values[0], valid_values[-1]),+ )+ interpolated[nan_frames, marker, dim] = interp_fn(nan_frames)++ elif method_to_use == "cubic":+ interp_fn = scipy.interpolate.CubicSpline(valid_frames, valid_values, extrapolate=False)+ result = interp_fn(nan_frames)+ result[nan_frames < valid_frames[0]] = valid_values[0]+ result[nan_frames > valid_frames[-1]] = valid_values[-1]+ interpolated[nan_frames, marker, dim] = result++ return interpolateddiff --git a/freemocap/core/tasks/calibration/shared/transform_math.py b/freemocap/core/tasks/calibration/shared/transform_math.pyindex 781b8c42..539d01c2 100644--- a/freemocap/core/tasks/calibration/shared/transform_math.py+++ b/freemocap/core/tasks/calibration/shared/transform_math.py@@ -15,11 +15,12 @@ import numpy as npfrom numpy.typing import NDArrayfrom scipy.cluster.hierarchy import linkage, fclusterfrom scipy.cluster.vq import whiten+from skellycam.core.types.type_overloads import CameraIdStringlogger = logging.getLogger(__name__)-def make_M(rvec: NDArray[np.float64], tvec: NDArray[np.float64]) -> NDArray[np.float64]:+def build_transformation_matrix(rvec: NDArray[np.float64], tvec: NDArray[np.float64]) -> NDArray[np.float64]:"""Build a 4x4 rigid transformation matrix from a Rodrigues rotation vector and translation.Args:@@ -123,7 +124,7 @@ def mean_transform(matrices: list[NDArray[np.float64]]) -> NDArray[np.float64]:if np.any(np.isnan(mean_tvec)):raise ValueError(f"NaN in mean tvec: {mean_tvec}")- return make_M(mean_rvec, mean_tvec)+ return build_transformation_matrix(mean_rvec, mean_tvec)def mean_transform_robust(@@ -227,34 +228,33 @@ def robust_average_transforms(transforms: list[NDArray[np.float64]]) -> NDArray[def build_maximum_spanning_tree(- connection_counts: dict[tuple[int, int], int],+ connection_counts: dict[tuple[CameraIdString, CameraIdString], int],n_nodes: int,- node_labels: list[str] | None = None,-) -> dict[int, list[int]]:+ node_ids: list[str] ,+) -> dict[CameraIdString, list[CameraIdString]]:"""Build a maximum spanning tree from weighted edges via greedy Kruskal.Args:connection_counts: Mapping of (node_a, node_b) → weight for all pairs(both directions, i.e. (a,b) and (b,a)).n_nodes: Total number of nodes.- node_labels: Human-readable labels for error messages.+ node_ids: Human-readable labels for error messages.Returns:- Adjacency list representation of the spanning tree.+ Adjacency list representation of the spanning treeRaises:ValueError: If the graph cannot be connected."""- if node_labels is None:- node_labels = [str(i) for i in range(n_nodes)]- components = {i: i for i in range(n_nodes)}++ components = {node_id: node_id for node_id in node_ids}edges = set(connection_counts.items())- graph: dict[int, list[int]] = defaultdict(list)+ graph: dict[CameraIdString, list[CameraIdString]] = defaultdict(list)for _ in range(n_nodes - 1):if len(edges) == 0:- comp_map = {node_labels[k]: v for k, v in components.items()}+ comp_map = {node_ids[k]: v for k, v in components.items()}raise ValueError(f"Cannot build connected calibration graph. "f"Some cameras have no shared board observations. "@@ -280,9 +280,9 @@ def build_maximum_spanning_tree(def find_spanning_tree_pairs(- graph: dict[int, list[int]],- root: int = 0,-) -> list[tuple[int, int]]:+ graph: dict[CameraIdString, list[CameraIdString]],+ root: CameraIdString|None = None,+) -> list[tuple[CameraIdString, CameraIdString]]:"""BFS from root to produce (parent, child) pairs for the spanning tree.Args:@@ -292,9 +292,11 @@ def find_spanning_tree_pairs(Returns:List of (parent, child) tuples in BFS order."""- pairs: list[tuple[int, int]] = []- visited: set[int] = set()- q: queue.Queue[int] = queue.Queue()+ if root is None:+ root = list(graph.keys())[0]+ pairs: list[tuple[CameraIdString, CameraIdString]] = []+ visited: set[CameraIdString] = set()+ q: queue.Queue[CameraIdString] = queue.Queue()q.put(root)visited.add(root)diff --git a/freemocap/core/tasks/calibration/shared/triangulator.py b/freemocap/core/tasks/calibration/shared/triangulator.pydeleted file mode 100644index 13a5b7cc..00000000--- a/freemocap/core/tasks/calibration/shared/triangulator.py+++ /dev/null@@ -1,322 +0,0 @@-"""Triangulator: pure DLT triangulation from CameraModel list.--No dependency on anipose. Works directly with the Pydantic CameraModel-and CalibrationResult types from calibration_models.py.-"""--import logging--import cv2-import numpy as np-from numpy.typing import NDArray-from pydantic import BaseModel, ConfigDict, model_validator--from freemocap.core.tasks.calibration.shared.calibration_models import CameraModel, CalibrationResult--logger = logging.getLogger(__name__)---def _undistort_points(- points_2d: NDArray[np.float64],- camera: CameraModel,-) -> NDArray[np.float64]:- """Undistort 2D points using camera intrinsics. Returns normalized coordinates."""- pts = points_2d.reshape(-1, 1, 2).astype(np.float64)- K = camera.intrinsics.to_camera_matrix()- dist = camera.intrinsics.to_dist_coeffs()- undistorted = cv2.undistortPoints(pts, K, dist)- return undistorted.reshape(-1, 2)---def _triangulate_single_point(- normalized_points: NDArray[np.float64],- extrinsics_mats: NDArray[np.float64],-) -> NDArray[np.float64]:- """Triangulate a single 3D point from undistorted+normalized 2D observations via DLT.-- Args:- normalized_points: (N, 2) undistorted normalized coordinates for N cameras.- extrinsics_mats: (N, 3, 4) [R|t] matrices for those N cameras.-- Returns:- (3,) 3D point in world coordinates.- """- n_views = normalized_points.shape[0]- A = np.zeros((n_views * 2, 4), dtype=np.float64)- for i in range(n_views):- x, y = normalized_points[i]- P = extrinsics_mats[i]- A[i * 2] = x * P[2] - P[0]- A[i * 2 + 1] = y * P[2] - P[1]-- _, _, vh = np.linalg.svd(A, full_matrices=True)- p_homogeneous = vh[-1]- return p_homogeneous[:3] / p_homogeneous[3]---class Triangulator(BaseModel):- """Triangulates 2D observations into 3D using calibrated CameraModels.-- Constructed from a list of CameraModel (as produced by CalibrationResult).- Camera ordering is determined by the order of the cameras list.- All input data must follow this same ordering.- """-- model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)-- cameras: list[CameraModel]-- # Precomputed arrays cached after construction- _extrinsics_mats: NDArray[np.float64] | None = None- _projection_mats: NDArray[np.float64] | None = None-- @model_validator(mode="after")- def _precompute(self) -> "Triangulator":- if len(self.cameras) < 2:- raise ValueError(f"Triangulator requires at least 2 cameras, got {len(self.cameras)}")- # Precompute [R|t] and P matrices for each camera- ext = np.zeros((len(self.cameras), 3, 4), dtype=np.float64)- proj = np.zeros((len(self.cameras), 3, 4), dtype=np.float64)- for i, cam in enumerate(self.cameras):- R = cam.extrinsics.rotation_matrix- t = cam.extrinsics.translation- ext[i, :, :3] = R- ext[i, :, 3] = t- proj[i] = cam.projection_matrix- object.__setattr__(self, "_extrinsics_mats", ext)- object.__setattr__(self, "_projection_mats", proj)- return self-- @property- def camera_names(self) -> list[str]:- return [cam.name for cam in self.cameras]-- @property- def n_cameras(self) -> int:- return len(self.cameras)-- # =========================================================================- # CONSTRUCTION HELPERS- # =========================================================================-- @classmethod- def from_calibration_result(cls, calibration: CalibrationResult) -> "Triangulator":- """Build a triangulator using all cameras from a CalibrationResult."""- return cls(cameras=calibration.cameras)-- @classmethod- def from_calibration_for_cameras(- cls,- calibration: CalibrationResult,- camera_ids: list[str],- ) -> "Triangulator":- """Build a triangulator with cameras ordered to match camera_ids.-- Each camera_id must exactly match a CameraModel.name in the calibration.- The resulting Triangulator's camera ordering matches the camera_ids ordering.-- Raises:- KeyError: If any camera_id is not found in the calibration.- """- calibration_cameras_by_name = {cam.name: cam for cam in calibration.cameras}- ordered_cameras: list[CameraModel] = []- for cam_id in camera_ids:- if cam_id not in calibration_cameras_by_name:- raise KeyError(- f"Camera '{cam_id}' not found in calibration. "- f"Calibration contains: {list(calibration_cameras_by_name.keys())}"- )- ordered_cameras.append(calibration_cameras_by_name[cam_id])- return cls(cameras=ordered_cameras)-- @classmethod- def from_calibration_toml(cls, path: str) -> "Triangulator":- """Load a calibration TOML and build a triangulator from all its cameras."""- from pathlib import Path as _Path- result = CalibrationResult.load_anipose_toml(_Path(path))- return cls.from_calibration_result(calibration=result)-- # =========================================================================- # CORE TRIANGULATION- # =========================================================================-- def triangulate_points(- self,- points_2d: NDArray[np.float64],- undistort: bool = True,- ) -> NDArray[np.float64]:- """Triangulate 2D points to 3D via DLT.-- Args:- points_2d: (n_cameras, n_points, 2) array of 2D pixel coordinates.- NaN entries indicate a missing observation for that camera/point.- undistort: If True, undistort points using camera intrinsics before- triangulating. Set to False if points are already normalized.-- Returns:- (n_points, 3) array of 3D world coordinates. Points with fewer than- 2 valid observations are filled with NaN.- """- n_cams, n_points, _ = points_2d.shape- if n_cams != self.n_cameras:- raise ValueError(- f"points_2d has {n_cams} cameras but triangulator has {self.n_cameras}"- )-- # Undistort all points- if undistort:- undistorted = np.empty_like(points_2d)- for cam_idx, cam in enumerate(self.cameras):- undistorted[cam_idx] = _undistort_points(- points_2d=points_2d[cam_idx],- camera=cam,- )- else:- undistorted = points_2d-- # Triangulate each point- out = np.full((n_points, 3), np.nan, dtype=np.float64)- for pt_idx in range(n_points):- subp = undistorted[:, pt_idx, :]- valid = ~np.isnan(subp[:, 0])- if np.sum(valid) < 2:- continue- out[pt_idx] = _triangulate_single_point(- normalized_points=subp[valid],- extrinsics_mats=self._extrinsics_mats[valid],- )-- return out-- def triangulate_dict(- self,- points_2d_by_camera: dict[str, NDArray[np.float64]],- ) -> NDArray[np.float64]:- """Triangulate from a dict of {camera_name: (n_frames, n_points, 2)}.-- Camera ordering is matched by name. Raises if a camera name is unknown.-- Returns:- (n_frames, n_points, 3) array of triangulated 3D coordinates.- """- name_to_idx = {name: i for i, name in enumerate(self.camera_names)}-- # Validate camera names- for cam_name in points_2d_by_camera:- if cam_name not in name_to_idx:- raise KeyError(- f"Camera '{cam_name}' not found in triangulator. "- f"Known cameras: {self.camera_names}"- )-- # Determine shape from first entry- first_array = next(iter(points_2d_by_camera.values()))- if first_array.ndim != 3 or first_array.shape[2] != 2:- raise ValueError(- f"Expected arrays of shape (n_frames, n_points, 2), got {first_array.shape}"- )- n_frames = first_array.shape[0]- n_points = first_array.shape[1]-- # Stack into (n_cameras, n_frames, n_points, 2) in triangulator camera order- stacked = np.full(- (self.n_cameras, n_frames, n_points, 2), np.nan, dtype=np.float64,- )- for cam_name, data in points_2d_by_camera.items():- if data.shape != (n_frames, n_points, 2):- raise ValueError(- f"Camera '{cam_name}' has shape {data.shape}, "- f"expected ({n_frames}, {n_points}, 2)"- )- stacked[name_to_idx[cam_name]] = data-- return self.triangulate_array(data2d=stacked)-- def triangulate_array(- self,- data2d: NDArray[np.float64],- ) -> NDArray[np.float64]:- """Triangulate from a (n_cameras, n_frames, n_points, 2) array.-- Camera ordering must match self.cameras ordering.-- Returns:- (n_frames, n_points, 3) array.- """- n_cameras, n_frames, n_points, n_dims = data2d.shape- if n_cameras != self.n_cameras:- raise ValueError(- f"data2d has {n_cameras} cameras but triangulator has {self.n_cameras}"- )- if n_dims == 3:- data2d = data2d[..., :2]-- # Flatten frames*points, triangulate, reshape- flat = data2d.reshape(n_cameras, -1, 2)- triangulated_flat = self.triangulate_points(points_2d=flat)- return triangulated_flat.reshape(n_frames, n_points, 3)-- # =========================================================================- # REPROJECTION- # =========================================================================-- def project(self, points_3d: NDArray[np.float64]) -> NDArray[np.float64]:- """Project 3D points through all cameras.-- Args:- points_3d: (n_points, 3) world coordinates.-- Returns:- (n_cameras, n_points, 2) pixel coordinates.- """- n_points = points_3d.shape[0]- out = np.empty((self.n_cameras, n_points, 2), dtype=np.float64)- pts = points_3d.reshape(-1, 1, 3)- for cam_idx, cam in enumerate(self.cameras):- rvec = cam.extrinsics.rodrigues_vector- tvec = cam.extrinsics.translation- K = cam.intrinsics.to_camera_matrix()- dist = cam.intrinsics.to_dist_coeffs()- projected, _ = cv2.projectPoints(pts, rvec, tvec, K, dist)- out[cam_idx] = projected.reshape(n_points, 2)- return out-- def reprojection_error(- self,- points_3d: NDArray[np.float64],- points_2d: NDArray[np.float64],- ) -> NDArray[np.float64]:- """Compute reprojection error.-- Args:- points_3d: (n_points, 3) triangulated 3D points.- points_2d: (n_cameras, n_points, 2) original 2D observations.-- Returns:- (n_cameras, n_points, 2) signed reprojection error per camera per point.- NaN where the original observation was NaN.- """- projected = self.project(points_3d=points_3d)- error = points_2d - projected- # Preserve NaN mask- nan_mask = np.isnan(points_2d)- error[nan_mask] = np.nan- return error-- def mean_reprojection_error(- self,- points_3d: NDArray[np.float64],- points_2d: NDArray[np.float64],- ) -> NDArray[np.float64]:- """Mean reprojection error per point (across cameras).-- Returns:- (n_points,) mean Euclidean reprojection error.- """- errors = self.reprojection_error(points_3d=points_3d, points_2d=points_2d)- errors_norm = np.linalg.norm(errors, axis=2) # (n_cameras, n_points)- valid = ~np.isnan(errors_norm)- errors_norm[~valid] = 0.0- denom = np.sum(valid, axis=0).astype(np.float64)- denom[denom < 1.5] = np.nan- return np.sum(errors_norm, axis=0) / denomdiff --git a/freemocap/core/tasks/mocap/mocap_helpers/charuco_model_from_observations.py b/freemocap/core/tasks/mocap/mocap_helpers/charuco_model_from_observations.pyindex 741bff01..7a94c3a6 100644--- a/freemocap/core/tasks/mocap/mocap_helpers/charuco_model_from_observations.py+++ b/freemocap/core/tasks/mocap/mocap_helpers/charuco_model_from_observations.py@@ -7,7 +7,6 @@ then interpolates, filters, and saves the result.import loggingfrom pathlib import Path-from typing import TYPE_CHECKINGfrom skellyforge.post_processing.filters.apply_filter import filter_trajectoryfrom skellyforge.post_processing.filters.filter_config import FilterConfig@@ -18,9 +17,12 @@ from skellyforge.skellymodels.models.tracking_model_info import CharucoBoard5x3Mfrom skellytracker.trackers.base_tracker.base_tracker_abcs import BaseRecorderfrom skellytracker.trackers.charuco_tracker.charuco_observation import CharucoObservation-from freemocap.core.tasks.calibration.anipose_calibration.helpers.freemocap_anipose import AniposeCameraGroup-from freemocap.core.tasks.mocap.mocap_helpers.triangulate_trajectory_array import TriangulationConfig, triangulate_dict-from freemocap.core.types.type_overloads import VideoIdString+from freemocap.core.tasks.calibration.shared.calibration_result import CalibrationResult+from freemocap.core.tasks.mocap.mocap_helpers.triangulate_trajectory_array import triangulate_dict+from freemocap.core.tasks.triangulation.helpers.triangulation_config import TriangulationConfig+from skellycam.core.types.type_overloads import CameraIdString++from freemocap.core.tasks.triangulation.triangulator import Triangulatorfrom skellyforge.data_models.trajectory_3d import Trajectory3d@@ -31,10 +33,10 @@ logger = logging.getLogger(__name__)def charuco_model_from_observations(*,- observation_recorders: dict[VideoIdString, BaseRecorder],+ observation_recorders: dict[CameraIdString, BaseRecorder],output_data_folder: Path | str,calibration_toml_path: Path | str | None,- anipose_camera_group: AniposeCameraGroup | None = None,+ triangulator: Triangulator | None = None,triangulation_config: TriangulationConfig | None = None,interp_config: InterpolationConfig | None = None,filter_config: FilterConfig | None = None,@@ -47,29 +49,30 @@ def charuco_model_from_observations(if filter_config is None:filter_config = FilterConfig()- if anipose_camera_group is not None and calibration_toml_path is not None:- raise ValueError("Provide either anipose_camera_group or calibration_toml_path, not both.")- if anipose_camera_group is None and calibration_toml_path is None:- raise ValueError("Must provide either anipose_camera_group or calibration_toml_path.")+ if triangulator is not None and calibration_toml_path is not None:+ raise ValueError("Provide either triangulator or calibration_toml_path, not both.")+ if triangulator is None and calibration_toml_path is None:+ raise ValueError("Must provide either triangulator or calibration_toml_path.")if calibration_toml_path is not None:- anipose_camera_group = AniposeCameraGroup.load(str(calibration_toml_path))+ calibration = CalibrationResult.load_anipose_toml(Path(calibration_toml_path))+ triangulator = Triangulator.from_calibration_result(calibration=calibration)Path(output_data_folder).mkdir(parents=True, exist_ok=True)- data2d_by_video: dict[VideoIdString, np.ndarray] = {}+ data2d_by_camera: dict[CameraIdString, np.ndarray] = {}if len(observation_recorders) == 0:raise ValueError("No observation recorders provided to process.")- for video_id, recorder in observation_recorders.items():+ for camera_id, recorder in observation_recorders.items():if not all(isinstance(observation, CharucoObservation) for observation in recorder.observations):- raise TypeError(f"Recorder for video ID {video_id} contains non-Charuco observations.")+ raise TypeError(f"Recorder for camera ID {camera_id} contains non-Charuco observations.")data2d_fr_id_xyc = recorder.to_array.copy()- logger.info(f"Processing video ID: {video_id} with 2D data shape: {data2d_fr_id_xyc.shape}")- data2d_by_video[video_id] = data2d_fr_id_xyc[..., :2]+ logger.info(f"Processing camera ID: {camera_id} with 2D data shape: {data2d_fr_id_xyc.shape}")+ data2d_by_camera[camera_id] = data2d_fr_id_xyc[..., :2]raw_trajectory_3d: Trajectory3d = triangulate_dict(- data2d_fr_mar_xy_by_camera=data2d_by_video,- camera_group=anipose_camera_group,+ data2d_fr_mar_xy_by_camera=data2d_by_camera,+ triangulator=triangulator,config=triangulation_config,)diff --git a/freemocap/core/tasks/mocap/mocap_helpers/skeleton_from_mediapipe_observations.py b/freemocap/core/tasks/mocap/mocap_helpers/skeleton_from_mediapipe_observations.pyindex e9dc150f..84c5b255 100644--- a/freemocap/core/tasks/mocap/mocap_helpers/skeleton_from_mediapipe_observations.py+++ b/freemocap/core/tasks/mocap/mocap_helpers/skeleton_from_mediapipe_observations.py@@ -12,26 +12,31 @@ from skellyforge.skellymodels.managers.human import Humanfrom skellyforge.skellymodels.models.tracking_model_info import MediapipeModelInfofrom skellytracker.trackers.base_tracker.base_tracker_abcs import BaseRecorder-from freemocap.core.tasks.calibration.shared.calibration_models import CalibrationResult-from freemocap.core.tasks.calibration.shared.triangulator import Triangulator-from freemocap.core.types.type_overloads import VideoIdString+from freemocap.core.tasks.calibration.shared.calibration_result import CalibrationResult+from freemocap.core.tasks.triangulation.helpers.triangulation_config import TriangulationConfig+from skellycam.core.types.type_overloads import CameraIdString++from freemocap.core.tasks.triangulation.triangulator import Triangulatorlogger = logging.getLogger(__name__)def skeleton_from_mediapipe_observation_recorders(- observation_recorders: dict[VideoIdString, BaseRecorder],+ observation_recorders: dict[CameraIdString, BaseRecorder],path_to_calibration_toml: Path | str,path_to_output_data_folder: Path | str,+ triangulation_config: TriangulationConfig | None = None,interp_config: InterpolationConfig | None = None,filter_config: FilterConfig | None = None,) -> Human:"""Triangulate mediapipe 2D observations into a 3D skeleton.- Camera matching: observation_recorders keys (VideoIdString, i.e. camera IDs)+ Camera matching: observation_recorders keys (CameraIdString)are matched to calibration camera names. Each key must have an exact matchin the calibration file's camera names."""+ if triangulation_config is None:+ triangulation_config = TriangulationConfig()if interp_config is None:interp_config = InterpolationConfig()if filter_config is None:@@ -43,11 +48,11 @@ def skeleton_from_mediapipe_observation_recorders(raise ValueError("No observation recorders provided to process.")# Extract 2D data from observation recorders- data2d_by_camera: dict[VideoIdString, np.ndarray] = {}- for video_id, recorder in observation_recorders.items():+ data2d_by_camera: dict[CameraIdString, np.ndarray] = {}+ for camera_id, recorder in observation_recorders.items():data2d_fr_id_xyc = recorder.to_array.copy()- logger.info(f"Processing camera ID: {video_id} with 2D data shape: {data2d_fr_id_xyc.shape}")- data2d_by_camera[video_id] = data2d_fr_id_xyc[..., :2]+ logger.info(f"Processing camera ID: {camera_id} with 2D data shape: {data2d_fr_id_xyc.shape}")+ data2d_by_camera[camera_id] = data2d_fr_id_xyc[..., :2]# Load calibration and build triangulator matched to our camera IDscalibration = CalibrationResult.load_anipose_toml(Path(path_to_calibration_toml))@@ -58,16 +63,27 @@ def skeleton_from_mediapipe_observation_recorders(camera_ids=camera_ids,)- # Triangulate- raw_3d = triangulator.triangulate_dict(points_2d_by_camera=data2d_by_camera)+ result = triangulator.triangulate(+ data2d=data2d_by_camera,+ config=triangulation_config,+ )+ raw_3d = result.points_3d++ # Persist per-camera weights as a sibling NPY (only useful when outlier rejection is on,+ # but always written so downstream can read consistently).+ #TODO - Make this less dumb and sloppy+ np.save(+ Path(path_to_output_data_folder) / "per_camera_weights.npy",+ result.per_camera_weights,+ )n_frames = raw_3d.shape[0]raw_trajectory_3d = Trajectory3d(start_frame=0,end_frame=n_frames,triangulated_data=raw_3d,- reprojection_error=np.array([]),- reprojection_error_by_camera=np.array([]),+ reprojection_error=np.nanmean(result.reprojection_error, axis=0),+ reprojection_error_by_camera=result.reprojection_error,)interpolated_trajectory_3d: Trajectory3d = interpolate_trajectory(@@ -86,10 +102,13 @@ def skeleton_from_mediapipe_observation_recorders(tracked_points_numpy_array=filtered_trajectory_3d.triangulated_data,)- try:- skeleton.put_skeleton_on_ground()- except Exception as e:- logger.warning(f"Could not put skeleton on ground: {e}")++ if not calibration.groundplane_aligned:+ try:+ logger.debug("Groundplane undefined in calibration - aligning to skeleton feet")+ skeleton.put_skeleton_on_ground()+ except Exception as e:+ logger.warning(f"Could not put skeleton on ground: {e}")try:skeleton.fix_hands_to_wrist()diff --git a/freemocap/core/tasks/mocap/mocap_helpers/triangulate_trajectory_array.py b/freemocap/core/tasks/mocap/mocap_helpers/triangulate_trajectory_array.pyindex 4eb43dc8..9a202a04 100644--- a/freemocap/core/tasks/mocap/mocap_helpers/triangulate_trajectory_array.py+++ b/freemocap/core/tasks/mocap/mocap_helpers/triangulate_trajectory_array.py@@ -2,232 +2,117 @@ import loggingfrom typing import Anyimport numpy as np-from pydantic import BaseModel-from skellyforge.data_models.trajectory_3d import Observation3d, Trajectory3d-from skellyforge.data_models.type_overloads import CameraIdString, FrameObservationsByCamera, Trajectory2dGroup-from skellytracker.trackers.base_tracker.base_tracker_abcs import BaseObservation+from skellyforge.data_models.trajectory_3d import Trajectory3d+from skellyforge.data_models.type_overloads import CameraIdString-from freemocap.core.tasks.calibration.anipose_calibration.helpers.freemocap_anipose import AniposeCameraGroup+from freemocap.core.tasks.triangulation.helpers.triangulation_config import TriangulationConfig+from freemocap.core.tasks.triangulation.triangulator import Triangulatorlogger = logging.getLogger(__name__)-class TriangulationConfig(BaseModel):- use_ransac: bool = False---def triangulate_array(- data2d_cam_id_xy: np.ndarray, # shape: cameras × frames × points × 2- camera_group: AniposeCameraGroup,- config: TriangulationConfig,- calculate_reprojection_error: bool = False,-) -> tuple[np.ndarray, np.ndarray, np.ndarray]:- number_of_cameras = data2d_cam_id_xy.shape[0]- number_of_frames = data2d_cam_id_xy.shape[1]- number_of_tracked_points = data2d_cam_id_xy.shape[2]- number_of_spatial_dimensions = data2d_cam_id_xy.shape[3]-- if number_of_spatial_dimensions == 3:- # if provided 3d, ignore z dimension- data2d_cam_id_xy = data2d_cam_id_xy[..., :2]-- data2d_flat = data2d_cam_id_xy.reshape(number_of_cameras, -1, 2)--- # Triangulate 2D points to 3D- if config.use_ransac:- logger.info("Using RANSAC triangulation method")- triangulated_data_flat = camera_group.triangulate_ransac(- data2d_flat, progress=True, kill_event=None- )- else:- triangulated_data_flat = camera_group.triangulate(- data2d_flat, progress=False, kill_event=None- )-- triangulated3d_fr_id_xyz = triangulated_data_flat.reshape(- number_of_frames, number_of_tracked_points, 3- )-- # Calculate reprojection error- reprojection_error_by_camera = camera_group.reprojection_error(- triangulated3d_fr_id_xyz.reshape(-1, 3),- data2d_flat,- mean=False,- )- reprojection_error_flat = np.mean(np.linalg.norm(reprojection_error_by_camera, axis=2), axis=0)- reprojection_error = reprojection_error_flat.reshape(- number_of_frames, number_of_tracked_points- )-- return triangulated3d_fr_id_xyz, reprojection_error, reprojection_error_by_camera---def triangulate_frame_observations(frame_number: int,- frame_observations_by_camera: FrameObservationsByCamera,- anipose_camera_group: AniposeCameraGroup,- config: TriangulationConfig=TriangulationConfig(),- calculate_reprojection_error: bool = False- ) -> Observation3d:- anipose_camera_group = subset_camera_names(data_dict=frame_observations_by_camera, anipose_camera_group=anipose_camera_group)-- ordered_frame_observations = preserve_camera_group_order(data_by_camera=frame_observations_by_camera,- camera_group=anipose_camera_group)-- if not all([isinstance(obs, BaseObservation) for obs in ordered_frame_observations.values()]):- raise TypeError("All values in frame_observations_by_camera must be BaseObservation instances")- data2d_stack_list = [obs.to_2d_array() for obs in ordered_frame_observations.values()]- if not len(set(data.shape for data in data2d_stack_list)) == 1:- raise ValueError(f"2d data from each camera must be the same shape- got: {[data.shape for data in data2d_stack_list]}")- data2d_cam_id_xy = np.stack(data2d_stack_list, axis=0)-- if len(frame_observations_by_camera) != data2d_cam_id_xy.shape[0]:- logger.error(- f"Expected {len(frame_observations_by_camera)} cameras but got {data2d_cam_id_xy.shape[0]} cameras"- )- raise ValueError(- "Input data must have the same number of cameras as the camera group"- )- # add singleton frame dimension- data2d_cam_fr_id_xyz = data2d_cam_id_xy.reshape((data2d_cam_id_xy.shape[0], 1, data2d_cam_id_xy.shape[1], data2d_cam_id_xy.shape[2]))- triangulated_data, _, _ = triangulate_array(- data2d_cam_id_xy=data2d_cam_fr_id_xyz,- camera_group=anipose_camera_group,- config=config,- calculate_reprojection_error=calculate_reprojection_error,- )-- rotated_triangulated = rotate_by_180_deg_about_x(triangulated_data)-- # Get names from the PointCloud — structurally guaranteed to match- # to_2d_array() row order because both read from the same object.- first_obs = next(iter(frame_observations_by_camera.values()))- point_names = list(first_obs.points.names)-- return Observation3d(- frame_number=frame_number,- triangulated_data=np.squeeze(rotated_triangulated),- names=point_names,- )--def rotate_by_180_deg_about_x(points_3d: np.ndarray) -> np.ndarray:- rotation_matrix = np.array([[1, 0, 0],- [0, -1, 0],- [0, 0, -1]])- rotated_points = points_3d @ rotation_matrix.T- return rotated_points--def triangulate_frame_groups(- frame_groups: dict[int, FrameObservationsByCamera],- camera_group: AniposeCameraGroup,- config: TriangulationConfig,-) -> Trajectory3d:- observations_3d = []- frame_groups = dict(sorted(frame_groups.items()))- for frame_number, frame_group in frame_groups.items():- observation_3d = triangulate_frame_observations(- frame_number=frame_number,- frame_observations_by_camera=frame_group,- anipose_camera_group=camera_group,- config=config,- )- observations_3d.append(observation_3d)- return Trajectory3d.from_observations(observations_3d)--def triangulate_dict(data2d_fr_mar_xy_by_camera: dict[CameraIdString, np.ndarray],- camera_group: AniposeCameraGroup,- config: TriangulationConfig = TriangulationConfig(),+ triangulator: Triangulator,+ config: TriangulationConfig | None = None,start_frame: int | None = None,end_frame: int | None = None,) -> Trajectory3d:- """Triangulate pre-stacked 2D arrays (one per camera) into a 3D trajectory."""- camera_group = subset_camera_names(- data_dict=data2d_fr_mar_xy_by_camera, anipose_camera_group=camera_group- )+ """Triangulate pre-stacked 2D arrays (one per camera) into a 3D trajectory.++ Camera matching is fuzzy: each triangulator camera is matched to the data+ dict key that contains it as a substring (e.g. data key "video_synchronized_cam_0"+ matches triangulator camera "cam_0").+ """+ if config is None:+ config = TriangulationConfig()- ordered_data_dict: dict[CameraIdString, object] = preserve_camera_group_order(- data_by_camera=data2d_fr_mar_xy_by_camera, camera_group=camera_group+ triangulator = _subset_triangulator_to_data(+ triangulator=triangulator, data_dict=data2d_fr_mar_xy_by_camera,)- stacked_2d_data_list = []- for camera_id, data2d_fr_mar_xy in ordered_data_dict.items():- if any([not isinstance(d, np.ndarray) for d in ordered_data_dict.values()]):- raise TypeError("All values in data2d_fr_mar_xy_by_camera must be numpy arrays")- if len(data2d_fr_mar_xy.shape) != 3:- raise ValueError(- f"Input data arrays must have shape (frames, markers, 2) — "- f"got shape {data2d_fr_mar_xy.shape} for camera {camera_id}"- )- if data2d_fr_mar_xy.shape[2] != 2:+ ordered_by_camera_name = _reorder_data_to_triangulator(+ triangulator=triangulator, data_by_camera=data2d_fr_mar_xy_by_camera,+ )++ for cam_name, data in ordered_by_camera_name.items():+ if data.ndim != 3 or data.shape[2] != 2:raise ValueError(- f"Input data arrays must have last dimension of size 2 — "- f"got size {data2d_fr_mar_xy.shape[2]} for camera {camera_id}"+ f"Input data arrays must have shape (frames, markers, 2); "+ f"got shape {data.shape} for camera {cam_name}")- stacked_2d_data_list.append(data2d_fr_mar_xy)-- data2d_camera_fr_mar_xy = np.stack(stacked_2d_data_list, axis=0)- logger.info(f"shape of combined_2d_data: {data2d_camera_fr_mar_xy.shape}")- triangulated_data, reprojection_error, reprojection_error_by_camera = triangulate_array(- data2d_camera_fr_mar_xy, camera_group, config+ logger.info(+ f"Triangulating {triangulator.n_cameras} cameras, "+ f"{next(iter(ordered_by_camera_name.values())).shape[0]} frames, "+ f"use_outlier_rejection={config.use_outlier_rejection}")++ result = triangulator.triangulate(data2d=ordered_by_camera_name, config=config)++ n_frames = result.points_3d.shape[0]if start_frame is None:start_frame = 0if end_frame is None:- end_frame = data2d_camera_fr_mar_xy.shape[1]+ end_frame = n_frames++ rep_err_per_camera = result.reprojection_error # (n_cameras, n_frames, n_points)+ rep_err_mean = np.nanmean(rep_err_per_camera, axis=0) # (n_frames, n_points)+return Trajectory3d(start_frame=start_frame,end_frame=end_frame,- triangulated_data=triangulated_data,- reprojection_error=reprojection_error,- reprojection_error_by_camera=reprojection_error_by_camera,+ triangulated_data=result.points_3d,+ reprojection_error=rep_err_mean,+ reprojection_error_by_camera=rep_err_per_camera,)-def triangulate_trajectories(- trajectories_2d: Trajectory2dGroup,- camera_group: AniposeCameraGroup,- config: TriangulationConfig = TriangulationConfig(),-) -> Trajectory3d:- return triangulate_frame_groups(- frame_groups=trajectories_2d.as_frame_groups(),- camera_group=camera_group,- config=config,- )-+def _subset_triangulator_to_data(+ *,+ triangulator: Triangulator,+ data_dict: dict[str, Any],+) -> Triangulator:+ """Return a Triangulator whose cameras match the data_dict keys (substring match).-def subset_camera_names(data_dict: dict, anipose_camera_group: AniposeCameraGroup) -> AniposeCameraGroup:- valid_calibration_names = []- for camera in anipose_camera_group.cameras:+ Mirrors the legacy fuzzy-match behavior: triangulator camera 'cam_0' matches+ data dict key 'video_synchronized_cam_0'.+ """+ valid_camera_ids: list[CameraIdString] = []+ for camera_id in triangulator.camera_ids:for key in data_dict.keys():- if camera.name in key:- valid_calibration_names.append(camera.name)+ if camera_id in key:+ valid_camera_ids.append(camera_id)break- if len(valid_calibration_names) != len(data_dict.keys()):++ if len(valid_camera_ids) != len(data_dict):raise ValueError(- f"Camera names in frame group do not match camera names in camera group. "+ f"Camera names in data do not match triangulator. "f"Make sure calibration matches input data. "- f"Expected: {valid_calibration_names}, got: {list(data_dict.keys())}"+ f"Triangulator: {triangulator.camera_ids}, data: {list(data_dict.keys())}")- if len(valid_calibration_names) == len(anipose_camera_group.cameras):- return anipose_camera_group++ if len(valid_camera_ids) == triangulator.n_cameras:+ return triangulatorlogger.warning(- f"Frame group is missing cameras from camera group, "- f"triangulating with only cameras in frame group: {valid_calibration_names}"+ f"Data is missing cameras from triangulator, "+ f"triangulating with only cameras present in data: {valid_camera_ids}")- return anipose_camera_group.subset_cameras_names(valid_calibration_names)+ return triangulator.subset(camera_ids=valid_camera_ids)++def _reorder_data_to_triangulator(+ *,+ triangulator: Triangulator,+ data_by_camera: dict[str, np.ndarray],+) -> dict[str, np.ndarray]:+ """Reorder the data dict to match the triangulator's camera order, keyed by triangulator camera names.-def preserve_camera_group_order(- data_by_camera: dict[str, Any],- camera_group: AniposeCameraGroup,-) -> dict[str, Any]:- """Reorder the data dict to match the camera group's camera order."""- ordered_data_dict = {}- for camera in camera_group.cameras:+ Returns a dict whose keys are triangulator camera names (not the original data keys).+ """+ ordered: dict[str, np.ndarray] = {}+ for camera_name in triangulator.camera_ids:for camera_id, data in data_by_camera.items():- if camera.name in camera_id:- ordered_data_dict[camera_id] = data+ if camera_name in camera_id:+ ordered[camera_name] = databreak- return ordered_data_dict+ return ordereddiff --git a/freemocap/core/tasks/mocap/posthoc_mocap_task.py b/freemocap/core/tasks/mocap/posthoc_mocap_task.pyindex 07a72ba5..87e4c153 100644--- a/freemocap/core/tasks/mocap/posthoc_mocap_task.py+++ b/freemocap/core/tasks/mocap/posthoc_mocap_task.py@@ -8,9 +8,9 @@ Pre-bind task_config via functools.partial when creating the pipeline."""from __future__ import annotations+import jsonimport loggingimport shutil-from collections.abc import Callablefrom pathlib import Pathfrom typing import TYPE_CHECKING@@ -26,52 +26,56 @@ from skellytracker.trackers.base_tracker.base_tracker_abcs import BaseObservatio# from skellytracker.trackers.mediapipe_tracker import MediapipeObservationfrom freemocap.core.blender.export_to_blender import export_to_blender+from freemocap.core.pipeline.posthoc.pipeline_phases import MocapStage+from freemocap.core.pipeline.posthoc.task_progress_reporter import TaskProgressReporterfrom freemocap.core.tasks.calibration.shared.calibration_paths import get_last_successful_calibration_toml_pathfrom freemocap.core.tasks.mocap.mocap_helpers.skeleton_from_mediapipe_observations import \skeleton_from_mediapipe_observation_recorders+from skellycam.core.types.type_overloads import CameraIdString+from freemocap.core.pipeline.posthoc.video_group_helper import VideoMetadata-from freemocap.core.types.type_overloads import VideoIdStringfrom skellytracker.trackers.mediapipe_tracker import MediapipeObservation+from skellytracker.trackers.mediapipe_tracker.names_and_connections import MEDIAPIPE_HOLISTIC_DEFINITION+from skellytracker.trackers.rtmpose_tracker.names_and_connections import RTMPOSE_WHOLEBODY_DEFINITIONlogger = logging.getLogger(__name__)def run_posthoc_mocap_aggregator_task(*,- frame_observations: list[dict[VideoIdString, BaseObservation]],+ frame_observations: list[dict[CameraIdString, BaseObservation]],recording_info: RecordingInfo,- video_metadata: dict[VideoIdString, VideoMetadata],+ video_metadata: dict[CameraIdString, VideoMetadata],task_config: PosthocMocapPipelineConfig,- report_progress: Callable[[str, float], None] | None = None,-+ reporter: TaskProgressReporter | None = None,) -> None:"""Run posthoc motion capture on collected mediapipe observations.Args:- frame_observations: Per-frame dict of {video_id: MediapipeObservation}.+ frame_observations: Per-frame dict of {camera_id: MediapipeObservation}.recording_info: Recording metadata.- video_metadata: Per-video metadata.- report_progress: Callback for (detail, fraction) progress updates.+ video_metadata: Per-camera metadata.+ reporter: Progress reporter for named stage updates.task_config: Mocap-specific config (pre-bound via partial)."""- video_ids = list(video_metadata.keys())+ _reporter = reporter or TaskProgressReporter.noop()+ camera_ids = list(video_metadata.keys())# ---- Build observation recorders ----- if report_progress is not None:- report_progress("Building observation recorders", 0.1)+ _reporter.report(stage=MocapStage.BUILDING_RECORDERS, detail="Building observation recorders")- observation_recorders: dict[VideoIdString, BaseRecorder] = {- vid_id: BaseRecorder() for vid_id in video_ids+ observation_recorders: dict[CameraIdString, BaseRecorder] = {+ cam_id: BaseRecorder() for cam_id in camera_ids}for frame_idx, frame_obs in enumerate(frame_observations):- for vid_id, obs in frame_obs.items():+ for cam_id, obs in frame_obs.items():if not isinstance(obs, RTMPoseObservation) and not isinstance(obs, MediapipeObservation):raise TypeError(- f"Expected MediapipeObservation for video {vid_id} frame {frame_idx}, "+ f"Expected MediapipeObservation for camera {cam_id} frame {frame_idx}, "f"got {type(obs).__name__}")- observation_recorders[vid_id].add_observation(observation=obs)+ observation_recorders[cam_id].add_observation(observation=obs)# ---- Get calibration path ----if task_config.calibration_source == CalibrationSource.SPECIFIED:@@ -99,8 +103,7 @@ def run_posthoc_mocap_aggregator_task(logger.info(f"Copied calibration file to recording folder: {recording_calibration_copy}")# ---- Run skeleton triangulation ----- if report_progress is not None:- report_progress("Triangulating skeleton", 0.3)+ _reporter.report(stage=MocapStage.TRIANGULATING, detail="Triangulating skeleton")logger.info("Starting skeleton triangulation...")output_folder = Path(recording_info.full_recording_path) / "output_data"@@ -111,9 +114,20 @@ def run_posthoc_mocap_aggregator_task(path_to_output_data_folder=output_folder,)+ # ---- Save tracker schema alongside outputs ----+ first_obs = next(iter(frame_observations[0].values()))+ if isinstance(first_obs, MediapipeObservation):+ definition = MEDIAPIPE_HOLISTIC_DEFINITION+ else:+ definition = RTMPOSE_WHOLEBODY_DEFINITION++ schema_path = recording_folder / "tracker_schema.json"+ schema_path.write_text(json.dumps(definition.model_dump(), indent=2))+ logger.info(f"Saved tracker schema ({definition.name}) to {schema_path}")if task_config.export_to_blender:+ _reporter.report(stage=MocapStage.EXPORTING_BLENDER, detail="Exporting to Blender")try:export_to_blender(recording_folder_path=str(recording_info.full_recording_path),@@ -124,8 +138,6 @@ def run_posthoc_mocap_aggregator_task(# Don't crash the whole aggregator if blender export fails —# mocap outputs are already saved; blender is an optional post-step.logger.exception(f"Blender export failed (mocap data still saved): {e}")- if report_progress is not None:- report_progress("Mocap complete", 1.0)logger.info(f"Posthoc mocap complete! Output saved to {output_folder}")diff --git a/freemocap/core/tasks/mocap/skeleton_dewiggler/realtime_skeleton_filter.py b/freemocap/core/tasks/mocap/skeleton_dewiggler/realtime_skeleton_filter.pyindex 7fef0e33..fae023de 100644--- a/freemocap/core/tasks/mocap/skeleton_dewiggler/realtime_skeleton_filter.py+++ b/freemocap/core/tasks/mocap/skeleton_dewiggler/realtime_skeleton_filter.py@@ -64,7 +64,7 @@ class RealtimeFilterConfig(BaseModel):# One Euro Filter params# min_cutoff: minimum cutoff frequency (Hz). Lower = more smoothing, higher = more responsive.- min_cutoff: float = 0.005+ min_cutoff: float = 0.01#0.005# beta: speed coefficient. Higher = less lag during fast motion, but more jitter at rest.beta: float = 0.3# d_cutoff: cutoff frequency for the derivative (speed estimate) filter.diff --git a/freemocap/core/tasks/triangulation/__init__.py b/freemocap/core/tasks/triangulation/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/freemocap/core/tasks/triangulation/helpers/__init__.py b/freemocap/core/tasks/triangulation/helpers/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/freemocap/core/tasks/triangulation/helpers/default_triangulation_values.py b/freemocap/core/tasks/triangulation/helpers/default_triangulation_values.pynew file mode 100644index 00000000..fb6c3e9b--- /dev/null+++ b/freemocap/core/tasks/triangulation/helpers/default_triangulation_values.py@@ -0,0 +1,5 @@+from typing import Final++DEFAULT_MIN_CAMERAS: Final[int] = 2+DEFAULT_MAX_CAMERAS_TO_DROP: Final[int] = 2+DEFAULT_TARGET_REPROJECTION_ERROR: Final[float] = 0.02diff --git a/freemocap/core/tasks/triangulation/helpers/outlier_rejection.py b/freemocap/core/tasks/triangulation/helpers/outlier_rejection.pynew file mode 100644index 00000000..9905ba7f--- /dev/null+++ b/freemocap/core/tasks/triangulation/helpers/outlier_rejection.py@@ -0,0 +1,127 @@+"""Pure-numpy triangulation primitives.++These functions are the single source of triangulation math used everywhere+in the codebase. They operate on undistorted-normalized 2D coordinates and+[R|t] (3x4) extrinsics matrices.++Ported from the recently-added subset-ensemble outlier-rejection routine+in `OLD-capture_volume_calibration/anipose_camera_calibration/freemocap_anipose.py`.+Algorithm unchanged; only signatures, naming, and type hints were updated.+"""+import itertools++import numpy as np+from numpy.typing import NDArray++from freemocap.core.tasks.triangulation.helpers.default_triangulation_values import DEFAULT_MIN_CAMERAS, \+ DEFAULT_MAX_CAMERAS_TO_DROP, DEFAULT_TARGET_REPROJECTION_ERROR+from freemocap.core.tasks.triangulation.helpers.project_point_to_camera import project_point_to_camera+from freemocap.core.tasks.triangulation.helpers.triangulate_simple import triangulate_simple++_WEIGHT_DECAY_K: float = 5.0+++def triangulate_with_outlier_rejection(+ *,+ points_2d: NDArray[np.float64],+ extrinsics_mats: NDArray[np.float64],+ minimum_cameras_for_triangulation: int = DEFAULT_MIN_CAMERAS,+ maximum_cameras_to_drop: int = DEFAULT_MAX_CAMERAS_TO_DROP,+ target_reprojection_error: float = DEFAULT_TARGET_REPROJECTION_ERROR,+) -> tuple[NDArray[np.float64], NDArray[np.float64]]:+ """Triangulate one 3D point with progressive subset-ensemble outlier rejection.++ Triangulates using all valid cameras; if reprojection error exceeds target,+ iteratively tests camera subsets (dropping 1..max_drop cameras) and returns+ an exponentially-weighted ensemble average plus per-camera confidence weights.++ Args:+ points_2d: shape (N, 2) - undistorted-normalized 2D detections from N cameras.+ extrinsics_mats: shape (N, 3, 4) - [R|t] matrices for those N cameras.+ minimum_cameras_for_triangulation: minimum cameras required for any subset.+ maximum_cameras_to_drop: maximum cameras to drop while searching for subsets.+ target_reprojection_error: target mean reprojection error in normalized+ coords (~0.01); also drives the exp(-5 * error / target) weighting.++ Returns:+ (point_3d_xyz, normalized_camera_weights):+ - point_3d_xyz: shape (3,) - 3D point in world coordinates.+ - normalized_camera_weights: shape (N,) - per-camera confidence weights+ that sum to 1.0 across all subsets (uniform 1.0 if baseline already+ meets target_reprojection_error).+ """+ total_valid_cams = len(extrinsics_mats)+ local_indices = list(range(total_valid_cams))+ normalized_camera_weights = np.zeros(total_valid_cams, dtype=np.float64)++ default_p3d = triangulate_simple(points=points_2d, extrinsics_mats=extrinsics_mats)+ default_proj = np.array(+ [+ project_point_to_camera(point_3d=default_p3d, extrinsics_mat=mat)+ for mat in extrinsics_mats+ ]+ )+ default_errors = np.linalg.norm(default_proj - points_2d, axis=1)+ default_mean_error = float(np.mean(default_errors))++ if default_mean_error < target_reprojection_error:+ normalized_camera_weights[:] = 1.0+ return default_p3d, normalized_camera_weights++ best_p3d, best_error = default_p3d, default_mean_error+ best_camera_combo: list[int] = list(local_indices)++ default_weight = float(np.exp(-_WEIGHT_DECAY_K * default_mean_error / target_reprojection_error))+ weighted_p3d_sum = default_weight * default_p3d+ total_weight = default_weight+ normalized_camera_weights[:] += default_weight++ for camera_drop_count in range(1, maximum_cameras_to_drop + 1):+ selected_camera_count = total_valid_cams - camera_drop_count+ if selected_camera_count < minimum_cameras_for_triangulation:+ break++ combinations = list(itertools.combinations(local_indices, selected_camera_count))+ for combo in combinations:+ kept_local_indices = list(combo)+ candidate_pts = points_2d[kept_local_indices]+ candidate_cams = extrinsics_mats[kept_local_indices]++ candidate_p3d = triangulate_simple(+ points=candidate_pts, extrinsics_mats=candidate_cams,+ )+ candidate_proj = np.array(+ [+ project_point_to_camera(point_3d=candidate_p3d, extrinsics_mat=mat)+ for mat in candidate_cams+ ]+ )+ candidate_errors = np.linalg.norm(candidate_proj - candidate_pts, axis=1)+ candidate_mean_error = float(np.mean(candidate_errors))++ weight = float(np.exp(-_WEIGHT_DECAY_K * candidate_mean_error / target_reprojection_error))+ weighted_p3d_sum = weighted_p3d_sum + weight * candidate_p3d+ total_weight += weight+ normalized_camera_weights[kept_local_indices] += weight++ if candidate_mean_error < best_error:+ best_error = candidate_mean_error+ best_p3d = candidate_p3d+ best_camera_combo = kept_local_indices++ if best_error < target_reprojection_error:+ break++ if total_weight > 1e-12:+ weighted_p3d = weighted_p3d_sum / total_weight+ normalized_camera_weights /= total_weight+ else:+ weighted_p3d = best_p3d+ normalized_camera_weights[:] = 0.0+ normalized_camera_weights[best_camera_combo] = 1.0++ if best_error < default_mean_error:+ return weighted_p3d, normalized_camera_weights++ normalized_camera_weights[:] = 1.0+ return default_p3d, normalized_camera_weightsdiff --git a/freemocap/core/tasks/triangulation/helpers/project_point_to_camera.py b/freemocap/core/tasks/triangulation/helpers/project_point_to_camera.pynew file mode 100644index 00000000..5bac5da0--- /dev/null+++ b/freemocap/core/tasks/triangulation/helpers/project_point_to_camera.py@@ -0,0 +1,21 @@+import numpy as np+from numpy._typing import NDArray+++def project_point_to_camera(+ *,+ point_3d: NDArray[np.float64],+ extrinsics_mat: NDArray[np.float64],+) -> NDArray[np.float64]:+ """Project a single 3D world point through a [R|t] matrix.++ Args:+ point_3d: shape (3,) - 3D point [X, Y, Z] in world coordinates.+ extrinsics_mat: shape (3, 4) - [R|t] matrix.++ Returns:+ shape (2,) - normalized image coordinates [u, v] before applying intrinsics.+ """+ hom = np.array([point_3d[0], point_3d[1], point_3d[2], 1.0], dtype=np.float64)+ projected = extrinsics_mat @ hom+ return projected[:2] / projected[2]diff --git a/freemocap/core/tasks/triangulation/helpers/triangulate_simple.py b/freemocap/core/tasks/triangulation/helpers/triangulate_simple.pynew file mode 100644index 00000000..4d69e166--- /dev/null+++ b/freemocap/core/tasks/triangulation/helpers/triangulate_simple.py@@ -0,0 +1,63 @@+import numpy as np+from numpy._typing import NDArray+++def triangulate_simple(+ *,+ points: NDArray[np.float64],+ extrinsics_mats: NDArray[np.float64],+) -> NDArray[np.float64]:+ """DLT triangulation of a single 3D point from N cameras via SVD.++ Args:+ points: shape (N, 2) - undistorted-normalized 2D observations.+ extrinsics_mats: shape (N, 3, 4) - [R|t] matrices.++ Returns:+ shape (3,) - 3D point in world coordinates.+ """+ num_cams = len(extrinsics_mats)+ a_matrix = np.zeros((num_cams * 2, 4), dtype=np.float64)+ for i in range(num_cams):+ x, y = points[i]+ mat = extrinsics_mats[i]+ a_matrix[(i * 2): (i * 2 + 1)] = x * mat[2] - mat[0]+ a_matrix[(i * 2 + 1): (i * 2 + 2)] = y * mat[2] - mat[1]+ _, _, vh = np.linalg.svd(a_matrix, full_matrices=True)+ p_homogeneous = vh[-1]+ return p_homogeneous[:3] / p_homogeneous[3]+++def triangulate_simple_batch(+ *,+ points_batch: NDArray[np.float64],+ extrinsics_mats: NDArray[np.float64],+) -> NDArray[np.float64]:+ """Batched DLT triangulation of P 3D points from N cameras, single SVD call.++ All P points must have valid (non-NaN) observations from ALL N cameras.++ Args:+ points_batch: shape (P, N, 2) - undistorted-normalized 2D observations.+ extrinsics_mats: shape (N, 3, 4) - [R|t] matrices.++ Returns:+ shape (P, 3) - 3D points in world coordinates.+ """+ n_points, n_cameras, _ = points_batch.shape++ x = points_batch[:, :, 0] # (P, N)+ y = points_batch[:, :, 1] # (P, N)++ # rows_x[p, c] = x[p,c] * ext[c,2] - ext[c,0] shape (P, N, 4)+ rows_x = x[:, :, None] * extrinsics_mats[None, :, 2, :] - extrinsics_mats[None, :, 0, :]+ rows_y = y[:, :, None] * extrinsics_mats[None, :, 2, :] - extrinsics_mats[None, :, 1, :]++ # Interleave into DLT A-matrix: shape (P, 2*N, 4)+ A = np.empty((n_points, 2 * n_cameras, 4), dtype=np.float64)+ A[:, 0::2, :] = rows_x+ A[:, 1::2, :] = rows_y++ _, _, Vh = np.linalg.svd(A, full_matrices=False) # Vh: (P, 4, 4)+ p_hom = Vh[:, -1, :] # (P, 4)+ return p_hom[:, :3] / p_hom[:, 3:4] # (P, 3)diff --git a/freemocap/core/tasks/triangulation/helpers/triangulation_config.py b/freemocap/core/tasks/triangulation/helpers/triangulation_config.pynew file mode 100644index 00000000..59203e2f--- /dev/null+++ b/freemocap/core/tasks/triangulation/helpers/triangulation_config.py@@ -0,0 +1,58 @@+from pydantic import BaseModel, ConfigDict, Field++from freemocap.core.tasks.triangulation.helpers.default_triangulation_values import DEFAULT_MIN_CAMERAS, \+ DEFAULT_MAX_CAMERAS_TO_DROP, DEFAULT_TARGET_REPROJECTION_ERROR+++class TriangulationConfig(BaseModel):+ model_config = ConfigDict(populate_by_name=True, extra="forbid")++ use_outlier_rejection: bool = Field(+ default=True,+ alias="useOutlierRejection",+ description=(+ "If True, triangulation uses the subset-ensemble outlier-rejection method: "+ "for each 3D point, the algorithm triangulates with all cameras, then iteratively "+ "drops cameras to find subsets that lower the reprojection error, and returns an "+ "exponentially-weighted average of all candidate 3D points along with per-camera "+ "confidence weights. Robust to mistracked or partially occluded cameras at extra "+ "compute cost (combinations x n_points per frame). "+ "If False, triangulation uses plain DLT - fast, but a single bad observation can "+ "skew the 3D estimate."+ ),+ )+ minimum_cameras_for_triangulation: int = Field(+ default=DEFAULT_MIN_CAMERAS,+ alias="minimumCamerasForTriangulation",+ ge=2,+ description=(+ "Minimum number of valid camera observations required to triangulate a point. "+ "Points seen by fewer cameras are returned as NaN. DLT is geometrically defined "+ "for >=2 cameras, but >=3 is recommended when use_outlier_rejection=True so that "+ "dropping a camera still leaves a well-conditioned solve."+ ),+ )+ maximum_cameras_to_drop: int = Field(+ default=DEFAULT_MAX_CAMERAS_TO_DROP,+ alias="maximumCamerasToDrop",+ ge=0,+ description=(+ "Maximum number of cameras the outlier-rejection method is allowed to drop "+ "when searching for a better subset. Higher values explore more combinations "+ "(C(n_cameras, n_cameras - k)) and can recover from more simultaneous outliers, "+ "but cost grows combinatorially. Ignored when use_outlier_rejection=False."+ ),+ )+ target_reprojection_error: float = Field(+ default=DEFAULT_TARGET_REPROJECTION_ERROR,+ alias="targetReprojectionError",+ gt=0.0,+ description=(+ "Target mean reprojection error, expressed in undistorted-normalized image "+ "coordinates (typical range ~[-1, 1], so ~0.01 ~= 1% of the image plane). "+ "Subset weights decay as exp(-5 * mean_error / target). Smaller values weight "+ "low-error subsets more aggressively; larger values produce a softer average. "+ "Also acts as the early-exit threshold: if the all-cameras triangulation already "+ "achieves this error, no subsets are tried. Ignored when use_outlier_rejection=False."+ ),+ )diff --git a/freemocap/core/tasks/triangulation/helpers/triangulation_result.py b/freemocap/core/tasks/triangulation/helpers/triangulation_result.pynew file mode 100644index 00000000..3789dfd8--- /dev/null+++ b/freemocap/core/tasks/triangulation/helpers/triangulation_result.py@@ -0,0 +1,35 @@+from dataclasses import dataclass++import numpy as np+from numpy.typing import NDArray+++@dataclass(slots=True, frozen=True)+class TriangulationResult:+ """Output of `Triangulator.triangulate(...)`.++ Hot path - slots removes per-instance __dict__ overhead, frozen makes it+ immutable so it can be shared across threads/queues without copying.++ Shape conventions:+ - Single-frame input (data2d shape (n_cameras, n_points, 2)):+ points_3d: (n_points, 3)+ per_camera_weights: (n_points, n_cameras)+ reprojection_error: (n_cameras, n_points)+ - Batch input (dict / 4D array):+ points_3d: (n_frames, n_points, 3)+ per_camera_weights: (n_frames, n_points, n_cameras)+ reprojection_error: (n_cameras, n_frames, n_points)++ NaN encodes 'no observation' (where the input 2D was NaN) or 'insufficient+ cameras to triangulate' (fewer than minimum_cameras_for_triangulation valid+ observations for that point).++ When `use_outlier_rejection=False`, per_camera_weights is uniform+ 1/n_valid_cameras for valid cameras and NaN for cameras with no observation.+ When True, weights are the ensemble-weighted per-camera confidences.+ """++ points_3d: NDArray[np.float64]+ per_camera_weights: NDArray[np.float64]+ reprojection_error: NDArray[np.float64]diff --git a/freemocap/core/tasks/triangulation/triangulator.py b/freemocap/core/tasks/triangulation/triangulator.pynew file mode 100644index 00000000..8d5413be--- /dev/null+++ b/freemocap/core/tasks/triangulation/triangulator.py@@ -0,0 +1,578 @@+"""Triangulator: pure DLT triangulation from CameraModel list.++Single source of triangulation in the codebase. One class, one public method+`triangulate(...)` that handles dict, 3D-array, and 4D-array inputs internally+and dispatches to either simple DLT or the subset-ensemble outlier-rejection+algorithm based on the supplied `TriangulationConfig`.++Pure numpy + cv2 (for undistortion). No aniposelib coupling.+"""+import itertools+import logging+from pathlib import Path++import cv2+import numpy as np+from numpy.typing import NDArray+from pydantic import BaseModel, ConfigDict, model_validator+from skellycam.core.types.type_overloads import CameraIdString++from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from freemocap.core.tasks.calibration.shared.calibration_result import CalibrationResult+from freemocap.core.tasks.triangulation.helpers.outlier_rejection import (+ triangulate_with_outlier_rejection,+)+from freemocap.core.tasks.triangulation.helpers.triangulate_simple import triangulate_simple, triangulate_simple_batch+from freemocap.core.tasks.triangulation.helpers.triangulation_config import TriangulationConfig+from freemocap.core.tasks.triangulation.helpers.triangulation_result import TriangulationResult++logger = logging.getLogger(__name__)++PointsByCamera = dict[str, NDArray[np.float64]]+PointsArray = NDArray[np.float64]+TriangulateInput = PointsByCamera | PointsArray+++def _undistort_points_for_camera(+ *,+ points_2d: NDArray[np.float64],+ camera: CameraModel,+) -> NDArray[np.float64]:+ """Undistort 2D pixel points using camera intrinsics. Returns normalized coords."""+ pts = points_2d.reshape(-1, 1, 2).astype(np.float64)+ K = camera.intrinsics.to_camera_matrix()+ dist = camera.intrinsics.to_dist_coeffs()+ undistorted = cv2.undistortPoints(pts, K, dist)+ return undistorted.reshape(-1, 2)+++class Triangulator(BaseModel):+ """Triangulates 2D observations into 3D using calibrated CameraModels."""++ model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)++ cameras: list[CameraModel]++ _extrinsics_mats: NDArray[np.float64] | None = None+ # Cached per-camera cv2 inputs (computed once at construction, not on every project() call)+ _rvecs: list | None = None # list of (3,1) Rodrigues vectors+ _tvecs: list | None = None # list of (3,) translation vectors+ _Ks: list | None = None # list of (3,3) camera matrices+ _dists: list | None = None # list of distortion coefficient arrays++ @model_validator(mode="after")+ def _precompute(self) -> "Triangulator":+ if len(self.cameras) < 2:+ raise ValueError(f"Triangulator requires at least 2 cameras, got {len(self.cameras)}")+ ext = np.zeros((len(self.cameras), 3, 4), dtype=np.float64)+ rvecs, tvecs, Ks, dists = [], [], [], []+ for i, cam in enumerate(self.cameras):+ ext[i, :, :3] = cam.extrinsics.rotation_matrix+ ext[i, :, 3] = cam.extrinsics.translation+ rvecs.append(cam.extrinsics.rodrigues_vector.reshape(3, 1))+ tvecs.append(cam.extrinsics.translation)+ Ks.append(cam.intrinsics.to_camera_matrix())+ dists.append(cam.intrinsics.to_dist_coeffs())+ object.__setattr__(self, "_extrinsics_mats", ext)+ object.__setattr__(self, "_rvecs", rvecs)+ object.__setattr__(self, "_tvecs", tvecs)+ object.__setattr__(self, "_Ks", Ks)+ object.__setattr__(self, "_dists", dists)+ return self++ @property+ def camera_ids(self) -> list[str]:+ return [cam.id for cam in self.cameras]++ @property+ def n_cameras(self) -> int:+ return len(self.cameras)++ # =========================================================================+ # CONSTRUCTION HELPERS+ # =========================================================================++ @classmethod+ def from_calibration_result(cls, calibration: CalibrationResult) -> "Triangulator":+ return cls(cameras=calibration.cameras)++ @classmethod+ def from_calibration_for_cameras(+ cls,+ calibration: CalibrationResult,+ camera_ids: list[CameraIdString],+ ) -> "Triangulator":+ """Build a triangulator with cameras ordered to match camera_ids."""+ calibration_cameras_by_id = {cam.id: cam for cam in calibration.cameras}+ ordered_cameras: list[CameraModel] = []+ for cam_id in camera_ids:+ # TODO - Should add more robust camera matching method here. Camera ID's are not stable across (say) reboot, but there might be a way to match by index, or even by min reproj err+ if cam_id not in calibration_cameras_by_id:+ raise KeyError(+ f"Camera '{cam_id}' not found in calibration. "+ f"Calibration contains: {list(calibration_cameras_by_id.keys())}"+ )+ ordered_cameras.append(calibration_cameras_by_id[cam_id])+ return cls(cameras=ordered_cameras)++ @classmethod+ def from_anipose_calibration_toml(cls, path: str | Path) -> "Triangulator":+ result = CalibrationResult.load_anipose_toml(Path(path))+ return cls.from_calibration_result(calibration=result)++ def subset(self, camera_ids: list[CameraIdString]) -> "Triangulator":+ """Return a new Triangulator restricted to the named cameras (preserving order of camera_names)."""+ by_id = {cam.id: cam for cam in self.cameras}+ missing = [n for n in camera_ids if n not in by_id]+ if missing:+ raise KeyError(f"Unknown cameras: {missing}. Known: {self.camera_ids}")+ return Triangulator(cameras=[by_id[n] for n in camera_ids])++ # =========================================================================+ # PROJECTION+ # =========================================================================++ def project(self, points_3d: NDArray[np.float64]) -> NDArray[np.float64]:+ """Project 3D points through all cameras (with intrinsics + distortion).++ Args:+ points_3d: shape (n_points, 3) world coordinates. NaN-rows are skipped.++ Returns:+ shape (n_cameras, n_points, 2) pixel coordinates. NaN where the+ corresponding 3D point was NaN.+ """+ n_points = points_3d.shape[0]+ out = np.empty((self.n_cameras, n_points, 2), dtype=np.float64)+ nan_mask = np.isnan(points_3d).any(axis=1)+ valid_pts = points_3d[~nan_mask].reshape(-1, 1, 3)+ for cam_idx in range(self.n_cameras):+ if valid_pts.shape[0] == 0:+ out[cam_idx] = np.nan+ continue+ projected, _ = cv2.projectPoints(+ valid_pts, self._rvecs[cam_idx], self._tvecs[cam_idx],+ self._Ks[cam_idx], self._dists[cam_idx],+ )+ full = np.full((n_points, 2), np.nan, dtype=np.float64)+ full[~nan_mask] = projected.reshape(-1, 2)+ out[cam_idx] = full+ return out++ # =========================================================================+ # CORE TRIANGULATION+ # =========================================================================++ def triangulate(+ self,+ *,+ data2d: TriangulateInput,+ config: TriangulationConfig | None = None,+ assume_undistorted_normalized: bool = False,+ camera_order: list[CameraIdString] | None = None,+ ) -> TriangulationResult:+ """Triangulate 2D pixel observations into 3D.++ Accepts either:+ - dict[camera_name, NDArray of shape (n_frames, n_points, 2)]+ - NDArray of shape (n_cameras, n_points, 2) [single-frame batch]+ - NDArray of shape (n_cameras, n_frames, n_points, 2) [multi-frame batch]++ Camera ordering is matched by name for dicts. For array input, the+ first axis is positionally aligned with `self.cameras` — the caller+ is responsible for that alignment. Pass `camera_order` (a list of+ camera names matching the array's first axis) to assert that+ alignment explicitly; if it doesn't match `self.camera_names`,+ triangulation raises rather than silently producing garbage 3D.++ If `assume_undistorted_normalized=True`, callers must pass already-undistorted+ normalized coordinates (intrinsics-removed); used by the calibration solver+ path that handles undistortion itself. The reprojection error in the result+ is then also reported in normalized coords.++ Returns a `TriangulationResult` whose array shapes mirror the input rank:+ - single-frame array input -> points_3d (n_points, 3)+ - dict / 4D array input -> points_3d (n_frames, n_points, 3)+ """+ if config is None:+ config = TriangulationConfig()++ if camera_order is not None and camera_order != self.camera_ids:+ # TODO - This dumb, we should do better than this+ raise ValueError(+ f"camera_order does not match this Triangulator's camera order. "+ f"Got {camera_order}, expected {self.camera_ids}. Either reorder "+ f"the input array's first axis to match, or rebuild the Triangulator "+ f"via Triangulator.from_calibration_for_cameras(...) with the desired order."+ )++ stacked, was_single_frame, n_frames, n_points = self._normalize_input(data2d=data2d)++ if assume_undistorted_normalized:+ undistorted = stacked+ else:+ undistorted = np.empty_like(stacked)+ for cam_idx in range(self.n_cameras):+ pts = stacked[cam_idx].reshape(-1, 2).astype(np.float64)+ pts_cv = pts.reshape(-1, 1, 2)+ und = cv2.undistortPoints(pts_cv, self._Ks[cam_idx], self._dists[cam_idx])+ undistorted[cam_idx] = und.reshape(n_frames, n_points, 2)++ # Flatten frames * points -> (n_cameras, n_flat, 2)+ n_flat = n_frames * n_points+ und_flat = undistorted.reshape(self.n_cameras, n_flat, 2)++ points_3d_flat = np.full((n_flat, 3), np.nan, dtype=np.float64)+ weights_flat = np.full((n_flat, self.n_cameras), np.nan, dtype=np.float64)++ # Per-point validity: True where the 2D observation is not NaN.+ valid_all = ~np.isnan(und_flat[:, :, 0]) # (n_cameras, n_flat)+ n_valid_per_pt = valid_all.sum(axis=0) # (n_flat,)++ # --- Batch path: points visible in ALL cameras (common case for RTMPose) ---+ all_cams_valid = valid_all.all(axis=0) & (n_valid_per_pt >= config.minimum_cameras_for_triangulation)+ batch_idx = np.where(all_cams_valid)[0]++ if batch_idx.size > 0:+ # (n_batch, n_cameras, 2) — rearrange from (n_cameras, n_batch, 2)+ pts_batch = np.ascontiguousarray(und_flat[:, batch_idx, :].transpose(1, 0, 2))+ p3d_batch = triangulate_simple_batch(+ points_batch=pts_batch, extrinsics_mats=self._extrinsics_mats+ ) # (n_batch, 3)++ if config.use_outlier_rejection:+ # Batch-project to check normalized reprojection error+ n_batch = batch_idx.size+ hom = np.concatenate(+ [p3d_batch, np.ones((n_batch, 1), dtype=np.float64)], axis=1+ ) # (n_batch, 4)+ proj = self._extrinsics_mats @ hom.T # (n_cameras, 3, n_batch)+ z = proj[:, 2, :]+ with np.errstate(invalid="ignore", divide="ignore"):+ proj_2d = proj[:, :2, :] / z[:, None, :] # (n_cameras, 2, n_batch)+ proj_2d_T = proj_2d.transpose(2, 0, 1) # (n_batch, n_cameras, 2)+ mean_errors = np.linalg.norm(proj_2d_T - pts_batch, axis=2).mean(axis=1) # (n_batch,)++ good_mask = mean_errors < config.target_reprojection_error+ good_global = batch_idx[good_mask]+ points_3d_flat[good_global] = p3d_batch[good_mask]+ weights_flat[good_global, :] = 1.0++ # For batch points above error threshold, use vectorized batch outlier rejection+ bad_local = np.where(~good_mask)[0]+ n_bad = len(bad_local)+ if n_bad > 0:+ bad_global = batch_idx[bad_local]+ p3d_rej, cam_w_rej = self._batch_outlier_rejection(+ pts_batch=pts_batch[bad_local],+ p3d_default=p3d_batch[bad_local],+ default_mean_errors=mean_errors[bad_local],+ config=config,+ )+ points_3d_flat[bad_global] = p3d_rej+ weights_flat[bad_global, :] = cam_w_rej+ else:+ points_3d_flat[batch_idx] = p3d_batch+ weights_flat[batch_idx, :] = 1.0 / self.n_cameras++ # --- Per-point path: points with partial camera coverage ---+ for pt_idx in np.where(~all_cams_valid & (n_valid_per_pt >= config.minimum_cameras_for_triangulation))[0]:+ subp = und_flat[:, pt_idx, :] # (n_cameras, 2)+ valid_idx = np.where(valid_all[:, pt_idx])[0]+ n_valid = len(valid_idx)+ valid_pts = subp[valid_idx]+ valid_ext = self._extrinsics_mats[valid_idx]++ if config.use_outlier_rejection:+ p3d, cam_weights_valid = triangulate_with_outlier_rejection(+ points_2d=valid_pts,+ extrinsics_mats=valid_ext,+ minimum_cameras_for_triangulation=config.minimum_cameras_for_triangulation,+ maximum_cameras_to_drop=config.maximum_cameras_to_drop,+ target_reprojection_error=config.target_reprojection_error,+ )+ else:+ p3d = triangulate_simple(points=valid_pts, extrinsics_mats=valid_ext)+ cam_weights_valid = np.full(n_valid, 1.0 / n_valid, dtype=np.float64)++ points_3d_flat[pt_idx] = p3d+ weights_flat[pt_idx, valid_idx] = cam_weights_valid++ if assume_undistorted_normalized:+ reprojection_error_flat = self._compute_reprojection_error_flat_normalized(+ points_3d_flat=points_3d_flat,+ data2d_normalized_flat=stacked.reshape(self.n_cameras, n_flat, 2),+ )+ else:+ reprojection_error_flat = self._compute_reprojection_error_flat(+ points_3d_flat=points_3d_flat,+ data2d_pixel_flat=stacked.reshape(self.n_cameras, n_flat, 2),+ )+ # Reshape outputs+ if was_single_frame:+ points_3d = points_3d_flat.reshape(n_points, 3)+ per_camera_weights = weights_flat.reshape(n_points, self.n_cameras)+ reprojection_error = reprojection_error_flat.reshape(self.n_cameras, n_points)+ else:+ points_3d = points_3d_flat.reshape(n_frames, n_points, 3)+ per_camera_weights = weights_flat.reshape(n_frames, n_points, self.n_cameras)+ reprojection_error = reprojection_error_flat.reshape(self.n_cameras, n_frames, n_points)++ return TriangulationResult(+ points_3d=points_3d,+ per_camera_weights=per_camera_weights,+ reprojection_error=reprojection_error,+ )++ # =========================================================================+ # INTERNAL HELPERS+ # =========================================================================++ def _batch_outlier_rejection(+ self,+ *,+ pts_batch: NDArray[np.float64],+ p3d_default: NDArray[np.float64],+ default_mean_errors: NDArray[np.float64],+ config: "TriangulationConfig",+ ) -> tuple[NDArray[np.float64], NDArray[np.float64]]:+ """Vectorized subset-ensemble outlier rejection for P points simultaneously.++ Instead of calling triangulate_with_outlier_rejection() P times (one per+ failing keypoint), runs triangulate_simple_batch() once per camera+ combination — O(n_combos) SVD calls instead of O(P × n_combos).++ Args:+ pts_batch: (P, n_cameras, 2) undistorted-normalized coords, no NaNs.+ p3d_default: (P, 3) triangulated from all cameras.+ default_mean_errors: (P,) mean reprojection error for the default result.+ config: triangulation config (target_reprojection_error, max_drop, etc.)++ Returns:+ (points_3d, camera_weights): shapes (P, 3) and (P, n_cameras).+ """+ P = pts_batch.shape[0]+ n_cam = self.n_cameras+ target = config.target_reprojection_error+ min_cams = config.minimum_cameras_for_triangulation+ max_drop = config.maximum_cameras_to_drop++ # Initialise weighted ensemble accumulators using the default (all-cameras) result+ default_weights = np.exp(-5.0 * default_mean_errors / target) # (P,)+ weighted_p3d_sum = p3d_default * default_weights[:, None] # (P, 3)+ total_weight = default_weights.copy() # (P,)+ cam_weights_acc = np.full((P, n_cam), 0.0, dtype=np.float64)+ cam_weights_acc += default_weights[:, None] # broadcast (P, n_cam)++ best_p3d = p3d_default.copy() # (P, 3)+ best_errors = default_mean_errors.copy() # (P,)++ local_indices = list(range(n_cam))++ for drop_count in range(1, max_drop + 1):+ selected = n_cam - drop_count+ if selected < min_cams:+ break++ for combo in itertools.combinations(local_indices, selected):+ combo_arr = np.array(combo, dtype=np.intp)+ pts_sub = pts_batch[:, combo_arr, :] # (P, selected, 2)+ ext_sub = self._extrinsics_mats[combo_arr] # (selected, 3, 4)++ # Triangulate all P points for this camera subset in one SVD call+ p3d_sub = triangulate_simple_batch(+ points_batch=pts_sub, extrinsics_mats=ext_sub+ ) # (P, 3)++ # Batch-project through subset cameras to get mean reprojection error per point+ hom = np.concatenate(+ [p3d_sub, np.ones((P, 1), dtype=np.float64)], axis=1+ ) # (P, 4)+ proj = ext_sub @ hom.T # (selected, 3, P)+ z = proj[:, 2, :]+ with np.errstate(invalid="ignore", divide="ignore"):+ proj_2d = proj[:, :2, :] / z[:, None, :] # (selected, 2, P)+ proj_2d_T = proj_2d.transpose(2, 0, 1) # (P, selected, 2)+ mean_errs = np.linalg.norm(proj_2d_T - pts_sub, axis=2).mean(axis=1) # (P,)++ # Accumulate weighted ensemble+ weights = np.exp(-5.0 * mean_errs / target) # (P,)+ weighted_p3d_sum += p3d_sub * weights[:, None]+ total_weight += weights+ cam_weights_acc[:, combo_arr] += weights[:, None]++ # Update per-point best+ improved = mean_errs < best_errors+ best_p3d = np.where(improved[:, None], p3d_sub, best_p3d)+ best_errors = np.where(improved, mean_errs, best_errors)++ # Build output: weighted ensemble where weight > threshold, else best+ valid_w = total_weight > 1e-12+ safe_w = np.where(valid_w, total_weight, 1.0)+ weighted_p3d = np.where(valid_w[:, None], weighted_p3d_sum / safe_w[:, None], best_p3d)+ cam_weights = np.where(valid_w[:, None], cam_weights_acc / safe_w[:, None], 0.0)++ # If best never improved over default, revert to default with flat weights+ no_improvement = best_errors >= default_mean_errors+ weighted_p3d = np.where(no_improvement[:, None], p3d_default, weighted_p3d)+ cam_weights = np.where(no_improvement[:, None], 1.0, cam_weights)++ return weighted_p3d, cam_weights++ def _normalize_input(+ self,+ *,+ data2d: TriangulateInput,+ ) -> tuple[NDArray[np.float64], bool, int, int]:+ """Normalize all accepted input shapes to (n_cameras, n_frames, n_points, 2).++ Returns (stacked, was_single_frame, n_frames, n_points).+ """+ if isinstance(data2d, dict):+ return self._normalize_dict(points_2d_by_camera=data2d)++ arr = np.asarray(data2d, dtype=np.float64)+ if arr.ndim == 3:+ n_cams, n_points, n_dims = arr.shape+ if n_cams != self.n_cameras:+ raise ValueError(+ f"data2d has {n_cams} cameras but triangulator has {self.n_cameras}"+ )+ if n_dims not in (2, 3):+ raise ValueError(f"Last dim must be 2 (xy) or 3 (xyz, slicing :2), got {n_dims}")+ stacked = arr[..., :2].reshape(n_cams, 1, n_points, 2)+ return stacked, True, 1, n_points++ if arr.ndim == 4:+ n_cams, n_frames, n_points, n_dims = arr.shape+ if n_cams != self.n_cameras:+ raise ValueError(+ f"data2d has {n_cams} cameras but triangulator has {self.n_cameras}"+ )+ if n_dims not in (2, 3):+ raise ValueError(f"Last dim must be 2 (xy) or 3 (xyz, slicing :2), got {n_dims}")+ return arr[..., :2], False, n_frames, n_points++ raise ValueError(+ f"data2d array must be 3D (n_cameras, n_points, 2) or 4D "+ f"(n_cameras, n_frames, n_points, 2); got ndim={arr.ndim}, shape={arr.shape}"+ )++ def _normalize_dict(+ self,+ *,+ points_2d_by_camera: PointsByCamera,+ ) -> tuple[NDArray[np.float64], bool, int, int]:+ id_to_idx = {name: i for i, name in enumerate(self.camera_ids)}+ for camera_id in points_2d_by_camera:+ if camera_id not in id_to_idx:+ raise KeyError(+ f"Camera '{camera_id}' not found in triangulator. "+ f"Known cameras: {self.camera_ids}"+ )++ first_array = next(iter(points_2d_by_camera.values()))+ if first_array.ndim != 3 or first_array.shape[2] != 2:+ raise ValueError(+ f"Expected dict values of shape (n_frames, n_points, 2), got {first_array.shape}"+ )+ n_frames, n_points = first_array.shape[0], first_array.shape[1]++ stacked = np.full(+ (self.n_cameras, n_frames, n_points, 2), np.nan, dtype=np.float64,+ )+ for camera_id, data in points_2d_by_camera.items():+ if data.shape != (n_frames, n_points, 2):+ raise ValueError(+ f"Camera '{camera_id}' has shape {data.shape}, "+ f"expected ({n_frames}, {n_points}, 2)"+ )+ stacked[id_to_idx[camera_id]] = data.astype(np.float64, copy=False)++ return stacked, False, n_frames, n_points++ def _compute_reprojection_error_flat(+ self,+ *,+ points_3d_flat: NDArray[np.float64],+ data2d_pixel_flat: NDArray[np.float64],+ ) -> NDArray[np.float64]:+ """Compute per-camera Euclidean pixel reprojection error. Returns (n_cameras, n_flat)."""+ projected = self.project(points_3d=points_3d_flat)+ diff = data2d_pixel_flat - projected+ nan_mask = np.isnan(data2d_pixel_flat).any(axis=2)+ norm = np.linalg.norm(diff, axis=2)+ norm[nan_mask] = np.nan+ return norm++ def _compute_reprojection_error_flat_normalized(+ self,+ *,+ points_3d_flat: NDArray[np.float64],+ data2d_normalized_flat: NDArray[np.float64],+ ) -> NDArray[np.float64]:+ """Per-camera Euclidean reprojection error in undistorted-normalized coords."""+ n_flat = points_3d_flat.shape[0]+ hom = np.concatenate(+ [points_3d_flat, np.ones((n_flat, 1), dtype=np.float64)], axis=1+ ) # (n_flat, 4)+ # _extrinsics_mats: (n_cameras, 3, 4); hom.T: (4, n_flat)+ proj = self._extrinsics_mats @ hom.T # (n_cameras, 3, n_flat)+ z = proj[:, 2, :] # (n_cameras, n_flat)+ with np.errstate(invalid="ignore", divide="ignore"):+ proj_2d = proj[:, :2, :] / z[:, None, :] # (n_cameras, 2, n_flat)+ proj_2d = np.transpose(proj_2d, (0, 2, 1)) # (n_cameras, n_flat, 2)+ diff = data2d_normalized_flat - proj_2d # (n_cameras, n_flat, 2)+ out = np.linalg.norm(diff, axis=2) # (n_cameras, n_flat)+ nan_mask = (+ np.isnan(data2d_normalized_flat).any(axis=2)+ | np.isnan(points_3d_flat).any(axis=1)[None, :]+ )+ out[nan_mask] = np.nan+ return out++ # =========================================================================+ # REPROJECTION ERROR (public helpers used by callers that already have 3D)+ # =========================================================================++ def signed_reprojection_error(+ self,+ *,+ points_3d: NDArray[np.float64],+ points_2d_pixel: NDArray[np.float64],+ ) -> NDArray[np.float64]:+ """Signed pixel reprojection error per camera, per point.++ Args:+ points_3d: (n_points, 3) world coordinates.+ points_2d_pixel: (n_cameras, n_points, 2) pixel observations.++ Returns:+ (n_cameras, n_points, 2) signed error = observation - projection.+ NaN where the original observation was NaN.+ """+ projected = self.project(points_3d=points_3d)+ error = points_2d_pixel - projected+ nan_mask = np.isnan(points_2d_pixel)+ error[nan_mask] = np.nan+ return error++ def mean_reprojection_error(+ self,+ *,+ points_3d: NDArray[np.float64],+ points_2d_pixel: NDArray[np.float64],+ ) -> NDArray[np.float64]:+ """Mean Euclidean reprojection error per point, averaged across valid cameras.++ Returns shape (n_points,) - NaN for points with fewer than 2 valid observations.+ """+ signed = self.signed_reprojection_error(+ points_3d=points_3d, points_2d_pixel=points_2d_pixel,+ )+ norm = np.linalg.norm(signed, axis=2) # (n_cameras, n_points)+ valid = ~np.isnan(norm)+ norm_zeroed = np.where(valid, norm, 0.0)+ denom = np.sum(valid, axis=0).astype(np.float64)+ denom[denom < 1.5] = np.nan+ return np.sum(norm_zeroed, axis=0) / denomdiff --git a/freemocap/core/types/type_overloads.py b/freemocap/core/types/type_overloads.pyindex 74ba9388..ab67a815 100644--- a/freemocap/core/types/type_overloads.py+++ b/freemocap/core/types/type_overloads.py@@ -6,7 +6,6 @@ import msgspecPointIndex = intPipelineIdString = strTrackedPointNameString = str-VideoIdString = strTopicPublicationQueue = multiprocessing.queues.QueueTopicSubscriptionQueue = multiprocessing.queues.Queuediff --git a/freemocap/core/viz/frontend_keypoints_serializer.py b/freemocap/core/viz/frontend_keypoints_serializer.pynew file mode 100644index 00000000..8d2e0493--- /dev/null+++ b/freemocap/core/viz/frontend_keypoints_serializer.py@@ -0,0 +1,156 @@+"""Build the binary keypoints websocket message from aggregation output.++The wire format is documented in `freemocap.api.websocket.binary_keypoints_protocol`.++This module:+ * Densifies the sparse `dict[name, ndarray(3,)]` from the aggregator into a+ fixed-size `(N, 3)` array aligned to the canonical schema point order+ (NaN for points that did not triangulate).+ * Appends a visibility column (1.0 if present, 0.0 if NaN).+ * Casts to the wire dtype (float32 by default — see the plan's "Open+ questions" decision: f32 on the wire is plenty for visualization and+ halves bandwidth vs the upstream f64).+ * Concatenates header + per-block (block_header + block_data) + footer into+ one contiguous bytearray ready for `websocket.send_bytes`.+"""+from __future__ import annotations++import logging++import numpy as np++from freemocap.api.websocket.binary_keypoints_protocol import (+ BLOCK_HEADER_SIZE,+ BlockKind,+ Dtype,+ KEYPOINTS_BLOCK_HEADER_DTYPE,+ KEYPOINTS_PAYLOAD_HEADER_FOOTER_DTYPE,+ MessageType,+ PAYLOAD_FOOTER_SIZE,+ PAYLOAD_HEADER_SIZE,+ TRACKER_ID_BYTES,+ CAMERA_ID_BYTES,+ numpy_dtype_for,+)++logger = logging.getLogger(__name__)+++_WIRE_DTYPE: Dtype = Dtype.FLOAT32+++def _densify_3d(+ sparse: dict[str, np.ndarray],+ point_names: tuple[str, ...] | list[str],+) -> np.ndarray:+ """Build an (N, 4) [x, y, z, visibility] array in canonical point-name order.++ Missing points → row of NaN with visibility 0.+ """+ n = len(point_names)+ arr = np.full((n, 4), np.nan, dtype=np.float32)+ arr[:, 3] = 0.0+ if not sparse:+ return arr+ for i, name in enumerate(point_names):+ coords = sparse.get(name)+ if coords is None:+ continue+ # Defensive: some upstream paths could hand us a (1, 3) or (3,)+ flat = np.asarray(coords, dtype=np.float32).reshape(-1)+ if flat.size < 3:+ continue+ arr[i, 0] = flat[0]+ arr[i, 1] = flat[1]+ arr[i, 2] = flat[2]+ arr[i, 3] = 1.0+ return arr+++def _build_block(+ *,+ kind: BlockKind,+ tracker_id: str,+ point_names: tuple[str, ...] | list[str],+ sparse_arrays: dict[str, np.ndarray],+ camera_id: str = "",+) -> bytes:+ dims = 3+ interleaved = _densify_3d(sparse_arrays, point_names)+ wire_np_dtype = numpy_dtype_for(_WIRE_DTYPE)+ payload_arr = interleaved.astype(wire_np_dtype, copy=False)+ payload_bytes = payload_arr.tobytes(order="C")++ header = np.zeros(1, dtype=KEYPOINTS_BLOCK_HEADER_DTYPE)+ header["message_type"] = int(MessageType.KEYPOINTS_BLOCK_HEADER)+ header["block_kind"] = int(kind)+ header["dtype_code"] = int(_WIRE_DTYPE)+ header["dims"] = dims+ header["camera_id"] = camera_id.encode("ascii", errors="ignore")[:CAMERA_ID_BYTES]+ header["tracker_id"] = tracker_id.encode("ascii", errors="ignore")[:TRACKER_ID_BYTES]+ header["num_points"] = len(point_names)+ header["data_byte_length"] = len(payload_bytes)+ return header.tobytes() + payload_bytes+++def build_keypoints_payload(+ *,+ frame_number: int,+ tracker_id: str,+ point_names: tuple[str, ...] | list[str],+ keypoints_raw_arrays: dict[str, np.ndarray],+ keypoints_filtered_arrays: dict[str, np.ndarray],+) -> bytearray:+ """Serialize the per-frame 3D keypoints into the binary wire format.++ Step 1 of the JSON→binary refactor: only `KEYPOINTS_RAW_3D` and+ `KEYPOINTS_FILTERED_3D` blocks. 2D overlays remain on the JSON path until+ Step 2.+ """+ blocks: list[bytes] = []+ blocks.append(+ _build_block(+ kind=BlockKind.KEYPOINTS_RAW_3D,+ tracker_id=tracker_id,+ point_names=point_names,+ sparse_arrays=keypoints_raw_arrays,+ )+ )+ blocks.append(+ _build_block(+ kind=BlockKind.KEYPOINTS_FILTERED_3D,+ tracker_id=tracker_id,+ point_names=point_names,+ sparse_arrays=keypoints_filtered_arrays,+ )+ )+ num_blocks = len(blocks)++ header = np.zeros(1, dtype=KEYPOINTS_PAYLOAD_HEADER_FOOTER_DTYPE)+ header["message_type"] = int(MessageType.KEYPOINTS_PAYLOAD_HEADER)+ header["frame_number"] = int(frame_number)+ header["num_blocks"] = num_blocks++ footer = np.zeros(1, dtype=KEYPOINTS_PAYLOAD_HEADER_FOOTER_DTYPE)+ footer["message_type"] = int(MessageType.KEYPOINTS_PAYLOAD_FOOTER)+ footer["frame_number"] = int(frame_number)+ footer["num_blocks"] = num_blocks++ total_size = (+ PAYLOAD_HEADER_SIZE+ + sum(len(b) for b in blocks)+ + PAYLOAD_FOOTER_SIZE+ )+ out = bytearray(total_size)+ offset = 0+ header_bytes = header.tobytes()+ out[offset:offset + len(header_bytes)] = header_bytes+ offset += len(header_bytes)+ for b in blocks:+ out[offset:offset + len(b)] = b+ offset += len(b)+ footer_bytes = footer.tobytes()+ out[offset:offset + len(footer_bytes)] = footer_bytes+ offset += len(footer_bytes)+ assert offset == total_size, (offset, total_size)+ return outdiff --git a/freemocap/core/viz/frontend_payload.py b/freemocap/core/viz/frontend_payload.pyindex 7b4b8df7..e3d3bbcf 100644--- a/freemocap/core/viz/frontend_payload.py+++ b/freemocap/core/viz/frontend_payload.py@@ -57,6 +57,9 @@ class FrontendImagePacket:images_bytearray: bytearraymultiframe_timestamp: MultiframeTimestampFloatfrontend_payload: FrontendPayload+ # Optional binary keypoints message. Built when FREEMOCAP_BINARY_KEYPOINTS=1.+ # Format: see freemocap.api.websocket.binary_keypoints_protocol.+ keypoints_binary_payload: bytearray | None = None@propertydef frame_number(self) -> FrameNumberInt:diff --git a/freemocap/pubsub/pubsub_abcs.py b/freemocap/pubsub/pubsub_abcs.pyindex 411c35fd..17d9cfb5 100644--- a/freemocap/pubsub/pubsub_abcs.py+++ b/freemocap/pubsub/pubsub_abcs.py@@ -1,13 +1,15 @@import loggingimport multiprocessingfrom dataclasses import dataclass, field-from queue import Empty+from queue import Empty, Fullfrom typing import TypeVar, Generic, ClassVarfrom freemocap.core.types.type_overloads import TopicPublicationQueue, TopicSubscriptionQueuelogger = logging.getLogger(__name__)+_TOPIC_QUEUE_MAXSIZE: int = 100 # prevents unbounded growth when consumers lag+@dataclassclass TopicMessageABC:@@ -27,13 +29,20 @@ class PubSubTopicABC(Generic[MessageType]):in children, or via publish() in the main process). The PubSubRelaythread reads from the publication queue and fans out to allsubscription queues.++ Set queue_maxsize=0 on a subclass for an unbounded queue (e.g. topics+ where the producer can outrun the consumer before the consumer starts)."""topic_registry: ClassVar[set[type['PubSubTopicABC']]] = set()+ queue_maxsize: ClassVar[int] = _TOPIC_QUEUE_MAXSIZEmessage_type: type[TopicMessageABC] = TopicMessageABC- publication: TopicPublicationQueue = field(default_factory=multiprocessing.Queue)+ publication: TopicPublicationQueue = field(init=False)subscriptions: list[TopicSubscriptionQueue] = field(default_factory=list)+ def __post_init__(self) -> None:+ self.publication = multiprocessing.Queue(maxsize=self.__class__.queue_maxsize)+def __init_subclass__(cls, **kwargs) -> None:"""Auto-register when subclassed."""super().__init_subclass__(**kwargs)@@ -45,7 +54,7 @@ class PubSubTopicABC(Generic[MessageType]):def get_subscription(self) -> TopicSubscriptionQueue:"""Create and register a new subscription queue."""- sub = multiprocessing.Queue()+ sub = multiprocessing.Queue(maxsize=self.__class__.queue_maxsize)self.subscriptions.append(sub)return sub@@ -74,7 +83,17 @@ class PubSubTopicABC(Generic[MessageType]):except Empty:breakfor sub in self.subscriptions:- sub.put(message)+ try:+ sub.put_nowait(message)+ except Full:+ try:+ sub.get_nowait() # evict oldest to make room+ except Empty:+ pass+ try:+ sub.put_nowait(message)+ except Full:+ pass # concurrent consumer drained it between our get and putrelayed += 1return relayed@@ -93,18 +112,26 @@ class PubSubTopicABC(Generic[MessageType]):def create_topic(message_type: type[MessageType],+ queue_maxsize: int | None = None,) -> type[PubSubTopicABC[MessageType]]:"""Factory that creates a topic class for a message type.Uses type() to dynamically create a subclass — triggers auto-registrationvia __init_subclass__.++ Pass queue_maxsize=0 for an unbounded queue on topics where a slow-starting+ consumer (e.g. a child process) must not lose messages produced before it starts."""topic_name = message_type.__name__.replace('Message', 'Topic')- topic_class = type(topic_name, (PubSubTopicABC,), {+ attrs: dict = {'message_type': message_type,'__module__': message_type.__module__,- })+ }+ if queue_maxsize is not None:+ attrs['queue_maxsize'] = queue_maxsize++ topic_class = type(topic_name, (PubSubTopicABC,), attrs)return topic_classdiff --git a/freemocap/pubsub/pubsub_manager.py b/freemocap/pubsub/pubsub_manager.pyindex 350407c7..b4bb24f0 100644--- a/freemocap/pubsub/pubsub_manager.py+++ b/freemocap/pubsub/pubsub_manager.py@@ -102,6 +102,17 @@ class PubSubTopicManager:)self.topics[topic_type].publish(message)+ def drain(self) -> None:+ """Flush pending messages from publication queues to subscription queues.++ Safe to call while the relay thread is running — both this method and+ the relay loop acquire the subscriptions lock before touching queues,+ so they never race. Use this to capture messages that a worker process+ put into a publication queue just before exiting.+ """+ if self._relay is not None:+ self._relay._drain()+def close(self) -> None:"""Stop the relay thread (draining remaining messages), then close all topics."""logger.debug("Closing PubSubTopicManager...")diff --git a/freemocap/pubsub/pubsub_relay.py b/freemocap/pubsub/pubsub_relay.pyindex 92a1c821..a16046b1 100644--- a/freemocap/pubsub/pubsub_relay.py+++ b/freemocap/pubsub/pubsub_relay.py@@ -131,10 +131,10 @@ class PubSubRelay:Drain all remaining messages from publication queues to subscribers.Called during shutdown to ensure no messages are lost."""- deadline = time.monotonic() + RELAY_DRAIN_TIMEOUT_SECONDS+ deadline = time.perf_counter() + RELAY_DRAIN_TIMEOUT_SECONDStotal_drained = 0- while time.monotonic() < deadline:+ while time.perf_counter() < deadline:drained_this_pass = 0with self._subscriptions_lock:for topic in self.topics.values():diff --git a/freemocap/pubsub/pubsub_topics.py b/freemocap/pubsub/pubsub_topics.pyindex 26f50e81..fde311ce 100644--- a/freemocap/pubsub/pubsub_topics.py+++ b/freemocap/pubsub/pubsub_topics.py@@ -6,8 +6,9 @@ via __init_subclass__ so the PubSubTopicManager discovers them at startup."""import loggingfrom dataclasses import dataclass, field-from typing import TYPE_CHECKING, Self+from typing import TYPE_CHECKING+import numpy as npfrom skellycam.core.types.type_overloads import CameraGroupIdString, CameraIdString, MultiframeTimestampFloatfrom skellyforge.data_models.trajectory_3d import Point3dfrom skellytracker.trackers.base_tracker.base_tracker_abcs import BaseObservation@@ -17,7 +18,6 @@ from freemocap.core.tasks.mocap.skeleton_dewiggler.dewiggling_methods.rigid_bodyfrom freemocap.core.types.type_overloads import (FrameNumberInt,PipelineIdString,- VideoIdString,TrackedPointNameString,)from freemocap.pubsub.pubsub_abcs import TopicMessageABC, create_topic@@ -68,13 +68,32 @@ class CameraNodeOutputMessage(TopicMessageABC):raise ValueError(f"frame_number must be >= 0, got {self.frame_number}")+# ---------------------------------------------------------------------------+# Centralized GPU skeleton inference results+# ---------------------------------------------------------------------------+# Published by RealtimeSkeletonInferenceNode when GPU mode is on. One message+# per processed multi-camera frame, holding per-camera skeleton observations+# from a single batched ONNX call. Aggregator merges this with per-camera+# CameraNodeOutputMessage (which carries charuco only in this mode) by+# (frame_number).++@dataclass+class SkeletonInferenceResultMessage(TopicMessageABC):+ frame_number: FrameNumberInt = 0+ per_camera_skeleton: dict[CameraIdString, BaseObservation | None] = field(default_factory=dict)++ def __post_init__(self) -> None:+ if self.frame_number < 0:+ raise ValueError(f"frame_number must be >= 0, got {self.frame_number}")++# ---------------------------------------------------------------------------# Video (posthoc) node outputs# ---------------------------------------------------------------------------@dataclassclass VideoNodeOutputMessage(TopicMessageABC):- video_id: VideoIdString = ""+ camera_id: CameraIdString = ""frame_number: FrameNumberInt = 0observation: BaseObservation = None@@ -96,6 +115,12 @@ class AggregationNodeOutputMessage(TopicMessageABC):camera_node_outputs: dict[CameraIdString, CameraNodeOutputMessage] = field(default_factory=dict)keypoints_raw: dict[TrackedPointNameString, Point3d] = field(default_factory=dict)keypoints_filtered: dict[TrackedPointNameString, Point3d] = field(default_factory=dict)+ # Pre-Point3d numpy form of the same data, kept around so the websocket+ # binary serializer can ship raw bytes without re-unwrapping each+ # Pydantic model. Each value is a (3,) float array. Sparse — only points+ # that triangulated successfully are present.+ keypoints_raw_arrays: dict[TrackedPointNameString, np.ndarray] = field(default_factory=dict)+ keypoints_filtered_arrays: dict[TrackedPointNameString, np.ndarray] = field(default_factory=dict)rigid_body_poses: dict[str, RigidBodyPose] = field(default_factory=dict)def __post_init__(self) -> None:@@ -147,47 +172,20 @@ class AggregationNodeOutputMessage(TopicMessageABC):# ----------------------------------------------------------------------------# Posthoc progress reporting+# Pipeline stage timing (opt-in profiling)# ---------------------------------------------------------------------------+# Each instrumented node batches its per-stage elapsed-ms samples and publishes+# them periodically. The aggregator runs a reporter thread that subscribes,+# maintains rolling buffers across all nodes, and prints one consolidated+# report. Camera-node samples for the same stage collapse across camera_id+# into ensemble statistics so adding cameras doesn't multiply log volume.@dataclass-class PipelineProgressMessage(TopicMessageABC):- pipeline_id: PipelineIdString = ""- frame_count: int = 0- last_processed: FrameNumberInt = -1- working: bool = False- complete: bool = False- error: bool = False- error_message: str | None = None-- def __post_init__(self) -> None:- if self.frame_count < 0:- raise ValueError(f"frame_count must be >= 0, got {self.frame_count}")-- def increment(self) -> Self:- if not self.working:- self.working = True- if self.last_processed + 1 >= self.frame_count:- self.complete = True- self.working = False- if self.last_processed > self.frame_count:- raise ValueError(- f"Cannot increment last_processed beyond frame_count: "- f"{self.last_processed} + 1 > {self.frame_count}"- )- self.last_processed += 1- return self----@dataclass-class VideoNodeProgressMessage(PipelineProgressMessage):- video_id: VideoIdString = ""---@dataclass-class AggregatorNodeProgressMessage(PipelineProgressMessage):- running_aggregation_task: bool = False+class PipelineTimingMessage(TopicMessageABC):+ node_kind: str = "" # "camera" | "skeleton_inference" | "aggregator"+ node_label: str = "" # human-readable label for log section headers+ camera_id: CameraIdString | None = None # set only for camera nodes+ samples: dict[str, list[float]] = field(default_factory=dict) # stage -> elapsed_ms batch# ---------------------------------------------------------------------------@@ -197,7 +195,7 @@ class AggregatorNodeProgressMessage(PipelineProgressMessage):ProcessFrameNumberTopic = create_topic(ProcessFrameNumberMessage)PipelineConfigUpdateTopic = create_topic(PipelineConfigUpdateMessage)CameraNodeOutputTopic = create_topic(CameraNodeOutputMessage)-VideoNodeOutputTopic = create_topic(VideoNodeOutputMessage)+SkeletonInferenceResultTopic = create_topic(SkeletonInferenceResultMessage)+VideoNodeOutputTopic = create_topic(VideoNodeOutputMessage, queue_maxsize=0) # unbounded: posthoc video nodes finish before aggregation node startsAggregationNodeOutputTopic = create_topic(AggregationNodeOutputMessage)-VideoNodeProgressTopic = create_topic(VideoNodeProgressMessage)-AggregatorNodeProgressTopic = create_topic(AggregatorNodeProgressMessage)+PipelineTimingTopic = create_topic(PipelineTimingMessage)diff --git a/freemocap/system/default_paths.py b/freemocap/system/default_paths.pyindex 1d43bfdf..7e75e77f 100644--- a/freemocap/system/default_paths.py+++ b/freemocap/system/default_paths.py@@ -43,11 +43,6 @@ def get_default_recording_folder_path(tag: str = "") -> str:return str(Path(get_default_freemocap_base_folder_path()) / "recordings" / default_recording_name(string_tag=tag))-def get_default_calibration_toml_path() -> str:- calib_path = Path(- get_default_freemocap_base_folder_path()) / "calibrations" / f"{default_recording_name()}_camera_calibration.toml"- calib_path.parent.mkdir(exist_ok=True, parents=True)- return str(calib_path)def get_log_file_path() -> str:diff --git a/freemocap/system/recording_structure/__init__.py b/freemocap/system/recording_structure/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/freemocap/system/recording_structure/recording_structure.py b/freemocap/system/recording_structure/recording_structure.pynew file mode 100644index 00000000..8dec818a--- /dev/null+++ b/freemocap/system/recording_structure/recording_structure.py@@ -0,0 +1,178 @@+"""Canonical folder layout for a freemocap recording.++This module is the authoritative source of truth for "what files live where+in a recording folder". Every path reference in the backend should flow+through `RecordingStructure` rather than being hand-assembled from strings.++The frontend mirrors this layout in+`freemocap-ui/src/store/slices/active-recording/recording-structure.ts` — keep+the two in sync.++Layout (target):++ {base_directory}/{recording_name}/+ ├── videos/+ │ ├── synchronized/ # was synchronized_videos/+ │ └── annotated/ # was annotated_videos/+ ├── output/ # per-stage processed artifacts+ ├── logs/ # per-recording logs+ ├── {recording_name}_calibration.toml # authoritative TOML for this recording+ ├── {recording_name}_recording_info.json # camera configs + recording_type tags+ ├── {recording_name}_data.parquet # primary mocap data store+ └── {recording_name}.blend # optional Blender export++Calibration and mocap are recording-type tags (captured in+`recording_info.json`), not separate sibling folders.+"""+from __future__ import annotations++from datetime import datetime+from pathlib import Path+from typing import Literal++from pydantic import BaseModel, ConfigDict, computed_field++RecordingTypeTag = Literal["calibration", "mocap"]+++class FilePresence(BaseModel):+ path: str+ exists: bool+ size_bytes: int | None = None+++class RecordingLayoutValidation(BaseModel):+ """Report describing which expected files/dirs are present on disk.++ `is_legacy_layout` is true if any legacy marker exists — the frontend uses+ the individual marker fields to pick a layout preset.+ """++ full_path: str+ is_legacy_layout: bool = False+ videos_synchronized: FilePresence+ videos_annotated: FilePresence+ output_dir: FilePresence+ calibration_toml: FilePresence+ recording_info: FilePresence+ data_parquet: FilePresence+ blend: FilePresence+ synchronized_videos_dir: FilePresence+ annotated_videos_dir: FilePresence+ output_data_dir: FilePresence+ camera_calibration_toml: FilePresence+ legacy_parquet_in_output_data: FilePresence+++class RecordingStructure(BaseModel):+ """Canonical model of a freemocap recording folder layout.++ Consumers build one of these at the system boundary (router arg parsing,+ capture thunk completion, etc.) and pass it around instead of raw strings.+ """++ base_directory: Path+ recording_name: str++ @computed_field+ @property+ def full_path(self) -> Path:+ return self.base_directory / self.recording_name++ @computed_field+ @property+ def videos_synchronized_dir(self) -> Path:+ return self.full_path / "videos" / "synchronized"++ @computed_field+ @property+ def videos_annotated_dir(self) -> Path:+ return self.full_path / "videos" / "annotated"++ @computed_field+ @property+ def output_dir(self) -> Path:+ return self.full_path / "output"++ @computed_field+ @property+ def logs_dir(self) -> Path:+ return self.full_path / "logs"++ @computed_field+ @property+ def calibration_toml_path(self) -> Path:+ return self.full_path / f"{self.recording_name}_calibration.toml"++ @computed_field+ @property+ def recording_info_path(self) -> Path:+ return self.full_path / f"{self.recording_name}_recording_info.json"++ @computed_field+ @property+ def data_parquet_path(self) -> Path:+ return self.full_path / f"{self.recording_name}_data.parquet"++ @computed_field+ @property+ def blend_path(self) -> Path:+ return self.full_path / f"{self.recording_name}.blend"++ def create_on_disk(self) -> None:+ """Create the expected subdirectory skeleton. Idempotent."""+ for d in (self.videos_synchronized_dir, self.videos_annotated_dir, self.output_dir, self.logs_dir):+ d.mkdir(parents=True, exist_ok=True)++ def validate_layout(self) -> RecordingLayoutValidation:+ """Check which expected files/dirs exist. Returns a report, does not raise."""+ legacy_sync = self.full_path / "synchronized_videos"+ legacy_annot = self.full_path / "annotated_videos"+ legacy_output = self.full_path / "output_data"+ legacy_calib = self.full_path / f"{self.recording_name}_camera_calibration.toml"+ legacy_parquet = legacy_output / "freemocap_data_by_frame.parquet"++ synchronized_videos_dir = _presence(legacy_sync)+ annotated_videos_dir = _presence(legacy_annot)+ output_data_dir = _presence(legacy_output)+ camera_calibration_toml = _presence(legacy_calib)+ legacy_parquet_in_output_data = _presence(legacy_parquet)++ is_legacy = any((+ synchronized_videos_dir.exists,+ annotated_videos_dir.exists,+ output_data_dir.exists,+ camera_calibration_toml.exists,+ legacy_parquet_in_output_data.exists,+ ))++ return RecordingLayoutValidation(+ full_path=str(self.full_path),+ is_legacy_layout=is_legacy,+ videos_synchronized=_presence(+ self.videos_synchronized_dir+ if self.videos_synchronized_dir.exists()+ else legacy_sync+ ),+ videos_annotated=_presence(+ self.videos_annotated_dir+ if self.videos_annotated_dir.exists()+ else legacy_annot+ ),+ output_dir=_presence(self.output_dir),+ calibration_toml=_presence(self.calibration_toml_path),+ recording_info=_presence(self.recording_info_path),+ data_parquet=_presence(self.data_parquet_path),+ blend=_presence(self.blend_path),+ synchronized_videos_dir=synchronized_videos_dir,+ annotated_videos_dir=annotated_videos_dir,+ output_data_dir=output_data_dir,+ camera_calibration_toml=camera_calibration_toml,+ legacy_parquet_in_output_data=legacy_parquet_in_output_data,+ )+++def _presence(path: Path) -> FilePresence:+ exists = path.exists()+ size = path.stat().st_size if exists and path.is_file() else None+ return FilePresence(path=str(path), exists=exists, size_bytes=size)diff --git a/freemocap/tests/test_binary_keypoints_protocol.py b/freemocap/tests/test_binary_keypoints_protocol.pynew file mode 100644index 00000000..65d798ab--- /dev/null+++ b/freemocap/tests/test_binary_keypoints_protocol.py@@ -0,0 +1,154 @@+"""Round-trip tests for the binary keypoints websocket message.++The wire format is parsed by the freemocap-ui frontend; this test stands in+for that parser by reading the same dtypes back out with numpy and asserting+the bytes survive the trip unchanged.+"""+import numpy as np+import pytest++from freemocap.api.websocket.binary_keypoints_protocol import (+ BLOCK_HEADER_SIZE,+ BlockKind,+ Dtype,+ KEYPOINTS_BLOCK_HEADER_DTYPE,+ KEYPOINTS_PAYLOAD_HEADER_FOOTER_DTYPE,+ MessageType,+ PAYLOAD_FOOTER_SIZE,+ PAYLOAD_HEADER_SIZE,+ numpy_dtype_for,+)+from freemocap.core.viz.frontend_keypoints_serializer import build_keypoints_payload+++POINT_NAMES = ("nose", "left_shoulder", "right_shoulder", "left_hip", "right_hip")+++def test_dtype_sizes_are_stable():+ # Frontend mirrors these sizes — flag any change so the TS side is updated+ # in the same commit.+ assert PAYLOAD_HEADER_SIZE == 24+ assert PAYLOAD_FOOTER_SIZE == 24+ assert BLOCK_HEADER_SIZE == 60+++def test_round_trip_3d_blocks():+ raw = {+ "nose": np.array([1.0, 2.0, 3.0], dtype=np.float64),+ "left_shoulder": np.array([10.0, 20.0, 30.0], dtype=np.float64),+ # right_shoulder intentionally missing → NaN row + visibility 0+ "left_hip": np.array([100.0, 200.0, 300.0], dtype=np.float64),+ "right_hip": np.array([1000.0, 2000.0, 3000.0], dtype=np.float64),+ }+ filtered = {+ # Subset only — filtered points are typically a subset of raw+ "nose": np.array([1.1, 2.1, 3.1], dtype=np.float64),+ }++ blob = build_keypoints_payload(+ frame_number=42,+ tracker_id="rtmpose_wholebody",+ point_names=POINT_NAMES,+ keypoints_raw_arrays=raw,+ keypoints_filtered_arrays=filtered,+ )++ expected_block_size = BLOCK_HEADER_SIZE + len(POINT_NAMES) * 4 * 4 # f32, 4 cols+ expected_total = PAYLOAD_HEADER_SIZE + 2 * expected_block_size + PAYLOAD_FOOTER_SIZE+ assert len(blob) == expected_total++ buf = bytes(blob)++ header = np.frombuffer(buf[:PAYLOAD_HEADER_SIZE], dtype=KEYPOINTS_PAYLOAD_HEADER_FOOTER_DTYPE)[0]+ assert int(header["message_type"]) == int(MessageType.KEYPOINTS_PAYLOAD_HEADER)+ assert int(header["frame_number"]) == 42+ assert int(header["num_blocks"]) == 2++ cursor = PAYLOAD_HEADER_SIZE+ for kind, sparse in [+ (BlockKind.KEYPOINTS_RAW_3D, raw),+ (BlockKind.KEYPOINTS_FILTERED_3D, filtered),+ ]:+ block_header = np.frombuffer(+ buf[cursor:cursor + BLOCK_HEADER_SIZE],+ dtype=KEYPOINTS_BLOCK_HEADER_DTYPE,+ )[0]+ assert int(block_header["message_type"]) == int(MessageType.KEYPOINTS_BLOCK_HEADER)+ assert int(block_header["block_kind"]) == int(kind)+ assert int(block_header["dtype_code"]) == int(Dtype.FLOAT32)+ assert int(block_header["dims"]) == 3+ assert block_header["tracker_id"].decode("ascii").rstrip("\x00") == "rtmpose_wholebody"+ assert block_header["camera_id"].decode("ascii").rstrip("\x00") == ""+ assert int(block_header["num_points"]) == len(POINT_NAMES)+ cursor += BLOCK_HEADER_SIZE++ wire_dtype = numpy_dtype_for(Dtype.FLOAT32)+ data_len = int(block_header["data_byte_length"])+ assert data_len == len(POINT_NAMES) * 4 * wire_dtype.itemsize+ flat = np.frombuffer(buf[cursor:cursor + data_len], dtype=wire_dtype)+ arr = flat.reshape(len(POINT_NAMES), 4)+ cursor += data_len++ for i, name in enumerate(POINT_NAMES):+ if name in sparse:+ expected = sparse[name].astype(np.float32)+ np.testing.assert_array_equal(arr[i, :3], expected)+ assert arr[i, 3] == 1.0+ else:+ assert np.all(np.isnan(arr[i, :3]))+ assert arr[i, 3] == 0.0++ footer = np.frombuffer(buf[cursor:cursor + PAYLOAD_FOOTER_SIZE], dtype=KEYPOINTS_PAYLOAD_HEADER_FOOTER_DTYPE)[0]+ assert int(footer["message_type"]) == int(MessageType.KEYPOINTS_PAYLOAD_FOOTER)+ assert int(footer["frame_number"]) == 42+ assert int(footer["num_blocks"]) == 2+ cursor += PAYLOAD_FOOTER_SIZE+ assert cursor == len(blob)+++def test_empty_dicts_produce_all_nan_rows():+ blob = build_keypoints_payload(+ frame_number=0,+ tracker_id="rtmpose_wholebody",+ point_names=POINT_NAMES,+ keypoints_raw_arrays={},+ keypoints_filtered_arrays={},+ )+ # First block payload starts at PAYLOAD_HEADER_SIZE + BLOCK_HEADER_SIZE+ start = PAYLOAD_HEADER_SIZE + BLOCK_HEADER_SIZE+ end = start + len(POINT_NAMES) * 4 * 4+ arr = np.frombuffer(bytes(blob)[start:end], dtype=np.float32).reshape(len(POINT_NAMES), 4)+ assert np.all(np.isnan(arr[:, :3]))+ assert np.all(arr[:, 3] == 0.0)+++def test_first_byte_is_payload_header_message_type():+ # The frontend demuxes inbound binary frames on byte 0. Image frames use+ # MessageType.PAYLOAD_HEADER = 0; keypoints messages must use a distinct+ # value or the demux fails.+ blob = build_keypoints_payload(+ frame_number=1,+ tracker_id="rtmpose_wholebody",+ point_names=POINT_NAMES,+ keypoints_raw_arrays={},+ keypoints_filtered_arrays={},+ )+ assert blob[0] == int(MessageType.KEYPOINTS_PAYLOAD_HEADER)+ assert int(MessageType.KEYPOINTS_PAYLOAD_HEADER) >= 3 # avoids skellycam image protocol values 0/1/2+++def test_tracker_id_truncates_safely_on_overlong_input():+ # Defensive: if a tracker ever has a name >16 chars, we should still emit+ # a valid blob (truncated id), not crash.+ blob = build_keypoints_payload(+ frame_number=0,+ tracker_id="x" * 64,+ point_names=POINT_NAMES,+ keypoints_raw_arrays={},+ keypoints_filtered_arrays={},+ )+ block_header = np.frombuffer(+ bytes(blob)[PAYLOAD_HEADER_SIZE:PAYLOAD_HEADER_SIZE + BLOCK_HEADER_SIZE],+ dtype=KEYPOINTS_BLOCK_HEADER_DTYPE,+ )[0]+ assert block_header["tracker_id"] == b"x" * 32diff --git a/freemocap/tests/test_e2e_pipeline.py b/freemocap/tests/test_e2e_pipeline.pyindex 74234481..2626bf62 100644--- a/freemocap/tests/test_e2e_pipeline.py+++ b/freemocap/tests/test_e2e_pipeline.py@@ -42,9 +42,9 @@ PIPELINE_TIMEOUT_SECONDS = 600def _wait_for_pipeline(pipeline: PosthocPipeline, timeout: float = PIPELINE_TIMEOUT_SECONDS) -> None:"""Poll until the pipeline finishes or timeout is reached."""- start = time.monotonic()+ start = time.perf_counter()while pipeline.alive:- if time.monotonic() - start > timeout:+ if time.perf_counter() - start > timeout:pipeline.shutdown()raise TimeoutError(f"Pipeline [{pipeline.id}] did not complete within {timeout}s"diff --git a/freemocap/tests/triangulation/__init__.py b/freemocap/tests/triangulation/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/freemocap/tests/triangulation/test_outlier_rejection.py b/freemocap/tests/triangulation/test_outlier_rejection.pynew file mode 100644index 00000000..0bd5eafd--- /dev/null+++ b/freemocap/tests/triangulation/test_outlier_rejection.py@@ -0,0 +1,178 @@+"""Unit tests for the unified triangulation module.++Covers:+ - triangulate_with_outlier_rejection clean-data parity with triangulate_simple+ - triangulate_with_outlier_rejection actually rejects a corrupt camera+ - Triangulator.triangulate dispatches across dict / 3D-array / 4D-array inputs+"""+import numpy as np++from freemocap.core.tasks.calibration.shared.camera_intrinsics import CameraIntrinsics+from freemocap.core.tasks.calibration.shared.camera_extrinsics import CameraExtrinsics+from freemocap.core.tasks.calibration.shared.camera_model import CameraModel+from freemocap.core.tasks.triangulation.helpers.outlier_rejection import (+ triangulate_with_outlier_rejection,+)+from freemocap.core.tasks.triangulation import triangulate_simple, project_point_to_camera+from freemocap.core.tasks.triangulation.helpers.triangulation_config import TriangulationConfig+from freemocap.core.tasks.triangulation.triangulator import Triangulator+++# =============================================================================+# Synthetic 4-camera scene+# =============================================================================+++def _make_synthetic_extrinsics() -> tuple[np.ndarray, list[CameraModel]]:+ """4 cameras around a 1m scene cube, looking inward at the origin.++ Returns (extrinsics_mats (4,3,4), CameraModels with identity-like intrinsics).+ """+ rng = np.random.default_rng(42)+ rotations = []+ translations = []+ extrinsics_mats = np.zeros((4, 3, 4), dtype=np.float64)++ # Place cameras at the corners of a square in the XY plane, looking at origin.+ cam_positions = np.array(+ [+ [2.0, 0.0, 0.5],+ [0.0, 2.0, 0.5],+ [-2.0, 0.0, 0.5],+ [0.0, -2.0, 0.5],+ ]+ )++ cameras: list[CameraModel] = []+ for i, pos in enumerate(cam_positions):+ # Rotation that points the camera at the origin+ forward = -pos / np.linalg.norm(pos)+ up = np.array([0.0, 0.0, 1.0])+ right = np.cross(forward, up)+ right = right / np.linalg.norm(right)+ up = np.cross(right, forward)+ # Camera coordinate frame: right (x), -up (y, image y flips), forward (z)+ R = np.stack([right, -up, forward], axis=0)+ t = -R @ pos+ extrinsics_mats[i, :, :3] = R+ extrinsics_mats[i, :, 3] = t+ rotations.append(R)+ translations.append(t)++ cameras.append(+ CameraModel(+ id=f"cam_{i}",+ image_size=(640, 480),+ intrinsics=CameraIntrinsics(fx=500.0, fy=500.0, cx=320.0, cy=240.0),+ extrinsics=CameraExtrinsics.from_rodrigues(+ rvec=np.asarray(__import__("cv2").Rodrigues(R)[0]).ravel(),+ tvec=t,+ ),+ )+ )+ return extrinsics_mats, cameras+++def _project_normalized(point_3d: np.ndarray, extrinsics_mats: np.ndarray) -> np.ndarray:+ """Project a single 3D point through each camera's [R|t] -> normalized 2D."""+ return np.array(+ [project_point_to_camera(point_3d=point_3d, extrinsics_mat=mat) for mat in extrinsics_mats]+ )+++# =============================================================================+# Tests+# =============================================================================+++def test_outlier_rejection_clean_data_matches_simple_dlt():+ """With perfectly clean observations the outlier-rejection method should match simple DLT+ and return uniform per-camera weights (all 1.0 - the early-exit branch)."""+ extrinsics_mats, _ = _make_synthetic_extrinsics()+ truth = np.array([0.1, 0.2, 0.3])+ obs = _project_normalized(point_3d=truth, extrinsics_mats=extrinsics_mats)++ p3d_simple = triangulate_simple(points=obs, extrinsics_mats=extrinsics_mats)+ p3d_robust, weights = triangulate_with_outlier_rejection(+ points_2d=obs,+ extrinsics_mats=extrinsics_mats,+ target_reprojection_error=1e-3,+ )++ np.testing.assert_allclose(p3d_simple, truth, atol=1e-9)+ np.testing.assert_allclose(p3d_robust, truth, atol=1e-9)+ np.testing.assert_allclose(p3d_robust, p3d_simple, atol=1e-9)+ # Early-exit branch returns uniform 1.0 weights.+ np.testing.assert_allclose(weights, 1.0)+++def test_outlier_rejection_recovers_from_corrupt_camera():+ """If one camera's observation is corrupted, the recovered 3D point should be closer to+ ground truth than plain DLT, and the corrupt camera's weight should be lowest."""+ extrinsics_mats, _ = _make_synthetic_extrinsics()+ truth = np.array([0.1, 0.2, 0.3])+ obs = _project_normalized(point_3d=truth, extrinsics_mats=extrinsics_mats)++ corrupt_idx = 2+ obs_corrupt = obs.copy()+ obs_corrupt[corrupt_idx] += np.array([0.5, 0.5]) # large normalized-coord offset++ p3d_simple = triangulate_simple(points=obs_corrupt, extrinsics_mats=extrinsics_mats)+ p3d_robust, weights = triangulate_with_outlier_rejection(+ points_2d=obs_corrupt,+ extrinsics_mats=extrinsics_mats,+ target_reprojection_error=0.001,+ maximum_cameras_to_drop=1,+ )++ err_simple = float(np.linalg.norm(p3d_simple - truth))+ err_robust = float(np.linalg.norm(p3d_robust - truth))+ assert err_robust < err_simple, (+ f"Outlier rejection should beat plain DLT on corrupt input; "+ f"err_simple={err_simple}, err_robust={err_robust}"+ )++ # The corrupt camera should carry the lowest weight.+ other_weights = np.delete(weights, corrupt_idx)+ assert weights[corrupt_idx] < float(np.min(other_weights)), (+ f"Corrupt camera weight ({weights[corrupt_idx]}) should be < min of others "+ f"({float(np.min(other_weights))}); got weights={weights}"+ )+++def test_triangulator_dispatch_across_input_shapes():+ """All three input shapes (dict, 3D, 4D) should produce the same 3D points;+ use_outlier_rejection True/False should match within 1e-9 on clean data."""+ _, cameras = _make_synthetic_extrinsics()+ triangulator = Triangulator(cameras=cameras)++ truth = np.array([10.0, 20.0, 30.0]) # in mm-ish scale, doesn't matter++ # Project through each camera's full intrinsics+extrinsics into pixel coords.+ pixel_obs = triangulator.project(points_3d=truth.reshape(1, 3)) # (n_cameras, 1, 2)++ # Build the three input shapes:+ arr_3d = pixel_obs.reshape(triangulator.n_cameras, 1, 2) # (n_cameras, n_points=1, 2)+ arr_4d = pixel_obs.reshape(triangulator.n_cameras, 1, 1, 2) # (n_cameras, n_frames=1, n_points=1, 2)+ dict_input = {+ cam.name: pixel_obs[i].reshape(1, 1, 2) # (n_frames, n_points, 2)+ for i, cam in enumerate(triangulator.cameras)+ }++ cfg_off = TriangulationConfig(use_outlier_rejection=False)+ cfg_on = TriangulationConfig(use_outlier_rejection=True, target_reprojection_error=1e-3)++ res_3d = triangulator.triangulate(data2d=arr_3d, config=cfg_off)+ res_4d = triangulator.triangulate(data2d=arr_4d, config=cfg_off)+ res_dict = triangulator.triangulate(data2d=dict_input, config=cfg_off)+ res_or = triangulator.triangulate(data2d=arr_3d, config=cfg_on)++ assert res_3d.points_3d.shape == (1, 3)+ assert res_4d.points_3d.shape == (1, 1, 3)+ assert res_dict.points_3d.shape == (1, 1, 3)+ assert res_or.points_3d.shape == (1, 3)++ np.testing.assert_allclose(res_3d.points_3d.ravel(), truth, atol=1e-6)+ np.testing.assert_allclose(res_4d.points_3d.ravel(), truth, atol=1e-6)+ np.testing.assert_allclose(res_dict.points_3d.ravel(), truth, atol=1e-6)+ np.testing.assert_allclose(res_or.points_3d.ravel(), res_3d.points_3d.ravel(), atol=1e-9)diff --git a/freemocap/utilities/asyncio_exception_handler.py b/freemocap/utilities/asyncio_exception_handler.pynew file mode 100644index 00000000..ce390643--- /dev/null+++ b/freemocap/utilities/asyncio_exception_handler.py@@ -0,0 +1,30 @@+import asyncio+import logging++logger = logging.getLogger(__name__)+++def suppress_proactor_connection_reset(loop: asyncio.AbstractEventLoop) -> None:+ """Silence noisy ConnectionResetError callbacks on Windows proactor loop.++ On Windows, remote TCP resets after HTTP responses / WebSocket close can+ cause ``_ProactorBasePipeTransport._call_connection_lost`` to fire a+ ``ConnectionResetError`` during transport cleanup. The data was already+ delivered — this is purely transport-layer noise.+ """+ default_handler = loop.get_exception_handler()++ def handler(loop: asyncio.AbstractEventLoop, context: dict) -> None:+ msg = context.get("message", "")+ exc = context.get("exception")+ if isinstance(exc, ConnectionResetError):+ return+ if "connection_lost" in str(msg).lower():+ return+ if default_handler is not None:+ default_handler(loop, context)+ else:+ loop.default_exception_handler(context)++ loop.set_exception_handler(handler)+ logger.debug("Registered proactor ConnectionResetError suppressor on event loop")diff --git a/pyproject.toml b/pyproject.tomlindex ec515d27..12c08c12 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -5,7 +5,8 @@ description = "Add your description here"readme = "README.md"requires-python = ">=3.11"dependencies = [- "aniposelib>=0.7.0",+ # "aniposelib>=0.7.0",+ "numba>=0.65.1","libsass>=0.23.0","opencv-contrib-python",#==4.10.*","pyinstaller>=6.11.0",@@ -18,20 +19,17 @@ dependencies = ["scipy-stubs~=1.17.1","beartype>=0.19","msgspec>=0.19",-#sub-skellies"freemocap_blender_addon","skellycam","skellyforge",-# "skellytracker[rtmpose-gpu]",-# "skellytracker[mediapipe]",+ # "skellytracker[rtmpose-gpu]",+ # "skellytracker[mediapipe]","skellytracker[recommended]",-#skelly utils"skellylogs","skellypings",-# "skellymodels",-+ # "skellymodels",][tool.uv.sources]@@ -45,13 +43,14 @@ skellypings = { git = "https://github.com/freemocap/skellypings" }#skellymodels = { git = "https://github.com/freemocap/skellymodels" }[project.scripts]-freemocap = "freemocap.__main__:main"+freemocap = "freemocap.__main__:run_main"[tool.setuptools]py-modules = ["freemocap"][tool.uv]package = true-exclude-dependencies = ["onnxruntime"]+exclude-dependencies = ["onnxruntime"] # fix erroneous inclusion of onnxruntime that happens alongside onnxruntime-gpu+override-dependencies = ["numpy>=2.3.4"] # fix cv2 vs rtmlib conflict on numpy version[tool.bumpver]current_version = "v1.4.7"@@ -83,7 +82,6 @@ dev = ["pytest-asyncio>=1.0.0","pytest-timeout>=2.0.0","httpx>=0.28.0",-# "nuitka>=2.7.7","pyinstaller>=6.15.0","ruff>=0.9.0","poethepoet>=0.32.0",diff --git a/uv.lock b/uv.lockindex 5b21c93c..d8b08e19 100644--- a/uv.lock+++ b/uv.lock@@ -2,15 +2,16 @@ version = 1revision = 3requires-python = ">=3.11"resolution-markers = [- "python_full_version >= '3.14' and sys_platform == 'win32'",- "python_full_version >= '3.14' and sys_platform == 'emscripten'",- "python_full_version >= '3.14' and sys_platform != 'emscripten' and sys_platform != 'win32'",- "python_full_version < '3.14' and sys_platform == 'win32'",- "python_full_version < '3.14' and sys_platform == 'emscripten'",- "python_full_version < '3.14' and sys_platform != 'emscripten' and sys_platform != 'win32'",+ "platform_machine != 's390x' and sys_platform == 'win32'",+ "platform_machine == 's390x' and sys_platform == 'win32'",+ "platform_machine != 's390x' and sys_platform == 'emscripten'",+ "platform_machine == 's390x' and sys_platform == 'emscripten'",+ "platform_machine != 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'",+ "platform_machine == 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'",][manifest]+overrides = [{ name = "numpy", specifier = ">=2.3.4" }]excludes = ["onnxruntime"][[package]]@@ -31,24 +32,6 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/a9/ba/000a1996d4308bc65120167c21241a3b205464a2e0b58deda26ae8ac21d1/altgraph-0.17.5-py2.py3-none-any.whl", hash = "sha256:f3a22400bce1b0c701683820ac4f3b159cd301acab067c51c653e06961600597", size = 21228, upload-time = "2025-11-21T20:35:49.444Z" },]-[[package]]-name = "aniposelib"-version = "0.7.2"-source = { registry = "https://pypi.org/simple" }-dependencies = [- { name = "numba" },- { name = "numpy" },- { name = "opencv-contrib-python" },- { name = "pandas" },- { name = "scipy" },- { name = "toml" },- { name = "tqdm" },-]-sdist = { url = "https://files.pythonhosted.org/packages/67/62/371f2f863cf622005cbd416c3c3ef0a3b6affb8457279dfb7d907a554404/aniposelib-0.7.2.tar.gz", hash = "sha256:fec4ea30e2673385fa4574364bf949fbc27e9416901d57f04ec1c46bc665619c", size = 22420, upload-time = "2025-06-04T21:33:35.814Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/b9/92/f42ac9b51451f051be1edae7bb33171b270e671b7ad97a9bcd98f4ca4af0/aniposelib-0.7.2-py3-none-any.whl", hash = "sha256:07534e7ba3554770bd4f04c18526bba75559897df4abc7145c4c84e0596c3b01", size = 22824, upload-time = "2025-06-04T21:33:33.759Z" },-]-[[package]]name = "annotated-doc"version = "0.0.4"@@ -115,16 +98,16 @@ wheels = [[[package]]name = "build"-version = "1.4.3"+version = "1.5.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "colorama", marker = "os_name == 'nt'" },{ name = "packaging" },{ name = "pyproject-hooks" },]-sdist = { url = "https://files.pythonhosted.org/packages/3f/16/4b272700dea44c1d2e8ca963ebb3c684efe22b3eba8cfa31c5fdb60de707/build-1.4.3.tar.gz", hash = "sha256:5aa4231ae0e807efdf1fd0623e07366eca2ab215921345a2e38acdd5d0fa0a74", size = 89314, upload-time = "2026-04-10T21:25:40.857Z" }+sdist = { url = "https://files.pythonhosted.org/packages/78/e0/df5e171f685f82f37b12e1f208064e24244911079d7b767447d1af7e0d70/build-1.5.0.tar.gz", hash = "sha256:302c22c3ba2a0fd5f3911918651341ebb3896176cbdec15bd421f80b1afc7647", size = 89796, upload-time = "2026-04-30T03:18:25.17Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/b2/30/f169e1d8b2071beaf8b97088787e30662b1d8fb82f8c0941d14678c0cbf1/build-1.4.3-py3-none-any.whl", hash = "sha256:1bc22b19b383303de8f2c8554c9a32894a58d3f185fe3756b0b20d255bee9a38", size = 26171, upload-time = "2026-04-10T21:25:39.671Z" },+ { url = "https://files.pythonhosted.org/packages/0d/fe/6bea5c9162869c5beba5d9c8abbed835ec85bf1ec1fba05a3822325c45f3/build-1.5.0-py3-none-any.whl", hash = "sha256:13f3eecb844759ab66efec90ca17639bbf14dc06cb2fdf37a9010322d9c50a6f", size = 26018, upload-time = "2026-04-30T03:18:23.644Z" },][[package]]@@ -144,11 +127,11 @@ wheels = [[[package]]name = "certifi"-version = "2026.2.25"+version = "2026.4.22"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/af/2d/7bf41579a8986e348fa033a31cdd0e4121114f6bce2457e8876010b092dd/certifi-2026.2.25.tar.gz", hash = "sha256:e887ab5cee78ea814d3472169153c2d12cd43b14bd03329a39a9c6e2e80bfba7", size = 155029, upload-time = "2026-02-25T02:54:17.342Z" }+sdist = { url = "https://files.pythonhosted.org/packages/25/ee/6caf7a40c36a1220410afe15a1cc64993a1f864871f698c0f93acb72842a/certifi-2026.4.22.tar.gz", hash = "sha256:8d455352a37b71bf76a79caa83a3d6c25afee4a385d632127b6afb3963f1c580", size = 137077, upload-time = "2026-04-22T11:26:11.191Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/9a/3c/c17fb3ca2d9c3acff52e30b309f538586f9f5b9c9cf454f3845fc9af4881/certifi-2026.2.25-py3-none-any.whl", hash = "sha256:027692e4402ad994f1c42e52a4997a9763c646b73e4096e4d5d6db8af1d6f0fa", size = 153684, upload-time = "2026-02-25T02:54:15.766Z" },+ { url = "https://files.pythonhosted.org/packages/22/30/7cd8fdcdfbc5b869528b079bfb76dcdf6056b1a2097a662e5e8c04f42965/certifi-2026.4.22-py3-none-any.whl", hash = "sha256:3cb2210c8f88ba2318d29b0388d1023c8492ff72ecdde4ebdaddbb13a31b1c4a", size = 135707, upload-time = "2026-04-22T11:26:09.372Z" },][[package]]@@ -312,14 +295,14 @@ wheels = [[[package]]name = "click"-version = "8.3.2"+version = "8.3.3"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "colorama", marker = "sys_platform == 'win32'" },]-sdist = { url = "https://files.pythonhosted.org/packages/57/75/31212c6bf2503fdf920d87fee5d7a86a2e3bcf444984126f13d8e4016804/click-8.3.2.tar.gz", hash = "sha256:14162b8b3b3550a7d479eafa77dfd3c38d9dc8951f6f69c78913a8f9a7540fd5", size = 302856, upload-time = "2026-04-03T19:14:45.118Z" }+sdist = { url = "https://files.pythonhosted.org/packages/bb/63/f9e1ea081ce35720d8b92acde70daaedace594dc93b693c869e0d5910718/click-8.3.3.tar.gz", hash = "sha256:398329ad4837b2ff7cbe1dd166a4c0f8900c3ca3a218de04466f38f6497f18a2", size = 328061, upload-time = "2026-04-22T15:11:27.506Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/e4/20/71885d8b97d4f3dde17b1fdb92dbd4908b00541c5a3379787137285f602e/click-8.3.2-py3-none-any.whl", hash = "sha256:1924d2c27c5653561cd2cae4548d1406039cb79b858b747cfea24924bbc1616d", size = 108379, upload-time = "2026-04-03T19:14:43.505Z" },+ { url = "https://files.pythonhosted.org/packages/ae/44/c1221527f6a71a01ec6fbad7fa78f1d50dfa02217385cf0fa3eec7087d59/click-8.3.3-py3-none-any.whl", hash = "sha256:a2bf429bb3033c89fa4936ffb35d5cb471e3719e1f3c8a7c3fff0b8314305613", size = 110502, upload-time = "2026-04-22T15:11:25.044Z" },][[package]]@@ -438,7 +421,7 @@ wheels = [[[package]]name = "fastapi"-version = "0.136.0"+version = "0.136.1"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "annotated-doc" },@@ -447,9 +430,9 @@ dependencies = [{ name = "typing-extensions" },{ name = "typing-inspection" },]-sdist = { url = "https://files.pythonhosted.org/packages/4e/d9/e66315807e41e69e7f6a1b42a162dada2f249c5f06ad3f1a95f84ab336ef/fastapi-0.136.0.tar.gz", hash = "sha256:cf08e067cc66e106e102d9ba659463abfac245200752f8a5b7b1e813de4ff73e", size = 396607, upload-time = "2026-04-16T11:47:13.623Z" }+sdist = { url = "https://files.pythonhosted.org/packages/5d/45/c130091c2dfa061bbfe3150f2a5091ef1adf149f2a8d2ae769ecaf6e99a2/fastapi-0.136.1.tar.gz", hash = "sha256:7af665ad7acfa0a3baf8983d393b6b471b9da10ede59c60045f49fbc89a0fa7f", size = 397448, upload-time = "2026-04-23T16:49:44.046Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/26/a3/0bd5f0cdb0bbc92650e8dc457e9250358411ee5d1b65e42b6632387daf81/fastapi-0.136.0-py3-none-any.whl", hash = "sha256:8793d44ec7378e2be07f8a013cf7f7aa47d6327d0dfe9804862688ec4541a6b4", size = 117556, upload-time = "2026-04-16T11:47:11.922Z" },+ { url = "https://files.pythonhosted.org/packages/5a/ff/2e4eca3ade2c22fe1dea7043b8ee9dabe47753349eb1b56a202de8af6349/fastapi-0.136.1-py3-none-any.whl", hash = "sha256:a6e9d7eeada96c93a4d69cb03836b44fa34e2854accb7244a1ece36cd4781c3f", size = 117683, upload-time = "2026-04-23T16:49:42.437Z" },][[package]]@@ -514,11 +497,11 @@ name = "freemocap"version = "0.1.0"source = { editable = "." }dependencies = [- { name = "aniposelib" },{ name = "beartype" },{ name = "freemocap-blender-addon" },{ name = "libsass" },{ name = "msgspec" },+ { name = "numba" },{ name = "numpydantic" },{ name = "opencv-contrib-python" },{ name = "pyceres" },@@ -550,11 +533,11 @@ dev = [[package.metadata]requires-dist = [- { name = "aniposelib", specifier = ">=0.7.0" },{ name = "beartype", specifier = ">=0.19" },{ name = "freemocap-blender-addon", git = "https://github.com/freemocap/freemocap_blender_addon?branch=development" },{ name = "libsass", specifier = ">=0.23.0" },{ name = "msgspec", specifier = ">=0.19" },+ { name = "numba", specifier = ">=0.65.1" },{ name = "numpydantic", specifier = ">=1.6.7" },{ name = "opencv-contrib-python" },{ name = "pyceres", specifier = ">=2.5" },@@ -587,7 +570,7 @@ dev = [[[package]]name = "freemocap-blender-addon"version = "2025.11.1038"-source = { git = "https://github.com/freemocap/freemocap_blender_addon?branch=development#66fd590e8c3c0f3b75a2da06a7ae8dfba96fe254" }+source = { git = "https://github.com/freemocap/freemocap_blender_addon?branch=development#5a5c40317cc46175ae2c2013a72253fc669858d1" }[[package]]name = "h11"@@ -628,11 +611,11 @@ wheels = [[[package]]name = "idna"-version = "3.11"+version = "3.13"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" }+sdist = { url = "https://files.pythonhosted.org/packages/ce/cc/762dfb036166873f0059f3b7de4565e1b5bc3d6f28a414c13da27e442f99/idna-3.13.tar.gz", hash = "sha256:585ea8fe5d69b9181ec1afba340451fba6ba764af97026f92a91d4eef164a242", size = 194210, upload-time = "2026-04-22T16:42:42.314Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" },+ { url = "https://files.pythonhosted.org/packages/5d/13/ad7d7ca3808a898b4612b6fe93cde56b53f3034dcde235acb1f0e1df24c6/idna-3.13-py3-none-any.whl", hash = "sha256:892ea0cde124a99ce773decba204c5552b69c3c67ffd5f232eb7696135bc8bb3", size = 68629, upload-time = "2026-04-22T16:42:40.909Z" },][[package]]@@ -823,7 +806,7 @@ wheels = [[[package]]name = "matplotlib"-version = "3.10.8"+version = "3.10.9"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "contourpy" },@@ -836,53 +819,53 @@ dependencies = [{ name = "pyparsing" },{ name = "python-dateutil" },]-sdist = { url = "https://files.pythonhosted.org/packages/8a/76/d3c6e3a13fe484ebe7718d14e269c9569c4eb0020a968a327acb3b9a8fe6/matplotlib-3.10.8.tar.gz", hash = "sha256:2299372c19d56bcd35cf05a2738308758d32b9eaed2371898d8f5bd33f084aa3", size = 34806269, upload-time = "2025-12-10T22:56:51.155Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/f8/86/de7e3a1cdcfc941483af70609edc06b83e7c8a0e0dc9ac325200a3f4d220/matplotlib-3.10.8-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:6be43b667360fef5c754dda5d25a32e6307a03c204f3c0fc5468b78fa87b4160", size = 8251215, upload-time = "2025-12-10T22:55:16.175Z" },- { url = "https://files.pythonhosted.org/packages/fd/14/baad3222f424b19ce6ad243c71de1ad9ec6b2e4eb1e458a48fdc6d120401/matplotlib-3.10.8-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a2b336e2d91a3d7006864e0990c83b216fcdca64b5a6484912902cef87313d78", size = 8139625, upload-time = "2025-12-10T22:55:17.712Z" },- { url = "https://files.pythonhosted.org/packages/8f/a0/7024215e95d456de5883e6732e708d8187d9753a21d32f8ddb3befc0c445/matplotlib-3.10.8-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:efb30e3baaea72ce5928e32bab719ab4770099079d66726a62b11b1ef7273be4", size = 8712614, upload-time = "2025-12-10T22:55:20.8Z" },- { url = "https://files.pythonhosted.org/packages/5a/f4/b8347351da9a5b3f41e26cf547252d861f685c6867d179a7c9d60ad50189/matplotlib-3.10.8-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d56a1efd5bfd61486c8bc968fa18734464556f0fb8e51690f4ac25d85cbbbbc2", size = 9540997, upload-time = "2025-12-10T22:55:23.258Z" },- { url = "https://files.pythonhosted.org/packages/9e/c0/c7b914e297efe0bc36917bf216b2acb91044b91e930e878ae12981e461e5/matplotlib-3.10.8-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:238b7ce5717600615c895050239ec955d91f321c209dd110db988500558e70d6", size = 9596825, upload-time = "2025-12-10T22:55:25.217Z" },- { url = "https://files.pythonhosted.org/packages/6f/d3/a4bbc01c237ab710a1f22b4da72f4ff6d77eb4c7735ea9811a94ae239067/matplotlib-3.10.8-cp311-cp311-win_amd64.whl", hash = "sha256:18821ace09c763ec93aef5eeff087ee493a24051936d7b9ebcad9662f66501f9", size = 8135090, upload-time = "2025-12-10T22:55:27.162Z" },- { url = "https://files.pythonhosted.org/packages/89/dd/a0b6588f102beab33ca6f5218b31725216577b2a24172f327eaf6417d5c9/matplotlib-3.10.8-cp311-cp311-win_arm64.whl", hash = "sha256:bab485bcf8b1c7d2060b4fcb6fc368a9e6f4cd754c9c2fea281f4be21df394a2", size = 8012377, upload-time = "2025-12-10T22:55:29.185Z" },- { url = "https://files.pythonhosted.org/packages/9e/67/f997cdcbb514012eb0d10cd2b4b332667997fb5ebe26b8d41d04962fa0e6/matplotlib-3.10.8-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:64fcc24778ca0404ce0cb7b6b77ae1f4c7231cdd60e6778f999ee05cbd581b9a", size = 8260453, upload-time = "2025-12-10T22:55:30.709Z" },- { url = "https://files.pythonhosted.org/packages/7e/65/07d5f5c7f7c994f12c768708bd2e17a4f01a2b0f44a1c9eccad872433e2e/matplotlib-3.10.8-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b9a5ca4ac220a0cdd1ba6bcba3608547117d30468fefce49bb26f55c1a3d5c58", size = 8148321, upload-time = "2025-12-10T22:55:33.265Z" },- { url = "https://files.pythonhosted.org/packages/3e/f3/c5195b1ae57ef85339fd7285dfb603b22c8b4e79114bae5f4f0fcf688677/matplotlib-3.10.8-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:3ab4aabc72de4ff77b3ec33a6d78a68227bf1123465887f9905ba79184a1cc04", size = 8716944, upload-time = "2025-12-10T22:55:34.922Z" },- { url = "https://files.pythonhosted.org/packages/00/f9/7638f5cc82ec8a7aa005de48622eecc3ed7c9854b96ba15bd76b7fd27574/matplotlib-3.10.8-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:24d50994d8c5816ddc35411e50a86ab05f575e2530c02752e02538122613371f", size = 9550099, upload-time = "2025-12-10T22:55:36.789Z" },- { url = "https://files.pythonhosted.org/packages/57/61/78cd5920d35b29fd2a0fe894de8adf672ff52939d2e9b43cb83cd5ce1bc7/matplotlib-3.10.8-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:99eefd13c0dc3b3c1b4d561c1169e65fe47aab7b8158754d7c084088e2329466", size = 9613040, upload-time = "2025-12-10T22:55:38.715Z" },- { url = "https://files.pythonhosted.org/packages/30/4e/c10f171b6e2f44d9e3a2b96efa38b1677439d79c99357600a62cc1e9594e/matplotlib-3.10.8-cp312-cp312-win_amd64.whl", hash = "sha256:dd80ecb295460a5d9d260df63c43f4afbdd832d725a531f008dad1664f458adf", size = 8142717, upload-time = "2025-12-10T22:55:41.103Z" },- { url = "https://files.pythonhosted.org/packages/f1/76/934db220026b5fef85f45d51a738b91dea7d70207581063cd9bd8fafcf74/matplotlib-3.10.8-cp312-cp312-win_arm64.whl", hash = "sha256:3c624e43ed56313651bc18a47f838b60d7b8032ed348911c54906b130b20071b", size = 8012751, upload-time = "2025-12-10T22:55:42.684Z" },- { url = "https://files.pythonhosted.org/packages/3d/b9/15fd5541ef4f5b9a17eefd379356cf12175fe577424e7b1d80676516031a/matplotlib-3.10.8-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:3f2e409836d7f5ac2f1c013110a4d50b9f7edc26328c108915f9075d7d7a91b6", size = 8261076, upload-time = "2025-12-10T22:55:44.648Z" },- { url = "https://files.pythonhosted.org/packages/8d/a0/2ba3473c1b66b9c74dc7107c67e9008cb1782edbe896d4c899d39ae9cf78/matplotlib-3.10.8-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:56271f3dac49a88d7fca5060f004d9d22b865f743a12a23b1e937a0be4818ee1", size = 8148794, upload-time = "2025-12-10T22:55:46.252Z" },- { url = "https://files.pythonhosted.org/packages/75/97/a471f1c3eb1fd6f6c24a31a5858f443891d5127e63a7788678d14e249aea/matplotlib-3.10.8-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:a0a7f52498f72f13d4a25ea70f35f4cb60642b466cbb0a9be951b5bc3f45a486", size = 8718474, upload-time = "2025-12-10T22:55:47.864Z" },- { url = "https://files.pythonhosted.org/packages/01/be/cd478f4b66f48256f42927d0acbcd63a26a893136456cd079c0cc24fbabf/matplotlib-3.10.8-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:646d95230efb9ca614a7a594d4fcacde0ac61d25e37dd51710b36477594963ce", size = 9549637, upload-time = "2025-12-10T22:55:50.048Z" },- { url = "https://files.pythonhosted.org/packages/5d/7c/8dc289776eae5109e268c4fb92baf870678dc048a25d4ac903683b86d5bf/matplotlib-3.10.8-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f89c151aab2e2e23cb3fe0acad1e8b82841fd265379c4cecd0f3fcb34c15e0f6", size = 9613678, upload-time = "2025-12-10T22:55:52.21Z" },- { url = "https://files.pythonhosted.org/packages/64/40/37612487cc8a437d4dd261b32ca21fe2d79510fe74af74e1f42becb1bdb8/matplotlib-3.10.8-cp313-cp313-win_amd64.whl", hash = "sha256:e8ea3e2d4066083e264e75c829078f9e149fa119d27e19acd503de65e0b13149", size = 8142686, upload-time = "2025-12-10T22:55:54.253Z" },- { url = "https://files.pythonhosted.org/packages/66/52/8d8a8730e968185514680c2a6625943f70269509c3dcfc0dcf7d75928cb8/matplotlib-3.10.8-cp313-cp313-win_arm64.whl", hash = "sha256:c108a1d6fa78a50646029cb6d49808ff0fc1330fda87fa6f6250c6b5369b6645", size = 8012917, upload-time = "2025-12-10T22:55:56.268Z" },- { url = "https://files.pythonhosted.org/packages/b5/27/51fe26e1062f298af5ef66343d8ef460e090a27fea73036c76c35821df04/matplotlib-3.10.8-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:ad3d9833a64cf48cc4300f2b406c3d0f4f4724a91c0bd5640678a6ba7c102077", size = 8305679, upload-time = "2025-12-10T22:55:57.856Z" },- { url = "https://files.pythonhosted.org/packages/2c/1e/4de865bc591ac8e3062e835f42dd7fe7a93168d519557837f0e37513f629/matplotlib-3.10.8-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:eb3823f11823deade26ce3b9f40dcb4a213da7a670013929f31d5f5ed1055b22", size = 8198336, upload-time = "2025-12-10T22:55:59.371Z" },- { url = "https://files.pythonhosted.org/packages/c6/cb/2f7b6e75fb4dce87ef91f60cac4f6e34f4c145ab036a22318ec837971300/matplotlib-3.10.8-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d9050fee89a89ed57b4fb2c1bfac9a3d0c57a0d55aed95949eedbc42070fea39", size = 8731653, upload-time = "2025-12-10T22:56:01.032Z" },- { url = "https://files.pythonhosted.org/packages/46/b3/bd9c57d6ba670a37ab31fb87ec3e8691b947134b201f881665b28cc039ff/matplotlib-3.10.8-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b44d07310e404ba95f8c25aa5536f154c0a8ec473303535949e52eb71d0a1565", size = 9561356, upload-time = "2025-12-10T22:56:02.95Z" },- { url = "https://files.pythonhosted.org/packages/c0/3d/8b94a481456dfc9dfe6e39e93b5ab376e50998cddfd23f4ae3b431708f16/matplotlib-3.10.8-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:0a33deb84c15ede243aead39f77e990469fff93ad1521163305095b77b72ce4a", size = 9614000, upload-time = "2025-12-10T22:56:05.411Z" },- { url = "https://files.pythonhosted.org/packages/bd/cd/bc06149fe5585ba800b189a6a654a75f1f127e8aab02fd2be10df7fa500c/matplotlib-3.10.8-cp313-cp313t-win_amd64.whl", hash = "sha256:3a48a78d2786784cc2413e57397981fb45c79e968d99656706018d6e62e57958", size = 8220043, upload-time = "2025-12-10T22:56:07.551Z" },- { url = "https://files.pythonhosted.org/packages/e3/de/b22cf255abec916562cc04eef457c13e58a1990048de0c0c3604d082355e/matplotlib-3.10.8-cp313-cp313t-win_arm64.whl", hash = "sha256:15d30132718972c2c074cd14638c7f4592bd98719e2308bccea40e0538bc0cb5", size = 8062075, upload-time = "2025-12-10T22:56:09.178Z" },- { url = "https://files.pythonhosted.org/packages/3c/43/9c0ff7a2f11615e516c3b058e1e6e8f9614ddeca53faca06da267c48345d/matplotlib-3.10.8-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:b53285e65d4fa4c86399979e956235deb900be5baa7fc1218ea67fbfaeaadd6f", size = 8262481, upload-time = "2025-12-10T22:56:10.885Z" },- { url = "https://files.pythonhosted.org/packages/6f/ca/e8ae28649fcdf039fda5ef554b40a95f50592a3c47e6f7270c9561c12b07/matplotlib-3.10.8-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:32f8dce744be5569bebe789e46727946041199030db8aeb2954d26013a0eb26b", size = 8151473, upload-time = "2025-12-10T22:56:12.377Z" },- { url = "https://files.pythonhosted.org/packages/f1/6f/009d129ae70b75e88cbe7e503a12a4c0670e08ed748a902c2568909e9eb5/matplotlib-3.10.8-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4cf267add95b1c88300d96ca837833d4112756045364f5c734a2276038dae27d", size = 9553896, upload-time = "2025-12-10T22:56:14.432Z" },- { url = "https://files.pythonhosted.org/packages/f5/26/4221a741eb97967bc1fd5e4c52b9aa5a91b2f4ec05b59f6def4d820f9df9/matplotlib-3.10.8-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2cf5bd12cecf46908f286d7838b2abc6c91cda506c0445b8223a7c19a00df008", size = 9824193, upload-time = "2025-12-10T22:56:16.29Z" },- { url = "https://files.pythonhosted.org/packages/1f/f3/3abf75f38605772cf48a9daf5821cd4f563472f38b4b828c6fba6fa6d06e/matplotlib-3.10.8-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:41703cc95688f2516b480f7f339d8851a6035f18e100ee6a32bc0b8536a12a9c", size = 9615444, upload-time = "2025-12-10T22:56:18.155Z" },- { url = "https://files.pythonhosted.org/packages/93/a5/de89ac80f10b8dc615807ee1133cd99ac74082581196d4d9590bea10690d/matplotlib-3.10.8-cp314-cp314-win_amd64.whl", hash = "sha256:83d282364ea9f3e52363da262ce32a09dfe241e4080dcedda3c0db059d3c1f11", size = 8272719, upload-time = "2025-12-10T22:56:20.366Z" },- { url = "https://files.pythonhosted.org/packages/69/ce/b006495c19ccc0a137b48083168a37bd056392dee02f87dba0472f2797fe/matplotlib-3.10.8-cp314-cp314-win_arm64.whl", hash = "sha256:2c1998e92cd5999e295a731bcb2911c75f597d937341f3030cc24ef2733d78a8", size = 8144205, upload-time = "2025-12-10T22:56:22.239Z" },- { url = "https://files.pythonhosted.org/packages/68/d9/b31116a3a855bd313c6fcdb7226926d59b041f26061c6c5b1be66a08c826/matplotlib-3.10.8-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:b5a2b97dbdc7d4f353ebf343744f1d1f1cca8aa8bfddb4262fcf4306c3761d50", size = 8305785, upload-time = "2025-12-10T22:56:24.218Z" },- { url = "https://files.pythonhosted.org/packages/1e/90/6effe8103f0272685767ba5f094f453784057072f49b393e3ea178fe70a5/matplotlib-3.10.8-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:3f5c3e4da343bba819f0234186b9004faba952cc420fbc522dc4e103c1985908", size = 8198361, upload-time = "2025-12-10T22:56:26.787Z" },- { url = "https://files.pythonhosted.org/packages/d7/65/a73188711bea603615fc0baecca1061429ac16940e2385433cc778a9d8e7/matplotlib-3.10.8-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5f62550b9a30afde8c1c3ae450e5eb547d579dd69b25c2fc7a1c67f934c1717a", size = 9561357, upload-time = "2025-12-10T22:56:28.953Z" },- { url = "https://files.pythonhosted.org/packages/f4/3d/b5c5d5d5be8ce63292567f0e2c43dde9953d3ed86ac2de0a72e93c8f07a1/matplotlib-3.10.8-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:495672de149445ec1b772ff2c9ede9b769e3cb4f0d0aa7fa730d7f59e2d4e1c1", size = 9823610, upload-time = "2025-12-10T22:56:31.455Z" },- { url = "https://files.pythonhosted.org/packages/4d/4b/e7beb6bbd49f6bae727a12b270a2654d13c397576d25bd6786e47033300f/matplotlib-3.10.8-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:595ba4d8fe983b88f0eec8c26a241e16d6376fe1979086232f481f8f3f67494c", size = 9614011, upload-time = "2025-12-10T22:56:33.85Z" },- { url = "https://files.pythonhosted.org/packages/7c/e6/76f2813d31f032e65f6f797e3f2f6e4aab95b65015924b1c51370395c28a/matplotlib-3.10.8-cp314-cp314t-win_amd64.whl", hash = "sha256:25d380fe8b1dc32cf8f0b1b448470a77afb195438bafdf1d858bfb876f3edf7b", size = 8362801, upload-time = "2025-12-10T22:56:36.107Z" },- { url = "https://files.pythonhosted.org/packages/5d/49/d651878698a0b67f23aa28e17f45a6d6dd3d3f933fa29087fa4ce5947b5a/matplotlib-3.10.8-cp314-cp314t-win_arm64.whl", hash = "sha256:113bb52413ea508ce954a02c10ffd0d565f9c3bc7f2eddc27dfe1731e71c7b5f", size = 8192560, upload-time = "2025-12-10T22:56:38.008Z" },- { url = "https://files.pythonhosted.org/packages/04/30/3afaa31c757f34b7725ab9d2ba8b48b5e89c2019c003e7d0ead143aabc5a/matplotlib-3.10.8-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:6da7c2ce169267d0d066adcf63758f0604aa6c3eebf67458930f9d9b79ad1db1", size = 8249198, upload-time = "2025-12-10T22:56:45.584Z" },- { url = "https://files.pythonhosted.org/packages/48/2f/6334aec331f57485a642a7c8be03cb286f29111ae71c46c38b363230063c/matplotlib-3.10.8-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:9153c3292705be9f9c64498a8872118540c3f4123d1a1c840172edf262c8be4a", size = 8136817, upload-time = "2025-12-10T22:56:47.339Z" },- { url = "https://files.pythonhosted.org/packages/73/e4/6d6f14b2a759c622f191b2d67e9075a3f56aaccb3be4bb9bb6890030d0a0/matplotlib-3.10.8-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:1ae029229a57cd1e8fe542485f27e7ca7b23aa9e8944ddb4985d0bc444f1eca2", size = 8713867, upload-time = "2025-12-10T22:56:48.954Z" },+sdist = { url = "https://files.pythonhosted.org/packages/63/1b/4be5be87d43d327a0cf4de1a56e86f7f84c89312452406cf122efe2839e6/matplotlib-3.10.9.tar.gz", hash = "sha256:fd66508e8c6877d98e586654b608a0456db8d7e8a546eb1e2600efd957302358", size = 34811233, upload-time = "2026-04-24T00:14:13.539Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/4c/8c/290f021104741fea63769c31494f5324c0cd249bf536a65a4350767b1f22/matplotlib-3.10.9-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:68cfdcede415f7c8f5577b03303dd94526cdb6d11036cecdc205e08733b2d2bb", size = 8306860, upload-time = "2026-04-24T00:12:01.207Z" },+ { url = "https://files.pythonhosted.org/packages/51/18/325cd32ece1120d1da51cc4e4294c6580190699490183fc2fe8cb6d61ec5/matplotlib-3.10.9-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:dfca0129678bd56379db26c52b5d77ed7de314c047492fbdc763aa7501710cfb", size = 8199254, upload-time = "2026-04-24T00:12:04.239Z" },+ { url = "https://files.pythonhosted.org/packages/79/db/e28c1b83e3680740aa78925f5fb2ae4d16207207419ad75ea9fe604f8676/matplotlib-3.10.9-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8e436d155fa8a3399dc62683f8f5d0e2e50d25d0144a73edd73f82eec8f4abfb", size = 8777092, upload-time = "2026-04-24T00:12:06.793Z" },+ { url = "https://files.pythonhosted.org/packages/55/fa/3ce7adfe9ba101748f465211660d9c6374c876b671bdb8c2bb6d347e8b94/matplotlib-3.10.9-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:56fc0bd271b00025c6edfdc7c2dcd247372c8e1544971d62e1dc7c17367e8bf9", size = 9595691, upload-time = "2026-04-24T00:12:09.706Z" },+ { url = "https://files.pythonhosted.org/packages/36/c4/6960a76686ed668f2c60f84e9799ba4c0d56abdb36b1577b60c1d061d1ec/matplotlib-3.10.9-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:a5a6104ed666402ba5106d7f36e0e0cdca4e8d7fa4d39708ca88019e2835a2eb", size = 9659771, upload-time = "2026-04-24T00:12:12.766Z" },+ { url = "https://files.pythonhosted.org/packages/7e/0d/271aace3342157c64700c9ff4c59c7b392f3dbab393692e8db6fbe7ab96c/matplotlib-3.10.9-cp311-cp311-win_amd64.whl", hash = "sha256:d730e984eddf56974c3e72b6129c7ca462ac38dc624338f4b0b23eb23ecba00f", size = 8205112, upload-time = "2026-04-24T00:12:15.773Z" },+ { url = "https://files.pythonhosted.org/packages/e2/ee/cb57ad4754f3e7b9174ce6ce66d9205fb827067e48a9f58ac09d7e7d6b77/matplotlib-3.10.9-cp311-cp311-win_arm64.whl", hash = "sha256:51bf0ddbdc598e060d46c16b5590708f81a1624cefbaaf62f6a81bf9285b8c80", size = 8132310, upload-time = "2026-04-24T00:12:18.645Z" },+ { url = "https://files.pythonhosted.org/packages/35/c6/5581e26c72233ebb2a2a6fed2d24fb7c66b4700120b813f51b0555acf0b6/matplotlib-3.10.9-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:f0c3c28d9fbcc1fe7a03be236d73430cf6409c41fb2383a7ac52fe932b072cb1", size = 8319908, upload-time = "2026-04-24T00:12:21.323Z" },+ { url = "https://files.pythonhosted.org/packages/b7/18/4880dd762e40cd360c1bf06e890c5a97b997e91cb324602b1a19950ad5ce/matplotlib-3.10.9-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:41cb28c2bd769aa3e98322c6ab09854cbcc52ab69d2759d681bba3e327b2b320", size = 8216016, upload-time = "2026-04-24T00:12:23.4Z" },+ { url = "https://files.pythonhosted.org/packages/32/91/d024616abdba99e83120e07a20658976f6a343646710760c4a51df126029/matplotlib-3.10.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ae20801130378b82d647ff5047c07316295b68dc054ca6b3c13519d0ea624285", size = 8789336, upload-time = "2026-04-24T00:12:26.096Z" },+ { url = "https://files.pythonhosted.org/packages/5c/04/030a2f61ef2158f5e4c259487a92ac877732499fb33d871585d89e03c42d/matplotlib-3.10.9-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6c63ebcd8b4b169eb2f5c200552ae6b8be8999a005b6b507ed76fb8d7d674fe2", size = 9604602, upload-time = "2026-04-24T00:12:29.052Z" },+ { url = "https://files.pythonhosted.org/packages/fc/c2/541e4d09d87bb6b5830fc28b4c887a9a8cf4e1c6cee698a8c05552ae2003/matplotlib-3.10.9-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:d75d11c949914165976c621b2324f9ef162af7ebf4b057ddf95dd1dba7e5edcf", size = 9670966, upload-time = "2026-04-24T00:12:32.131Z" },+ { url = "https://files.pythonhosted.org/packages/04/a1/4571fc46e7702de8d0c2dc54ad1b2f8e29328dea3ee90831181f7353d93c/matplotlib-3.10.9-cp312-cp312-win_amd64.whl", hash = "sha256:d091f9d758b34aaaaa6331d13574bf01891d903b3dec59bfff458ef7551de5d6", size = 8217462, upload-time = "2026-04-24T00:12:35.226Z" },+ { url = "https://files.pythonhosted.org/packages/4b/d0/2269edb12aa30c13c8bcc9382892e39943ce1d28aab4ec296e0381798e81/matplotlib-3.10.9-cp312-cp312-win_arm64.whl", hash = "sha256:10cc5ce06d10231c36f40e875f3c7e8050362a4ee8f0ee5d29a6b3277d57bb42", size = 8136688, upload-time = "2026-04-24T00:12:37.442Z" },+ { url = "https://files.pythonhosted.org/packages/aa/d3/8d4f6afbecb49fc04e060a57c0fce39ea51cc163a6bd87303ccd698e4fa6/matplotlib-3.10.9-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:b580440f1ff81a0e34122051a3dfabb7e4b7f9e380629929bde0eff9af72165f", size = 8320331, upload-time = "2026-04-24T00:12:39.688Z" },+ { url = "https://files.pythonhosted.org/packages/63/d9/9e14bc7564bf92d5ffa801ae5fac819ce74b925dfb55e3ebde61a3bbad3e/matplotlib-3.10.9-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:b1b745c489cd1a77a0dc1120a05dc87af9798faebc913601feb8c73d89bf2d1e", size = 8216461, upload-time = "2026-04-24T00:12:42.494Z" },+ { url = "https://files.pythonhosted.org/packages/8a/17/4402d0d14ccf1dfc70932600b68097fbbf9c898a4871d2cbbe79c7801a32/matplotlib-3.10.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8f3bcac1ca5ed000a6f4337d47ba67dfddf37ed6a46c15fd7f014997f7bf865f", size = 8790091, upload-time = "2026-04-24T00:12:44.789Z" },+ { url = "https://files.pythonhosted.org/packages/3e/0b/322aeec06dd9b91411f92028b37d447342770a24392aa4813e317064dad5/matplotlib-3.10.9-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7a8d66a55def891c33147ba3ba9bfcabf0b526a43764c818acbb4525e5ed0838", size = 9605027, upload-time = "2026-04-24T00:12:47.583Z" },+ { url = "https://files.pythonhosted.org/packages/74/88/5f13482f55e7b00bcfc09838b093c2456e1379978d2a146844aae05350ad/matplotlib-3.10.9-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:d843374407c4017a6403b59c6c81606773d136f3259d5b6da3131bc814542cc2", size = 9671269, upload-time = "2026-04-24T00:12:50.878Z" },+ { url = "https://files.pythonhosted.org/packages/c5/e0/0840fd2f93da988ec660b8ad1984abe9f25d2aed22a5e394ff1c68c88307/matplotlib-3.10.9-cp313-cp313-win_amd64.whl", hash = "sha256:f4399f64b3e94cd500195490972ae1ee81170df1636fa15364d157d5bdd7b921", size = 8217588, upload-time = "2026-04-24T00:12:53.784Z" },+ { url = "https://files.pythonhosted.org/packages/47/b9/d706d06dd605c49b9f83a2aed8c13e3e5db70697d7a80b7e3d7915de6b17/matplotlib-3.10.9-cp313-cp313-win_arm64.whl", hash = "sha256:ba7b3b8ef09eab7df0e86e9ae086faa433efbfbdb46afcb3aa16aabf779469a8", size = 8136913, upload-time = "2026-04-24T00:12:56.501Z" },+ { url = "https://files.pythonhosted.org/packages/9b/45/6e32d96978264c8ca8c4b1010adb955a1a49cfaf314e212bbc8908f04a61/matplotlib-3.10.9-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:09218df8a93712bd6ea133e83a153c755448cf7868316c531cffcc43f69d1cc9", size = 8368019, upload-time = "2026-04-24T00:12:58.896Z" },+ { url = "https://files.pythonhosted.org/packages/86/0a/c8e3d3bba245f0f7fc424937f8ff7ef77291a36af3edb97ccd78aa93d84f/matplotlib-3.10.9-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:82368699727bfb7b0182e1aa13082e3c08e092fa1a25d3e1fd92405bff96f6d4", size = 8264645, upload-time = "2026-04-24T00:13:01.406Z" },+ { url = "https://files.pythonhosted.org/packages/3d/aa/5bf5a14fe4fed73a4209a155606f8096ff797aad89c6c35179026571133e/matplotlib-3.10.9-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:3225f4e1edcb8c86c884ddf79ebe20ecd0a67d30188f279897554ccd8fded4dc", size = 8802194, upload-time = "2026-04-24T00:13:03.702Z" },+ { url = "https://files.pythonhosted.org/packages/dd/5e/b4be852d6bba6fd15893fadf91ff26ae49cb91aac789e95dde9d342e664f/matplotlib-3.10.9-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:de2445a0c6690d21b7eb6ce071cebad6d40a2e9bdf10d039074a96ba19797b99", size = 9622684, upload-time = "2026-04-24T00:13:06.647Z" },+ { url = "https://files.pythonhosted.org/packages/4c/3d/ed428c971139112ef730f62770654d609467346d09d4b62617e1afd68a5a/matplotlib-3.10.9-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:b2b9516251cb89ff618d757daec0e2ed1bf21248013844a853d87ef85ab3081d", size = 9680790, upload-time = "2026-04-24T00:13:10.009Z" },+ { url = "https://files.pythonhosted.org/packages/e7/09/052e884aaf2b985c63cb79f715f1d5b6a3eaa7de78f6a52b9dbc077d5b53/matplotlib-3.10.9-cp313-cp313t-win_amd64.whl", hash = "sha256:e9fae004b941b23ff2edcf1567a857ed77bafc8086ffa258190462328434faf8", size = 8287571, upload-time = "2026-04-24T00:13:13.087Z" },+ { url = "https://files.pythonhosted.org/packages/f4/38/ae27288e788c35a4250491422f3db7750366fc8c97d6f36fbdecfc1f5518/matplotlib-3.10.9-cp313-cp313t-win_arm64.whl", hash = "sha256:6b63d9c7c769b88ab81e10dc86e4e0607cf56817b9f9e6cf24b2a5f1693b8e38", size = 8188292, upload-time = "2026-04-24T00:13:15.546Z" },+ { url = "https://files.pythonhosted.org/packages/d6/e6/3bd8afd04949f02eabc1c17115ea5255e19cacd4d06fc5abdde4eeb0052c/matplotlib-3.10.9-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:172db52c9e683f5d12eaf57f0f54834190e12581fe1cc2a19595a8f5acb4e77d", size = 8321276, upload-time = "2026-04-24T00:13:18.318Z" },+ { url = "https://files.pythonhosted.org/packages/41/86/86231232fff41c9f8e4a1a7d7a597d349a02527109c3af7d618366122139/matplotlib-3.10.9-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:97e35e8d39ccc85859095e01a53847432ba9a53ddf7986f7a54a11b73d0e143f", size = 8218218, upload-time = "2026-04-24T00:13:20.974Z" },+ { url = "https://files.pythonhosted.org/packages/85/8f/becc9722cafc64f5d2eb0b7c1bf5f585271c618a45dbd8fabeb021f898b6/matplotlib-3.10.9-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:aba1615dabe83188e19d4f75a253c6a08423e04c1425e64039f800050a69de6b", size = 9608145, upload-time = "2026-04-24T00:13:23.228Z" },+ { url = "https://files.pythonhosted.org/packages/32/5d/f7e914f7d9325abff4057cee62c0fa70263683189f774473cbfb534cd13b/matplotlib-3.10.9-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:34cf8167e023ad956c15f36302911d5406bd99a9862c1a8499ea6f7c0e015dc2", size = 9885085, upload-time = "2026-04-24T00:13:25.849Z" },+ { url = "https://files.pythonhosted.org/packages/a5/fd/fa69f2221534e80cc5772ac2b7d222011a2acafc2ec7216d5dd174c864ae/matplotlib-3.10.9-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:59476c6d29d612b8e9bb6ce8c5b631be6ba8f9e3a2421f22a02b192c7dd28716", size = 9672358, upload-time = "2026-04-24T00:13:28.906Z" },+ { url = "https://files.pythonhosted.org/packages/ab/1a/5a4f747a8b271cbb024946d2dd3c913ab5032ba430626f8c3528ada96b4b/matplotlib-3.10.9-cp314-cp314-win_amd64.whl", hash = "sha256:336b9acc64d309063126edcdaca00db9373af3c476bb94388fe9c5a53ad13e6f", size = 8349970, upload-time = "2026-04-24T00:13:31.904Z" },+ { url = "https://files.pythonhosted.org/packages/64/dc/95d60ecaefe30680a154b52ea96ab4b0dab547f1fd6aa12f5fb655e89cae/matplotlib-3.10.9-cp314-cp314-win_arm64.whl", hash = "sha256:2dc9477819ffd78ad12a20df1d9d6a6bd4fec6aaa9072681465fddca052f1456", size = 8272785, upload-time = "2026-04-24T00:13:34.511Z" },+ { url = "https://files.pythonhosted.org/packages/70/a0/005d68bc8b8418300ce6591f18586910a8526806e2ab663933d9f20a41e9/matplotlib-3.10.9-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:da4e09638420548f31c354032a6250e473c68e5a4e96899b4844cf39ddea23fe", size = 8367999, upload-time = "2026-04-24T00:13:36.962Z" },+ { url = "https://files.pythonhosted.org/packages/22/05/1236cc9290be70b2498af20ca348add76e3fffe7f67b477db5133a84f3ea/matplotlib-3.10.9-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:345f6f68ecc8da0ca56fad2ea08fde1a115eda530079eca185d50a7bc3e146c6", size = 8264543, upload-time = "2026-04-24T00:13:39.851Z" },+ { url = "https://files.pythonhosted.org/packages/cd/c2/071f5a5ff6c5bd63aaaf2f45c811d9bf2ced94bde188d9e1a519e21d0cba/matplotlib-3.10.9-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4edcfbd8565339aa62f1cd4012f7180926fdbe71850f7b0d3c379c175cd6b66c", size = 9622800, upload-time = "2026-04-24T00:13:42.296Z" },+ { url = "https://files.pythonhosted.org/packages/95/57/da7d1f10a85624b9e7db68e069dd94e58dc41dbf9463c5921632ecbe3661/matplotlib-3.10.9-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6be157fe17fc37cb95ac1d7374cf717ce9259616edec911a78d9d26dae8522d4", size = 9888561, upload-time = "2026-04-24T00:13:45.026Z" },+ { url = "https://files.pythonhosted.org/packages/67/b2/ef8d6bb59b0edb6c16c968b70f548aa13b54348972def5aa6ac85df67145/matplotlib-3.10.9-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:4e42042d54db34fda4e95a7bd3e5789c2a995d2dad3eb8850232ee534092fbbf", size = 9680884, upload-time = "2026-04-24T00:13:48.066Z" },+ { url = "https://files.pythonhosted.org/packages/61/1c/d21bfeb9931881ebe96bcfcff27c7ae4b160ae0ec291a714c42641a56d75/matplotlib-3.10.9-cp314-cp314t-win_amd64.whl", hash = "sha256:c27df8b3848f32a83d1767566595e43cfaa4460380974da06f4279a7ec143c39", size = 8432333, upload-time = "2026-04-24T00:13:51.008Z" },+ { url = "https://files.pythonhosted.org/packages/78/23/92493c3e6e1b635ccfff146f7b99e674808787915420373ac399283764c2/matplotlib-3.10.9-cp314-cp314t-win_arm64.whl", hash = "sha256:a49f1eadc84ca85fd72fa4e89e70e61bf86452df6f971af04b12c60761a0772c", size = 8324785, upload-time = "2026-04-24T00:13:53.633Z" },+ { url = "https://files.pythonhosted.org/packages/63/e2/9f66ca6a651a52abfe0d4964ce01439ed34f3f1e119de10ff3a07f403043/matplotlib-3.10.9-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:42fb814efabe95c06c1994d8ab5a8385f43a249e23badd3ba931d4308e5bca20", size = 8304420, upload-time = "2026-04-24T00:14:04.57Z" },+ { url = "https://files.pythonhosted.org/packages/e8/e8/467c03568218792906aa87b5e7bb379b605e056ed0c74fe00c051786d925/matplotlib-3.10.9-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:f76e640a5268850bfda54b5131b1b1941cc685e42c5fa98ed9f2d64038308cba", size = 8197981, upload-time = "2026-04-24T00:14:07.233Z" },+ { url = "https://files.pythonhosted.org/packages/6f/87/afead29192170917537934c6aff4b008c805fff7b1ccea0c79120d96beda/matplotlib-3.10.9-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:3fc0364dfbe1d07f6d15c5ebd0c5bf89e126916e5a8667dd4a7a6e84c36653d4", size = 8774002, upload-time = "2026-04-24T00:14:09.816Z" },][[package]]@@ -904,12 +887,44 @@ wheels = [][[package]]-name = "mpmath"-version = "1.3.0"+name = "ml-dtypes"+version = "0.5.4"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/e0/47/dd32fa426cc72114383ac549964eecb20ecfd886d1e5ccf5340b55b02f57/mpmath-1.3.0.tar.gz", hash = "sha256:7a28eb2a9774d00c7bc92411c19a89209d5da7c4c9a9e227be8330a23a25b91f", size = 508106, upload-time = "2023-03-07T16:47:11.061Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl", hash = "sha256:a0b2b9fe80bbcd81a6647ff13108738cfb482d481d826cc0e02f5b35e5c88d2c", size = 536198, upload-time = "2023-03-07T16:47:09.197Z" },+dependencies = [+ { name = "numpy" },+]+sdist = { url = "https://files.pythonhosted.org/packages/0e/4a/c27b42ed9b1c7d13d9ba8b6905dece787d6259152f2309338aed29b2447b/ml_dtypes-0.5.4.tar.gz", hash = "sha256:8ab06a50fb9bf9666dd0fe5dfb4676fa2b0ac0f31ecff72a6c3af8e22c063453", size = 692314, upload-time = "2025-11-17T22:32:31.031Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/c6/5e/712092cfe7e5eb667b8ad9ca7c54442f21ed7ca8979745f1000e24cf8737/ml_dtypes-0.5.4-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6c7ecb74c4bd71db68a6bea1edf8da8c34f3d9fe218f038814fd1d310ac76c90", size = 679734, upload-time = "2025-11-17T22:31:39.223Z" },+ { url = "https://files.pythonhosted.org/packages/4f/cf/912146dfd4b5c0eea956836c01dcd2fce6c9c844b2691f5152aca196ce4f/ml_dtypes-0.5.4-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bc11d7e8c44a65115d05e2ab9989d1e045125d7be8e05a071a48bc76eb6d6040", size = 5056165, upload-time = "2025-11-17T22:31:41.071Z" },+ { url = "https://files.pythonhosted.org/packages/a9/80/19189ea605017473660e43762dc853d2797984b3c7bf30ce656099add30c/ml_dtypes-0.5.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:19b9a53598f21e453ea2fbda8aa783c20faff8e1eeb0d7ab899309a0053f1483", size = 5034975, upload-time = "2025-11-17T22:31:42.758Z" },+ { url = "https://files.pythonhosted.org/packages/b4/24/70bd59276883fdd91600ca20040b41efd4902a923283c4d6edcb1de128d2/ml_dtypes-0.5.4-cp311-cp311-win_amd64.whl", hash = "sha256:7c23c54a00ae43edf48d44066a7ec31e05fdc2eee0be2b8b50dd1903a1db94bb", size = 210742, upload-time = "2025-11-17T22:31:44.068Z" },+ { url = "https://files.pythonhosted.org/packages/a0/c9/64230ef14e40aa3f1cb254ef623bf812735e6bec7772848d19131111ac0d/ml_dtypes-0.5.4-cp311-cp311-win_arm64.whl", hash = "sha256:557a31a390b7e9439056644cb80ed0735a6e3e3bb09d67fd5687e4b04238d1de", size = 160709, upload-time = "2025-11-17T22:31:46.557Z" },+ { url = "https://files.pythonhosted.org/packages/a8/b8/3c70881695e056f8a32f8b941126cf78775d9a4d7feba8abcb52cb7b04f2/ml_dtypes-0.5.4-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:a174837a64f5b16cab6f368171a1a03a27936b31699d167684073ff1c4237dac", size = 676927, upload-time = "2025-11-17T22:31:48.182Z" },+ { url = "https://files.pythonhosted.org/packages/54/0f/428ef6881782e5ebb7eca459689448c0394fa0a80bea3aa9262cba5445ea/ml_dtypes-0.5.4-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a7f7c643e8b1320fd958bf098aa7ecf70623a42ec5154e3be3be673f4c34d900", size = 5028464, upload-time = "2025-11-17T22:31:50.135Z" },+ { url = "https://files.pythonhosted.org/packages/3a/cb/28ce52eb94390dda42599c98ea0204d74799e4d8047a0eb559b6fd648056/ml_dtypes-0.5.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9ad459e99793fa6e13bd5b7e6792c8f9190b4e5a1b45c63aba14a4d0a7f1d5ff", size = 5009002, upload-time = "2025-11-17T22:31:52.001Z" },+ { url = "https://files.pythonhosted.org/packages/f5/f0/0cfadd537c5470378b1b32bd859cf2824972174b51b873c9d95cfd7475a5/ml_dtypes-0.5.4-cp312-cp312-win_amd64.whl", hash = "sha256:c1a953995cccb9e25a4ae19e34316671e4e2edaebe4cf538229b1fc7109087b7", size = 212222, upload-time = "2025-11-17T22:31:53.742Z" },+ { url = "https://files.pythonhosted.org/packages/16/2e/9acc86985bfad8f2c2d30291b27cd2bb4c74cea08695bd540906ed744249/ml_dtypes-0.5.4-cp312-cp312-win_arm64.whl", hash = "sha256:9bad06436568442575beb2d03389aa7456c690a5b05892c471215bfd8cf39460", size = 160793, upload-time = "2025-11-17T22:31:55.358Z" },+ { url = "https://files.pythonhosted.org/packages/d9/a1/4008f14bbc616cfb1ac5b39ea485f9c63031c4634ab3f4cf72e7541f816a/ml_dtypes-0.5.4-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:8c760d85a2f82e2bed75867079188c9d18dae2ee77c25a54d60e9cc79be1bc48", size = 676888, upload-time = "2025-11-17T22:31:56.907Z" },+ { url = "https://files.pythonhosted.org/packages/d3/b7/dff378afc2b0d5a7d6cd9d3209b60474d9819d1189d347521e1688a60a53/ml_dtypes-0.5.4-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ce756d3a10d0c4067172804c9cc276ba9cc0ff47af9078ad439b075d1abdc29b", size = 5036993, upload-time = "2025-11-17T22:31:58.497Z" },+ { url = "https://files.pythonhosted.org/packages/eb/33/40cd74219417e78b97c47802037cf2d87b91973e18bb968a7da48a96ea44/ml_dtypes-0.5.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:533ce891ba774eabf607172254f2e7260ba5f57bdd64030c9a4fcfbd99815d0d", size = 5010956, upload-time = "2025-11-17T22:31:59.931Z" },+ { url = "https://files.pythonhosted.org/packages/e1/8b/200088c6859d8221454825959df35b5244fa9bdf263fd0249ac5fb75e281/ml_dtypes-0.5.4-cp313-cp313-win_amd64.whl", hash = "sha256:f21c9219ef48ca5ee78402d5cc831bd58ea27ce89beda894428bc67a52da5328", size = 212224, upload-time = "2025-11-17T22:32:01.349Z" },+ { url = "https://files.pythonhosted.org/packages/8f/75/dfc3775cb36367816e678f69a7843f6f03bd4e2bcd79941e01ea960a068e/ml_dtypes-0.5.4-cp313-cp313-win_arm64.whl", hash = "sha256:35f29491a3e478407f7047b8a4834e4640a77d2737e0b294d049746507af5175", size = 160798, upload-time = "2025-11-17T22:32:02.864Z" },+ { url = "https://files.pythonhosted.org/packages/4f/74/e9ddb35fd1dd43b1106c20ced3f53c2e8e7fc7598c15638e9f80677f81d4/ml_dtypes-0.5.4-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:304ad47faa395415b9ccbcc06a0350800bc50eda70f0e45326796e27c62f18b6", size = 702083, upload-time = "2025-11-17T22:32:04.08Z" },+ { url = "https://files.pythonhosted.org/packages/74/f5/667060b0aed1aa63166b22897fdf16dca9eb704e6b4bbf86848d5a181aa7/ml_dtypes-0.5.4-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6a0df4223b514d799b8a1629c65ddc351b3efa833ccf7f8ea0cf654a61d1e35d", size = 5354111, upload-time = "2025-11-17T22:32:05.546Z" },+ { url = "https://files.pythonhosted.org/packages/40/49/0f8c498a28c0efa5f5c95a9e374c83ec1385ca41d0e85e7cf40e5d519a21/ml_dtypes-0.5.4-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:531eff30e4d368cb6255bc2328d070e35836aa4f282a0fb5f3a0cd7260257298", size = 5366453, upload-time = "2025-11-17T22:32:07.115Z" },+ { url = "https://files.pythonhosted.org/packages/8c/27/12607423d0a9c6bbbcc780ad19f1f6baa2b68b18ce4bddcdc122c4c68dc9/ml_dtypes-0.5.4-cp313-cp313t-win_amd64.whl", hash = "sha256:cb73dccfc991691c444acc8c0012bee8f2470da826a92e3a20bb333b1a7894e6", size = 225612, upload-time = "2025-11-17T22:32:08.615Z" },+ { url = "https://files.pythonhosted.org/packages/e5/80/5a5929e92c72936d5b19872c5fb8fc09327c1da67b3b68c6a13139e77e20/ml_dtypes-0.5.4-cp313-cp313t-win_arm64.whl", hash = "sha256:3bbbe120b915090d9dd1375e4684dd17a20a2491ef25d640a908281da85e73f1", size = 164145, upload-time = "2025-11-17T22:32:09.782Z" },+ { url = "https://files.pythonhosted.org/packages/72/4e/1339dc6e2557a344f5ba5590872e80346f76f6cb2ac3dd16e4666e88818c/ml_dtypes-0.5.4-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:2b857d3af6ac0d39db1de7c706e69c7f9791627209c3d6dedbfca8c7e5faec22", size = 673781, upload-time = "2025-11-17T22:32:11.364Z" },+ { url = "https://files.pythonhosted.org/packages/04/f9/067b84365c7e83bda15bba2b06c6ca250ce27b20630b1128c435fb7a09aa/ml_dtypes-0.5.4-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:805cef3a38f4eafae3a5bf9ebdcdb741d0bcfd9e1bd90eb54abd24f928cd2465", size = 5036145, upload-time = "2025-11-17T22:32:12.783Z" },+ { url = "https://files.pythonhosted.org/packages/c6/bb/82c7dcf38070b46172a517e2334e665c5bf374a262f99a283ea454bece7c/ml_dtypes-0.5.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:14a4fd3228af936461db66faccef6e4f41c1d82fcc30e9f8d58a08916b1d811f", size = 5010230, upload-time = "2025-11-17T22:32:14.38Z" },+ { url = "https://files.pythonhosted.org/packages/e9/93/2bfed22d2498c468f6bcd0d9f56b033eaa19f33320389314c19ef6766413/ml_dtypes-0.5.4-cp314-cp314-win_amd64.whl", hash = "sha256:8c6a2dcebd6f3903e05d51960a8058d6e131fe69f952a5397e5dbabc841b6d56", size = 221032, upload-time = "2025-11-17T22:32:15.763Z" },+ { url = "https://files.pythonhosted.org/packages/76/a3/9c912fe6ea747bb10fe2f8f54d027eb265db05dfb0c6335e3e063e74e6e8/ml_dtypes-0.5.4-cp314-cp314-win_arm64.whl", hash = "sha256:5a0f68ca8fd8d16583dfa7793973feb86f2fbb56ce3966daf9c9f748f52a2049", size = 163353, upload-time = "2025-11-17T22:32:16.932Z" },+ { url = "https://files.pythonhosted.org/packages/cd/02/48aa7d84cc30ab4ee37624a2fd98c56c02326785750cd212bc0826c2f15b/ml_dtypes-0.5.4-cp314-cp314t-macosx_10_13_universal2.whl", hash = "sha256:bfc534409c5d4b0bf945af29e5d0ab075eae9eecbb549ff8a29280db822f34f9", size = 702085, upload-time = "2025-11-17T22:32:18.175Z" },+ { url = "https://files.pythonhosted.org/packages/5a/e7/85cb99fe80a7a5513253ec7faa88a65306be071163485e9a626fce1b6e84/ml_dtypes-0.5.4-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2314892cdc3fcf05e373d76d72aaa15fda9fb98625effa73c1d646f331fcecb7", size = 5355358, upload-time = "2025-11-17T22:32:19.7Z" },+ { url = "https://files.pythonhosted.org/packages/79/2b/a826ba18d2179a56e144aef69e57fb2ab7c464ef0b2111940ee8a3a223a2/ml_dtypes-0.5.4-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0d2ffd05a2575b1519dc928c0b93c06339eb67173ff53acb00724502cda231cf", size = 5366332, upload-time = "2025-11-17T22:32:21.193Z" },+ { url = "https://files.pythonhosted.org/packages/84/44/f4d18446eacb20ea11e82f133ea8f86e2bf2891785b67d9da8d0ab0ef525/ml_dtypes-0.5.4-cp314-cp314t-win_amd64.whl", hash = "sha256:4381fe2f2452a2d7589689693d3162e876b3ddb0a832cde7a414f8e1adf7eab1", size = 236612, upload-time = "2025-11-17T22:32:22.579Z" },+ { url = "https://files.pythonhosted.org/packages/ad/3f/3d42e9a78fe5edf792a83c074b13b9b770092a4fbf3462872f4303135f09/ml_dtypes-0.5.4-cp314-cp314t-win_arm64.whl", hash = "sha256:11942cbf2cf92157db91e5022633c0d9474d4dfd813a909383bd23ce828a4b7d", size = 168825, upload-time = "2025-11-17T22:32:23.766Z" },][[package]]@@ -962,34 +977,34 @@ wheels = [[[package]]name = "numba"-version = "0.65.0"+version = "0.65.1"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "llvmlite" },{ name = "numpy" },]-sdist = { url = "https://files.pythonhosted.org/packages/49/61/7299643b9c18d669e04be7c5bcb64d985070d07553274817b45b049e7bfe/numba-0.65.0.tar.gz", hash = "sha256:edad0d9f6682e93624c00125a471ae4df186175d71fd604c983c377cdc03e68b", size = 2764131, upload-time = "2026-04-01T03:52:01.946Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/ba/ce/d67c499703eb5479ce02420e8ccd65c5753d87d2e16d563f152d71405346/numba-0.65.0-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:28e547d0b18024f19cbaf9de02fc5c145790213d9be8a2c95b43f93ec162b9e4", size = 2680228, upload-time = "2026-04-01T03:51:25.401Z" },- { url = "https://files.pythonhosted.org/packages/c1/a7/11e2b24251d57cf41fc9ad83f378d890d61a890e3f8eb6338b39833f67a4/numba-0.65.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:032b0b8e879512cd424d79eed6d772a1399c6387ded184c2cf3cc22c08d750a6", size = 3744674, upload-time = "2026-04-01T03:51:27.311Z" },- { url = "https://files.pythonhosted.org/packages/fe/0b/7c63eb742859a6243f42288441f65ac9dac96ea59f409e43b713aafbe867/numba-0.65.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:af143d823624033a128b5950c0aaf9ffc2386dfe954eb757119cf0432335534c", size = 3450620, upload-time = "2026-04-01T03:51:29.092Z" },- { url = "https://files.pythonhosted.org/packages/53/ff/1371cbbe955be340a46093a10b61462437e0fadc7a63290473a0e584cb03/numba-0.65.0-cp311-cp311-win_amd64.whl", hash = "sha256:15d159578e59a39df246b83480f78d7794b0fca40153b5684d3849a99c48a0fb", size = 2747081, upload-time = "2026-04-01T03:51:30.785Z" },- { url = "https://files.pythonhosted.org/packages/6c/2f/8bd31a1ea43c01ac215283d83aa5f8d5acbe7a36c85b82f1757bfe9ccb31/numba-0.65.0-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:b27ee4847e1bfb17e9604d100417ee7c1d10f15a6711c6213404b3da13a0b2aa", size = 2680705, upload-time = "2026-04-01T03:51:32.597Z" },- { url = "https://files.pythonhosted.org/packages/73/36/88406bd58600cc696417b8e5dd6a056478da808f3eaf48d18e2421e0c2d9/numba-0.65.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:a52d92ffd297c10364bce60cd1fcb88f99284ab5df085f2c6bcd1cb33b529a6f", size = 3801411, upload-time = "2026-04-01T03:51:34.321Z" },- { url = "https://files.pythonhosted.org/packages/0c/61/ce753a1d7646dd477e16d15e89473703faebb8995d2f71d7ad69a540b565/numba-0.65.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:da8e371e328c06d0010c3d8b44b21858652831b85bcfba78cb22c042e22dbd8e", size = 3501622, upload-time = "2026-04-01T03:51:36.348Z" },- { url = "https://files.pythonhosted.org/packages/7d/86/db87a5393f1b1fabef53ac3ba4e6b938bb27e40a04ad7cc512098fcae032/numba-0.65.0-cp312-cp312-win_amd64.whl", hash = "sha256:59bb9f2bb9f1238dfd8e927ba50645c18ae769fef4f3d58ea0ea22a2683b91f5", size = 2749979, upload-time = "2026-04-01T03:51:37.88Z" },- { url = "https://files.pythonhosted.org/packages/8b/f8/eee0f1ff456218db036bfc9023995ec1f85a9dc8f2422f1594f6a87829e0/numba-0.65.0-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:c6334094563a456a695c812e6846288376ca02327cf246cdcc83e1bb27862367", size = 2680679, upload-time = "2026-04-01T03:51:39.491Z" },- { url = "https://files.pythonhosted.org/packages/1b/8f/3d116e4b8e92f6abace431afa4b2b944f4d65bdee83af886f5c4b263df95/numba-0.65.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b8a9008411615c69d083d1dcf477f75a5aa727b30beb16e139799e2be945cdfd", size = 3809537, upload-time = "2026-04-01T03:51:41.42Z" },- { url = "https://files.pythonhosted.org/packages/b5/2c/6a3ca4128e253cb67affe06deb47688f51ce968f5111e2a06d010e6f1fa6/numba-0.65.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:af96c0cba53664efcb361528b8c75e011a6556c859c7e08424c2715201c6cf7a", size = 3508615, upload-time = "2026-04-01T03:51:43.444Z" },- { url = "https://files.pythonhosted.org/packages/96/0e/267f9a36fb282c104a971d7eecb685b411c47dce2a740fe69cf5fc2945d9/numba-0.65.0-cp313-cp313-win_amd64.whl", hash = "sha256:6254e73b9c929dc736a1fbd3d6f5680789709a5067cae1fa7198707385129c04", size = 2749938, upload-time = "2026-04-01T03:51:45.218Z" },- { url = "https://files.pythonhosted.org/packages/56/a4/90edb01e9176053578e343d7a7276bc28356741ee67059aed8ed2c1a4e59/numba-0.65.0-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:ee336b398a6fca51b1f626034de99f50cb1bd87d537a166275158a3cee744b82", size = 2680878, upload-time = "2026-04-01T03:51:46.91Z" },- { url = "https://files.pythonhosted.org/packages/24/8d/e12d6ff4b9119db3cbf7b2db1ce257576441bd3c76388c786dea74f20b02/numba-0.65.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:05c0a9fdf75d85f57dee47b719e8d6415707b80aae45d75f63f9dc1b935c29f7", size = 3778456, upload-time = "2026-04-01T03:51:48.552Z" },- { url = "https://files.pythonhosted.org/packages/17/89/abcd83e76f6a773276fe76244140671bcc5bf820f6e2ae1a15362ae4c8c9/numba-0.65.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:583680e0e8faf124d362df23b4b593f3221a8996341a63d1b664c122401bec2f", size = 3478464, upload-time = "2026-04-01T03:51:50.527Z" },- { url = "https://files.pythonhosted.org/packages/73/5b/fbce55ce3d933afbc7ade04df826853e4a846aaa47d58d2fbb669b8f2d08/numba-0.65.0-cp314-cp314-win_amd64.whl", hash = "sha256:add297d3e1c08dd884f44100152612fa41e66a51d15fdf91307f9dde31d06830", size = 2752012, upload-time = "2026-04-01T03:51:52.691Z" },- { url = "https://files.pythonhosted.org/packages/1e/ab/af705f4257d9388fb2fd6d7416573e98b6ca9c786e8b58f02720978557bd/numba-0.65.0-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:194a243ba53a9157c8538cbb3166ec015d785a8c5d584d06cdd88bee902233c7", size = 2683961, upload-time = "2026-04-01T03:51:54.281Z" },- { url = "https://files.pythonhosted.org/packages/ff/e5/8267b0adb0c01b52b553df5062fbbb42c30ed5362d08b85cc913a36f838f/numba-0.65.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c7fa502960f7a2f3f5cb025bc7bff888a3551277b92431bfdc5ba2f11a375749", size = 3816373, upload-time = "2026-04-01T03:51:56.18Z" },- { url = "https://files.pythonhosted.org/packages/b0/f5/b8397ca360971669a93706b9274592b6864e4367a37d498fbbcb62aa2d48/numba-0.65.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5046c63f783ca3eb6195f826a50797465e7c4ce811daa17c9bea47e310c9b964", size = 3532782, upload-time = "2026-04-01T03:51:58.387Z" },- { url = "https://files.pythonhosted.org/packages/f5/21/1e73fa16bf0393ebb74c5bb208d712152ffdfc84600a8e93a3180317856e/numba-0.65.0-cp314-cp314t-win_amd64.whl", hash = "sha256:46fd679ae4f68c7a5d5721efbd29ecee0b0f3013211591891d79b51bfdf73113", size = 2757611, upload-time = "2026-04-01T03:52:00.083Z" },+sdist = { url = "https://files.pythonhosted.org/packages/f6/c5/db2ac3685833d626c0dcae6bd2330cd68433e1fd248d15f70998160d3ad7/numba-0.65.1.tar.gz", hash = "sha256:19357146c32fe9ed25059ab915e8465fb13951cf6b0aace3826b76886373ab23", size = 2765600, upload-time = "2026-04-24T02:02:56.551Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/96/b3/650500c2eab4534d98e9166f4298e0f3c69c742afdf24e6eabccd1f16ad8/numba-0.65.1-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:7020d74b19cdb8cff16506542fdd510756e28c5e7f3bd0b7f574f0f42272fcd9", size = 2680563, upload-time = "2026-04-24T02:02:18.414Z" },+ { url = "https://files.pythonhosted.org/packages/44/0b/0615dbedb98f5b32a35a53290fbdc6e22306968109278d7e58df82d7a9f6/numba-0.65.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f80ed83774b5173abd6581cd8d2165d1d38e13d2e5c8155c0c0b421784745420", size = 3745018, upload-time = "2026-04-24T02:02:20.252Z" },+ { url = "https://files.pythonhosted.org/packages/49/aa/4361698f35bf63bff67dfe6c90493731177f48ede954f77b0588731537bc/numba-0.65.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7ed425a43b0a5f9772f2f4e2dd0bbd12eabecae1af0b24efcfd4e053f012aac6", size = 3450962, upload-time = "2026-04-24T02:02:22.449Z" },+ { url = "https://files.pythonhosted.org/packages/bd/9a/af61ec03b3116c161fd7a06b9e8a265729a8718458333e8ffbb06d9a3978/numba-0.65.1-cp311-cp311-win_amd64.whl", hash = "sha256:df40a5028a975b9ea66f6a2a3f7abbdbd541a863070e34ed367aff21141248e4", size = 2747417, upload-time = "2026-04-24T02:02:24.43Z" },+ { url = "https://files.pythonhosted.org/packages/57/bc/76f8f8c5cf9adee47fdb7bbb03be8900f76f902d451d7477cf12b845e1de/numba-0.65.1-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:ac3f1e77c352dd0ea9712732c2d8f9ca507717435eec5b5013bf138ac33c4a08", size = 2681371, upload-time = "2026-04-24T02:02:26.105Z" },+ { url = "https://files.pythonhosted.org/packages/69/47/a415af0283e4db0398104c6d1c11c9861a98dc67a7aa442a7769ed5d6196/numba-0.65.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:52bc6f3ceb8fcaff9b2ae26b4c6b1e9fee39db8d355534c0fe4f39a901246b84", size = 3802467, upload-time = "2026-04-24T02:02:27.712Z" },+ { url = "https://files.pythonhosted.org/packages/46/36/246f73ec99cfeab2f2cb2ce7d4218766cc36a2da418901223f4f4da9c813/numba-0.65.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:90ca10b3463bae0bd70589726fe3c77d01d6b5fc86bee54bcdf9fb6b47c28977", size = 3502628, upload-time = "2026-04-24T02:02:29.763Z" },+ { url = "https://files.pythonhosted.org/packages/db/9e/3c679b2ee078425b9e99a91e44f8d132a6830d8ccce5227bc5e9181aeed8/numba-0.65.1-cp312-cp312-win_amd64.whl", hash = "sha256:5971c632be2a2351500431f46213821dba8d02b18a9f7d02fd36bd2743e41a6a", size = 2750611, upload-time = "2026-04-24T02:02:31.477Z" },+ { url = "https://files.pythonhosted.org/packages/79/37/14a4579049c1eb673afd0de0cb4842982acd55b9ce2643e763db858bcea0/numba-0.65.1-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:1735c15c1134a5108b4d6a5c77fc0947924ea066a738dc09a52008c13df9cad3", size = 2681344, upload-time = "2026-04-24T02:02:33.65Z" },+ { url = "https://files.pythonhosted.org/packages/a0/22/b8d873f6466b20aa563fc9b33acd48dec89a07803ddaa2f1c8ca1cd33126/numba-0.65.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c09f49117ef255e1f1c6dad0c7a1ed39868243862a73be5706793241a3755f1b", size = 3810619, upload-time = "2026-04-24T02:02:36.041Z" },+ { url = "https://files.pythonhosted.org/packages/62/08/e16a8b5d9a018962ebb5c66be662317cde32b9f5dab08441f90bed5522fb/numba-0.65.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:594a8680b3fadac99e97e489b1fd89007177e5336713745c3b769528c635a464", size = 3509783, upload-time = "2026-04-24T02:02:38.245Z" },+ { url = "https://files.pythonhosted.org/packages/fd/a5/03c970d57f4c1741354837353ce39fb5206952ae1dba8922d29c86f64805/numba-0.65.1-cp313-cp313-win_amd64.whl", hash = "sha256:85be74c0d036842699a30058f82fb88fc5ffdc59f7615cab5792ea92914c9b62", size = 2750534, upload-time = "2026-04-24T02:02:39.903Z" },+ { url = "https://files.pythonhosted.org/packages/4f/2e/8aed9b726d9ba5f11ad287645fd479e88278db3060a25cb1225d730eb2b7/numba-0.65.1-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:33f5eb68eb1c843511615d14663ce60258525d6a4c65ab040e2c2b0c4cf17450", size = 2681554, upload-time = "2026-04-24T02:02:41.812Z" },+ { url = "https://files.pythonhosted.org/packages/87/96/f3eb235fafa82a34e2ab5dd7dc9ffff998ebf5f0bbc23fa56a96aeb44da6/numba-0.65.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:71e73029bf53a62cc6afcf96be4bd942290d8b4c55f0a454fb536158115790f7", size = 3779602, upload-time = "2026-04-24T02:02:43.726Z" },+ { url = "https://files.pythonhosted.org/packages/09/90/b0f09b48752d23640b8284f22aa597737e8adaddc7fbfacc4708b7f73a4c/numba-0.65.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3a07635e0be926b9bdbffb09137c230fb13f6ec0e564914ba937cee12ce3eb35", size = 3479532, upload-time = "2026-04-24T02:02:45.427Z" },+ { url = "https://files.pythonhosted.org/packages/56/46/3f7fc04fb853559e74b210e0b62c19974ec844cefec611f9e535f4da3761/numba-0.65.1-cp314-cp314-win_amd64.whl", hash = "sha256:2a20fcdabdefbdacf88d85caf70c3b18c4bcb7ebb8f82e6a19486383dd26ab63", size = 2752637, upload-time = "2026-04-24T02:02:47.664Z" },+ { url = "https://files.pythonhosted.org/packages/81/7b/c1a341a9067367778f4152a5f01061cf281fb09582c92c510ec4918cabf6/numba-0.65.1-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:548dd4b3a4508d5062768d1514b2cd7b015f9a25ec7af651c50dee243965e652", size = 2684600, upload-time = "2026-04-24T02:02:49.653Z" },+ { url = "https://files.pythonhosted.org/packages/03/36/98ddbcf3e4f04a6dd07e1c67249955920579ba4af6bb6868e3088f4ed282/numba-0.65.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:78abc28feff2c2ff8307fff3975b6438352759c9acb797ecd6b1fb6e7e39e31d", size = 3817198, upload-time = "2026-04-24T02:02:51.266Z" },+ { url = "https://files.pythonhosted.org/packages/a3/83/0dad21057ece5a835599f5d24099b091703995e23dbbf894f259e91c010b/numba-0.65.1-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ee7676cb389555805f9b9a1840cbcd1ea6c8bd5376ab6918e3a29c5ea1dbda20", size = 3533862, upload-time = "2026-04-24T02:02:52.987Z" },+ { url = "https://files.pythonhosted.org/packages/32/36/8be7118ffd4c8440881046eac3d0982cc5ab42909508cf5d67024d62a2e4/numba-0.65.1-cp314-cp314t-win_amd64.whl", hash = "sha256:20609346e3bd75204950dcbbfe383a8d7dbf4902f442aedbf00f97fef4aa8f38", size = 2758237, upload-time = "2026-04-24T02:02:54.612Z" },][[package]]@@ -1131,15 +1146,15 @@ wheels = [[[package]]name = "nvidia-cudnn-cu12"-version = "9.21.0.82"+version = "9.21.1.3"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "nvidia-cublas-cu12" },]wheels = [- { url = "https://files.pythonhosted.org/packages/f4/e9/aea85c214a5dad046e56131428c22ff40d0359db3a930040698c0c6c8e68/nvidia_cudnn_cu12-9.21.0.82-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:8ba7c5067854d2b8d8dc21a65bbc5a642b31e4dddc8864cf3a093d25a92e874c", size = 759281118, upload-time = "2026-04-14T15:30:44.958Z" },- { url = "https://files.pythonhosted.org/packages/5c/cf/47778414dd633ba93395f9d34c87283916c3163f57000c2aeef1f869c649/nvidia_cudnn_cu12-9.21.0.82-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:286af0a8ee51e3e5eb0e858b0b93a85a5ae6a686f22a0c83c8d7d4dc9151402f", size = 704763924, upload-time = "2026-04-15T16:43:40.04Z" },- { url = "https://files.pythonhosted.org/packages/c6/e9/e91296c0d7b4b565f38de9ccbf757a8c3172b62a485222751d39f673a26c/nvidia_cudnn_cu12-9.21.0.82-py3-none-win_amd64.whl", hash = "sha256:29c69af1d2f8a6778ef6dbc7829416e6a4c8585b7ca2cab5fb1876bf2e393589", size = 686896833, upload-time = "2026-04-14T15:35:00.959Z" },+ { url = "https://files.pythonhosted.org/packages/7c/90/306a6f3937706b089c72535a2bf2a42e49168923481f82a4c79e7629d00c/nvidia_cudnn_cu12-9.21.1.3-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:8f8bf4d0f942bc9c3a501cc990dbc2397e2dfbe4af8d3f2984fab14aa7a606e2", size = 759361824, upload-time = "2026-04-21T15:51:51.106Z" },+ { url = "https://files.pythonhosted.org/packages/3c/8e/0c3aeef5f8a9507ad0b2d6fb3f28f38997cda1c7e7f614adc00ceb64a901/nvidia_cudnn_cu12-9.21.1.3-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:ffd5bf372071423c441f1de01af35abd6b6f3921a8ab80b23db8ba69a12131b0", size = 704835470, upload-time = "2026-04-21T15:53:03.458Z" },+ { url = "https://files.pythonhosted.org/packages/ce/a5/91672bf58b23479f89744d02ae918f8d8cc940a97e2548d44c19b786d681/nvidia_cudnn_cu12-9.21.1.3-py3-none-win_amd64.whl", hash = "sha256:4e87cb118a52d7cb4a758d1dc47652975bb81e52f230febd361eba04d0204799", size = 686950248, upload-time = "2026-04-21T15:55:20.889Z" },][[package]]@@ -1166,63 +1181,79 @@ wheels = [][[package]]-name = "onnxruntime-gpu"-version = "1.24.4"+name = "onnx"+version = "1.21.0"source = { registry = "https://pypi.org/simple" }dependencies = [- { name = "flatbuffers" },+ { name = "ml-dtypes" },{ name = "numpy" },- { name = "packaging" },{ name = "protobuf" },- { name = "sympy" },+ { name = "typing-extensions" },]-wheels = [- { url = "https://files.pythonhosted.org/packages/9f/13/e080d758f2b60f71abe518c707135fb121d6a3019e0761ead89b5283ac3d/onnxruntime_gpu-1.24.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c2a698659271c28220b3f56fe9b63f70eae3b3c36afa544201bf750b929a36dc", size = 252761835, upload-time = "2026-03-17T22:03:45.584Z" },- { url = "https://files.pythonhosted.org/packages/d2/07/036825cbe30f91ea8574a18a759beccd0ea31b7b71e17f6a9ee9304b51d2/onnxruntime_gpu-1.24.4-cp311-cp311-win_amd64.whl", hash = "sha256:1a799a16e5f1ff4d6a9e5f72d750849ab0fe534da8d323ae4a5d8d8bb7daeca8", size = 207193563, upload-time = "2026-03-17T21:58:28.097Z" },- { url = "https://files.pythonhosted.org/packages/d0/2c/5b3fd4748cf7ed291eae541a37e426efc20ea04cb6e6a05768304ab0aa41/onnxruntime_gpu-1.24.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:eb0e38f0c1ef3b76ae0081c8e51eed20dd8925aa916f0fc6f9b8b17d05610e99", size = 252765531, upload-time = "2026-03-17T22:03:57.528Z" },- { url = "https://files.pythonhosted.org/packages/f2/86/70cecfdab1e963cc7f8c11e72040dfcd5cff85b1de2de74deba9611e0059/onnxruntime_gpu-1.24.4-cp312-cp312-win_amd64.whl", hash = "sha256:da5c1e327d8e119a831be2790e69f93cf6daab9145ed0aca7577f412a620f709", size = 207197978, upload-time = "2026-03-17T21:58:38.43Z" },- { url = "https://files.pythonhosted.org/packages/be/4e/56d11203d7a35e7d6a5ea735f5fecb8673537038c07323e8d3090a896547/onnxruntime_gpu-1.24.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bbdaa73f9055fb2a177425edbed651a1843a6239f9d5430e284f4e5f65440a33", size = 252763446, upload-time = "2026-03-17T22:04:09.515Z" },- { url = "https://files.pythonhosted.org/packages/fa/bc/35f3a37226d7a28c84b8b456f52237ccd39eb7111114bcf9ac340178e1ec/onnxruntime_gpu-1.24.4-cp313-cp313-win_amd64.whl", hash = "sha256:6be8bf2048777c517fca33eb61e114969fa326619feaa789d8c75f24337ea762", size = 207198775, upload-time = "2026-03-17T21:58:48.768Z" },- { url = "https://files.pythonhosted.org/packages/37/83/0c851882051b38f245f44b4a51d6232b95b8cd5d334b2c1260f2d796834f/onnxruntime_gpu-1.24.4-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e4b348a078ced73fc577d21b83992fd2187edd10c233729c8d01b000b8543525", size = 252774594, upload-time = "2026-03-17T22:04:24.957Z" },- { url = "https://files.pythonhosted.org/packages/3e/5b/82b27f766b64f97c9a98b772dc07b608e900bd2faafdfa176b86d20be7f8/onnxruntime_gpu-1.24.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:af9dd7ef92d94c75e5523cf070e180f3d8cdbb2fc007dcea97ba71b03e3b96d6", size = 252765395, upload-time = "2026-03-17T22:04:37.305Z" },- { url = "https://files.pythonhosted.org/packages/5d/95/fa8c48e03790c979167d08164b34a8442c7074bca4c7253b4455497025de/onnxruntime_gpu-1.24.4-cp314-cp314-win_amd64.whl", hash = "sha256:4dde3d2f1039060c42b12fd446fc0da5b836cc65dceb4020ca60a04cffa1d90d", size = 209597109, upload-time = "2026-03-17T21:58:58.136Z" },- { url = "https://files.pythonhosted.org/packages/1a/98/7707edefcecf69d6c45b83a83f13ac58257017b4eaf58772668d302f849f/onnxruntime_gpu-1.24.4-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:097c6f53e99ee35f21d0fdba76ca283b92465a0e364c6f0209cb9653c424e2a4", size = 252776951, upload-time = "2026-03-17T22:04:49.715Z" },+sdist = { url = "https://files.pythonhosted.org/packages/c5/93/942d2a0f6a70538eea042ce0445c8aefd46559ad153469986f29a743c01c/onnx-1.21.0.tar.gz", hash = "sha256:4d8b67d0aaec5864c87633188b91cc520877477ec0254eda122bef8be43cd764", size = 12074608, upload-time = "2026-03-27T21:33:36.118Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/45/48/32e383aa6bc40b72a9fd419937aaa647078190c9bfccdc97b316d2dee687/onnx-1.21.0-cp311-cp311-macosx_12_0_universal2.whl", hash = "sha256:2aca19949260875c14866fc77ea0bc37e4e809b24976108762843d328c92d3ce", size = 17968053, upload-time = "2026-03-27T21:32:29.558Z" },+ { url = "https://files.pythonhosted.org/packages/e2/26/5726e8df7d36e96bb3c679912d1a86af42f393d77aa17d6b98a97d4289ce/onnx-1.21.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:82aa6ab51144df07c58c4850cb78d4f1ae969d8c0bf657b28041796d49ba6974", size = 17534821, upload-time = "2026-03-27T21:32:32.351Z" },+ { url = "https://files.pythonhosted.org/packages/d6/2b/021dcd2dd50c3c71b7959d7368526da384a295c162fb4863f36057973f78/onnx-1.21.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:10c3185a232089335581fabb98fba4e86d3e8246b8140f2e406082438100ebda", size = 17616664, upload-time = "2026-03-27T21:32:34.921Z" },+ { url = "https://files.pythonhosted.org/packages/12/00/afa32a46fa122a7ed42df1cfe8796922156a3725ba8fc581c4779c96e2fc/onnx-1.21.0-cp311-cp311-win32.whl", hash = "sha256:f53b3c15a3b539c16b99655c43c365622046d68c49b680c48eba4da2a4fb6f27", size = 16289035, upload-time = "2026-03-27T21:32:37.783Z" },+ { url = "https://files.pythonhosted.org/packages/73/8d/483cc980a24d4c0131d0af06d0ff6a37fb08ae90a7848ece8cef645194f1/onnx-1.21.0-cp311-cp311-win_amd64.whl", hash = "sha256:5f78c411743db317a76e5d009f84f7e3d5380411a1567a868e82461a1e5c775d", size = 16443748, upload-time = "2026-03-27T21:32:40.337Z" },+ { url = "https://files.pythonhosted.org/packages/38/78/9d06fd5aaaed1ec9cb8a3b70fbbf00c1bdc18db610771e96379f0ed58112/onnx-1.21.0-cp311-cp311-win_arm64.whl", hash = "sha256:ab6a488dabbb172eebc9f3b3e7ac68763f32b0c571626d4a5004608f866cc83d", size = 16406123, upload-time = "2026-03-27T21:32:45.159Z" },+ { url = "https://files.pythonhosted.org/packages/7d/ae/cb644ec84c25e63575d9d8790fdcc5d1a11d67d3f62f872edb35fa38d158/onnx-1.21.0-cp312-abi3-macosx_12_0_universal2.whl", hash = "sha256:fc2635400fe39ff37ebc4e75342cc54450eadadf39c540ff132c319bf4960095", size = 17965930, upload-time = "2026-03-27T21:32:48.089Z" },+ { url = "https://files.pythonhosted.org/packages/6f/b6/eeb5903586645ef8a49b4b7892580438741acc3df91d7a5bd0f3a59ea9cb/onnx-1.21.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9003d5206c01fa2ff4b46311566865d8e493e1a6998d4009ec6de39843f1b59b", size = 17531344, upload-time = "2026-03-27T21:32:50.837Z" },+ { url = "https://files.pythonhosted.org/packages/a7/00/4823f06357892d1e60d6f34e7299d2ba4ed2108c487cc394f7ce85a3ff14/onnx-1.21.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a9261bd580fb8548c9c37b3c6750387eb8f21ea43c63880d37b2c622e1684285", size = 17613697, upload-time = "2026-03-27T21:32:54.222Z" },+ { url = "https://files.pythonhosted.org/packages/23/1d/391f3c567ae068c8ac4f1d1316bae97c9eb45e702f05975fe0e17ad441f0/onnx-1.21.0-cp312-abi3-win32.whl", hash = "sha256:9ea4e824964082811938a9250451d89c4ec474fe42dd36c038bfa5df31993d1e", size = 16287200, upload-time = "2026-03-27T21:32:57.277Z" },+ { url = "https://files.pythonhosted.org/packages/9c/a6/5eefbe5b40ea96de95a766bd2e0e751f35bdea2d4b951991ec9afaa69531/onnx-1.21.0-cp312-abi3-win_amd64.whl", hash = "sha256:458d91948ad9a7729a347550553b49ab6939f9af2cddf334e2116e45467dc61f", size = 16441045, upload-time = "2026-03-27T21:33:00.081Z" },+ { url = "https://files.pythonhosted.org/packages/63/c4/0ed8dc037a39113d2a4d66e0005e07751c299c46b993f1ad5c2c35664c20/onnx-1.21.0-cp312-abi3-win_arm64.whl", hash = "sha256:ca14bc4842fccc3187eb538f07eabeb25a779b39388b006db4356c07403a7bbb", size = 16403134, upload-time = "2026-03-27T21:33:03.987Z" },+ { url = "https://files.pythonhosted.org/packages/f8/89/0e1a9beb536401e2f45ac88735e123f2735e12fc7b56ff6c11727e097526/onnx-1.21.0-cp313-cp313t-macosx_12_0_universal2.whl", hash = "sha256:257d1d1deb6a652913698f1e3f33ef1ca0aa69174892fe38946d4572d89dd94f", size = 17975430, upload-time = "2026-03-27T21:33:07.005Z" },+ { url = "https://files.pythonhosted.org/packages/ec/46/e6dc71a7b3b317265591b20a5f71d0ff5c0d26c24e52283139dc90c66038/onnx-1.21.0-cp313-cp313t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7cd7cb8f6459311bdb557cbf6c0ccc6d8ace11c304d1bba0a30b4a4688e245f8", size = 17537435, upload-time = "2026-03-27T21:33:09.765Z" },+ { url = "https://files.pythonhosted.org/packages/49/2e/27affcac63eaf2ef183a44fd1a1354b11da64a6c72fe6f3fdcf5571bcee5/onnx-1.21.0-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b58a4cfec8d9311b73dc083e4c1fa362069267881144c05139b3eba5dc3a840", size = 17617687, upload-time = "2026-03-27T21:33:12.619Z" },+ { url = "https://files.pythonhosted.org/packages/1c/5c/ac8ed15e941593a3672ce424280b764979026317811f2e8508432bfc3429/onnx-1.21.0-cp313-cp313t-win_amd64.whl", hash = "sha256:1a9baf882562c4cebf79589bebb7cd71a20e30b51158cac3e3bbaf27da6163bd", size = 16449402, upload-time = "2026-03-27T21:33:15.555Z" },+ { url = "https://files.pythonhosted.org/packages/0e/aa/d2231e0dcaad838217afc64c306c8152a080134d2034e247cc973d577674/onnx-1.21.0-cp313-cp313t-win_arm64.whl", hash = "sha256:bba12181566acf49b35875838eba49536a327b2944664b17125577d230c637ad", size = 16408273, upload-time = "2026-03-27T21:33:18.599Z" },+ { url = "https://files.pythonhosted.org/packages/bf/0a/8905b14694def6ad23edf1011fdd581500384062f8c4c567e114be7aa272/onnx-1.21.0-cp314-cp314t-macosx_12_0_universal2.whl", hash = "sha256:7ee9d8fd6a4874a5fa8b44bbcabea104ce752b20469b88bc50c7dcf9030779ad", size = 17975331, upload-time = "2026-03-27T21:33:21.69Z" },+ { url = "https://files.pythonhosted.org/packages/61/28/f4e401e5199d1b9c8b76c7e7ae1169e050515258e877b58fa8bb49d3bdcc/onnx-1.21.0-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5489f25fe461e7f32128218251a466cabbeeaf1eaa791c79daebf1a80d5a2cc9", size = 17537430, upload-time = "2026-03-27T21:33:24.547Z" },+ { url = "https://files.pythonhosted.org/packages/cf/cf/5d13320eb3660d5af360ea3b43aa9c63a70c92a9b4d1ea0d34501a32fcb8/onnx-1.21.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:db17fc0fec46180b6acbd1d5d8650a04e5527c02b09381da0b5b888d02a204c8", size = 17617662, upload-time = "2026-03-27T21:33:27.418Z" },+ { url = "https://files.pythonhosted.org/packages/4d/50/3eaa1878338247be021e6423696813d61e77e534dccbd15a703a144e703d/onnx-1.21.0-cp314-cp314t-win_amd64.whl", hash = "sha256:19d9971a3e52a12968ae6c70fd0f86c349536de0b0c33922ecdbe52d1972fe60", size = 16463688, upload-time = "2026-03-27T21:33:30.229Z" },+ { url = "https://files.pythonhosted.org/packages/a7/48/38d46b43bbb525e0b6a4c2c4204cc6795d67e45687a2f7403e06d8e7053d/onnx-1.21.0-cp314-cp314t-win_arm64.whl", hash = "sha256:efba467efb316baf2a9452d892c2f982b9b758c778d23e38c7f44fa211b30bb9", size = 16423387, upload-time = "2026-03-27T21:33:33.446Z" },][[package]]-name = "opencv-contrib-python"-version = "4.13.0.92"+name = "onnxruntime-gpu"+version = "1.25.1"source = { registry = "https://pypi.org/simple" }dependencies = [+ { name = "flatbuffers" },{ name = "numpy" },+ { name = "packaging" },+ { name = "protobuf" },]wheels = [- { url = "https://files.pythonhosted.org/packages/7e/4c/a45c96b9fe90b2c48ee604f5176eb7deb46ce7c2e87c8d819d2945dbcab6/opencv_contrib_python-4.13.0.92-cp37-abi3-macosx_13_0_arm64.whl", hash = "sha256:53c8ab81376210dda5836307eb6bda7266f39a3820a9a070c7131510ba815fe1", size = 52041546, upload-time = "2026-02-05T07:01:29.918Z" },- { url = "https://files.pythonhosted.org/packages/8b/6c/ba1f3177927deeb3002b62fb8db89daea3b5dc732d61de5bf4c73ed6ebf7/opencv_contrib_python-4.13.0.92-cp37-abi3-macosx_14_0_x86_64.whl", hash = "sha256:1973d0fc773873f9d1b5bf0d1b65895da2f47b06ba033b7d58393f5c28ba0778", size = 38830319, upload-time = "2026-02-05T07:01:47.222Z" },- { url = "https://files.pythonhosted.org/packages/ff/7a/fe87eaf109b454af4a2579f46958b3cafb0f804b9c788c108760723a9bb7/opencv_contrib_python-4.13.0.92-cp37-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:5f9cb522dd9e465dfca3536c15288f7936b9827432fb9c885eaf94dc5f88c2a3", size = 53339457, upload-time = "2026-02-05T10:09:02.332Z" },- { url = "https://files.pythonhosted.org/packages/b6/27/3665ca4b75ddfd218f9ab139f0463d9571e87aaf59391d3c4f5546c08df7/opencv_contrib_python-4.13.0.92-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f9ceec5886419860a31b518991a99e978e5a6a78dca1470103ad4ede0155f156", size = 76591184, upload-time = "2026-02-05T10:11:51.298Z" },- { url = "https://files.pythonhosted.org/packages/f3/11/10c46e9527c4591d5264117debd8fe0e21bb23dbf378ce760add6b1e85b6/opencv_contrib_python-4.13.0.92-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:a3c54377c5cf9c45d9b1a207df26dc8fe4f1042d07036cb17d80930c04b25d97", size = 52544155, upload-time = "2026-02-05T10:13:32.068Z" },- { url = "https://files.pythonhosted.org/packages/ba/f6/3c645c21358079097201090de7c30d110f5ec3fa01008e3ee81b0a77a354/opencv_contrib_python-4.13.0.92-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:fc5ee50e2be9d40e913536f7f20cc6f87f25d8e413ebb32a3335ab6edf245d3e", size = 79150872, upload-time = "2026-02-05T10:16:03.465Z" },- { url = "https://files.pythonhosted.org/packages/90/d7/bf4622e0ed8a93f5a685c76933e287477cf185a160c66478cf144fece489/opencv_contrib_python-4.13.0.92-cp37-abi3-win32.whl", hash = "sha256:f5d02357f4d5575c300eab3ec1c7ecfed3a9a53e55a76927bab7cfc9e0a67b68", size = 36829959, upload-time = "2026-02-05T07:02:22.25Z" },- { url = "https://files.pythonhosted.org/packages/d9/98/a03f69ff6fb86a67d584ecc990d85a95e6930b96e3f39ad1f8e019cb8ada/opencv_contrib_python-4.13.0.92-cp37-abi3-win_amd64.whl", hash = "sha256:cb694dcf76bb2c8d7fa573fc1a99339e8b6640194d7778381e74cc3445369e45", size = 46486178, upload-time = "2026-02-05T07:02:19.551Z" },+ { url = "https://files.pythonhosted.org/packages/bc/bb/d0aeb0910beee46d34568af9ba07d40bf9c5f94f188bf43c0ff47388f6de/onnxruntime_gpu-1.25.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fcdd93f7a74659e08137b5d9c705390e57b37ac86e6956ec0d7ccd81001afe0c", size = 271246304, upload-time = "2026-04-27T22:06:00.753Z" },+ { url = "https://files.pythonhosted.org/packages/41/a8/1e93491d72ea04318445b0053c00ab7aedecb2327f79a560868e97423ea4/onnxruntime_gpu-1.25.1-cp311-cp311-win_amd64.whl", hash = "sha256:5c2d00d7b62c098e5d0c720ae9e81dcb3143a4285516a43e39c4997fa9fcc1f3", size = 221700978, upload-time = "2026-04-27T21:59:31.581Z" },+ { url = "https://files.pythonhosted.org/packages/54/d9/0dc74ca5d208848e931abacde743d61c0c33ecc916ffac2b54d604b4cfe5/onnxruntime_gpu-1.25.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:264b65ed81c1a32c2e410423ef3e4ba3ebb603c099d5a374c8780fbeb3496239", size = 271272487, upload-time = "2026-04-27T22:06:11.243Z" },+ { url = "https://files.pythonhosted.org/packages/0e/10/2f72ca2a2c606e3245dca27e843f74493e544bf976bf5e97c41b0259d18b/onnxruntime_gpu-1.25.1-cp312-cp312-win_amd64.whl", hash = "sha256:d73660da130e03d6f5bfba2522af01491e26902643589fe466a10f6936dfc71a", size = 221708572, upload-time = "2026-04-27T21:59:41.786Z" },+ { url = "https://files.pythonhosted.org/packages/5b/45/cd3eacbe8b250164f2d3b745d7f66162139ed669b1c51cf4d4b5305bc6bf/onnxruntime_gpu-1.25.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:098a0f1eb7b6b5e0ae1befcb996cddfd67cbe5a0aad2356da162cc3f8213e870", size = 271272750, upload-time = "2026-04-27T22:06:21.099Z" },+ { url = "https://files.pythonhosted.org/packages/4b/e8/252532842000aded7cb9030a99d7564ac5205c6631588fb0807b3d0a6881/onnxruntime_gpu-1.25.1-cp313-cp313-win_amd64.whl", hash = "sha256:a03cc135ad38b249f5c343cc6f80333ba7571ced4c85c940ee282d5f931f207e", size = 221716176, upload-time = "2026-04-27T21:59:52.821Z" },+ { url = "https://files.pythonhosted.org/packages/cc/c1/f97022dcae5b52276117d37c127732abadd5c21d606bf40ef8af279e1906/onnxruntime_gpu-1.25.1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7d9ba9bc88084a270134c49f20d9d546f372a95bc4bd1bedc22f581a19820a4f", size = 271282502, upload-time = "2026-04-27T22:06:31.4Z" },+ { url = "https://files.pythonhosted.org/packages/77/53/0715544ca64145701e9cb9ff6f459969bd09f81bb7cd4825a019d6bcf2f3/onnxruntime_gpu-1.25.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b67c4f61d2ff62683271a2e52ce37e94f1e26ead24492e62ed68fb28aa29882a", size = 271274506, upload-time = "2026-04-27T22:06:41.099Z" },+ { url = "https://files.pythonhosted.org/packages/a5/80/0cfd2fba98eadb39cd71e298aa05a0ab175e4b6c85de50d2cc1a24426816/onnxruntime_gpu-1.25.1-cp314-cp314-win_amd64.whl", hash = "sha256:4d69af9d1c4de4a48f3d2a7f5c0d8f25d73febd6f467b02f545c6912005b04e6", size = 224246737, upload-time = "2026-04-27T22:00:02.606Z" },+ { url = "https://files.pythonhosted.org/packages/85/01/c863a5f27f17247d1bce7af2d5666bdaae2fd55843e848c2ba3bf2faf44a/onnxruntime_gpu-1.25.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:dacff3a1e1590da3caa08f86e65ae12c589b4f0a11205047bad2203948111917", size = 271276260, upload-time = "2026-04-27T22:06:50.95Z" },][[package]]-name = "opencv-python"-version = "4.13.0.92"+name = "opencv-contrib-python"+version = "4.12.0.88"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "numpy" },]+sdist = { url = "https://files.pythonhosted.org/packages/e0/b4/30fb53c33da02626b66dd40ad58dd4aa01eef834e422e098dfc056ed0873/opencv-contrib-python-4.12.0.88.tar.gz", hash = "sha256:0f1e22823aace09067b9a0e8e2b4ba6d7a1ef08807d6cebea315f3133f419a0e", size = 150785997, upload-time = "2025-07-07T09:20:16.755Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/fc/6f/5a28fef4c4a382be06afe3938c64cc168223016fa520c5abaf37e8862aa5/opencv_python-4.13.0.92-cp37-abi3-macosx_13_0_arm64.whl", hash = "sha256:caf60c071ec391ba51ed00a4a920f996d0b64e3e46068aac1f646b5de0326a19", size = 46247052, upload-time = "2026-02-05T07:01:25.046Z" },- { url = "https://files.pythonhosted.org/packages/08/ac/6c98c44c650b8114a0fb901691351cfb3956d502e8e9b5cd27f4ee7fbf2f/opencv_python-4.13.0.92-cp37-abi3-macosx_14_0_x86_64.whl", hash = "sha256:5868a8c028a0b37561579bfb8ac1875babdc69546d236249fff296a8c010ccf9", size = 32568781, upload-time = "2026-02-05T07:01:41.379Z" },- { url = "https://files.pythonhosted.org/packages/3e/51/82fed528b45173bf629fa44effb76dff8bc9f4eeaee759038362dfa60237/opencv_python-4.13.0.92-cp37-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0bc2596e68f972ca452d80f444bc404e08807d021fbba40df26b61b18e01838a", size = 47685527, upload-time = "2026-02-05T06:59:11.24Z" },- { url = "https://files.pythonhosted.org/packages/db/07/90b34a8e2cf9c50fe8ed25cac9011cde0676b4d9d9c973751ac7616223a2/opencv_python-4.13.0.92-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:402033cddf9d294693094de5ef532339f14ce821da3ad7df7c9f6e8316da32cf", size = 70460872, upload-time = "2026-02-05T06:59:19.162Z" },- { url = "https://files.pythonhosted.org/packages/02/6d/7a9cc719b3eaf4377b9c2e3edeb7ed3a81de41f96421510c0a169ca3cfd4/opencv_python-4.13.0.92-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:bccaabf9eb7f897ca61880ce2869dcd9b25b72129c28478e7f2a5e8dee945616", size = 46708208, upload-time = "2026-02-05T06:59:15.419Z" },- { url = "https://files.pythonhosted.org/packages/fd/55/b3b49a1b97aabcfbbd6c7326df9cb0b6fa0c0aefa8e89d500939e04aa229/opencv_python-4.13.0.92-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:620d602b8f7d8b8dab5f4b99c6eb353e78d3fb8b0f53db1bd258bb1aa001c1d5", size = 72927042, upload-time = "2026-02-05T06:59:23.389Z" },- { url = "https://files.pythonhosted.org/packages/fb/17/de5458312bcb07ddf434d7bfcb24bb52c59635ad58c6e7c751b48949b009/opencv_python-4.13.0.92-cp37-abi3-win32.whl", hash = "sha256:372fe164a3148ac1ca51e5f3ad0541a4a276452273f503441d718fab9c5e5f59", size = 30932638, upload-time = "2026-02-05T07:02:14.98Z" },- { url = "https://files.pythonhosted.org/packages/e9/a5/1be1516390333ff9be3a9cb648c9f33df79d5096e5884b5df71a588af463/opencv_python-4.13.0.92-cp37-abi3-win_amd64.whl", hash = "sha256:423d934c9fafb91aad38edf26efb46da91ffbc05f3f59c4b0c72e699720706f5", size = 40212062, upload-time = "2026-02-05T07:02:12.724Z" },+ { url = "https://files.pythonhosted.org/packages/26/c7/7cc80acd8a1ef9438542364b41751ecea2e95cf16b8ac4e48ebca643b203/opencv_contrib_python-4.12.0.88-cp37-abi3-macosx_13_0_arm64.whl", hash = "sha256:decc3a2627e03e61ec398919a8647b7f78315bf285e64bcd7dd4501b653f22bc", size = 46854784, upload-time = "2025-07-07T09:16:09.739Z" },+ { url = "https://files.pythonhosted.org/packages/24/50/632534ad4a029aab4e1693664d9116223345af4499c72903e7711a1b44bb/opencv_contrib_python-4.12.0.88-cp37-abi3-macosx_13_0_x86_64.whl", hash = "sha256:e1209da6553b9c2b348fb5c878c2cd0e0121f9335981b7a9735c10d1ef1580ac", size = 67163714, upload-time = "2025-07-07T09:16:22.948Z" },+ { url = "https://files.pythonhosted.org/packages/aa/30/0829882b280f40544a83c69312da4d935ff3d6086c10351c7b1659107b5c/opencv_contrib_python-4.12.0.88-cp37-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:7b3b834d5a2b84f26e5b62ff9ae07a287ab668d2343773372c3b97a335cd7c4f", size = 51290366, upload-time = "2025-07-07T09:16:33.078Z" },+ { url = "https://files.pythonhosted.org/packages/6a/67/905c2c9364dcd450a0997a489fd3976a10a83cd1ebcbd3d039bb2525b54c/opencv_contrib_python-4.12.0.88-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ac2627dcdf5bd625706949ada7994524320b656a991315ff6ae70043fc983689", size = 73160002, upload-time = "2025-07-07T09:16:45.815Z" },+ { url = "https://files.pythonhosted.org/packages/5a/78/8110f1de88155241d9df6a701e2e589734a8bf3dbe1fd1a3cd29243c732a/opencv_contrib_python-4.12.0.88-cp37-abi3-win32.whl", hash = "sha256:fe3a5cbc1467c3620aeda3afd8d363886298a6fc85b48d62b2991afab65076c5", size = 36169774, upload-time = "2025-07-07T09:16:54.401Z" },+ { url = "https://files.pythonhosted.org/packages/7f/8c/ec631100261b0fca25cafd1e1a06592e50b3cda8aa08e7c4c14d7b4d7115/opencv_contrib_python-4.12.0.88-cp37-abi3-win_amd64.whl", hash = "sha256:62c20c14fdd794c9d0fbc780b3d52a74bc967d205664d25b3906951abedc9f65", size = 45262376, upload-time = "2025-07-07T09:17:02.868Z" },][[package]]@@ -1245,11 +1276,11 @@ numpy = [[[package]]name = "packaging"-version = "26.1"+version = "26.2"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/df/de/0d2b39fb4af88a0258f3bac87dfcbb48e73fbdea4a2ed0e2213f9a4c2f9a/packaging-26.1.tar.gz", hash = "sha256:f042152b681c4bfac5cae2742a55e103d27ab2ec0f3d88037136b6bfe7c9c5de", size = 215519, upload-time = "2026-04-14T21:12:49.362Z" }+sdist = { url = "https://files.pythonhosted.org/packages/d7/f1/e7a6dd94a8d4a5626c03e4e99c87f241ba9e350cd9e6d75123f992427270/packaging-26.2.tar.gz", hash = "sha256:ff452ff5a3e828ce110190feff1178bb1f2ea2281fa2075aadb987c2fb221661", size = 228134, upload-time = "2026-04-24T20:15:23.917Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/7a/c2/920ef838e2f0028c8262f16101ec09ebd5969864e5a64c4c05fad0617c56/packaging-26.1-py3-none-any.whl", hash = "sha256:5d9c0669c6285e491e0ced2eee587eaf67b670d94a19e94e3984a481aba6802f", size = 95831, upload-time = "2026-04-14T21:12:47.56Z" },+ { url = "https://files.pythonhosted.org/packages/df/b2/87e62e8c3e2f4b32e5fe99e0b86d576da1312593b39f47d8ceef365e95ed/packaging-26.2-py3-none-any.whl", hash = "sha256:5fc45236b9446107ff2415ce77c807cee2862cb6fac22b8a73826d0693b0980e", size = 100195, upload-time = "2026-04-24T20:15:22.081Z" },][[package]]@@ -1419,11 +1450,11 @@ wheels = [[[package]]name = "pip"-version = "26.0.1"+version = "26.1.1"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/48/83/0d7d4e9efe3344b8e2fe25d93be44f64b65364d3c8d7bc6dc90198d5422e/pip-26.0.1.tar.gz", hash = "sha256:c4037d8a277c89b320abe636d59f91e6d0922d08a05b60e85e53b296613346d8", size = 1812747, upload-time = "2026-02-05T02:20:18.702Z" }+sdist = { url = "https://files.pythonhosted.org/packages/b6/48/cb9b7a682f6fe01a4221e1728941dd4ac3cd9090a17db3779d6ff490b602/pip-26.1.1.tar.gz", hash = "sha256:d36762751d156a4ee895de8af39aa0abeeeb577f93a2eca6ab62467bbf0f8a78", size = 1840400, upload-time = "2026-05-04T19:02:21.248Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/de/f0/c81e05b613866b76d2d1066490adf1a3dbc4ee9d9c839961c3fc8a6997af/pip-26.0.1-py3-none-any.whl", hash = "sha256:bdb1b08f4274833d62c1aa29e20907365a2ceb950410df15fc9521bad440122b", size = 1787723, upload-time = "2026-02-05T02:20:16.416Z" },+ { url = "https://files.pythonhosted.org/packages/3a/eb/fea4d1d51c49832120f7f285d07306db3960f423a2612c6057caf3e8196f/pip-26.1.1-py3-none-any.whl", hash = "sha256:99cb1c2899893b075ff56e4ed0af55669a955b49ad7fb8d8603ecdaf4ed653fb", size = 1812777, upload-time = "2026-05-04T19:02:18.9Z" },][[package]]@@ -1454,15 +1485,15 @@ wheels = [[[package]]name = "poethepoet"-version = "0.44.0"+version = "0.45.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "pastel" },{ name = "pyyaml" },]-sdist = { url = "https://files.pythonhosted.org/packages/a1/a4/e487662f12a5ecd2ac4d77f7697e4bda481953bb80032b158e5ab55173d4/poethepoet-0.44.0.tar.gz", hash = "sha256:c2667b513621788fb46482e371cdf81c0b04344e0e0bcb7aa8af45f84c2fce7b", size = 96040, upload-time = "2026-04-06T19:40:58.908Z" }+sdist = { url = "https://files.pythonhosted.org/packages/1d/28/d54e16913f591f01b2e1c4ab526ccbba47864d9bf10299904c823a760d25/poethepoet-0.45.0.tar.gz", hash = "sha256:cf2c2df4c185d33b619c2771de2b28c2b81c733f072226030c7fa4c273c040f8", size = 97150, upload-time = "2026-04-28T21:04:59.301Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/80/b7/503b7d3a51b0de9a329f1323048d166e309a97bb31bdc60e6acd11d2c71f/poethepoet-0.44.0-py3-none-any.whl", hash = "sha256:36d3d834708ed069ac1e4f8ed77915c55265b7b6e01aeb2fe617c9fe9cfd524a", size = 122873, upload-time = "2026-04-06T19:40:57.369Z" },+ { url = "https://files.pythonhosted.org/packages/e9/99/4aefb693b0f52783fab496492f4444a75137312c386eb7c3320f1b0a1602/poethepoet-0.45.0-py3-none-any.whl", hash = "sha256:8e25f6e834ecf25fe2ddca676a4e0207eeb2e19def0a8709fc5c7f18e86cd68c", size = 123920, upload-time = "2026-04-28T21:04:57.66Z" },][[package]]@@ -1496,52 +1527,52 @@ wheels = [[[package]]name = "pyarrow"-version = "23.0.1"-source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/88/22/134986a4cc224d593c1afde5494d18ff629393d74cc2eddb176669f234a4/pyarrow-23.0.1.tar.gz", hash = "sha256:b8c5873e33440b2bc2f4a79d2b47017a89c5a24116c055625e6f2ee50523f019", size = 1167336, upload-time = "2026-02-16T10:14:12.39Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/b0/41/8e6b6ef7e225d4ceead8459427a52afdc23379768f54dd3566014d7618c1/pyarrow-23.0.1-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:6f0147ee9e0386f519c952cc670eb4a8b05caa594eeffe01af0e25f699e4e9bb", size = 34302230, upload-time = "2026-02-16T10:09:03.859Z" },- { url = "https://files.pythonhosted.org/packages/bf/4a/1472c00392f521fea03ae93408bf445cc7bfa1ab81683faf9bc188e36629/pyarrow-23.0.1-cp311-cp311-macosx_12_0_x86_64.whl", hash = "sha256:0ae6e17c828455b6265d590100c295193f93cc5675eb0af59e49dbd00d2de350", size = 35850050, upload-time = "2026-02-16T10:09:11.877Z" },- { url = "https://files.pythonhosted.org/packages/0c/b2/bd1f2f05ded56af7f54d702c8364c9c43cd6abb91b0e9933f3d77b4f4132/pyarrow-23.0.1-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:fed7020203e9ef273360b9e45be52a2a47d3103caf156a30ace5247ffb51bdbd", size = 44491918, upload-time = "2026-02-16T10:09:18.144Z" },- { url = "https://files.pythonhosted.org/packages/0b/62/96459ef5b67957eac38a90f541d1c28833d1b367f014a482cb63f3b7cd2d/pyarrow-23.0.1-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:26d50dee49d741ac0e82185033488d28d35be4d763ae6f321f97d1140eb7a0e9", size = 47562811, upload-time = "2026-02-16T10:09:25.792Z" },- { url = "https://files.pythonhosted.org/packages/7d/94/1170e235add1f5f45a954e26cd0e906e7e74e23392dcb560de471f7366ec/pyarrow-23.0.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:3c30143b17161310f151f4a2bcfe41b5ff744238c1039338779424e38579d701", size = 48183766, upload-time = "2026-02-16T10:09:34.645Z" },- { url = "https://files.pythonhosted.org/packages/0e/2d/39a42af4570377b99774cdb47f63ee6c7da7616bd55b3d5001aa18edfe4f/pyarrow-23.0.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:db2190fa79c80a23fdd29fef4b8992893f024ae7c17d2f5f4db7171fa30c2c78", size = 50607669, upload-time = "2026-02-16T10:09:44.153Z" },- { url = "https://files.pythonhosted.org/packages/00/ca/db94101c187f3df742133ac837e93b1f269ebdac49427f8310ee40b6a58f/pyarrow-23.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:f00f993a8179e0e1c9713bcc0baf6d6c01326a406a9c23495ec1ba9c9ebf2919", size = 27527698, upload-time = "2026-02-16T10:09:50.263Z" },- { url = "https://files.pythonhosted.org/packages/9a/4b/4166bb5abbfe6f750fc60ad337c43ecf61340fa52ab386da6e8dbf9e63c4/pyarrow-23.0.1-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:f4b0dbfa124c0bb161f8b5ebb40f1a680b70279aa0c9901d44a2b5a20806039f", size = 34214575, upload-time = "2026-02-16T10:09:56.225Z" },- { url = "https://files.pythonhosted.org/packages/e1/da/3f941e3734ac8088ea588b53e860baeddac8323ea40ce22e3d0baa865cc9/pyarrow-23.0.1-cp312-cp312-macosx_12_0_x86_64.whl", hash = "sha256:7707d2b6673f7de054e2e83d59f9e805939038eebe1763fe811ee8fa5c0cd1a7", size = 35832540, upload-time = "2026-02-16T10:10:03.428Z" },- { url = "https://files.pythonhosted.org/packages/88/7c/3d841c366620e906d54430817531b877ba646310296df42ef697308c2705/pyarrow-23.0.1-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:86ff03fb9f1a320266e0de855dee4b17da6794c595d207f89bba40d16b5c78b9", size = 44470940, upload-time = "2026-02-16T10:10:10.704Z" },- { url = "https://files.pythonhosted.org/packages/2c/a5/da83046273d990f256cb79796a190bbf7ec999269705ddc609403f8c6b06/pyarrow-23.0.1-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:813d99f31275919c383aab17f0f455a04f5a429c261cc411b1e9a8f5e4aaaa05", size = 47586063, upload-time = "2026-02-16T10:10:17.95Z" },- { url = "https://files.pythonhosted.org/packages/5b/3c/b7d2ebcff47a514f47f9da1e74b7949138c58cfeb108cdd4ee62f43f0cf3/pyarrow-23.0.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:bf5842f960cddd2ef757d486041d57c96483efc295a8c4a0e20e704cbbf39c67", size = 48173045, upload-time = "2026-02-16T10:10:25.363Z" },- { url = "https://files.pythonhosted.org/packages/43/b2/b40961262213beaba6acfc88698eb773dfce32ecdf34d19291db94c2bd73/pyarrow-23.0.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:564baf97c858ecc03ec01a41062e8f4698abc3e6e2acd79c01c2e97880a19730", size = 50621741, upload-time = "2026-02-16T10:10:33.477Z" },- { url = "https://files.pythonhosted.org/packages/f6/70/1fdda42d65b28b078e93d75d371b2185a61da89dda4def8ba6ba41ebdeb4/pyarrow-23.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:07deae7783782ac7250989a7b2ecde9b3c343a643f82e8a4df03d93b633006f0", size = 27620678, upload-time = "2026-02-16T10:10:39.31Z" },- { url = "https://files.pythonhosted.org/packages/47/10/2cbe4c6f0fb83d2de37249567373d64327a5e4d8db72f486db42875b08f6/pyarrow-23.0.1-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:6b8fda694640b00e8af3c824f99f789e836720aa8c9379fb435d4c4953a756b8", size = 34210066, upload-time = "2026-02-16T10:10:45.487Z" },- { url = "https://files.pythonhosted.org/packages/cb/4f/679fa7e84dadbaca7a65f7cdba8d6c83febbd93ca12fa4adf40ba3b6362b/pyarrow-23.0.1-cp313-cp313-macosx_12_0_x86_64.whl", hash = "sha256:8ff51b1addc469b9444b7c6f3548e19dc931b172ab234e995a60aea9f6e6025f", size = 35825526, upload-time = "2026-02-16T10:10:52.266Z" },- { url = "https://files.pythonhosted.org/packages/f9/63/d2747d930882c9d661e9398eefc54f15696547b8983aaaf11d4a2e8b5426/pyarrow-23.0.1-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:71c5be5cbf1e1cb6169d2a0980850bccb558ddc9b747b6206435313c47c37677", size = 44473279, upload-time = "2026-02-16T10:11:01.557Z" },- { url = "https://files.pythonhosted.org/packages/b3/93/10a48b5e238de6d562a411af6467e71e7aedbc9b87f8d3a35f1560ae30fb/pyarrow-23.0.1-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:9b6f4f17b43bc39d56fec96e53fe89d94bac3eb134137964371b45352d40d0c2", size = 47585798, upload-time = "2026-02-16T10:11:09.401Z" },- { url = "https://files.pythonhosted.org/packages/5c/20/476943001c54ef078dbf9542280e22741219a184a0632862bca4feccd666/pyarrow-23.0.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:9fc13fc6c403d1337acab46a2c4346ca6c9dec5780c3c697cf8abfd5e19b6b37", size = 48179446, upload-time = "2026-02-16T10:11:17.781Z" },- { url = "https://files.pythonhosted.org/packages/4b/b6/5dd0c47b335fcd8edba9bfab78ad961bd0fd55ebe53468cc393f45e0be60/pyarrow-23.0.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:5c16ed4f53247fa3ffb12a14d236de4213a4415d127fe9cebed33d51671113e2", size = 50623972, upload-time = "2026-02-16T10:11:26.185Z" },- { url = "https://files.pythonhosted.org/packages/d5/09/a532297c9591a727d67760e2e756b83905dd89adb365a7f6e9c72578bcc1/pyarrow-23.0.1-cp313-cp313-win_amd64.whl", hash = "sha256:cecfb12ef629cf6be0b1887f9f86463b0dd3dc3195ae6224e74006be4736035a", size = 27540749, upload-time = "2026-02-16T10:12:23.297Z" },- { url = "https://files.pythonhosted.org/packages/a5/8e/38749c4b1303e6ae76b3c80618f84861ae0c55dd3c2273842ea6f8258233/pyarrow-23.0.1-cp313-cp313t-macosx_12_0_arm64.whl", hash = "sha256:29f7f7419a0e30264ea261fdc0e5fe63ce5a6095003db2945d7cd78df391a7e1", size = 34471544, upload-time = "2026-02-16T10:11:32.535Z" },- { url = "https://files.pythonhosted.org/packages/a3/73/f237b2bc8c669212f842bcfd842b04fc8d936bfc9d471630569132dc920d/pyarrow-23.0.1-cp313-cp313t-macosx_12_0_x86_64.whl", hash = "sha256:33d648dc25b51fd8055c19e4261e813dfc4d2427f068bcecc8b53d01b81b0500", size = 35949911, upload-time = "2026-02-16T10:11:39.813Z" },- { url = "https://files.pythonhosted.org/packages/0c/86/b912195eee0903b5611bf596833def7d146ab2d301afeb4b722c57ffc966/pyarrow-23.0.1-cp313-cp313t-manylinux_2_28_aarch64.whl", hash = "sha256:cd395abf8f91c673dd3589cadc8cc1ee4e8674fa61b2e923c8dd215d9c7d1f41", size = 44520337, upload-time = "2026-02-16T10:11:47.764Z" },- { url = "https://files.pythonhosted.org/packages/69/c2/f2a717fb824f62d0be952ea724b4f6f9372a17eed6f704b5c9526f12f2f1/pyarrow-23.0.1-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:00be9576d970c31defb5c32eb72ef585bf600ef6d0a82d5eccaae96639cf9d07", size = 47548944, upload-time = "2026-02-16T10:11:56.607Z" },- { url = "https://files.pythonhosted.org/packages/84/a7/90007d476b9f0dc308e3bc57b832d004f848fd6c0da601375d20d92d1519/pyarrow-23.0.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:c2139549494445609f35a5cda4eb94e2c9e4d704ce60a095b342f82460c73a83", size = 48236269, upload-time = "2026-02-16T10:12:04.47Z" },- { url = "https://files.pythonhosted.org/packages/b0/3f/b16fab3e77709856eb6ac328ce35f57a6d4a18462c7ca5186ef31b45e0e0/pyarrow-23.0.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:7044b442f184d84e2351e5084600f0d7343d6117aabcbc1ac78eb1ae11eb4125", size = 50604794, upload-time = "2026-02-16T10:12:11.797Z" },- { url = "https://files.pythonhosted.org/packages/e9/a1/22df0620a9fac31d68397a75465c344e83c3dfe521f7612aea33e27ab6c0/pyarrow-23.0.1-cp313-cp313t-win_amd64.whl", hash = "sha256:a35581e856a2fafa12f3f54fce4331862b1cfb0bef5758347a858a4aa9d6bae8", size = 27660642, upload-time = "2026-02-16T10:12:17.746Z" },- { url = "https://files.pythonhosted.org/packages/8d/1b/6da9a89583ce7b23ac611f183ae4843cd3a6cf54f079549b0e8c14031e73/pyarrow-23.0.1-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:5df1161da23636a70838099d4aaa65142777185cc0cdba4037a18cee7d8db9ca", size = 34238755, upload-time = "2026-02-16T10:12:32.819Z" },- { url = "https://files.pythonhosted.org/packages/ae/b5/d58a241fbe324dbaeb8df07be6af8752c846192d78d2272e551098f74e88/pyarrow-23.0.1-cp314-cp314-macosx_12_0_x86_64.whl", hash = "sha256:fa8e51cb04b9f8c9c5ace6bab63af9a1f88d35c0d6cbf53e8c17c098552285e1", size = 35847826, upload-time = "2026-02-16T10:12:38.949Z" },- { url = "https://files.pythonhosted.org/packages/54/a5/8cbc83f04aba433ca7b331b38f39e000efd9f0c7ce47128670e737542996/pyarrow-23.0.1-cp314-cp314-manylinux_2_28_aarch64.whl", hash = "sha256:0b95a3994f015be13c63148fef8832e8a23938128c185ee951c98908a696e0eb", size = 44536859, upload-time = "2026-02-16T10:12:45.467Z" },- { url = "https://files.pythonhosted.org/packages/36/2e/c0f017c405fcdc252dbccafbe05e36b0d0eb1ea9a958f081e01c6972927f/pyarrow-23.0.1-cp314-cp314-manylinux_2_28_x86_64.whl", hash = "sha256:4982d71350b1a6e5cfe1af742c53dfb759b11ce14141870d05d9e540d13bc5d1", size = 47614443, upload-time = "2026-02-16T10:12:55.525Z" },- { url = "https://files.pythonhosted.org/packages/af/6b/2314a78057912f5627afa13ba43809d9d653e6630859618b0fd81a4e0759/pyarrow-23.0.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c250248f1fe266db627921c89b47b7c06fee0489ad95b04d50353537d74d6886", size = 48232991, upload-time = "2026-02-16T10:13:04.729Z" },- { url = "https://files.pythonhosted.org/packages/40/f2/1bcb1d3be3460832ef3370d621142216e15a2c7c62602a4ea19ec240dd64/pyarrow-23.0.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5f4763b83c11c16e5f4c15601ba6dfa849e20723b46aa2617cb4bffe8768479f", size = 50645077, upload-time = "2026-02-16T10:13:14.147Z" },- { url = "https://files.pythonhosted.org/packages/eb/3f/b1da7b61cd66566a4d4c8383d376c606d1c34a906c3f1cb35c479f59d1aa/pyarrow-23.0.1-cp314-cp314-win_amd64.whl", hash = "sha256:3a4c85ef66c134161987c17b147d6bffdca4566f9a4c1d81a0a01cdf08414ea5", size = 28234271, upload-time = "2026-02-16T10:14:09.397Z" },- { url = "https://files.pythonhosted.org/packages/b5/78/07f67434e910a0f7323269be7bfbf58699bd0c1d080b18a1ab49ba943fe8/pyarrow-23.0.1-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:17cd28e906c18af486a499422740298c52d7c6795344ea5002a7720b4eadf16d", size = 34488692, upload-time = "2026-02-16T10:13:21.541Z" },- { url = "https://files.pythonhosted.org/packages/50/76/34cf7ae93ece1f740a04910d9f7e80ba166b9b4ab9596a953e9e62b90fe1/pyarrow-23.0.1-cp314-cp314t-macosx_12_0_x86_64.whl", hash = "sha256:76e823d0e86b4fb5e1cf4a58d293036e678b5a4b03539be933d3b31f9406859f", size = 35964383, upload-time = "2026-02-16T10:13:28.63Z" },- { url = "https://files.pythonhosted.org/packages/46/90/459b827238936d4244214be7c684e1b366a63f8c78c380807ae25ed92199/pyarrow-23.0.1-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:a62e1899e3078bf65943078b3ad2a6ddcacf2373bc06379aac61b1e548a75814", size = 44538119, upload-time = "2026-02-16T10:13:35.506Z" },- { url = "https://files.pythonhosted.org/packages/28/a1/93a71ae5881e99d1f9de1d4554a87be37da11cd6b152239fb5bd924fdc64/pyarrow-23.0.1-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:df088e8f640c9fae3b1f495b3c64755c4e719091caf250f3a74d095ddf3c836d", size = 47571199, upload-time = "2026-02-16T10:13:42.504Z" },- { url = "https://files.pythonhosted.org/packages/88/a3/d2c462d4ef313521eaf2eff04d204ac60775263f1fb08c374b543f79f610/pyarrow-23.0.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:46718a220d64677c93bc243af1d44b55998255427588e400677d7192671845c7", size = 48259435, upload-time = "2026-02-16T10:13:49.226Z" },- { url = "https://files.pythonhosted.org/packages/cc/f1/11a544b8c3d38a759eb3fbb022039117fd633e9a7b19e4841cc3da091915/pyarrow-23.0.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:a09f3876e87f48bc2f13583ab551f0379e5dfb83210391e68ace404181a20690", size = 50629149, upload-time = "2026-02-16T10:13:57.238Z" },- { url = "https://files.pythonhosted.org/packages/50/f2/c0e76a0b451ffdf0cf788932e182758eb7558953f4f27f1aff8e2518b653/pyarrow-23.0.1-cp314-cp314t-win_amd64.whl", hash = "sha256:527e8d899f14bd15b740cd5a54ad56b7f98044955373a17179d5956ddb93d9ce", size = 28365807, upload-time = "2026-02-16T10:14:03.892Z" },+version = "24.0.0"+source = { registry = "https://pypi.org/simple" }+sdist = { url = "https://files.pythonhosted.org/packages/91/13/13e1069b351bdc3881266e11147ffccf687505dbb0ea74036237f5d454a5/pyarrow-24.0.0.tar.gz", hash = "sha256:85fe721a14dd823aca09127acbb06c3ca723efbd436c004f16bca601b04dcc83", size = 1180261, upload-time = "2026-04-21T10:51:25.837Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/62/c9/a47ab7ece0d86cbe6678418a0fbd1ac4bb493b9184a3891dfa0e7f287ae0/pyarrow-24.0.0-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:b0e131f880cda8d04e076cee175a46fc0e8bc8b65c99c6c09dff6669335fde74", size = 35068898, upload-time = "2026-04-21T10:46:36.599Z" },+ { url = "https://files.pythonhosted.org/packages/d1/bc/8db86617a9a58008acf8913d6fed68ea2a46acb6de928db28d724c891a68/pyarrow-24.0.0-cp311-cp311-macosx_12_0_x86_64.whl", hash = "sha256:1b2fe7f9a5566401a0ef2571f197eb92358925c1f0c8dba305d6e43ea0871bb3", size = 36679915, upload-time = "2026-04-21T10:46:42.602Z" },+ { url = "https://files.pythonhosted.org/packages/eb/8e/fb178720400ef69db251eb4a9c3ccf4af269bc1feb5055529b8fc87170d1/pyarrow-24.0.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:0b3537c00fb8d384f15ac1e79b6eb6db04a16514c8c1d22e59a9b95c8ba42868", size = 45697931, upload-time = "2026-04-21T10:46:48.403Z" },+ { url = "https://files.pythonhosted.org/packages/f3/27/99c42abe8e21b44f4917f62631f3aa31404882a2c41d8a4cd5c110e13d52/pyarrow-24.0.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:14e31a3c9e35f1ab6356c6378f6f72830e6d2d5f1791df3774a7b097d18a6a1e", size = 48837449, upload-time = "2026-04-21T10:46:55.329Z" },+ { url = "https://files.pythonhosted.org/packages/36/b6/333749e2666e9032891125bf9c691146e92901bece62030ac1430e2e7c88/pyarrow-24.0.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:b7d9a514e73bc42711e6a35aaccf3587c520024fe0a25d830a1a8a27c15f4f57", size = 49395949, upload-time = "2026-04-21T10:47:01.869Z" },+ { url = "https://files.pythonhosted.org/packages/17/25/c5201706a2dd374e8ba6ee3fd7a8c89fb7ffc16eed5217a91fd2bd7f7626/pyarrow-24.0.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b196eb3f931862af3fa84c2a253514d859c08e0d8fe020e07be12e75a5a9780c", size = 51912986, upload-time = "2026-04-21T10:47:09.872Z" },+ { url = "https://files.pythonhosted.org/packages/f8/d2/4d1bbba65320b21a49678d6fbdc6ff7c649251359fdcfc03568c4136231d/pyarrow-24.0.0-cp311-cp311-win_amd64.whl", hash = "sha256:35405aecb474e683fb36af650618fd5340ee5471fc65a21b36076a18bbc6c981", size = 27255371, upload-time = "2026-04-21T10:47:15.943Z" },+ { url = "https://files.pythonhosted.org/packages/b4/a9/9686d9f07837f91f775e8932659192e02c74f9d8920524b480b85212cc68/pyarrow-24.0.0-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:6233c9ed9ab9d1db47de57d9753256d9dcffbf42db341576099f0fd9f6bf4810", size = 34981559, upload-time = "2026-04-21T10:47:22.17Z" },+ { url = "https://files.pythonhosted.org/packages/80/b6/0ddf0e9b6ead3474ab087ae598c76b031fc45532bf6a63f3a553440fb258/pyarrow-24.0.0-cp312-cp312-macosx_12_0_x86_64.whl", hash = "sha256:f7616236ec1bc2b15bfdec22a71ab38851c86f8f05ff64f379e1278cf20c634a", size = 36663654, upload-time = "2026-04-21T10:47:28.315Z" },+ { url = "https://files.pythonhosted.org/packages/7c/3b/926382efe8ce27ba729071d3566ade6dfb86bdf112f366000196b2f5780a/pyarrow-24.0.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:1617043b99bd33e5318ae18eb2919af09c71322ef1ca46566cdafc6e6712fb66", size = 45679394, upload-time = "2026-04-21T10:47:34.821Z" },+ { url = "https://files.pythonhosted.org/packages/b3/7a/829f7d9dfd37c207206081d6dad474d81dde29952401f07f2ba507814818/pyarrow-24.0.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:6165461f55ef6314f026de6638d661188e3455d3ec49834556a0ebbdbace18bb", size = 48863122, upload-time = "2026-04-21T10:47:42.056Z" },+ { url = "https://files.pythonhosted.org/packages/5f/e8/f88ce625fe8babaae64e8db2d417c7653adb3019b08aae85c5ed787dc816/pyarrow-24.0.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:3b13dedfe76a0ad2d1d859b0811b53827a4e9d93a0bcb05cf59333ab4980cc7e", size = 49376032, upload-time = "2026-04-21T10:47:48.967Z" },+ { url = "https://files.pythonhosted.org/packages/36/7a/82c363caa145fff88fb475da50d3bf52bb024f61917be5424c3392eaf878/pyarrow-24.0.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:25ea65d868eb04015cd18e6df2fbe98f07e5bda2abefabcb88fce39a947716f6", size = 51929490, upload-time = "2026-04-21T10:47:55.981Z" },+ { url = "https://files.pythonhosted.org/packages/66/1c/e3e72c8014ad2743ca64a701652c733cc5cbcee15c0463a32a8c55518d9e/pyarrow-24.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:295f0a7f2e242dabd513737cf076007dc5b2d59237e3eca37b05c0c6446f3826", size = 27355660, upload-time = "2026-04-21T10:48:01.718Z" },+ { url = "https://files.pythonhosted.org/packages/6f/d3/a1abf004482026ddc17f4503db227787fa3cfe41ec5091ff20e4fea55e57/pyarrow-24.0.0-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:02b001b3ed4723caa44f6cd1af2d5c86aa2cf9971dacc2ffa55b21237713dfba", size = 34976759, upload-time = "2026-04-21T10:48:07.258Z" },+ { url = "https://files.pythonhosted.org/packages/4f/4a/34f0a36d28a2dd32225301b79daad44e243dc1a2bb77d43b60749be255c4/pyarrow-24.0.0-cp313-cp313-macosx_12_0_x86_64.whl", hash = "sha256:04920d6a71aabd08a0417709efce97d45ea8e6fb733d9ca9ecffb13c67839f68", size = 36658471, upload-time = "2026-04-21T10:48:13.347Z" },+ { url = "https://files.pythonhosted.org/packages/1f/78/543b94712ae8bb1a6023bcc1acf1a740fbff8286747c289cd9468fced2a5/pyarrow-24.0.0-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:a964266397740257f16f7bb2e4f08a0c81454004beab8ff59dd531b73610e9f2", size = 45675981, upload-time = "2026-04-21T10:48:20.201Z" },+ { url = "https://files.pythonhosted.org/packages/84/9f/8fb7c222b100d314137fa40ec050de56cd8c6d957d1cfff685ce72f15b17/pyarrow-24.0.0-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:6f066b179d68c413374294bc1735f68475457c933258df594443bb9d88ddc2a0", size = 48859172, upload-time = "2026-04-21T10:48:27.541Z" },+ { url = "https://files.pythonhosted.org/packages/a7/d3/1ea72538e6c8b3b475ed78d1049a2c518e655761ea50fe1171fc855fcab7/pyarrow-24.0.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:1183baeb14c5f587b1ec52831e665718ce632caab84b7cd6b85fd44f96114495", size = 49385733, upload-time = "2026-04-21T10:48:34.7Z" },+ { url = "https://files.pythonhosted.org/packages/c3/be/c3d8b06a1ba35f2260f8e1f771abbee7d5e345c0937aab90675706b1690a/pyarrow-24.0.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:806f24b4085453c197a5078218d1ee08783ebbba271badd153d1ae22a3ee804f", size = 51934335, upload-time = "2026-04-21T10:48:42.099Z" },+ { url = "https://files.pythonhosted.org/packages/9c/62/89e07a1e7329d2cde3e3c6994ba0839a24977a2beda8be6005ea3d860b99/pyarrow-24.0.0-cp313-cp313-win_amd64.whl", hash = "sha256:e4505fc6583f7b05ab854934896bcac8253b04ac1171a77dfb73efef92076d91", size = 27271748, upload-time = "2026-04-21T10:49:42.532Z" },+ { url = "https://files.pythonhosted.org/packages/17/1a/cff3a59f80b5b1658549d46611b67163f65e0664431c076ad728bf9d5af4/pyarrow-24.0.0-cp313-cp313t-macosx_12_0_arm64.whl", hash = "sha256:1a4e45017efbf115032e4475ee876d525e0e36c742214fbe405332480ecd6275", size = 35238554, upload-time = "2026-04-21T10:48:48.526Z" },+ { url = "https://files.pythonhosted.org/packages/a8/99/cce0f42a327bfef2c420fb6078a3eb834826e5d6697bf3009fe11d2ad051/pyarrow-24.0.0-cp313-cp313t-macosx_12_0_x86_64.whl", hash = "sha256:7986f1fa71cee060ad00758bcc79d3a93bab8559bf978fab9e53472a2e25a17b", size = 36782301, upload-time = "2026-04-21T10:48:55.181Z" },+ { url = "https://files.pythonhosted.org/packages/2a/66/8e560d5ff6793ca29aca213c53eec0dd482dd46cb93b2819e5aab52e4252/pyarrow-24.0.0-cp313-cp313t-manylinux_2_28_aarch64.whl", hash = "sha256:d3e0b61e8efb24ed38898e5cdc5fffa9124be480008d401a1f8071500494ae42", size = 45721929, upload-time = "2026-04-21T10:49:03.676Z" },+ { url = "https://files.pythonhosted.org/packages/27/0c/a26e25505d030716e078d9f16eb74973cbf0b33b672884e9f9da1c83b871/pyarrow-24.0.0-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:55a3bc1e3df3b5567b7d27ef551b2283f0c68a5e86f1cd56abc569da4f31335b", size = 48825365, upload-time = "2026-04-21T10:49:11.714Z" },+ { url = "https://files.pythonhosted.org/packages/5f/eb/771f9ecb0c65e73fe9dccdd1717901b9594f08c4515d000c7c62df573811/pyarrow-24.0.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:641f795b361874ac9da5294f8f443dfdbee355cf2bd9e3b8d97aaac2306b9b37", size = 49451819, upload-time = "2026-04-21T10:49:21.474Z" },+ { url = "https://files.pythonhosted.org/packages/48/da/61ae89a88732f5a785646f3ec6125dbb640fa98a540eb2b9889caa561403/pyarrow-24.0.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:8adc8e6ce5fccf5dc707046ae4914fd537def529709cc0d285d37a7f9cd442ca", size = 51909252, upload-time = "2026-04-21T10:49:31.164Z" },+ { url = "https://files.pythonhosted.org/packages/cb/1a/8dd5cafab7b66573fa91c03d06d213356ad4edd71813aa75e08ce2b3a844/pyarrow-24.0.0-cp313-cp313t-win_amd64.whl", hash = "sha256:9b18371ad2f44044b81a8d23bc2d8a9b6a6226dca775e8e16cfee640473d6c5d", size = 27388127, upload-time = "2026-04-21T10:49:37.334Z" },+ { url = "https://files.pythonhosted.org/packages/ad/80/d022a34ff05d2cbedd8ccf841fc1f532ecfa9eb5ed1711b56d0e0ea71fc9/pyarrow-24.0.0-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:1cc9057f0319e26333b357e17f3c2c022f1a83739b48a88b25bfd5fa2dc18838", size = 35007997, upload-time = "2026-04-21T10:49:48.796Z" },+ { url = "https://files.pythonhosted.org/packages/1a/ff/f01485fda6f4e5d441afb8dd5e7681e4db18826c1e271852f5d3957d6a80/pyarrow-24.0.0-cp314-cp314-macosx_12_0_x86_64.whl", hash = "sha256:e6f1278ee4785b6db21229374a1c9e54ec7c549de5d1efc9630b6207de7e170b", size = 36678720, upload-time = "2026-04-21T10:49:55.858Z" },+ { url = "https://files.pythonhosted.org/packages/9e/c2/2d2d5fea814237923f71b36495211f20b43a1576f9a4d6da7e751a64ec6f/pyarrow-24.0.0-cp314-cp314-manylinux_2_28_aarch64.whl", hash = "sha256:adbbedc55506cbdabb830890444fb856bfb0060c46c6f8026c6c2f2cf86ae795", size = 45741852, upload-time = "2026-04-21T10:50:04.624Z" },+ { url = "https://files.pythonhosted.org/packages/8e/3a/28ba9c1c1ebdbb5f1b94dfebb46f207e52e6a554b7fe4132540fde29a3a0/pyarrow-24.0.0-cp314-cp314-manylinux_2_28_x86_64.whl", hash = "sha256:ae8a1145af31d903fa9bb166824d7abe9b4681a000b0159c9fb99c11bc11ad26", size = 48889852, upload-time = "2026-04-21T10:50:12.293Z" },+ { url = "https://files.pythonhosted.org/packages/df/51/4a389acfd31dca009f8fb82d7f510bb4130f2b3a8e18cf00194d0687d8ac/pyarrow-24.0.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:d7027eba1df3b2069e2e8d80f644fa0918b68c46432af3d088ddd390d063ecde", size = 49445207, upload-time = "2026-04-21T10:50:20.677Z" },+ { url = "https://files.pythonhosted.org/packages/19/4b/0bab2b23d2ae901b1b9a03c0efd4b2d070256f8ce3fc43f6e58c167b2081/pyarrow-24.0.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:e56a1ffe9bf7b727432b89104cc0849c21582949dd7bdcb34f17b2001a351a76", size = 51954117, upload-time = "2026-04-21T10:50:29.14Z" },+ { url = "https://files.pythonhosted.org/packages/29/88/f4e9145da0417b3d2c12035a8492b35ff4a3dbc653e614fcfb51d9dedb38/pyarrow-24.0.0-cp314-cp314-win_amd64.whl", hash = "sha256:38be1808cdd068605b787e6ca9119b27eb275a0234e50212c3492331680c3b1e", size = 28001155, upload-time = "2026-04-21T10:51:22.337Z" },+ { url = "https://files.pythonhosted.org/packages/79/4f/46a49a63f43526da895b1a45bbb51d5baf8e4d77159f8528fc3e5490007f/pyarrow-24.0.0-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:418e48ce50a45a6a6c73c454677203a9c75c966cb1e92ca3370959185f197a05", size = 35250387, upload-time = "2026-04-21T10:50:35.552Z" },+ { url = "https://files.pythonhosted.org/packages/a0/da/d5e0cd5ef00796922404806d5f00325cdadc3441ce2c13fe7115f2df9a64/pyarrow-24.0.0-cp314-cp314t-macosx_12_0_x86_64.whl", hash = "sha256:2f16197705a230a78270cdd4ea8a1d57e86b2fdcbc34a1f6aebc72e65c986f9a", size = 36797102, upload-time = "2026-04-21T10:50:42.417Z" },+ { url = "https://files.pythonhosted.org/packages/34/c7/5904145b0a593a05236c882933d439b5720f0a145381179063722fbfc123/pyarrow-24.0.0-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:fb24ac194bfc5e86839d7dcd52092ee31e5fe6733fe11f5e3b06ef0812b20072", size = 45745118, upload-time = "2026-04-21T10:50:49.324Z" },+ { url = "https://files.pythonhosted.org/packages/13/d3/cca42fe166d1c6e4d5b80e530b7949104d10e17508a90ae202dac205ce2a/pyarrow-24.0.0-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:9700ebd9a51f5895ce75ff4ac4b3c47a7d4b42bc618be8e713e5d56bacf5f931", size = 48844765, upload-time = "2026-04-21T10:50:55.579Z" },+ { url = "https://files.pythonhosted.org/packages/b0/49/942c3b79878ba928324d1e17c274ed84581db8c0a749b24bcf4cbdf15bd3/pyarrow-24.0.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:d8ddd2768da81d3ee08cfea9b597f4abb4e8e1dc8ae7e204b608d23a0d3ab699", size = 49471890, upload-time = "2026-04-21T10:51:02.439Z" },+ { url = "https://files.pythonhosted.org/packages/76/97/ff71431000a75d84135a1ace5ca4ba11726a231a8007bbb320a4c54075d5/pyarrow-24.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:61a3d7eaa97a14768b542f3d284dc6400dd2470d9f080708b13cd46b6ae18136", size = 51932250, upload-time = "2026-04-21T10:51:10.576Z" },+ { url = "https://files.pythonhosted.org/packages/51/be/6f79d55816d5c22557cf27533543d5d70dfe692adfbee4b99f2760674f38/pyarrow-24.0.0-cp314-cp314t-win_amd64.whl", hash = "sha256:c91d00057f23b8d353039520dc3a6c09d8608164c692e9f59a175a42b2ae0c19", size = 28131282, upload-time = "2026-04-21T10:51:16.815Z" },][[package]]@@ -1577,7 +1608,7 @@ wheels = [[[package]]name = "pydantic"-version = "2.13.2"+version = "2.13.4"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "annotated-types" },@@ -1585,111 +1616,111 @@ dependencies = [{ name = "typing-extensions" },{ name = "typing-inspection" },]-sdist = { url = "https://files.pythonhosted.org/packages/09/e5/06d23afac9973109d1e3c8ad38e1547a12e860610e327c05ee686827dc37/pydantic-2.13.2.tar.gz", hash = "sha256:b418196607e61081c3226dcd4f0672f2a194828abb9109e9cfb84026564df2d1", size = 843836, upload-time = "2026-04-17T09:31:59.636Z" }+sdist = { url = "https://files.pythonhosted.org/packages/18/a5/b60d21ac674192f8ab0ba4e9fd860690f9b4a6e51ca5df118733b487d8d6/pydantic-2.13.4.tar.gz", hash = "sha256:c40756b57adaa8b1efeeced5c196f3f3b7c435f90e84ea7f443901bec8099ef6", size = 844775, upload-time = "2026-05-06T13:43:05.343Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/77/ca/b45c378e6e8d0b90577288b533e04e95b7afd61bb1d51b6c263176435489/pydantic-2.13.2-py3-none-any.whl", hash = "sha256:a525087f4c03d7e7456a3de89b64cd693d2229933bb1068b9af6befd5563694e", size = 471947, upload-time = "2026-04-17T09:31:57.541Z" },+ { url = "https://files.pythonhosted.org/packages/fd/7b/122376b1fd3c62c1ed9dc80c931ace4844b3c55407b6fb2d199377c9736f/pydantic-2.13.4-py3-none-any.whl", hash = "sha256:45a282cde31d808236fd7ea9d919b128653c8b38b393d1c4ab335c62924d9aba", size = 472262, upload-time = "2026-05-06T13:43:02.641Z" },][[package]]name = "pydantic-core"-version = "2.46.2"+version = "2.46.4"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "typing-extensions" },]-sdist = { url = "https://files.pythonhosted.org/packages/43/bb/4742f05b739b2478459bb16fa8470549518c802e06ddcf3f106c5081315e/pydantic_core-2.46.2.tar.gz", hash = "sha256:37bb079f9ee3f1a519392b73fda2a96379b31f2013c6b467fe693e7f2987f596", size = 471269, upload-time = "2026-04-17T09:10:07.017Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/89/91/089f517a725f29084364169437833ab0ae4da4d7a6ed9d4474db7f1412e6/pydantic_core-2.46.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d8060f42db3cd204871db0afd51fef54a13fa544c4dd48cdcae2e174ef40c8ba", size = 2106218, upload-time = "2026-04-17T09:10:48.023Z" },- { url = "https://files.pythonhosted.org/packages/a0/92/23858ed1b58f2a134e50c2fdd0e34ea72721ccb257e1e9346514e1ccb5b9/pydantic_core-2.46.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:73a9d2809bd8d4a7cda4d336dc996a565eb4feaaa39932f9d85a65fa18382f28", size = 1948087, upload-time = "2026-04-17T09:11:58.639Z" },- { url = "https://files.pythonhosted.org/packages/5d/ac/e2240fccb4794e965817593d5a46cf5ea22f2001b73fe360b7578925b7d8/pydantic_core-2.46.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3b0a2dee92dfaabcfb93629188c3e9cf74fdfc0f22e7c369cb444a98814a1e50", size = 1972931, upload-time = "2026-04-17T09:13:13.304Z" },- { url = "https://files.pythonhosted.org/packages/1a/da/3b11dab2aa15c5c8ed20a01eb7aa432a78b8e3a4713659f7e58490a020a5/pydantic_core-2.46.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3098446ba8cf774f61cb8d4008c1dba14a30426a15169cd95ac3392a461193b1", size = 2040454, upload-time = "2026-04-17T09:13:47.895Z" },- { url = "https://files.pythonhosted.org/packages/d7/39/c4cf5e1f1c6c34c53c0902039c95d81dc15cdd1f03634bd1a93f33e70a72/pydantic_core-2.46.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:57c584af6c375ea3f826d8131a94cb212b3d9926eaff67117e3711bbff3a83a5", size = 2221320, upload-time = "2026-04-17T09:13:08.568Z" },- { url = "https://files.pythonhosted.org/packages/c7/46/891035bc9e93538e754c3188424d24b5a69ec3ae5210fa01d483e99b3302/pydantic_core-2.46.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:547381cca999be88b4715a0ed7afa11f07fc7e53cb1883687b190d25a92c56cf", size = 2274559, upload-time = "2026-04-17T09:11:10.257Z" },- { url = "https://files.pythonhosted.org/packages/ab/d0/7af0b905b3148152c159c9caf203e7ecd9b90b76389f0862e6ab0cf1b2a3/pydantic_core-2.46.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:caeed15dcb1233a5a94bc6ff37ef5393cf5b33a45e4bdfb2d6042f3d24e1cb27", size = 2089239, upload-time = "2026-04-17T09:13:06.326Z" },- { url = "https://files.pythonhosted.org/packages/c5/bc/566afe02ba2de37712eece74ac7bfba322abd7916410bf90504f1b17ddad/pydantic_core-2.46.2-cp311-cp311-manylinux_2_31_riscv64.whl", hash = "sha256:c05f53362568c75476b5c96659377a5dfd982cfbe5a5c07de5106d08a04efc4f", size = 2116182, upload-time = "2026-04-17T09:11:33.738Z" },- { url = "https://files.pythonhosted.org/packages/4e/5b/3fcb3a229bbfa23b0e3c65014057af0f9d51ec7a2d9f7adb282f41ff5ac8/pydantic_core-2.46.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2643ac7eae296200dbd48762a1c852cf2cad5f5e3eba34e652053cebf03becf8", size = 2172346, upload-time = "2026-04-17T09:10:46.472Z" },- { url = "https://files.pythonhosted.org/packages/43/9a/baa9e3aa70ea7bbcb9db0f87162a371649ac80c03e43eb54af193390cf17/pydantic_core-2.46.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:dc4620a47c6fe6a39f89392c00833a82fc050ce90169798f78a25a8d4df03b6e", size = 2179540, upload-time = "2026-04-17T09:11:21.881Z" },- { url = "https://files.pythonhosted.org/packages/bd/46/912047a5427f949c909495704b3c8b9ead9d1c66f87e96606011beab1fcb/pydantic_core-2.46.2-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:78cb0d2453b50bf2035f85fd0d9cfabdb98c47f9c53ddb7c23873cd83da9560b", size = 2327423, upload-time = "2026-04-17T09:13:40.291Z" },- { url = "https://files.pythonhosted.org/packages/e9/bf/c5e661451dc9411c2ab88a244c1ba57644950c971486040dc200f77b69f4/pydantic_core-2.46.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f0c1cbb7d6112932cc188c6be007a5e2867005a069e47f42fe67bf5f122b0908", size = 2348652, upload-time = "2026-04-17T09:10:37.76Z" },- { url = "https://files.pythonhosted.org/packages/77/b3/3219e7c522af54b010cf7422dcb11cc6616a4414d1ccd628b0d3f61c6af6/pydantic_core-2.46.2-cp311-cp311-win32.whl", hash = "sha256:c1ce5b2366f85cfdbf7f0907755043707f86d09a5b1b1acebbb7bf1600d75c64", size = 1974410, upload-time = "2026-04-17T09:13:27.392Z" },- { url = "https://files.pythonhosted.org/packages/e5/29/e5cfac8a74c59873dfd47d3a1477c39ad9247639a7120d3e251a9ff12417/pydantic_core-2.46.2-cp311-cp311-win_amd64.whl", hash = "sha256:f1a6197eadff5bd0bb932f12bb038d403cb75db5b0b391e70e816a647745ddaf", size = 2071158, upload-time = "2026-04-17T09:09:57.69Z" },- { url = "https://files.pythonhosted.org/packages/6f/8b/b7b19b717cdb3675cb109de143f62d4dc62f5d4a0b9879b6f1ace62c6654/pydantic_core-2.46.2-cp311-cp311-win_arm64.whl", hash = "sha256:15e42885b283f87846ee79e161002c5c496ef747a73f6e47054f45a13d9035bc", size = 2043507, upload-time = "2026-04-17T09:09:51.828Z" },- { url = "https://files.pythonhosted.org/packages/97/ec/2fafa4c86f5d2a69372c7cddef30925fd0e370b1efaf556609c1a0196d8a/pydantic_core-2.46.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:ea1ad8c89da31512fe2d249cf0638fb666925bda341901541bc5f3311c6fcc9e", size = 2101729, upload-time = "2026-04-17T09:12:30.042Z" },- { url = "https://files.pythonhosted.org/packages/cf/55/be5386c2c4b49af346e8a26b748194ff25757bbb6cf544130854e997af7a/pydantic_core-2.46.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b308da17b92481e0587244631c5529e5d91d04cb2b08194825627b1eca28e21e", size = 1951546, upload-time = "2026-04-17T09:10:10.585Z" },- { url = "https://files.pythonhosted.org/packages/29/92/89e273a055ce440e6636c756379af35ad86da9d336a560049c3ba5e41c80/pydantic_core-2.46.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d333a50bdd814a917d8d6a7ee35ba2395d53ddaa882613bc24e54a9d8b129095", size = 1976178, upload-time = "2026-04-17T09:11:49.619Z" },- { url = "https://files.pythonhosted.org/packages/91/b3/e4664469cf70c0cb0f7b2f5719d64e5968bb6f38217042c2afa3d3c4ba17/pydantic_core-2.46.2-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:1d00b99590c5bd1fabbc5d28b170923e32c1b1071b1f1de1851a4d14d89eb192", size = 2051697, upload-time = "2026-04-17T09:12:04.917Z" },- { url = "https://files.pythonhosted.org/packages/98/58/dbf68213ee06ce51cdd6d8c95f97980e646858c45bd96bd2dfb40433be73/pydantic_core-2.46.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9f0e686960ffe9e65066395af856ac2d52c159043144433602c50c221d81c1ba", size = 2233160, upload-time = "2026-04-17T09:12:00.956Z" },- { url = "https://files.pythonhosted.org/packages/f5/d3/68092aa0ee6c60ff4de4740eb82db3d4ce338ec89b3cecb978c532472f12/pydantic_core-2.46.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2d1128da41c9cb474e0a4701f9c363ec645c9d1a02229904c76bf4e0a194fde2", size = 2298398, upload-time = "2026-04-17T09:10:29.694Z" },- { url = "https://files.pythonhosted.org/packages/e4/51/5d6155eb737db55b0ad354ca5f333ef009f75feb67df2d79a84bace45af6/pydantic_core-2.46.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:48649cf2d8c358d79586e9fb2f8235902fcaa2d969ec1c5301f2d1873b2f8321", size = 2094058, upload-time = "2026-04-17T09:12:10.995Z" },- { url = "https://files.pythonhosted.org/packages/6b/f3/eb4a986197d71319430464ff181226c95adc8f06d932189b158bae5a82f5/pydantic_core-2.46.2-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:b902f0fc7c2cf503865a05718b68147c6cd5d0a3867af38c527be574a9fa6e9d", size = 2130388, upload-time = "2026-04-17T09:12:41.159Z" },- { url = "https://files.pythonhosted.org/packages/56/00/44a9c4fe6d0f64b5786d6a8c649d6f0e34ba6c89b3663add1066e54451a2/pydantic_core-2.46.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e80011f808b03d1d87a8f1e76ae3da19a18eb706c823e17981dcf1fae43744fc", size = 2184245, upload-time = "2026-04-17T09:12:36.532Z" },- { url = "https://files.pythonhosted.org/packages/78/6b/685b98a834d5e3d1c34a1bde1627525559dd223b75075bc7490cdb24eb33/pydantic_core-2.46.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:b839d5c802e31348b949b6473f8190cddbf7d47475856d8ac995a373ee16ec59", size = 2186842, upload-time = "2026-04-17T09:13:04.054Z" },- { url = "https://files.pythonhosted.org/packages/22/64/caa2f5a2ac8b6113adaa410ccdf31ba7f54897a6e54cd0d726fc7e780c88/pydantic_core-2.46.2-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:c6b1064f3f9cf9072e1d59dd2936f9f3b668bec1c37039708c9222db703c0d5b", size = 2336066, upload-time = "2026-04-17T09:12:13.006Z" },- { url = "https://files.pythonhosted.org/packages/ee/f9/7d2701bf82945b5b9e7df8347be97ef6a36da2846bfe5b4afec299ffe27b/pydantic_core-2.46.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:37a68e6f2ac95578ce3c0564802404b27b24988649616e556c07e77111ed3f1d", size = 2363691, upload-time = "2026-04-17T09:13:42.972Z" },- { url = "https://files.pythonhosted.org/packages/3b/65/0dab11574101522941055109419db3cc09db871643dc3fc74e2413215e5b/pydantic_core-2.46.2-cp312-cp312-win32.whl", hash = "sha256:d9ffa75a7ef4b97d6e5e205fabd4304ef01fec09e6f1bdde04b9ad1b07d20289", size = 1958801, upload-time = "2026-04-17T09:11:31.981Z" },- { url = "https://files.pythonhosted.org/packages/13/2b/df84baa609c676f6450b8ecad44ea59146c805e3371b7b52443c0899f989/pydantic_core-2.46.2-cp312-cp312-win_amd64.whl", hash = "sha256:0551f2d2ddb68af5a00e26497f8025c538f73ef3cb698f8e5a487042cd2792a8", size = 2072634, upload-time = "2026-04-17T09:11:02.407Z" },- { url = "https://files.pythonhosted.org/packages/d1/4e/e1ce8029fc438086a946739bf9d596f70ff470aad4a8345555920618cabe/pydantic_core-2.46.2-cp312-cp312-win_arm64.whl", hash = "sha256:83aef30f106edcc21a6a4cc44b82d3169a1dbe255508db788e778f3c804d3583", size = 2026188, upload-time = "2026-04-17T09:13:11.083Z" },- { url = "https://files.pythonhosted.org/packages/07/2b/662e48254479a2d3450ba24b1e25061108b64339794232f503990c519144/pydantic_core-2.46.2-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:d26e9eea3715008a09a74585fe9becd0c67fbb145dc4df9756d597d7230a652c", size = 2101762, upload-time = "2026-04-17T09:10:13.87Z" },- { url = "https://files.pythonhosted.org/packages/73/ab/bafd7c7503757ccc8ec4d1911e106fe474c629443648c51a88f08b0fe91a/pydantic_core-2.46.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:48b36e3235140510dc7861f0cd58b714b1cdd3d48f75e10ce52e69866b746f10", size = 1951814, upload-time = "2026-04-17T09:12:25.934Z" },- { url = "https://files.pythonhosted.org/packages/92/cc/7549c2d57ba2e9a42caa5861a2d398dbe31c02c6aca783253ace59ce84f8/pydantic_core-2.46.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:36b1f99dc451f1a3981f236151465bcf995bbe712d0727c9f7b236fe228a8133", size = 1977329, upload-time = "2026-04-17T09:13:37.605Z" },- { url = "https://files.pythonhosted.org/packages/18/50/7ed4a8a0d478a4dca8f0134a5efa7193f03cc8520dd4c9509339fb2e5002/pydantic_core-2.46.2-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8641c8d535c2d95b45c2e19b646ecd23ebba35d461e0ae48a3498277006250ab", size = 2051832, upload-time = "2026-04-17T09:12:49.771Z" },- { url = "https://files.pythonhosted.org/packages/dc/16/bb35b193741c0298ddc5f5e4234269efdc0c65e2bcd198aa0de9b68845e4/pydantic_core-2.46.2-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:20fb194788a0a50993e87013e693494ba183a2af5b44e99cf060bbae10912b11", size = 2233127, upload-time = "2026-04-17T09:11:04.449Z" },- { url = "https://files.pythonhosted.org/packages/91/a5/98f4b637149185addea19e1785ea20c373cca31b202f589111d8209d9873/pydantic_core-2.46.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9262d11d0cd11ee3303a95156939402bed6cedfe5ed0e331b95a283a4da6eb8b", size = 2297418, upload-time = "2026-04-17T09:11:25.929Z" },- { url = "https://files.pythonhosted.org/packages/36/90/93a5d21990b152da7b7507b7fddb0b935f6a0984d57ac3ec45a6e17777a2/pydantic_core-2.46.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ac204542736aa295fa25f713b7fad6fc50b46ab7764d16087575c85f085174f3", size = 2093735, upload-time = "2026-04-17T09:12:06.908Z" },- { url = "https://files.pythonhosted.org/packages/14/22/b8b1ffdddf08b4e84380bcb67f41dbbf4c171377c1d36fc6290794bb2094/pydantic_core-2.46.2-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:9a7c43a0584742dface3ca0daf6f719d46c1ac2f87cf080050f9ae052c75e1b2", size = 2127570, upload-time = "2026-04-17T09:11:53.906Z" },- { url = "https://files.pythonhosted.org/packages/c6/26/e60d72b4e2d0ce1fa811044a974412ac1c567fe067d97b3e6b290530786e/pydantic_core-2.46.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fd05e1edb6a90ad446fa268ab09e59202766b837597b714b2492db11ee87fab9", size = 2183524, upload-time = "2026-04-17T09:11:30.092Z" },- { url = "https://files.pythonhosted.org/packages/35/32/36bec7584a1eefb17dec4dfa1c946d3fe4440f466c5705b8adfda69c9a9f/pydantic_core-2.46.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:91155b110788b5501abc7ea954f1d08606219e4e28e3c73a94124307c06efb80", size = 2185408, upload-time = "2026-04-17T09:10:57.228Z" },- { url = "https://files.pythonhosted.org/packages/fc/d6/1a5689d873620efd67d6b163db0c444c056adb0849b5bc33e2b9f09665a6/pydantic_core-2.46.2-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:e4e2c72a529fa03ff228be1d2b76944013f428220b764e03cc50ada67e17a42c", size = 2335171, upload-time = "2026-04-17T09:11:43.369Z" },- { url = "https://files.pythonhosted.org/packages/3e/8e/675104802abe8ef502b072050ee5f2e915251aa1a3af87e1015ce31ec42d/pydantic_core-2.46.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:56291ec1a11c3499890c99a8fd9053b47e60fe837a77ec72c0671b1b8b3dce24", size = 2362743, upload-time = "2026-04-17T09:10:18.333Z" },- { url = "https://files.pythonhosted.org/packages/8d/bc/86c5dde4fa6e24467680eef5047da3c1a19be0a527d0d8e14aa76b39307c/pydantic_core-2.46.2-cp313-cp313-win32.whl", hash = "sha256:b50f9c5f826ddca1246f055148df939f5f3f2d0d96db73de28e2233f22210d4c", size = 1958074, upload-time = "2026-04-17T09:12:38.622Z" },- { url = "https://files.pythonhosted.org/packages/2a/97/2537e8c1282b2c4eb062580c0d7a4339e10b072b803d1ee0b7f1f0a5c22c/pydantic_core-2.46.2-cp313-cp313-win_amd64.whl", hash = "sha256:251a57788823230ca8cbc99e6245d1a2ed6e180ec4864f251c94182c580c7f2e", size = 2071741, upload-time = "2026-04-17T09:13:32.405Z" },- { url = "https://files.pythonhosted.org/packages/da/aa/2ee75798706f9dbc4e76dbe59e41a396c5c311e3d6223b9cf6a5fa7780be/pydantic_core-2.46.2-cp313-cp313-win_arm64.whl", hash = "sha256:315d32d1a71494d6b4e1e14a9fa7a4329597b4c4340088ad7e1a9dafbeed92a9", size = 2025955, upload-time = "2026-04-17T09:10:15.567Z" },- { url = "https://files.pythonhosted.org/packages/d0/96/a50ccb6b539ae780f73cea74905468777680e30c6c3bdf714b9d4c116ea0/pydantic_core-2.46.2-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:4f59b45f3ef8650c0c736a57f59031d47ed9df4c0a64e83796849d7d14863a2d", size = 2097111, upload-time = "2026-04-17T09:10:49.617Z" },- { url = "https://files.pythonhosted.org/packages/34/5f/fdead7b3afa822ab6e5a18ee0ecffd54937de1877c01ed13a342e0fb3f07/pydantic_core-2.46.2-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:3a075a29ebef752784a91532a1a85be6b234ccffec0a9d7978a92696387c3da6", size = 1951904, upload-time = "2026-04-17T09:12:32.062Z" },- { url = "https://files.pythonhosted.org/packages/95/e0/1c5d547e550cdab1bec737492aa08865337af6fe7fc9b96f7f45f17d9519/pydantic_core-2.46.2-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0d12d786e30c04a9d307c5d7080bf720d9bac7f1668191d8e37633a9562749e2", size = 1978667, upload-time = "2026-04-17T09:11:35.589Z" },- { url = "https://files.pythonhosted.org/packages/0e/cb/665ce629e218c8228302cb94beff4f6531082a2c87d3ecc3d5e63a26f392/pydantic_core-2.46.2-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0d5e6d6343b0b5dcacb3503b5de90022968da8ed0ab9ab39d3eda71c20cbf84e", size = 2046721, upload-time = "2026-04-17T09:11:47.725Z" },- { url = "https://files.pythonhosted.org/packages/77/e9/6cb2cf60f54c1472bbdfce19d957553b43dbba79d1d7b2930a195c594785/pydantic_core-2.46.2-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:233eebac0999b6b9ba76eb56f3ec8fce13164aa16b6d2225a36a79e0f95b5973", size = 2228483, upload-time = "2026-04-17T09:12:08.837Z" },- { url = "https://files.pythonhosted.org/packages/0d/2a/93e018dd5571f781ebaeda8c0cf65398489d5bee9b1f484df0b6149b43b9/pydantic_core-2.46.2-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9cc0eee720dd2f14f3b7c349469402b99ad81a174ab49d3533974529e9d93992", size = 2294663, upload-time = "2026-04-17T09:12:52.053Z" },- { url = "https://files.pythonhosted.org/packages/5e/4f/49e57ca55c770c93d9bb046666a54949b42e3c9099a0c5fe94557873fe30/pydantic_core-2.46.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:83ee76bf2c9910513dbc19e7d82367131fa7508dedd6186a462393071cc11059", size = 2098742, upload-time = "2026-04-17T09:13:45.472Z" },- { url = "https://files.pythonhosted.org/packages/c6/b0/6e46b5cd3332af665f794b8cdeea206618a8630bd9e7bcc36864518fce81/pydantic_core-2.46.2-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:d61db38eb4ee5192f0c261b7f2d38e420b554df8912245e3546aee5c45e2fd78", size = 2125922, upload-time = "2026-04-17T09:12:54.304Z" },- { url = "https://files.pythonhosted.org/packages/06/d1/40850c81585be443a2abfdf7f795f8fae831baf8e2f9b2133c8246ac671c/pydantic_core-2.46.2-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:8f09a713d17bcd55da8ab02ebd9110c5246a49c44182af213b5212800af8bc83", size = 2183000, upload-time = "2026-04-17T09:10:59.027Z" },- { url = "https://files.pythonhosted.org/packages/04/af/8493d7dfa03ebb7866909e577c6aa65ea0de7377b86023cc51d0c8e11db3/pydantic_core-2.46.2-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:30cacc5fb696e64b8ef6fd31d9549d394dd7d52760db072eecb98e37e3af1677", size = 2180335, upload-time = "2026-04-17T09:12:57.01Z" },- { url = "https://files.pythonhosted.org/packages/72/5b/1f6a344c4ffdf284da41c6067b82d5ebcbd11ce1b515ae4b662d4adb6f61/pydantic_core-2.46.2-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:7ccfb105fcfe91a22bbb5563ad3dc124bc1aa75bfd2e53a780ab05f78cdf6108", size = 2330002, upload-time = "2026-04-17T09:12:02.958Z" },- { url = "https://files.pythonhosted.org/packages/25/ff/9a694126c12d6d2f48a0cafa6f8eef88ef0d8825600e18d03ff2e896c3b2/pydantic_core-2.46.2-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:13ffef637dc8370c249e5b26bd18e9a80a4fca3d809618c44e18ec834a7ca7a8", size = 2359920, upload-time = "2026-04-17T09:10:27.764Z" },- { url = "https://files.pythonhosted.org/packages/51/c8/3a35c763d68a9cb2675eb10ef242cf66c5d4701b28ae12e688d67d2c180e/pydantic_core-2.46.2-cp314-cp314-win32.whl", hash = "sha256:1b0ab6d756ca2704a938e6c31b53f290c2f9c10d3914235410302a149de1a83e", size = 1953701, upload-time = "2026-04-17T09:13:30.021Z" },- { url = "https://files.pythonhosted.org/packages/1a/6a/f2726a780365f7dfd89d62036f984f7acb99978c60c5e1fa7c0cb898ed11/pydantic_core-2.46.2-cp314-cp314-win_amd64.whl", hash = "sha256:99ebade8c9ada4df975372d8dd25883daa0e379a05f1cd0c99aa0c04368d01a6", size = 2071867, upload-time = "2026-04-17T09:10:39.205Z" },- { url = "https://files.pythonhosted.org/packages/e1/79/76baacb9feba3d7c399b245ca1a29c74ea0db04ea693811374827eec2290/pydantic_core-2.46.2-cp314-cp314-win_arm64.whl", hash = "sha256:de87422197cf7f83db91d89c86a21660d749b3cd76cd8a45d115b8e675670f02", size = 2017252, upload-time = "2026-04-17T09:10:26.175Z" },- { url = "https://files.pythonhosted.org/packages/f1/3b/77c26938f817668d9ad9bab1a905cb23f11d9a3d4bf724d429b3e55a8eaf/pydantic_core-2.46.2-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:236f22b4a206b5b61db955396b7cf9e2e1ff77f372efe9570128ccfcd6a525eb", size = 2094545, upload-time = "2026-04-17T09:12:19.339Z" },- { url = "https://files.pythonhosted.org/packages/fe/de/42c13f590e3c260966aa49bcdb1674774f975467c49abd51191e502bea28/pydantic_core-2.46.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c2012f64d2cd7cca50f49f22445aa5a88691ac2b4498ee0a9a977f8ca4f7289f", size = 1933953, upload-time = "2026-04-17T09:09:55.889Z" },- { url = "https://files.pythonhosted.org/packages/4e/84/ebe3ebb3e2d8db656937cfa6f97f544cb7132f2307a4a7dfdcd0ea102a12/pydantic_core-2.46.2-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d07d6c63106d3a9c9a333e2636f9c82c703b1a9e3b079299e58747964e4fdb72", size = 1974435, upload-time = "2026-04-17T09:10:12.371Z" },- { url = "https://files.pythonhosted.org/packages/b9/15/0bf51ca6709477cd4ef86148b6d7844f3308f029eac361dd0383f1e17b1a/pydantic_core-2.46.2-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c326a2b4b85e959d9a1fc3a11f32f84611b6ec07c053e1828a860edf8d068208", size = 2031113, upload-time = "2026-04-17T09:10:00.752Z" },- { url = "https://files.pythonhosted.org/packages/02/ae/b7b5af9b79db036d9e61a44c481c17a213dc8fc4b8b71fe6875a72fc778b/pydantic_core-2.46.2-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ac8a65e798f2462552c00d2e013d532c94d646729dda98458beaf51f9ec7b120", size = 2236325, upload-time = "2026-04-17T09:10:33.227Z" },- { url = "https://files.pythonhosted.org/packages/a6/ae/ecef7477b5a03d4a499708f7e75d2836452ebb70b776c2d64612b334f57a/pydantic_core-2.46.2-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5a3c2bc1cc8164bedbc160b7bb1e8cc1e8b9c27f69ae4f9ae2b976cdae02b2dd", size = 2278135, upload-time = "2026-04-17T09:10:23.287Z" },- { url = "https://files.pythonhosted.org/packages/db/e4/2f9d82faa47af6c39fc3f120145fd915971e1e0cb6b55b494fad9fdf8275/pydantic_core-2.46.2-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e69aa5e10b7e8b1bb4a6888650fd12fcbf11d396ca11d4a44de1450875702830", size = 2109071, upload-time = "2026-04-17T09:11:06.149Z" },- { url = "https://files.pythonhosted.org/packages/f1/9c/677cf10873fbd0b116575ab7b97c90482b21564f8a8040beb18edef7a577/pydantic_core-2.46.2-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:4e6df5c3301e65fb42bc5338bf9a1027a02b0a31dc7f54c33775229af474daf0", size = 2106028, upload-time = "2026-04-17T09:10:51.525Z" },- { url = "https://files.pythonhosted.org/packages/d6/53/6a06183544daba51c059123a2064a99039df25f115a06bdb26f2ea177038/pydantic_core-2.46.2-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2c2f6e32548ac8d559b47944effcf8ae4d81c161f6b6c885edc53bc08b8f192d", size = 2164816, upload-time = "2026-04-17T09:11:56.187Z" },- { url = "https://files.pythonhosted.org/packages/57/6f/10fcdd9e3eca66fc828eef0f6f5850f2dd3bca2c59e6e041fb8bc3da39be/pydantic_core-2.46.2-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:b089a81c58e6ea0485562bbbbbca4f65c0549521606d5ef27fba217aac9b665a", size = 2166130, upload-time = "2026-04-17T09:10:03.804Z" },- { url = "https://files.pythonhosted.org/packages/29/83/92d3fd0e0156cad2e3cb5c26de73794af78ac9fa0c22ab666e566dd67061/pydantic_core-2.46.2-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:7f700a6d6f64112ae9193709b84303bbab84424ad4b47d0253301aabce9dfc70", size = 2316605, upload-time = "2026-04-17T09:12:45.249Z" },- { url = "https://files.pythonhosted.org/packages/97/f1/facffdb970981068219582e499b8d0871ed163ffcc6b347de5c412669e4c/pydantic_core-2.46.2-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:67db6814beaa5fefe91101ec7eb9efda613795767be96f7cf58b1ca8c9ca9972", size = 2358385, upload-time = "2026-04-17T09:09:54.657Z" },- { url = "https://files.pythonhosted.org/packages/8b/a1/b8160b2f22b2199467bc68581a4ed380643c16b348a27d6165c6c242d694/pydantic_core-2.46.2-cp314-cp314t-win32.whl", hash = "sha256:32fbc7447be8e3be99bf7869f7066308f16be55b61f9882c2cefc7931f5c7664", size = 1942373, upload-time = "2026-04-17T09:12:59.594Z" },- { url = "https://files.pythonhosted.org/packages/0d/90/db89acabe5b150e11d1b59fe3d947dda2ef6abbfef5c82f056ff63802f5d/pydantic_core-2.46.2-cp314-cp314t-win_amd64.whl", hash = "sha256:b317a2b97019c0b95ce99f4f901ae383f40132da6706cdf1731066a73394c25c", size = 2052078, upload-time = "2026-04-17T09:10:19.96Z" },- { url = "https://files.pythonhosted.org/packages/97/32/e19b83ceb07a3f1bb21798407790bbc9a31740158fd132b94139cb84e16c/pydantic_core-2.46.2-cp314-cp314t-win_arm64.whl", hash = "sha256:7dcb9d40930dfad7ab6b20bcc6ca9d2b030b0f347a0cd9909b54bd53ead521b1", size = 2016941, upload-time = "2026-04-17T09:12:34.447Z" },- { url = "https://files.pythonhosted.org/packages/25/ec/e91aa08df1c33d5e3c2b60c07a1eca9f21809728a824c7b467bb3bda68b5/pydantic_core-2.46.2-graalpy311-graalpy242_311_native-macosx_10_12_x86_64.whl", hash = "sha256:7c5a5b3dbb9e8918e223be6580da5ffcf861c0505bbc196ebed7176ce05b7b4e", size = 2105046, upload-time = "2026-04-17T09:10:55.614Z" },- { url = "https://files.pythonhosted.org/packages/f0/73/27112400a0452e375290e7c40aef5cc9844ac0920fb1029238cfc68121fa/pydantic_core-2.46.2-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl", hash = "sha256:bc1e8ce33d5a337f2ba862e0719b8201cd54aaed967406c748e009191d47efdd", size = 1940029, upload-time = "2026-04-17T09:12:21.5Z" },- { url = "https://files.pythonhosted.org/packages/b1/44/3d39f782bc82ddd0b2d82bde83b408aa40a332cdf6f3018acb34e3d4dcfc/pydantic_core-2.46.2-graalpy311-graalpy242_311_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b737c0b280f41143266445de2689c0e49c79307e51c44ce3a77fef2bedad4994", size = 1987772, upload-time = "2026-04-17T09:10:02.357Z" },- { url = "https://files.pythonhosted.org/packages/c4/1a/0242e5b7b6cf51dbccc065029f0420107b6bf7e191fcb918f5cb71218acf/pydantic_core-2.46.2-graalpy311-graalpy242_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1b877d597afb82b4898e35354bba55de6f7f048421ae0edadbb9886ec137b532", size = 2138468, upload-time = "2026-04-17T09:11:51.546Z" },- { url = "https://files.pythonhosted.org/packages/f3/d2/66c146f421178641bda880b0267c0d57dd84f5fec9ecc8e46be17b480742/pydantic_core-2.46.2-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:e9fcabd1857492b5bf16f90258babde50f618f55d046b1309972da2396321ff9", size = 2091621, upload-time = "2026-04-17T09:12:47.501Z" },- { url = "https://files.pythonhosted.org/packages/ee/b2/c28419aa9fc8055f4ac8e801d1d11c6357351bfa4321ed9bafab3eb98087/pydantic_core-2.46.2-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:fb3ec2c7f54c07b30d89983ce78dc32c37dd06a972448b8716d609493802d628", size = 1937059, upload-time = "2026-04-17T09:10:53.554Z" },- { url = "https://files.pythonhosted.org/packages/30/ce/cd0824a2db213dc17113291b7a09b9b0ccd9fbf97daa4b81548703341baf/pydantic_core-2.46.2-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:130a6c837d819ef33e8c2bf702ed2c3429237ea69807f1140943d6f4bdaf52fa", size = 1997278, upload-time = "2026-04-17T09:12:23.784Z" },- { url = "https://files.pythonhosted.org/packages/c9/69/47283fe3c0c967d3e9e9cd6c42b70907610c8a6f8d6e8381f1bb55f8006c/pydantic_core-2.46.2-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c2e25417cec5cd9bddb151e33cb08c50160f317479ecc02b22a95ec18f8fe004", size = 2147096, upload-time = "2026-04-17T09:12:43.124Z" },- { url = "https://files.pythonhosted.org/packages/16/d5/dec7c127fa722ff56e1ccf1e960ae1318a9f66742135e97bf9771447216f/pydantic_core-2.46.2-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:c3ad79ed32004d9de91cacd4b5faaff44d56051392fe1d5526feda596f01af25", size = 2107613, upload-time = "2026-04-17T09:10:36.269Z" },- { url = "https://files.pythonhosted.org/packages/bc/35/975c109b337260a71c93198baf663982b6b39fe3e584e279548a0969e5d4/pydantic_core-2.46.2-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:d157c48d28eebe5d46906de06a6a2f2c9e00b67d3e42de1f1b9c2d42b810f77c", size = 1947099, upload-time = "2026-04-17T09:12:15.304Z" },- { url = "https://files.pythonhosted.org/packages/4e/11/52a971a0f9218631690274be533f05e5ddde5547f0823bb3e9dfd1be49f6/pydantic_core-2.46.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b42c6471288dedc979ac8400d9c9770f03967dd187db1f8d3405d4d182cc714", size = 2133866, upload-time = "2026-04-17T09:12:27.994Z" },- { url = "https://files.pythonhosted.org/packages/fe/7a/33d94d0698602b2d1712e78c703a33952eb2ca69e02e8e4b208e7f6602b5/pydantic_core-2.46.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4f27bc4801358dc070d6697b41237fce9923d8e69a1ce1e95606ac36c1552dc1", size = 2161721, upload-time = "2026-04-17T09:11:16.111Z" },- { url = "https://files.pythonhosted.org/packages/b0/cb/0df7ee0a148e9ce0968a80787967ddca9f6b3f8a49152a881b88da262701/pydantic_core-2.46.2-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:e094a8f85db41aa7f6a45c5dac2950afc9862e66832934231962252b5d284eed", size = 2180175, upload-time = "2026-04-17T09:11:41.577Z" },- { url = "https://files.pythonhosted.org/packages/8e/a8/258a32878140347532be4e44c6f3b1ace3b52b9c9ca7548a65ce18adf4b4/pydantic_core-2.46.2-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:807eeda5551f6884d3b4421578be37be50ddb7a58832348e99617a6714a73748", size = 2319882, upload-time = "2026-04-17T09:10:21.872Z" },- { url = "https://files.pythonhosted.org/packages/13/b9/5071c298a0f91314a5402b8c56e0efbcebe77085327d0b4df7dc9cb0b674/pydantic_core-2.46.2-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:fcaa1c3c846a7f6686b38fe493d1b2e8007380e293bfef6a9354563c026cbf36", size = 2348065, upload-time = "2026-04-17T09:11:08.263Z" },- { url = "https://files.pythonhosted.org/packages/75/f3/0a7087e5f861d66ca64ce927230b397cc264c87b712156e6a93b26a459c8/pydantic_core-2.46.2-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:154dbfdfb11b8cbd8ff4d00d0b81e3d19f4cb4bedd5aa9f091060ba071474c6a", size = 2192159, upload-time = "2026-04-17T09:11:20.123Z" },+sdist = { url = "https://files.pythonhosted.org/packages/9d/56/921726b776ace8d8f5db44c4ef961006580d91dc52b803c489fafd1aa249/pydantic_core-2.46.4.tar.gz", hash = "sha256:62f875393d7f270851f20523dd2e29f082bcc82292d66db2b64ea71f64b6e1c1", size = 471464, upload-time = "2026-05-06T13:37:06.98Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/5c/fa/6d7708d2cfc1a832acb6aeb0cd16e801902df8a0f583bb3b4b527fde022e/pydantic_core-2.46.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:0e96592440881c74a213e5ad528e2b24d3d4f940de2766bed9010ab1d9e51594", size = 2111872, upload-time = "2026-05-06T13:40:27.596Z" },+ { url = "https://files.pythonhosted.org/packages/ae/6f/aa064a3e74b5745afbdf250594f38e7ead05e2d651bcb35994b9417a0d4d/pydantic_core-2.46.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e0d65b8c354be7fb5f720c3caa8bc940bc2d20ce749c8e06135f07f8ed95dd7c", size = 1948255, upload-time = "2026-05-06T13:39:12.574Z" },+ { url = "https://files.pythonhosted.org/packages/43/3a/41114a9f7569b84b4d84e7a018c57c56347dac30c0d4a872946ec4e36c46/pydantic_core-2.46.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7bfb192b3f4b9e8a89b6277b6ce787564f62cfd272055f6e685726b111dc7826", size = 1972827, upload-time = "2026-05-06T13:38:19.841Z" },+ { url = "https://files.pythonhosted.org/packages/ef/25/1ab42e8048fe551934d9884e8d64daa7e990ad386f310a15981aeb6a5b08/pydantic_core-2.46.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9037063db01f09b09e237c282b6792bd4da634b5402c4e7f0c61effed7701a04", size = 2041051, upload-time = "2026-05-06T13:38:10.447Z" },+ { url = "https://files.pythonhosted.org/packages/94/c2/1a934597ddf08da410385b3b7aae91956a5a76c635effef456074fad7e88/pydantic_core-2.46.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fc010ab034c8c7452522748bf937df58020d256ccae0874463d1f4d01758af8e", size = 2221314, upload-time = "2026-05-06T13:40:13.089Z" },+ { url = "https://files.pythonhosted.org/packages/02/6d/9e8ad178c9c4df27ad3c8f25d1fe2a7ab0d2ba0559fad4aee5d3d1f16771/pydantic_core-2.46.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8c5dac79fa1614d1e06ca695109c6105923bd9c7d1d6c918d4e637b7e6b32fd3", size = 2285146, upload-time = "2026-05-06T13:38:59.224Z" },+ { url = "https://files.pythonhosted.org/packages/80/50/540cd3aeefc041beb111125c4bff779831a2111fc6b15a9138cda277d32c/pydantic_core-2.46.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f9fa868638bf362d3d138ea55829cefb3d5f4b0d7f142234382a15e2485dbec4", size = 2089685, upload-time = "2026-05-06T13:38:17.762Z" },+ { url = "https://files.pythonhosted.org/packages/6b/a4/b440ad35f05f6a38f89fa0f149accb3f0e02be94ca5e15f3c449a61b4bc9/pydantic_core-2.46.4-cp311-cp311-manylinux_2_31_riscv64.whl", hash = "sha256:17299feefe090f2caa5b8e37222bb5f663e4935a8bfa6931d4102e5df1a9f398", size = 2115420, upload-time = "2026-05-06T13:37:58.195Z" },+ { url = "https://files.pythonhosted.org/packages/99/61/de4f55db8dfd57bfdfa9a12ec90fe1b57c4f41062f7ca86f08586b3e0ac0/pydantic_core-2.46.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4c63ebc82684aa89d9a3bcbd13d515b3be44250dc68dd3bd81526c1cb31286c3", size = 2165122, upload-time = "2026-05-06T13:37:01.167Z" },+ { url = "https://files.pythonhosted.org/packages/f7/52/7c529d7bdb2d1068bd52f51fe32572c8301f9a4febf1948f10639f1436f5/pydantic_core-2.46.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:aaa2a54443eff1950ba5ddc6b6ccda0d9c84a364276a62f969bdf2a390650848", size = 2182573, upload-time = "2026-05-06T13:38:45.04Z" },+ { url = "https://files.pythonhosted.org/packages/37/b3/7c40325848ba78247f2812dcf9c7274e38cd801820ca6dd9fe63bcfb0eb4/pydantic_core-2.46.4-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:18e5ceec2ab67e6d5f1a9085e5a24c9c4e2ac4545730bfe668680bca05e555f3", size = 2317139, upload-time = "2026-05-06T13:37:15.539Z" },+ { url = "https://files.pythonhosted.org/packages/d9/37/f913f81a657c865b75da6c0dbed79876073c2a43b5bd9edbe8da785e4d49/pydantic_core-2.46.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:a0f62d0a58f4e7da165457e995725421e0064f2255d8eccebc49f41bbc23b109", size = 2360433, upload-time = "2026-05-06T13:37:30.099Z" },+ { url = "https://files.pythonhosted.org/packages/c4/67/6acaa1be2567f9256b056d8477158cac7240813956ce86e49deae8e173b4/pydantic_core-2.46.4-cp311-cp311-win32.whl", hash = "sha256:041bde0a48fd37cf71cab1c9d56d3e8625a3793fef1f7dd232b3ff37e978ecda", size = 1985513, upload-time = "2026-05-06T13:38:15.669Z" },+ { url = "https://files.pythonhosted.org/packages/aa/e6/c505f83dfeda9a2e5c995cfd872949e4d05e12f7feb3dca72f633daefa94/pydantic_core-2.46.4-cp311-cp311-win_amd64.whl", hash = "sha256:6f2eeda33a839975441c86a4119e1383c50b47faf0cbb5176985565c6bb02c33", size = 2071114, upload-time = "2026-05-06T13:40:35.416Z" },+ { url = "https://files.pythonhosted.org/packages/0f/da/7a263a96d965d9d0df5e8de8a475f33495451117035b09acb110288c381f/pydantic_core-2.46.4-cp311-cp311-win_arm64.whl", hash = "sha256:14f4c5d6db102bd796a627bbb3a17b4cf4574b9ae861d8b7c9a9661c6dd3362d", size = 2044298, upload-time = "2026-05-06T13:38:29.754Z" },+ { url = "https://files.pythonhosted.org/packages/ce/8c/af022f0af448d7747c5154288d46b5f2bc5f17366eaa0e23e9aa04d59f3b/pydantic_core-2.46.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:3245406455a5d98187ec35530fd772b1d799b26667980872c8d4614991e2c4a2", size = 2106158, upload-time = "2026-05-06T13:38:57.215Z" },+ { url = "https://files.pythonhosted.org/packages/19/95/6195171e385007300f0f5574592e467c568becce2d937a0b6804f218bc49/pydantic_core-2.46.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:962ccbab7b642487b1d8b7df90ef677e03134cf1fd8880bf698649b22a69371f", size = 1951724, upload-time = "2026-05-06T13:37:02.697Z" },+ { url = "https://files.pythonhosted.org/packages/8e/bc/f47d1ff9cbb1620e1b5b697eef06010035735f07820180e74178226b27b3/pydantic_core-2.46.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8233f2947cf85404441fd7e0085f53b10c93e0ee78611099b5c7237e36aacbf7", size = 1975742, upload-time = "2026-05-06T13:37:09.448Z" },+ { url = "https://files.pythonhosted.org/packages/5b/11/9b9a5b0306345664a2da6410877af6e8082481b5884b3ddd78d47c6013ce/pydantic_core-2.46.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3a233125ac121aa3ffba9a2b59edfc4a985a76092dc8279586ab4b71390875e7", size = 2052418, upload-time = "2026-05-06T13:37:38.234Z" },+ { url = "https://files.pythonhosted.org/packages/f1/b7/a65fec226f5d78fc39f4a13c4cc0c768c22b113438f60c14adc9d2865038/pydantic_core-2.46.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5b712b53160b79a5850310b912a5ef8e57e56947c8ad690c227f5c9d7e561712", size = 2232274, upload-time = "2026-05-06T13:38:27.753Z" },+ { url = "https://files.pythonhosted.org/packages/68/f0/92039db98b907ef49269a8271f67db9cb78ae2fc68062ef7e4e77adb5f61/pydantic_core-2.46.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9401557acd873c3a7f3eb9383edef8ac4968f9510e340f4808d427e75667e7b4", size = 2309940, upload-time = "2026-05-06T13:38:05.353Z" },+ { url = "https://files.pythonhosted.org/packages/5f/97/2aab507d3d00ca626e8e57c1eac6a79e4e5fbcc63eb99733ff55d1717f65/pydantic_core-2.46.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:926c9541b14b12b1681dca8a0b75feb510b06c6341b70a8e500c2fdcff837cce", size = 2094516, upload-time = "2026-05-06T13:39:10.577Z" },+ { url = "https://files.pythonhosted.org/packages/22/37/a8aca44d40d737dde2bc05b3c6c07dff0de07ce6f82e9f3167aeaf4d5dea/pydantic_core-2.46.4-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:56cb4851bcaf3d117eddcef4fe66afd750a50274b0da8e22be256d10e5611987", size = 2136854, upload-time = "2026-05-06T13:40:22.59Z" },+ { url = "https://files.pythonhosted.org/packages/24/99/fcef1b79238c06a8cbec70819ac722ba76e02bc8ada9b0fd66eba40da01b/pydantic_core-2.46.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c68fcd102d71ea85c5b2dfac3f4f8476eff42a9e078fd5faefff6d145063536b", size = 2180306, upload-time = "2026-05-06T13:40:10.666Z" },+ { url = "https://files.pythonhosted.org/packages/ae/6c/fc44000918855b42779d007ae63b0532794739027b2f417321cddbc44f6a/pydantic_core-2.46.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:b2f69dec1725e79a012d920df1707de5caf7ed5e08f3be4435e25803efc47458", size = 2190044, upload-time = "2026-05-06T13:40:43.231Z" },+ { url = "https://files.pythonhosted.org/packages/6b/65/d9cadc9f1920d7a127ad2edba16c1db7916e59719285cd6c94600b0080ba/pydantic_core-2.46.4-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:8d0820e8192167f80d88d64038e609c31452eeca865b4e1d9950a27a4609b00b", size = 2329133, upload-time = "2026-05-06T13:39:57.365Z" },+ { url = "https://files.pythonhosted.org/packages/d0/cf/c873d91679f3a30bcf5e7ac280ce5573483e72295307685120d0d5ad3416/pydantic_core-2.46.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:fbdb89b3e1c94a30cc5edfce477c6e6a5dc4d8f84665b455c27582f211a1c72c", size = 2374464, upload-time = "2026-05-06T13:38:06.976Z" },+ { url = "https://files.pythonhosted.org/packages/47/bd/6f2fc8188f31bf10590f1e98e7b306336161fac930a8c514cd7bd828c7dc/pydantic_core-2.46.4-cp312-cp312-win32.whl", hash = "sha256:9aa768456404a8bf48a4406685ac2bec8e72b62c69313734fa3b73cf33b3a894", size = 1974823, upload-time = "2026-05-06T13:40:47.985Z" },+ { url = "https://files.pythonhosted.org/packages/40/8c/985c1d41ea1107c2534abd9870e4ed5c8e7669b5c308297835c001e7a1c4/pydantic_core-2.46.4-cp312-cp312-win_amd64.whl", hash = "sha256:e9c26f834c65f5752f3f06cb08cb86a913ceb7274d0db6e267808a708b46bc89", size = 2072919, upload-time = "2026-05-06T13:39:21.153Z" },+ { url = "https://files.pythonhosted.org/packages/c4/ba/f463d006e0c47373ca7ec5e1a261c59dc01ef4d62b2657af925fb0deee3a/pydantic_core-2.46.4-cp312-cp312-win_arm64.whl", hash = "sha256:4fc73cb559bdb54b1134a706a2802a4cddd27a0633f5abb7e53056268751ac6a", size = 2027604, upload-time = "2026-05-06T13:39:03.753Z" },+ { url = "https://files.pythonhosted.org/packages/51/a2/5d30b469c5267a17b39dec53208222f76a8d351dfac4af661888c5aee77d/pydantic_core-2.46.4-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:5d5902252db0d3cedf8d4a1bc68f70eeb430f7e4c7104c8c476753519b423008", size = 2106306, upload-time = "2026-05-06T13:37:48.029Z" },+ { url = "https://files.pythonhosted.org/packages/c1/81/4fa520eaffa8bd7d1525e644cd6d39e7d60b1592bc5b516693c7340b50f1/pydantic_core-2.46.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:c94f0688e7b8d0a67abf40e57a7eaaecd17cc9586706a31b76c031f63df052b4", size = 1951906, upload-time = "2026-05-06T13:37:17.012Z" },+ { url = "https://files.pythonhosted.org/packages/03/d5/fd02da45b659668b05923b17ba3a0100a0a3d5541e3bd8fcc4ecb711309e/pydantic_core-2.46.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f027324c56cd5406ca49c124b0db10e56c69064fec039acc571c29020cc87c76", size = 1976802, upload-time = "2026-05-06T13:37:35.113Z" },+ { url = "https://files.pythonhosted.org/packages/21/f2/95727e1368be3d3ed485eaab7adbd7dda408f33f7a36e8b48e0144002b91/pydantic_core-2.46.4-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e739fee756ba1010f8bcccb534252e85a35fe45ae92c295a06059ce58b74ccd3", size = 2052446, upload-time = "2026-05-06T13:37:12.313Z" },+ { url = "https://files.pythonhosted.org/packages/9c/86/5d99feea3f77c7234b8718075b23db11532773c1a0dbd9b9490215dc2eeb/pydantic_core-2.46.4-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9d56801be94b86a9da183e5f3766e6310752b99ff647e38b09a9500d88e46e76", size = 2232757, upload-time = "2026-05-06T13:39:01.149Z" },+ { url = "https://files.pythonhosted.org/packages/d2/3a/508ac615935ef7588cf6d9e9b91309fdc2da751af865e02a9098de88258c/pydantic_core-2.46.4-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2412e734dcb48da14d4e4006b82b46b74f2518b8a26ee7e58c6844a6cd6d03c4", size = 2309275, upload-time = "2026-05-06T13:37:41.406Z" },+ { url = "https://files.pythonhosted.org/packages/07/f8/41db9de19d7987d6b04715a02b3b40aea467000275d9d758ffaa31af7d50/pydantic_core-2.46.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9551187363ffc0de2a00b2e47c25aeaeb1020b69b668762966df15fc5659dd5a", size = 2094467, upload-time = "2026-05-06T13:39:18.847Z" },+ { url = "https://files.pythonhosted.org/packages/2c/e2/f35033184cb11d0052daf4416e8e10a502ea2ac006fc4f459aee872727d1/pydantic_core-2.46.4-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:0186750b482eefa11d7f435892b09c5c606193ef3375bcf94aa00ae6bfb66262", size = 2134417, upload-time = "2026-05-06T13:40:17.944Z" },+ { url = "https://files.pythonhosted.org/packages/7e/7b/6ceeb1cc90e193862f444ebe373d8fdf613f0a82572dde03fb10734c6c71/pydantic_core-2.46.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:5855698a4856556d86e8e6cd8434bc3ac0314ee8e12089ae0e143f64c6256e4e", size = 2179782, upload-time = "2026-05-06T13:40:32.618Z" },+ { url = "https://files.pythonhosted.org/packages/5a/f2/c8d7773ede6af08036423a00ae0ceffce266c3c52a096c435d68c896083f/pydantic_core-2.46.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:cbaf13819775b7f769bf4a1f066cb6df7a28d4480081a589828ef190226881cd", size = 2188782, upload-time = "2026-05-06T13:36:51.018Z" },+ { url = "https://files.pythonhosted.org/packages/59/31/0c864784e31f09f05cdd87606f08923b9c9e7f6e51dd27f20f62f975ce9f/pydantic_core-2.46.4-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:633147d34cf4550417f12e2b1a0383973bdf5cdfde212cb09e9a581cf10820be", size = 2328334, upload-time = "2026-05-06T13:40:37.764Z" },+ { url = "https://files.pythonhosted.org/packages/c2/eb/4f6c8a41efa30baa755590f4141abf3a8c370fab610915733e74134a7270/pydantic_core-2.46.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:82cf5301172168103724d49a1444d3378cb20cdee30b116a1bd6031236298a5d", size = 2372986, upload-time = "2026-05-06T13:39:34.152Z" },+ { url = "https://files.pythonhosted.org/packages/5b/24/b375a480d53113860c299764bfe9f349a3dc9108b3adc0d7f0d786492ebf/pydantic_core-2.46.4-cp313-cp313-win32.whl", hash = "sha256:9fa8ae11da9e2b3126c6426f147e0fba88d96d65921799bb30c6abd1cb2c97fb", size = 1973693, upload-time = "2026-05-06T13:37:55.072Z" },+ { url = "https://files.pythonhosted.org/packages/7e/e8/cff247591966f2d22ec8c003cd7587e27b7ba7b81ab2fb888e3ab75dc285/pydantic_core-2.46.4-cp313-cp313-win_amd64.whl", hash = "sha256:6b3ace8194b0e5204818c92802dcdca7fc6d88aabbb799d7c795540d9cd6d292", size = 2071819, upload-time = "2026-05-06T13:38:49.139Z" },+ { url = "https://files.pythonhosted.org/packages/c6/1a/f4aee670d5670e9e148e0c82c7db98d780be566c6e6a97ee8035528ca0b3/pydantic_core-2.46.4-cp313-cp313-win_arm64.whl", hash = "sha256:184c081504d17f1c1066e430e117142b2c77d9448a97f7b65c6ac9fd9aee238d", size = 2027411, upload-time = "2026-05-06T13:40:45.796Z" },+ { url = "https://files.pythonhosted.org/packages/8d/74/228a26ddad29c6672b805d9fd78e8d251cd04004fa7eed0e622096cd0250/pydantic_core-2.46.4-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:428e04521a40150c85216fc8b85e8d39fece235a9cf5e383761238c7fa9b96fb", size = 2102079, upload-time = "2026-05-06T13:38:41.019Z" },+ { url = "https://files.pythonhosted.org/packages/ad/1f/8970b150a4b4365623ae00fc88603491f763c627311ae8031e3111356d6e/pydantic_core-2.46.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:23ace664830ee0bfe014a0c7bc248b1f7f25ed7ad103852c317624a1083af462", size = 1952179, upload-time = "2026-05-06T13:36:59.812Z" },+ { url = "https://files.pythonhosted.org/packages/95/30/5211a831ae054928054b2f79731661087a2bc5c01e825c672b3a4a8f1b3e/pydantic_core-2.46.4-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ce5c1d2a8b27468f433ca974829c44060b8097eedc39933e3c206a90ee49c4a9", size = 1978926, upload-time = "2026-05-06T13:37:39.933Z" },+ { url = "https://files.pythonhosted.org/packages/57/e9/689668733b1eb67adeef047db3c2e8788fcf65a7fd9c9e2b46b7744fe245/pydantic_core-2.46.4-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:7283d57845ecf5a163403eb0702dfc220cc4fbdd18919cb5ccea4f95ee1cdab4", size = 2046785, upload-time = "2026-05-06T13:38:01.995Z" },+ { url = "https://files.pythonhosted.org/packages/60/d9/6715260422ff50a2109878fd24d948a6c3446bb2664f34ee78cd972b3acd/pydantic_core-2.46.4-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8daafc69c93ee8a0204506a3b6b30f586ef54028f52aeeeb5c4cfc5184fd5914", size = 2228733, upload-time = "2026-05-06T13:40:50.371Z" },+ { url = "https://files.pythonhosted.org/packages/18/ae/fdb2f64316afca925640f8e70bb1a564b0ec2721c1389e25b8eb4bf9a299/pydantic_core-2.46.4-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd2213145bcc2ba85884d0ac63d222fece9209678f77b9b4d76f054c561adb28", size = 2307534, upload-time = "2026-05-06T13:37:21.531Z" },+ { url = "https://files.pythonhosted.org/packages/89/1d/8eff589b45bb8190a9d12c49cfad0f176a5cbd1534908a6b5125e2886239/pydantic_core-2.46.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a5f930472650a82629163023e630d160863fce524c616f4e5186e5de9d9a49b", size = 2099732, upload-time = "2026-05-06T13:39:31.942Z" },+ { url = "https://files.pythonhosted.org/packages/06/d5/ee5a3366637fee41dee51a1fc91562dcf12ddbc68fda34e6b253da2324bb/pydantic_core-2.46.4-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:c1b3f518abeca3aa13c712fd202306e145abf59a18b094a6bafb2d2bbf59192c", size = 2129627, upload-time = "2026-05-06T13:37:25.033Z" },+ { url = "https://files.pythonhosted.org/packages/94/33/2414be571d2c6a6c4d08be21f9292b6d3fdb08949a97b6dfe985017821db/pydantic_core-2.46.4-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1a7dd0b3ee80d90150e3495a3a13ac34dbcbfd4f012996a6a1d8900e91b5c0fb", size = 2179141, upload-time = "2026-05-06T13:37:14.046Z" },+ { url = "https://files.pythonhosted.org/packages/7b/79/7daa95be995be0eecc4cf75064cb33f9bbbfe3fe0158caf2f0d4a996a5c7/pydantic_core-2.46.4-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:3fb702cd90b0446a3a1c5e470bfa0dd23c0233b676a9099ddcc964fa6ca13898", size = 2184325, upload-time = "2026-05-06T13:36:53.615Z" },+ { url = "https://files.pythonhosted.org/packages/9f/cb/d0a382f5c0de8a222dc61c65348e0ce831b1f68e0a018450d31c2cace3a5/pydantic_core-2.46.4-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:b8458003118a712e66286df6a707db01c52c0f52f7db8e4a38f0da1d3b94fc4e", size = 2323990, upload-time = "2026-05-06T13:40:29.971Z" },+ { url = "https://files.pythonhosted.org/packages/05/db/d9ba624cc4a5aced1598e88c04fdbd8310c8a69b9d38b9a3d39ce3a61ed7/pydantic_core-2.46.4-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:372429a130e469c9cd698925ce5fc50940b7a1336b0d82038e63d5bbc4edc519", size = 2369978, upload-time = "2026-05-06T13:37:23.027Z" },+ { url = "https://files.pythonhosted.org/packages/f2/20/d15df15ba918c423461905802bfd2981c3af0bfa0e40d05e13edbfa48bc3/pydantic_core-2.46.4-cp314-cp314-win32.whl", hash = "sha256:85bb3611ff1802f3ee7fdd7dbff26b56f343fb432d57a4728fdd49b6ef35e2f4", size = 1966354, upload-time = "2026-05-06T13:38:03.499Z" },+ { url = "https://files.pythonhosted.org/packages/fc/b6/6b8de4c0a7d7ab3004c439c80c5c1e0a3e8d78bbae19379b01960383d9e5/pydantic_core-2.46.4-cp314-cp314-win_amd64.whl", hash = "sha256:811ff8e9c313ab425368bcbb36e5c4ebd7108c2bbf4e4089cfbb0b01eff63fac", size = 2072238, upload-time = "2026-05-06T13:39:40.807Z" },+ { url = "https://files.pythonhosted.org/packages/32/36/51eb763beec1f4cf59b1db243a7dcc39cbb41230f050a09b9d69faaf0a48/pydantic_core-2.46.4-cp314-cp314-win_arm64.whl", hash = "sha256:bfec22eab3c8cc2ceec0248aec886624116dc079afa027ecc8ad4a7e62010f8a", size = 2018251, upload-time = "2026-05-06T13:37:26.72Z" },+ { url = "https://files.pythonhosted.org/packages/e8/91/855af51d625b23aa987116a19e231d2aaef9c4a415273ddc189b79a45fee/pydantic_core-2.46.4-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:af8244b2bef6aaad6d92cda81372de7f8c8d36c9f0c3ea36e827c60e7d9467a0", size = 2099593, upload-time = "2026-05-06T13:39:47.682Z" },+ { url = "https://files.pythonhosted.org/packages/fb/1b/8784a54c65edb5f49f0a14d6977cf1b209bba85a4c77445b255c2de58ab3/pydantic_core-2.46.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:5a4330cdbc57162e4b3aa303f588ba752257694c9c9be3e7ebb11b4aca659b5d", size = 1935226, upload-time = "2026-05-06T13:40:40.428Z" },+ { url = "https://files.pythonhosted.org/packages/e8/e7/1955d28d1afc56dd4b3ad7cc0cf39df1b9852964cf16e5d13912756d6d6b/pydantic_core-2.46.4-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:29c61fc04a3d840155ff08e475a04809278972fe6aef51e2720554e96367e34b", size = 1974605, upload-time = "2026-05-06T13:37:32.029Z" },+ { url = "https://files.pythonhosted.org/packages/93/e2/3fedbf0ba7a22850e6e9fd78117f1c0f10f950182344d8a6c535d468fdd8/pydantic_core-2.46.4-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c50f2528cf200c5eed56faf3f4e22fcd5f38c157a8b78576e6ba3168ec35f000", size = 2030777, upload-time = "2026-05-06T13:38:55.239Z" },+ { url = "https://files.pythonhosted.org/packages/f8/61/46be275fcaaba0b4f5b9669dd852267ce1ff616592dccf7a7845588df091/pydantic_core-2.46.4-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0cbe8b01f948de4286c74cdd6c667aceb38f5c1e26f0693b3983d9d74887c65e", size = 2236641, upload-time = "2026-05-06T13:37:08.096Z" },+ { url = "https://files.pythonhosted.org/packages/60/db/12e93e46a8bac9988be3c016860f83293daea8c716c029c9ace279036f2f/pydantic_core-2.46.4-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:617d7e2ca7dcb8c5cf6bcb8c59b8832c94b36196bbf1cbd1bfb56ed341905edd", size = 2286404, upload-time = "2026-05-06T13:40:20.221Z" },+ { url = "https://files.pythonhosted.org/packages/e2/4a/4d8b19008f38d31c53b8219cfedc2e3d5de5fe99d90076b7e767de29274f/pydantic_core-2.46.4-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7027560ee92211647d0d34e3f7cd6f50da56399d26a9c8ad0da286d3869a53f3", size = 2109219, upload-time = "2026-05-06T13:38:12.153Z" },+ { url = "https://files.pythonhosted.org/packages/88/70/3cbc40978fefb7bb09c6708d40d4ad1a5d70fd7213c3d17f971de868ec1f/pydantic_core-2.46.4-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:f99626688942fb746e545232e7726926f3be91b5975f8b55327665fafda991c7", size = 2110594, upload-time = "2026-05-06T13:40:02.971Z" },+ { url = "https://files.pythonhosted.org/packages/9d/20/b8d36736216e29491125531685b2f9e61aa5b4b2599893f8268551da3338/pydantic_core-2.46.4-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fc3e9034a63de20e15e8ade85358bc6efc614008cab72898b4b4952bea0509ff", size = 2159542, upload-time = "2026-05-06T13:39:27.506Z" },+ { url = "https://files.pythonhosted.org/packages/1d/a2/367df868eb584dacf6bf82a389272406d7178e301c4ac82545ab98bc2dd9/pydantic_core-2.46.4-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:97e7cf2be5c77b7d1a9713a05605d49460d02c6078d38d8bef3cbe323c548424", size = 2168146, upload-time = "2026-05-06T13:38:31.93Z" },+ { url = "https://files.pythonhosted.org/packages/c1/b8/4460f77f7e201893f649a29ab355dddd3beee8a97bcb1a320db414f9a06e/pydantic_core-2.46.4-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:3bf92c5d0e00fefaab325a4d27828fe6b6e2a21848686b5b60d2d9eeb09d76c6", size = 2306309, upload-time = "2026-05-06T13:37:44.717Z" },+ { url = "https://files.pythonhosted.org/packages/64/c4/be2639293acd87dc8ddbcec41a73cee9b2ebf996fe6d892a1a74e88ad3f7/pydantic_core-2.46.4-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:3ecbc122d18468d06ca279dc26a8c2e2d5acb10943bb35e36ae92096dc3b5565", size = 2369736, upload-time = "2026-05-06T13:37:05.645Z" },+ { url = "https://files.pythonhosted.org/packages/30/a6/9f9f380dbb301f67023bf8f707aaa75daadf84f7152d95c410fd7e81d994/pydantic_core-2.46.4-cp314-cp314t-win32.whl", hash = "sha256:e846ae7835bf0703ae43f534ab79a867146dadd59dc9ca5c8b53d5c8f7c9ef02", size = 1955575, upload-time = "2026-05-06T13:38:51.116Z" },+ { url = "https://files.pythonhosted.org/packages/40/1f/f1eb9eb350e795d1af8586289746f5c5677d16043040d63710e22abc43c9/pydantic_core-2.46.4-cp314-cp314t-win_amd64.whl", hash = "sha256:2108ba5c1c1eca18030634489dc544844144ee36357f2f9f780b93e7ddbb44b5", size = 2051624, upload-time = "2026-05-06T13:38:21.672Z" },+ { url = "https://files.pythonhosted.org/packages/f6/d2/42dd53d0a85c27606f316d3aa5d2869c4e8470a5ed6dec30e4a1abe19192/pydantic_core-2.46.4-cp314-cp314t-win_arm64.whl", hash = "sha256:4fcbe087dbc2068af7eda3aa87634eba216dbda64d1ae73c8684b621d33f6596", size = 2017325, upload-time = "2026-05-06T13:40:52.723Z" },+ { url = "https://files.pythonhosted.org/packages/ee/a4/73995fd4ebbb46ba0ee51e6fa049b8f02c40daebb762208feda8a6b7894d/pydantic_core-2.46.4-graalpy311-graalpy242_311_native-macosx_10_12_x86_64.whl", hash = "sha256:14d4edf427bdcf950a8a02d7cb44a08614388dd6e1bdcbf4f67504fa7887da9c", size = 2111589, upload-time = "2026-05-06T13:37:10.817Z" },+ { url = "https://files.pythonhosted.org/packages/fb/7f/f37d3a5e8bfcc2e403f5c57a730f2d815693fb42119e8ea48b3789335af1/pydantic_core-2.46.4-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl", hash = "sha256:0ce40cd7b21210e99342afafbd4d0f76d784eb5b1d60f3bdc566be4983c6c73b", size = 1944552, upload-time = "2026-05-06T13:36:56.717Z" },+ { url = "https://files.pythonhosted.org/packages/15/3c/d7eb777b3ff43e8433a4efb39a17aa8fd98a4ee8561a24a67ef5db07b2d6/pydantic_core-2.46.4-graalpy311-graalpy242_311_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:90884113d8b48f760e9587002789ddd741e76ab9f89518cd1e43b1f1a52ec44b", size = 1982984, upload-time = "2026-05-06T13:39:06.207Z" },+ { url = "https://files.pythonhosted.org/packages/63/87/70b9f40170a81afd55ca26c9b2acb25c20d64bcfbf888fafecb3ba077d4c/pydantic_core-2.46.4-graalpy311-graalpy242_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:66ce7632c22d837c95301830e111ad0128a32b8207533b60896a96c4915192ea", size = 2138417, upload-time = "2026-05-06T13:39:45.476Z" },+ { url = "https://files.pythonhosted.org/packages/9d/1d/8987ad40f65ae1432753072f214fb5c74fe47ffbd0698bb9cbbb585664f8/pydantic_core-2.46.4-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:1d8ba486450b14f3b1d63bc521d410ec7565e52f887b9fb671791886436a42f7", size = 2095527, upload-time = "2026-05-06T13:39:52.283Z" },+ { url = "https://files.pythonhosted.org/packages/64/d3/84c282a7eee1d3ac4c0377546ef5a1ea436ce26840d9ac3b7ed54a377507/pydantic_core-2.46.4-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:3009f12e4e90b7f88b4f9adb1b0c4a3d58fe7820f3238c190047209d148026df", size = 1936024, upload-time = "2026-05-06T13:40:15.671Z" },+ { url = "https://files.pythonhosted.org/packages/d7/ca/eac61596cdeb4d7e174d3dc0bd8a6238f14f75f97a24e7b7db4c7e7340a0/pydantic_core-2.46.4-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ad785e92e6dc634c21555edc8bd6b64957ab844541bcb96a1366c202951ae526", size = 1990696, upload-time = "2026-05-06T13:38:34.717Z" },+ { url = "https://files.pythonhosted.org/packages/fa/c3/7c8b240552251faf6b3a957db200fcfbbcec36763c050428b601e0c9b83b/pydantic_core-2.46.4-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:00c603d540afdd6b80eb39f078f33ebd46211f02f33e34a32d9f053bba711de0", size = 2147590, upload-time = "2026-05-06T13:39:29.883Z" },+ { url = "https://files.pythonhosted.org/packages/11/cb/428de0385b6c8d44b716feba566abfacfbd23ee3c4439faa789a1456242f/pydantic_core-2.46.4-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:0c563b08bca408dc7f65f700633d8442fffb2421fc47b8101377e9fd65051ff0", size = 2112782, upload-time = "2026-05-06T13:37:04.016Z" },+ { url = "https://files.pythonhosted.org/packages/0b/b5/6a17bdadd0fc1f170adfd05a20d37c832f52b117b4d9131da1f41bb097ce/pydantic_core-2.46.4-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:db06ffe51636ffe9ca531fe9023dd64bdd794be8754cb5df57c5498ae5b518a7", size = 1952146, upload-time = "2026-05-06T13:39:43.092Z" },+ { url = "https://files.pythonhosted.org/packages/2a/dc/03734d80e362cd43ef65428e9de77c730ce7f2f11c60d2b1e1b39f0fbf99/pydantic_core-2.46.4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:133878133d271ade3d41d1bfb2a45ec38dbdbda40bc065921c6b04e4630127e2", size = 2134492, upload-time = "2026-05-06T13:36:58.124Z" },+ { url = "https://files.pythonhosted.org/packages/de/df/5e5ffc085ed07cc22d298134d3d911c63e91f6a0eb91fe646750a3209910/pydantic_core-2.46.4-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:9bc519fbf2b7578398853d815009ae5e4d4603d12f4e3f91da8c06852d3da3e9", size = 2156604, upload-time = "2026-05-06T13:37:49.88Z" },+ { url = "https://files.pythonhosted.org/packages/81/44/6e112a4253e56f5705467cbab7ab5e91ee7398ba3d56d358635958893d3e/pydantic_core-2.46.4-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:c7a7bd4e39e8e4c12c39cd480356842b6a8a06e41b23a55a5e3e191718838ddf", size = 2183828, upload-time = "2026-05-06T13:37:43.053Z" },+ { url = "https://files.pythonhosted.org/packages/ac/ad/5565071e937d8e752842ac241463944c9eb14c87e2d269f2658a5bd05e98/pydantic_core-2.46.4-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:d396ec2b979760aaf3218e76c24e65bd0aca24983298653b3a9d7a45f9e47b30", size = 2310000, upload-time = "2026-05-06T13:37:56.694Z" },+ { url = "https://files.pythonhosted.org/packages/4f/c3/66883a5cec183e7fba4d024b4cbbe61851a63750ef606b0afecc46d1f2bf/pydantic_core-2.46.4-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:86e1a4418c6cd97d60c95c71164158eaf7324fae7b0923264016baa993eba6fc", size = 2361286, upload-time = "2026-05-06T13:40:05.667Z" },+ { url = "https://files.pythonhosted.org/packages/4b/2d/69abac8f838090bbecd5df894befb2c2619e7996a98ddb949db9f3b93225/pydantic_core-2.46.4-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:d51026d73fcfd93610abc7b27789c26b313920fcfb20e27462d74a7f8b06e983", size = 2193071, upload-time = "2026-05-06T13:38:08.682Z" },][[package]]@@ -1703,7 +1734,7 @@ wheels = [[[package]]name = "pyinstaller"-version = "6.19.0"+version = "6.20.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "altgraph" },@@ -1714,32 +1745,32 @@ dependencies = [{ name = "pywin32-ctypes", marker = "sys_platform == 'win32'" },{ name = "setuptools" },]-sdist = { url = "https://files.pythonhosted.org/packages/c8/63/fd62472b6371d89dc138d40c36d87a50dc2de18a035803bbdc376b4ffac4/pyinstaller-6.19.0.tar.gz", hash = "sha256:ec73aeb8bd9b7f2f1240d328a4542e90b3c6e6fbc106014778431c616592a865", size = 4036072, upload-time = "2026-02-14T18:06:28.718Z" }+sdist = { url = "https://files.pythonhosted.org/packages/46/60/d03d52e6690d4e9caf333dcd14550cde634ce6c118b3bc8fa3112c3186fd/pyinstaller-6.20.0.tar.gz", hash = "sha256:95c5c7e03d5d61e9dfb8ef259c699cf492bb1041beb6dbe83696608cec07347a", size = 4048728, upload-time = "2026-04-22T20:59:36.96Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/e3/eb/23374721fecfa72677e79800921cb6aceefa6ba48574dc404f3f6c6c3be7/pyinstaller-6.19.0-py3-none-macosx_10_13_universal2.whl", hash = "sha256:4190e76b74f0c4b5c5f11ac360928cd2e36ec8e3194d437bf6b8648c7bc0c134", size = 1040563, upload-time = "2026-02-14T18:05:22.436Z" },- { url = "https://files.pythonhosted.org/packages/cd/7e/dfd724b0b533f5aaec0ee5df406fe2319987ed6964480a706f85478b12ea/pyinstaller-6.19.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:8bd68abd812d8a6ba33b9f1810e91fee0f325969733721b78151f0065319ca11", size = 735477, upload-time = "2026-02-14T18:05:27.143Z" },- { url = "https://files.pythonhosted.org/packages/88/c9/ee3a4101c31f26344e66896c73c1fd6ed8282bf871473365b7f8674af406/pyinstaller-6.19.0-py3-none-manylinux2014_i686.whl", hash = "sha256:1ec54ef967996ca61dacba676227e2b23219878ccce5ee9d6f3aada7b8ed8abf", size = 747143, upload-time = "2026-02-14T18:05:31.488Z" },- { url = "https://files.pythonhosted.org/packages/da/0a/fc77e9f861be8cf300ac37155f59cc92aff99b29f2ddd78546f563a5b5a6/pyinstaller-6.19.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:4ab2bb52e58448e14ddf9450601bdedd66800465043501c1d8f1cab87b60b122", size = 744849, upload-time = "2026-02-14T18:05:35.492Z" },- { url = "https://files.pythonhosted.org/packages/6d/e3/6872e020ee758afe0b821663858492c10745608b07150e5e2c824a5b3e1c/pyinstaller-6.19.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:da6d5c6391ccefe73554b9fa29b86001c8e378e0f20c2a4004f836ba537eff63", size = 741590, upload-time = "2026-02-14T18:05:39.59Z" },- { url = "https://files.pythonhosted.org/packages/53/60/b8db5f1a4b0fb228175f2ea0aa33f949adcc097fbe981cc524f9faf85777/pyinstaller-6.19.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:a0fc5f6b3c55aa54353f0c74ffa59b1115433c1850c6f655d62b461a2ed6cbbe", size = 741448, upload-time = "2026-02-14T18:05:45.636Z" },- { url = "https://files.pythonhosted.org/packages/6f/4d/63b0600f2694e9141b83129fbc1c488ec84d5a0770b1448ec154dcd0fee9/pyinstaller-6.19.0-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:e649ba6bd1b0b89b210ad92adb5fbdc8a42dd2c5ca4f72ef3a0bfec83a424b83", size = 740613, upload-time = "2026-02-14T18:05:49.726Z" },- { url = "https://files.pythonhosted.org/packages/01/d4/e812ad36178093a0e9fd4b8127577748dd85b0cb71de912229dca21fd741/pyinstaller-6.19.0-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:481a909c8e60c8692fc60fcb1344d984b44b943f8bc9682f2fcdae305ad297e6", size = 740350, upload-time = "2026-02-14T18:05:54.093Z" },- { url = "https://files.pythonhosted.org/packages/52/03/b2c2ee41fb8e10fd2a45d21f5ec2ef25852cfb978dbf762972eed59e3d63/pyinstaller-6.19.0-py3-none-win32.whl", hash = "sha256:3c5c251054fe4cfaa04c34a363dcfbf811545438cb7198304cd444756bc2edd2", size = 1324317, upload-time = "2026-02-14T18:06:00.085Z" },- { url = "https://files.pythonhosted.org/packages/9c/d3/6d5e62b8270e2b53a6065e281b3a7785079b00e9019c8019952828dd1669/pyinstaller-6.19.0-py3-none-win_amd64.whl", hash = "sha256:b5bb6536c6560330d364d91522250f254b107cf69129d9cbcd0e6727c570be33", size = 1384894, upload-time = "2026-02-14T18:06:06.425Z" },- { url = "https://files.pythonhosted.org/packages/81/65/458cd523308a101a22fd2742893405030cc24994cc74b1b767cecf137160/pyinstaller-6.19.0-py3-none-win_arm64.whl", hash = "sha256:c2d5a539b0bfe6159d5522c8c70e1c0e487f22c2badae0f97d45246223b798ea", size = 1325374, upload-time = "2026-02-14T18:06:12.804Z" },+ { url = "https://files.pythonhosted.org/packages/d0/e4/e228d6d1bbb7fd62dc660a8fb202a583b023d3a3624ca95d1a9290ee4d6a/pyinstaller-6.20.0-py3-none-macosx_10_13_universal2.whl", hash = "sha256:bf3be4e1284ee78ddccba5e29f99443a12a7b4673168288ffc4c9d38c6f7b90e", size = 1047642, upload-time = "2026-04-22T20:58:32.006Z" },+ { url = "https://files.pythonhosted.org/packages/ce/bd/afb631bcb3f9040efebd4f6d067f0828b51710818f69fb41a2d4b7787f52/pyinstaller-6.20.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:72ae9c1fdea134afa791f58bdc9a1934d5c7609753c111e0026bfc272b32b712", size = 742494, upload-time = "2026-04-22T20:58:36.285Z" },+ { url = "https://files.pythonhosted.org/packages/76/08/0729a5bac14754150e5d83b39d87d842eb42b0bffcaa03dbad6252e23a39/pyinstaller-6.20.0-py3-none-manylinux2014_i686.whl", hash = "sha256:1031bcc307f3fbeffd4e162723e64d46dbf591c82dd0997413afb2a07328b941", size = 754191, upload-time = "2026-04-22T20:58:40.603Z" },+ { url = "https://files.pythonhosted.org/packages/e6/82/bc0ee4c7b97db1958eb651e0da9fb1e672e5ae53ca8867fd97701de52906/pyinstaller-6.20.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:8df3b3f347659fa2562d8d193a98ad4600133b8b8d07c268df89e4154376750e", size = 751902, upload-time = "2026-04-22T20:58:44.7Z" },+ { url = "https://files.pythonhosted.org/packages/3d/e7/770002d6aaa54173881cb2c49bb195ba67b97bf39bac1cdf320f28401629/pyinstaller-6.20.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:b0d3cc9dd8120d448459bd3880a12e2f9774c51443af49047801446377999a59", size = 748634, upload-time = "2026-04-22T20:58:48.579Z" },+ { url = "https://files.pythonhosted.org/packages/fe/db/68ba1fccb71278b2124fb90b37b7c8c0bc4c1173fba45b94466df3d9cb7f/pyinstaller-6.20.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:03696bb6350177c6bc23bcaf78e71a33c4a89b6754dd90d1be2f318e978c918b", size = 748490, upload-time = "2026-04-22T20:58:52.749Z" },+ { url = "https://files.pythonhosted.org/packages/03/0f/ac77ffa996a56be3d5c8f85734a007f8347240691657f9704e7de2527fa3/pyinstaller-6.20.0-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:6357f1699f6af84f37e7367f031d4f68abdba65543b83990c9e8f5a4cebed0b7", size = 747650, upload-time = "2026-04-22T20:58:57.093Z" },+ { url = "https://files.pythonhosted.org/packages/e0/56/1ee91c3a2bc10ca1f36da10a6fd55ff7efc4dec367171eb25992a827874f/pyinstaller-6.20.0-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:0ab39c690abad26ba148e8f664f0478acc82a733997f4f22e757774832802da9", size = 747413, upload-time = "2026-04-22T20:59:01.174Z" },+ { url = "https://files.pythonhosted.org/packages/d7/55/ae264339996953c4cdf9d89d916a0a8fa26a83cf917a742fff8b9d5f3fe8/pyinstaller-6.20.0-py3-none-win32.whl", hash = "sha256:9a7637e8e44b4387b13667fdcaac86ab6b29c446c16d34d8401539b81838759c", size = 1331584, upload-time = "2026-04-22T20:59:07.201Z" },+ { url = "https://files.pythonhosted.org/packages/76/8c/300f57578882cce259bfb5ae56fda3b69caa3fe9df40a176c719920ea6e2/pyinstaller-6.20.0-py3-none-win_amd64.whl", hash = "sha256:d588844e890ee80c4365867f98146636e1849bbca8e4284bbf0c809aff0f161a", size = 1391851, upload-time = "2026-04-22T20:59:14.024Z" },+ { url = "https://files.pythonhosted.org/packages/8a/ea/b2f8e1642aecda78c0b75c7321f708e49e10bb3c00dd4f148c40761a1527/pyinstaller-6.20.0-py3-none-win_arm64.whl", hash = "sha256:bd53282c0a73e5c95573e1ddc8e5d564d4932bec91efbaed4dc5fdff9c2ae7f2", size = 1332259, upload-time = "2026-04-22T20:59:20.509Z" },][[package]]name = "pyinstaller-hooks-contrib"-version = "2026.4"+version = "2026.5"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "packaging" },{ name = "setuptools" },]-sdist = { url = "https://files.pythonhosted.org/packages/c7/fe/9278c29394bf69169febc21f96b4252c3ee7c8ec22c2fc545004bed47e71/pyinstaller_hooks_contrib-2026.4.tar.gz", hash = "sha256:766c281acb1ecc32e21c8c667056d7ebf5da0aabd5e30c219f9c2a283620eeaa", size = 173050, upload-time = "2026-03-31T14:10:51.188Z" }+sdist = { url = "https://files.pythonhosted.org/packages/1a/67/f4452d68793fb15beba4f19ef39a38a8822f0da7452b503c400d5a21f5c1/pyinstaller_hooks_contrib-2026.5.tar.gz", hash = "sha256:f066dfca8f7c45ff6336c9cf9fe25b4e48bfeb322a1aa24faaedfb8a8d1b0b08", size = 173689, upload-time = "2026-05-04T22:36:55.124Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/88/f4/035fb8c06deff827f540a9a4ed9122c54e5376fca3e42eddf0c263730775/pyinstaller_hooks_contrib-2026.4-py3-none-any.whl", hash = "sha256:1de1a5e49a878122010b88c7e295502bc69776c157c4a4dc78741a4e6178b00f", size = 455496, upload-time = "2026-03-31T14:10:49.867Z" },+ { url = "https://files.pythonhosted.org/packages/f6/5c/fd465d11da4d12b50d7eb5d2ee2ceb780d8d049dbb489f3828d131e387af/pyinstaller_hooks_contrib-2026.5-py3-none-any.whl", hash = "sha256:ea1535783fbdac4626351709e83f3ea80b681d3a4745763ebb407b5e27342eb9", size = 457314, upload-time = "2026-05-04T22:36:53.598Z" },][[package]]@@ -2007,44 +2038,29 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/d7/8e/7540e8a2036f79a125c1d2ebadf69ed7901608859186c856fa0388ef4197/requests-2.33.1-py3-none-any.whl", hash = "sha256:4e6d1ef462f3626a1f0a0a9c42dd93c63bad33f9f1c1937509b8c5c8718ab56a", size = 64947, upload-time = "2026-03-30T16:09:13.83Z" },]-[[package]]-name = "rtmlib"-version = "0.0.14"-source = { registry = "https://pypi.org/simple" }-dependencies = [- { name = "numpy" },- { name = "opencv-contrib-python" },- { name = "opencv-python" },- { name = "tqdm" },-]-sdist = { url = "https://files.pythonhosted.org/packages/1e/74/b3a33e88f1961a3fa80d7a6a3e2910670ebbb10b9c1d06d334ac2115843b/rtmlib-0.0.14.tar.gz", hash = "sha256:2d3090b1e93f7eddcedb01233f2181fb6f974ab3250e356eb94eae872358317a", size = 40656, upload-time = "2025-11-05T16:54:56.993Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/c4/d5/3c55515efe506ea33c221e29b12d9d9ddfff7e4995eb8fbcb47589fbdcb3/rtmlib-0.0.14-py3-none-any.whl", hash = "sha256:dbba2a0a8d7de7bfd8bfb3fa557607f7a9ad6266ace3ceff89665c2d743bfe58", size = 51464, upload-time = "2025-11-05T16:54:55.732Z" },-]-[[package]]name = "ruff"-version = "0.15.11"-source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/e4/8d/192f3d7103816158dfd5ea50d098ef2aec19194e6cbccd4b3485bdb2eb2d/ruff-0.15.11.tar.gz", hash = "sha256:f092b21708bf0e7437ce9ada249dfe688ff9a0954fc94abab05dcea7dcd29c33", size = 4637264, upload-time = "2026-04-16T18:46:26.58Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/02/1e/6aca3427f751295ab011828e15e9bf452200ac74484f1db4be0197b8170b/ruff-0.15.11-py3-none-linux_armv6l.whl", hash = "sha256:e927cfff503135c558eb581a0c9792264aae9507904eb27809cdcff2f2c847b7", size = 10607943, upload-time = "2026-04-16T18:46:05.967Z" },- { url = "https://files.pythonhosted.org/packages/e7/26/1341c262e74f36d4e84f3d6f4df0ac68cd53331a66bfc5080daa17c84c0b/ruff-0.15.11-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:7a1b5b2938d8f890b76084d4fa843604d787a912541eae85fd7e233398bbb73e", size = 10988592, upload-time = "2026-04-16T18:46:00.742Z" },- { url = "https://files.pythonhosted.org/packages/03/71/850b1d6ffa9564fbb6740429bad53df1094082fe515c8c1e74b6d8d05f18/ruff-0.15.11-py3-none-macosx_11_0_arm64.whl", hash = "sha256:d4176f3d194afbdaee6e41b9ccb1a2c287dba8700047df474abfbe773825d1cb", size = 10338501, upload-time = "2026-04-16T18:46:03.723Z" },- { url = "https://files.pythonhosted.org/packages/f2/11/cc1284d3e298c45a817a6aadb6c3e1d70b45c9b36d8d9cce3387b495a03a/ruff-0.15.11-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3b17c886fb88203ced3afe7f14e8d5ae96e9d2f4ccc0ee66aa19f2c2675a27e4", size = 10670693, upload-time = "2026-04-16T18:46:41.941Z" },- { url = "https://files.pythonhosted.org/packages/ce/9e/f8288b034ab72b371513c13f9a41d9ba3effac54e24bfb467b007daee2ca/ruff-0.15.11-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:49fafa220220afe7758a487b048de4c8f9f767f37dfefad46b9dd06759d003eb", size = 10416177, upload-time = "2026-04-16T18:46:21.717Z" },- { url = "https://files.pythonhosted.org/packages/85/71/504d79abfd3d92532ba6bbe3d1c19fada03e494332a59e37c7c2dabae427/ruff-0.15.11-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f2ab8427e74a00d93b8bda1307b1e60970d40f304af38bccb218e056c220120d", size = 11221886, upload-time = "2026-04-16T18:46:15.086Z" },- { url = "https://files.pythonhosted.org/packages/43/5a/947e6ab7a5ad603d65b474be15a4cbc6d29832db5d762cd142e4e3a74164/ruff-0.15.11-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:195072c0c8e1fc8f940652073df082e37a5d9cb43b4ab1e4d0566ab8977a13b7", size = 12075183, upload-time = "2026-04-16T18:46:07.944Z" },- { url = "https://files.pythonhosted.org/packages/9f/a1/0b7bb6268775fdd3a0818aee8efd8f5b4e231d24dd4d528ced2534023182/ruff-0.15.11-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a3a0996d486af3920dec930a2e7daed4847dfc12649b537a9335585ada163e9e", size = 11516575, upload-time = "2026-04-16T18:46:31.687Z" },- { url = "https://files.pythonhosted.org/packages/30/c3/bb5168fc4d233cc06e95f482770d0f3c87945a0cd9f614b90ea8dc2f2833/ruff-0.15.11-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1bef2cb556d509259f1fe440bb9cd33c756222cf0a7afe90d15edf0866702431", size = 11306537, upload-time = "2026-04-16T18:46:36.988Z" },- { url = "https://files.pythonhosted.org/packages/e4/92/4cfae6441f3967317946f3b788136eecf093729b94d6561f963ed810c82e/ruff-0.15.11-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:030d921a836d7d4a12cf6e8d984a88b66094ccb0e0f17ddd55067c331191bf19", size = 11296813, upload-time = "2026-04-16T18:46:24.182Z" },- { url = "https://files.pythonhosted.org/packages/43/26/972784c5dde8313acde8ac71ba8ac65475b85db4a2352a76c9934361f9bc/ruff-0.15.11-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:0e783b599b4577788dbbb66b9addcef87e9a8832f4ce0c19e34bf55543a2f890", size = 10633136, upload-time = "2026-04-16T18:46:39.802Z" },- { url = "https://files.pythonhosted.org/packages/5b/53/3985a4f185020c2f367f2e08a103032e12564829742a1b417980ce1514a0/ruff-0.15.11-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:ae90592246625ba4a34349d68ec28d4400d75182b71baa196ddb9f82db025ef5", size = 10424701, upload-time = "2026-04-16T18:46:10.381Z" },- { url = "https://files.pythonhosted.org/packages/d3/57/bf0dfb32241b56c83bb663a826133da4bf17f682ba8c096973065f6e6a68/ruff-0.15.11-py3-none-musllinux_1_2_i686.whl", hash = "sha256:1f111d62e3c983ed20e0ca2e800f8d77433a5b1161947df99a5c2a3fb60514f0", size = 10873887, upload-time = "2026-04-16T18:46:29.157Z" },- { url = "https://files.pythonhosted.org/packages/02/05/e48076b2a57dc33ee8c7a957296f97c744ca891a8ffb4ffb1aaa3b3f517d/ruff-0.15.11-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:06f483d6646f59eaffba9ae30956370d3a886625f511a3108994000480621d1c", size = 11404316, upload-time = "2026-04-16T18:46:19.462Z" },- { url = "https://files.pythonhosted.org/packages/88/27/0195d15fe7a897cbcba0904792c4b7c9fdd958456c3a17d2ea6093716a9a/ruff-0.15.11-py3-none-win32.whl", hash = "sha256:476a2aa56b7da0b73a3ee80b6b2f0e19cce544245479adde7baa65466664d5f3", size = 10655535, upload-time = "2026-04-16T18:46:12.47Z" },- { url = "https://files.pythonhosted.org/packages/3a/5e/c927b325bd4c1d3620211a4b96f47864633199feed60fa936025ab27e090/ruff-0.15.11-py3-none-win_amd64.whl", hash = "sha256:8b6756d88d7e234fb0c98c91511aae3cd519d5e3ed271cae31b20f39cb2a12a3", size = 11779692, upload-time = "2026-04-16T18:46:17.268Z" },- { url = "https://files.pythonhosted.org/packages/63/b6/aeadee5443e49baa2facd51131159fd6301cc4ccfc1541e4df7b021c37dd/ruff-0.15.11-py3-none-win_arm64.whl", hash = "sha256:063fed18cc1bbe0ee7393957284a6fe8b588c6a406a285af3ee3f46da2391ee4", size = 11032614, upload-time = "2026-04-16T18:46:34.487Z" },+version = "0.15.12"+source = { registry = "https://pypi.org/simple" }+sdist = { url = "https://files.pythonhosted.org/packages/99/43/3291f1cc9106f4c63bdce7a8d0df5047fe8422a75b091c16b5e9355e0b11/ruff-0.15.12.tar.gz", hash = "sha256:ecea26adb26b4232c0c2ca19ccbc0083a68344180bba2a600605538ce51a40a6", size = 4643852, upload-time = "2026-04-24T18:17:14.305Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/c3/6e/e78ffb61d4686f3d96ba3df2c801161843746dcbcbb17a1e927d4829312b/ruff-0.15.12-py3-none-linux_armv6l.whl", hash = "sha256:f86f176e188e94d6bdbc09f09bfd9dc729059ad93d0e7390b5a73efe19f8861c", size = 10640713, upload-time = "2026-04-24T18:17:22.841Z" },+ { url = "https://files.pythonhosted.org/packages/ae/08/a317bc231fb9e7b93e4ef3089501e51922ff88d6936ce5cf870c4fe55419/ruff-0.15.12-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e3bcd123364c3770b8e1b7baaf343cc99a35f197c5c6e8af79015c666c423a6c", size = 11069267, upload-time = "2026-04-24T18:17:30.105Z" },+ { url = "https://files.pythonhosted.org/packages/aa/a4/f828e9718d3dce1f5f11c39c4f65afd32783c8b2aebb2e3d259e492c47bd/ruff-0.15.12-py3-none-macosx_11_0_arm64.whl", hash = "sha256:fe87510d000220aa1ed530d4448a7c696a0cae1213e5ec30e5874287b66557b5", size = 10397182, upload-time = "2026-04-24T18:17:07.177Z" },+ { url = "https://files.pythonhosted.org/packages/71/e0/3310fc6d1b5e1fdea22bf3b1b807c7e187b581021b0d7d4514cccdb5fb71/ruff-0.15.12-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:84a1630093121375a3e2a95b4a6dc7b59e2b4ee76216e32d81aae550a832d002", size = 10758012, upload-time = "2026-04-24T18:16:55.759Z" },+ { url = "https://files.pythonhosted.org/packages/11/c1/a606911aee04c324ddaa883ae418f3569792fd3c4a10c50e0dd0a2311e1e/ruff-0.15.12-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fb129f40f114f089ebe0ca56c0d251cf2061b17651d464bb6478dc01e69f11f5", size = 10447479, upload-time = "2026-04-24T18:16:51.677Z" },+ { url = "https://files.pythonhosted.org/packages/9d/68/4201e8444f0894f21ab4aeeaee68aa4f10b51613514a20d80bd628d57e88/ruff-0.15.12-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b0c862b172d695db7598426b8af465e7e9ac00a3ea2a3630ee67eb82e366aaa6", size = 11234040, upload-time = "2026-04-24T18:17:16.529Z" },+ { url = "https://files.pythonhosted.org/packages/34/ff/8a6d6cf4ccc23fd67060874e832c18919d1557a0611ebef03fdb01fff11e/ruff-0.15.12-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2849ea9f3484c3aca43a82f484210370319e7170df4dfe4843395ddf6c57bc33", size = 12087377, upload-time = "2026-04-24T18:17:04.944Z" },+ { url = "https://files.pythonhosted.org/packages/85/f6/c669cf73f5152f623d34e69866a46d5e6185816b19fcd5b6dd8a2d299922/ruff-0.15.12-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9e77c7e51c07fe396826d5969a5b846d9cd4c402535835fb6e21ce8b28fef847", size = 11367784, upload-time = "2026-04-24T18:17:25.409Z" },+ { url = "https://files.pythonhosted.org/packages/e8/39/c61d193b8a1daaa8977f7dea9e8d8ba866e02ea7b65d32f6861693aa4c12/ruff-0.15.12-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:83b2f4f2f3b1026b5fb449b467d9264bf22067b600f7b6f41fc5958909f449d0", size = 11344088, upload-time = "2026-04-24T18:17:12.258Z" },+ { url = "https://files.pythonhosted.org/packages/c2/8d/49afab3645e31e12c590acb6d3b5b69d7aab5b81926dbaf7461f9441f37a/ruff-0.15.12-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:9ba3b8f1afd7e2e43d8943e55f249e13f9682fde09711644a6e7290eb4f3e339", size = 11271770, upload-time = "2026-04-24T18:17:02.457Z" },+ { url = "https://files.pythonhosted.org/packages/46/06/33f41fe94403e2b755481cdfb9b7ef3e4e0ed031c4581124658d935d52b4/ruff-0.15.12-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:e852ba9fdc890655e1d78f2df1499efbe0e54126bd405362154a75e2bde159c5", size = 10719355, upload-time = "2026-04-24T18:17:27.648Z" },+ { url = "https://files.pythonhosted.org/packages/0d/59/18aa4e014debbf559670e4048e39260a85c7fcee84acfd761ac01e7b8d35/ruff-0.15.12-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:dd8aed930da53780d22fc70bdf84452c843cf64f8cb4eb38984319c24c5cd5fd", size = 10462758, upload-time = "2026-04-24T18:17:32.347Z" },+ { url = "https://files.pythonhosted.org/packages/25/e7/cc9f16fd0f3b5fddcbd7ec3d6ae30c8f3fde1047f32a4093a98d633c6570/ruff-0.15.12-py3-none-musllinux_1_2_i686.whl", hash = "sha256:01da3988d225628b709493d7dc67c3b9b12c0210016b08690ef9bd27970b262b", size = 10953498, upload-time = "2026-04-24T18:17:20.674Z" },+ { url = "https://files.pythonhosted.org/packages/72/7a/a9ba7f98c7a575978698f4230c5e8cc54bbc761af34f560818f933dafa0c/ruff-0.15.12-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:9cae0f92bd5700d1213188b31cd3bdd2b315361296d10b96b8e2337d3d11f53e", size = 11447765, upload-time = "2026-04-24T18:17:09.755Z" },+ { url = "https://files.pythonhosted.org/packages/ea/f9/0ae446942c846b8266059ad8a30702a35afae55f5cdc54c5adf8d7afdc27/ruff-0.15.12-py3-none-win32.whl", hash = "sha256:d0185894e038d7043ba8fd6aee7499ece6462dc0ea9f1e260c7451807c714c20", size = 10657277, upload-time = "2026-04-24T18:17:18.591Z" },+ { url = "https://files.pythonhosted.org/packages/33/f1/9614e03e1cdcbf9437570b5400ced8a720b5db22b28d8e0f1bda429f660d/ruff-0.15.12-py3-none-win_amd64.whl", hash = "sha256:c87a162d61ab3adca47c03f7f717c68672edec7d1b5499e652331780fe74950d", size = 11837758, upload-time = "2026-04-24T18:17:00.113Z" },+ { url = "https://files.pythonhosted.org/packages/c0/98/6beb4b351e472e5f4c4613f7c35a5290b8be2497e183825310c4c3a3984b/ruff-0.15.12-py3-none-win_arm64.whl", hash = "sha256:a538f7a82d061cee7be55542aca1d86d1393d55d81d4fcc314370f4340930d4f", size = 11120821, upload-time = "2026-04-24T18:16:57.979Z" },][[package]]@@ -2232,8 +2248,8 @@ wheels = [[[package]]name = "skellycam"-version = "2.0.0a1"-source = { git = "https://github.com/freemocap/skellycam?branch=development#f673e077a61d0f70d0915ac81e87dc28110a767e" }+version = "2.0.0a5"+source = { git = "https://github.com/freemocap/skellycam?branch=development#0e9a0b1350729bac0a90450544ed307c107fec9a" }dependencies = [{ name = "av" },{ name = "beartype" },@@ -2289,7 +2305,7 @@ dependencies = [[[package]]name = "skellytracker"version = "2024.9.1019"-source = { git = "https://github.com/freemocap/skellytracker?branch=development#185c05b0f76c0dc60ef54571fda24644862a6d55" }+source = { git = "https://github.com/freemocap/skellytracker?branch=development#b605d1163a1f9b966684818742377e5c4e22a0b8" }dependencies = [{ name = "beartype" },{ name = "numpy" },@@ -2308,8 +2324,9 @@ recommended = [{ name = "nvidia-cuda-runtime-cu12" },{ name = "nvidia-cudnn-cu12" },{ name = "nvidia-cufft-cu12" },+ { name = "onnx" },{ name = "onnxruntime-gpu" },- { name = "rtmlib" },+ { name = "tensorrt" },][[package]]@@ -2342,26 +2359,55 @@ wheels = [][[package]]-name = "sympy"-version = "1.14.0"+name = "tabulate"+version = "0.10.0"+source = { registry = "https://pypi.org/simple" }+sdist = { url = "https://files.pythonhosted.org/packages/46/58/8c37dea7bbf769b20d58e7ace7e5edfe65b849442b00ffcdd56be88697c6/tabulate-0.10.0.tar.gz", hash = "sha256:e2cfde8f79420f6deeffdeda9aaec3b6bc5abce947655d17ac662b126e48a60d", size = 91754, upload-time = "2026-03-04T18:55:34.402Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/99/55/db07de81b5c630da5cbf5c7df646580ca26dfaefa593667fc6f2fe016d2e/tabulate-0.10.0-py3-none-any.whl", hash = "sha256:f0b0622e567335c8fabaaa659f1b33bcb6ddfe2e496071b743aa113f8774f2d3", size = 39814, upload-time = "2026-03-04T18:55:31.284Z" },+]++[[package]]+name = "tensorrt"+version = "10.16.1.11"source = { registry = "https://pypi.org/simple" }dependencies = [- { name = "mpmath" },+ { name = "tensorrt-cu13" },]-sdist = { url = "https://files.pythonhosted.org/packages/83/d3/803453b36afefb7c2bb238361cd4ae6125a569b4db67cd9e79846ba2d68c/sympy-1.14.0.tar.gz", hash = "sha256:d3d3fe8df1e5a0b42f0e7bdf50541697dbe7d23746e894990c030e2b05e72517", size = 7793921, upload-time = "2025-04-27T18:05:01.611Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/a2/09/77d55d46fd61b4a135c444fc97158ef34a095e5681d0a6c10b75bf356191/sympy-1.14.0-py3-none-any.whl", hash = "sha256:e091cc3e99d2141a0ba2847328f5479b05d94a6635cb96148ccb3f34671bd8f5", size = 6299353, upload-time = "2025-04-27T18:04:59.103Z" },+sdist = { url = "https://files.pythonhosted.org/packages/fc/ca/e50b15ccd364a5347a23d56f93479735510109b70caabbe91a47d493bba7/tensorrt-10.16.1.11.tar.gz", hash = "sha256:5c31ef98e1a1b53197acc600327d6b1e4abb503024119a2e66f21a5654ea3996", size = 16617, upload-time = "2026-04-07T19:37:13.586Z" }++[[package]]+name = "tensorrt-cu13"+version = "10.16.1.11"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "tensorrt-cu13-bindings" },+ { name = "tensorrt-cu13-libs" },]+sdist = { url = "https://files.pythonhosted.org/packages/7c/9a/dfe6c293faa625457563c293d165f8948532d71b29a490e4f59773edf2aa/tensorrt_cu13-10.16.1.11.tar.gz", hash = "sha256:5d34203a92f38851b150c4eddd32b9b55c01fd40fc4d19bff83e8dfef1d8f69e", size = 17916, upload-time = "2026-04-07T19:37:15.536Z" }[[package]]-name = "tabulate"-version = "0.10.0"+name = "tensorrt-cu13-bindings"+version = "10.16.1.11"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/46/58/8c37dea7bbf769b20d58e7ace7e5edfe65b849442b00ffcdd56be88697c6/tabulate-0.10.0.tar.gz", hash = "sha256:e2cfde8f79420f6deeffdeda9aaec3b6bc5abce947655d17ac662b126e48a60d", size = 91754, upload-time = "2026-03-04T18:55:34.402Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/99/55/db07de81b5c630da5cbf5c7df646580ca26dfaefa593667fc6f2fe016d2e/tabulate-0.10.0-py3-none-any.whl", hash = "sha256:f0b0622e567335c8fabaaa659f1b33bcb6ddfe2e496071b743aa113f8774f2d3", size = 39814, upload-time = "2026-03-04T18:55:31.284Z" },+ { url = "https://files.pythonhosted.org/packages/cc/25/c9118b04afb96e0cd4d492199d9b476de9c0087b2e406c34515f0c7458d1/tensorrt_cu13_bindings-10.16.1.11-cp311-none-manylinux_2_28_x86_64.whl", hash = "sha256:f986d47980d042cc126506a9b84586e55ad13737a7a46826fe45457c04d66294", size = 1346363, upload-time = "2026-04-07T19:39:58.905Z" },+ { url = "https://files.pythonhosted.org/packages/3b/29/63935339615bc98289a173fd06b275e61959cbf7513bbc9fb1852303e330/tensorrt_cu13_bindings-10.16.1.11-cp311-none-manylinux_2_35_aarch64.whl", hash = "sha256:6fa40558659d027ef6d71b475f012e0531f3d69c7b27b4a2b92779cc6de24a9a", size = 1340941, upload-time = "2026-04-07T19:41:07.568Z" },+ { url = "https://files.pythonhosted.org/packages/fa/d5/2595b547ab7228f7c424b6901b59f90360006a537603c13417c30b3bcc3c/tensorrt_cu13_bindings-10.16.1.11-cp311-none-win_amd64.whl", hash = "sha256:483a58b8cf3a7e97d66d7245084d08f9ee9cd19d09210305ed43b34fbb721f7c", size = 963765, upload-time = "2026-04-07T19:38:58.426Z" },+ { url = "https://files.pythonhosted.org/packages/76/6d/d46fd241895091d11d0e55a389abc5711c71892e8e63b03e272e61ca880a/tensorrt_cu13_bindings-10.16.1.11-cp312-none-manylinux_2_28_x86_64.whl", hash = "sha256:2fb87ac24a5e5f42e43f283c16d1b661dc72ef18568fd847ce2080b7db9ca232", size = 1341248, upload-time = "2026-04-07T19:42:10.807Z" },+ { url = "https://files.pythonhosted.org/packages/ee/bb/3513236bc1b69fc6b88722f0f1f62ae4afd74b9f417ad3abf9a2bf971f22/tensorrt_cu13_bindings-10.16.1.11-cp312-none-manylinux_2_35_aarch64.whl", hash = "sha256:80d0cea41cb695e73a442ab5a0c1fb023730c488caa93ee3ca9c49d57314821d", size = 1329585, upload-time = "2026-04-07T19:42:35.412Z" },+ { url = "https://files.pythonhosted.org/packages/e9/a8/dfda48ab992050f40d0b2da7a795f16db403f48ee89e6a526cbd00133445/tensorrt_cu13_bindings-10.16.1.11-cp312-none-win_amd64.whl", hash = "sha256:70ca2d73301ff427104d7986c26d5fa56f6a91578242d20e82b37c139be14ec0", size = 964883, upload-time = "2026-04-07T19:44:07.702Z" },+ { url = "https://files.pythonhosted.org/packages/58/41/0b6f0d81862b058393cd0b5616e11d1826c8e02b14294dabcaee92ce4365/tensorrt_cu13_bindings-10.16.1.11-cp313-none-manylinux_2_28_x86_64.whl", hash = "sha256:da17c222ba99f46e77e1dab568cd17c4652b0432d4fae074e4c79285356aa0ac", size = 1341149, upload-time = "2026-04-07T19:39:15.597Z" },+ { url = "https://files.pythonhosted.org/packages/06/34/726efe8d5ff22a032a324e57313325fc1a126c2abd27c2422919059f6093/tensorrt_cu13_bindings-10.16.1.11-cp313-none-manylinux_2_35_aarch64.whl", hash = "sha256:2cba1722377323516a46ed15859deaf03f20ab2a47e63a89d69b3898d110fcac", size = 1331542, upload-time = "2026-04-07T19:42:58.098Z" },+ { url = "https://files.pythonhosted.org/packages/f7/e8/f6e4bcd9656bfdae64366606b386b5963035ac5fb01d83ccfccd97432a7a/tensorrt_cu13_bindings-10.16.1.11-cp313-none-win_amd64.whl", hash = "sha256:44b44154027e5e9e39d74e14b453704af50ba774b3775704f6d40408c8457526", size = 964906, upload-time = "2026-04-07T19:43:16.083Z" },]+[[package]]+name = "tensorrt-cu13-libs"+version = "10.16.1.11"+source = { registry = "https://pypi.org/simple" }+sdist = { url = "https://files.pythonhosted.org/packages/67/25/085bcc297237bfea56fac62cca0439f2298f875b6a26de5ae0413671687d/tensorrt_cu13_libs-10.16.1.11.tar.gz", hash = "sha256:0e86cd02321b7258c2521495a7d8f0591852e6966ed7e43cfe33640c737495a3", size = 15737, upload-time = "2026-04-07T19:38:09.175Z" }+[[package]]name = "threadpoolctl"version = "3.6.0"@@ -2424,11 +2470,11 @@ wheels = [[[package]]name = "tzdata"-version = "2026.1"+version = "2026.2"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/19/f5/cd531b2d15a671a40c0f66cf06bc3570a12cd56eef98960068ebbad1bf5a/tzdata-2026.1.tar.gz", hash = "sha256:67658a1903c75917309e753fdc349ac0efd8c27db7a0cb406a25be4840f87f98", size = 197639, upload-time = "2026-04-03T11:25:22.002Z" }+sdist = { url = "https://files.pythonhosted.org/packages/ba/19/1b9b0e29f30c6d35cb345486df41110984ea67ae69dddbc0e8a100999493/tzdata-2026.2.tar.gz", hash = "sha256:9173fde7d80d9018e02a662e168e5a2d04f87c41ea174b139fbef642eda62d10", size = 198254, upload-time = "2026-04-24T15:22:08.651Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/b0/70/d460bd685a170790ec89317e9bd33047988e4bce507b831f5db771e142de/tzdata-2026.1-py2.py3-none-any.whl", hash = "sha256:4b1d2be7ac37ceafd7327b961aa3a54e467efbdb563a23655fbfe0d39cfc42a9", size = 348952, upload-time = "2026-04-03T11:25:20.313Z" },+ { url = "https://files.pythonhosted.org/packages/ce/e4/dccd7f47c4b64213ac01ef921a1337ee6e30e8c6466046018326977efd95/tzdata-2026.2-py2.py3-none-any.whl", hash = "sha256:bbe9af844f658da81a5f95019480da3a89415801f6cc966806612cc7169bffe7", size = 349321, upload-time = "2026-04-24T15:22:05.876Z" },][[package]]@@ -2454,15 +2500,15 @@ wheels = [[[package]]name = "uvicorn"-version = "0.44.0"+version = "0.46.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "click" },{ name = "h11" },]-sdist = { url = "https://files.pythonhosted.org/packages/5e/da/6eee1ff8b6cbeed47eeb5229749168e81eb4b7b999a1a15a7176e51410c9/uvicorn-0.44.0.tar.gz", hash = "sha256:6c942071b68f07e178264b9152f1f16dfac5da85880c4ce06366a96d70d4f31e", size = 86947, upload-time = "2026-04-06T09:23:22.826Z" }+sdist = { url = "https://files.pythonhosted.org/packages/1f/93/041fca8274050e40e6791f267d82e0e2e27dd165627bd640d3e0e378d877/uvicorn-0.46.0.tar.gz", hash = "sha256:fb9da0926999cc6cb22dc7cd71a94a632f078e6ae47ff683c5c420750fb7413d", size = 88758, upload-time = "2026-04-23T07:16:00.151Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/b7/23/a5bbd9600dd607411fa644c06ff4951bec3a4d82c4b852374024359c19c0/uvicorn-0.44.0-py3-none-any.whl", hash = "sha256:ce937c99a2cc70279556967274414c087888e8cec9f9c94644dfca11bd3ced89", size = 69425, upload-time = "2026-04-06T09:23:21.524Z" },+ { url = "https://files.pythonhosted.org/packages/31/a3/5b1562db76a5a488274b2332a97199b32d0442aca0ed193697fd47786316/uvicorn-0.46.0-py3-none-any.whl", hash = "sha256:bbebbcbed972d162afca128605223022bedd345b7bc7855ce66deb31487a9048", size = 70926, upload-time = "2026-04-23T07:15:58.355Z" },][[package]]@@ -2526,12 +2572,12 @@ wheels = [[[package]]name = "wheel"-version = "0.46.3"+version = "0.47.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "packaging" },]-sdist = { url = "https://files.pythonhosted.org/packages/89/24/a2eb353a6edac9a0303977c4cb048134959dd2a51b48a269dfc9dde00c8a/wheel-0.46.3.tar.gz", hash = "sha256:e3e79874b07d776c40bd6033f8ddf76a7dad46a7b8aa1b2787a83083519a1803", size = 60605, upload-time = "2026-01-22T12:39:49.136Z" }+sdist = { url = "https://files.pythonhosted.org/packages/39/62/75f18a0f03b4219c456652c7780e4d749b929eb605c098ce3a5b6b6bc081/wheel-0.47.0.tar.gz", hash = "sha256:cc72bd1009ba0cf63922e28f94d9d83b920aa2bb28f798a31d0691b02fa3c9b3", size = 63854, upload-time = "2026-04-22T15:51:27.727Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/87/22/b76d483683216dde3d67cba61fb2444be8d5be289bf628c13fc0fd90e5f9/wheel-0.46.3-py3-none-any.whl", hash = "sha256:4b399d56c9d9338230118d705d9737a2a468ccca63d5e813e2a4fc7815d8bc4d", size = 30557, upload-time = "2026-01-22T12:39:48.099Z" },+ { url = "https://files.pythonhosted.org/packages/87/1b/9e33c09813d65e248f7f773119148a612516a4bea93e9c6f545f78455b7c/wheel-0.47.0-py3-none-any.whl", hash = "sha256:212281cab4dff978f6cedd499cd893e1f620791ca6ff7107cf270781e587eced", size = 32218, upload-time = "2026-04-22T15:51:26.296Z" },]