Free Motion Capture for Everyone πβ¨
TypeScript
chkchk
jonmatthisd954dfffa8ca
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.tsxindex f4b11701..0b9ead97 100644--- a/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationControlPanel.tsx+++ b/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationControlPanel.tsx@@ -5,12 +5,8 @@ import {Button,Chip,CircularProgress,- FormControl,IconButton,InputAdornment,- InputLabel,- MenuItem,- Select,Stack,TextField,Tooltip,@@ -32,18 +28,8 @@ 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";-type BoardPreset = "5x3" | "7x5" | "custom";--interface BoardPresetConfig {- xSquares: number;- ySquares: number;-}--const BOARD_PRESETS: Record<Exclude<BoardPreset, "custom">, BoardPresetConfig> = {- "5x3": {xSquares: 5, ySquares: 3},- "7x5": {xSquares: 7, ySquares: 5},-};export const CalibrationControlPanel: React.FC = () => {const theme = useTheme();@@ -52,7 +38,6 @@ export const CalibrationControlPanel: React.FC = () => {const {api} = useElectronIPC();const {- config,error,isLoading,isRecording,@@ -62,7 +47,6 @@ export const CalibrationControlPanel: React.FC = () => {calibrationRecordingPath,directoryInfo,isUsingManualPath,- updateCalibrationConfig,dispatchStopCalibrationRecording,dispatchStartCalibrationRecording,setManualRecordingPath,@@ -78,55 +62,11 @@ export const CalibrationControlPanel: React.FC = () => {}}, [calibrationRecordingPath, validateDirectory]);- const currentPreset = useMemo<BoardPreset>(() => {- for (const [preset, presetConfig] of Object.entries(BOARD_PRESETS)) {- if (- presetConfig.xSquares === config.charucoBoardXSquares &&- presetConfig.ySquares === config.charucoBoardYSquares- ) {- return preset as BoardPreset;- }- }- return "custom";- }, [config.charucoBoardXSquares, config.charucoBoardYSquares]);-const handleClearError = useCallback((): void => {clearError();setLocalError(null);}, [clearError]);- const handlePresetChange = useCallback(- (preset: BoardPreset): void => {- if (preset === "custom") return;- const presetConfig = BOARD_PRESETS[preset];- updateCalibrationConfig({- charucoBoardXSquares: presetConfig.xSquares,- charucoBoardYSquares: presetConfig.ySquares,- });- },- [updateCalibrationConfig]- );-- const handleXSquaresChange = useCallback(- (value: string): void => {- const numValue = parseInt(value, 10);- if (!isNaN(numValue) && numValue > 0) {- updateCalibrationConfig({charucoBoardXSquares: numValue});- }- },- [updateCalibrationConfig]- );-- const handleYSquaresChange = useCallback(- (value: string): void => {- const numValue = parseInt(value, 10);- if (!isNaN(numValue) && numValue > 0) {- updateCalibrationConfig({charucoBoardYSquares: numValue});- }- },- [updateCalibrationConfig]- );-const handleSelectDirectory = async (): Promise<void> => {if (!api) {console.warn("Electron API not available");@@ -459,62 +399,8 @@ export const CalibrationControlPanel: React.FC = () => {isRefreshing={isRefreshing}/>- {/* Board Size Configuration */}- <Stack direction="row" spacing={2}>- <FormControl size="small" sx={{minWidth: 140}}>- <InputLabel id="board-preset-label">Preset</InputLabel>- <Select- labelId="board-preset-label"- value={currentPreset}- label="Preset"- onChange={(e) =>- handlePresetChange(e.target.value as BoardPreset)- }- disabled={isLoading}- sx={{color: theme.palette.text.primary}}- >- <MenuItem value="5x3">5Γ3</MenuItem>- <MenuItem value="7x5">7Γ5</MenuItem>- <MenuItem value="custom">Custom</MenuItem>- </Select>- </FormControl>- <TextField- label="X Squares"- type="number"- value={config.charucoBoardXSquares}- onChange={(e) => handleXSquaresChange(e.target.value)}- disabled={isLoading}- size="small"- sx={{flex: 1}}- inputProps={{min: 2, max: 20}}- />- <TextField- label="Y Squares"- type="number"- value={config.charucoBoardYSquares}- onChange={(e) => handleYSquaresChange(e.target.value)}- disabled={isLoading}- size="small"- sx={{flex: 1}}- inputProps={{min: 2, max: 20}}- />- </Stack>-- {/* Square Length */}- <TextField- label="Square Length (mm)"- type="number"- value={config.charucoSquareLength}- onChange={(e) =>- updateCalibrationConfig({- charucoSquareLength: parseFloat(e.target.value) || 0,- })- }- disabled={isLoading}- size="small"- fullWidth- inputProps={{min: 1, step: 0.1}}- />+ {/* Charuco Board Configuration */}+ <CharucoBoardConfigSection />{/* Solver Method & Groundplane */}<CalibrationSolverSection />diff --git a/freemocap-ui/src/components/control-panels/post-processing-panel/CalibrationSubsection.tsx b/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationPanel.tsxsimilarity index 64%rename from freemocap-ui/src/components/control-panels/post-processing-panel/CalibrationSubsection.tsxrename to freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationPanel.tsxindex febab5ec..567c9bd5 100644--- a/freemocap-ui/src/components/control-panels/post-processing-panel/CalibrationSubsection.tsx+++ b/freemocap-ui/src/components/control-panels/calibration-control-panel/CalibrationPanel.tsx@@ -1,27 +1,17 @@import React, {useCallback, useMemo, useState} from "react";import {- Accordion,- AccordionDetails,- AccordionSummary,Alert,Box,Button,- Checkbox,Chip,- FormControl,- FormControlLabel,IconButton,InputAdornment,- InputLabel,- MenuItem,- Select,Stack,TextField,Tooltip,Typography,useTheme,} from "@mui/material";-import ExpandMoreIcon from "@mui/icons-material/ExpandMore";import SquareFootIcon from "@mui/icons-material/SquareFoot";import PlayArrowIcon from "@mui/icons-material/PlayArrow";import StopIcon from "@mui/icons-material/Stop";@@ -33,26 +23,15 @@ import {useCalibration} from "@/hooks/useCalibration";import {useDirectoryWatcher} from "@/hooks/useDirectoryWatcher";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";-type BoardPreset = "5x3" | "7x5" | "custom";--interface BoardPresetConfig {- xSquares: number;- ySquares: number;-}--const BOARD_PRESETS: Record<Exclude<BoardPreset, "custom">, BoardPresetConfig> = {- "5x3": {xSquares: 5, ySquares: 3},- "7x5": {xSquares: 7, ySquares: 5},-};--export const CalibrationSubsection: React.FC = () => {+export const CalibrationPanel: React.FC = () => {const theme = useTheme();const [localError, setLocalError] = useState<string | null>(null);const {api} = useElectronIPC();const {- config,error,isLoading,isRecording,@@ -62,7 +41,6 @@ export const CalibrationSubsection: React.FC = () => {calibrationRecordingPath,directoryInfo,isUsingManualPath,- updateCalibrationConfig,dispatchStopCalibrationRecording,dispatchStartCalibrationRecording,setManualRecordingPath,@@ -79,35 +57,11 @@ export const CalibrationSubsection: React.FC = () => {3000,);- const currentPreset = useMemo<BoardPreset>(() => {- for (const [preset, presetConfig] of Object.entries(BOARD_PRESETS)) {- if (- presetConfig.xSquares === config.charucoBoardXSquares &&- presetConfig.ySquares === config.charucoBoardYSquares- ) {- return preset as BoardPreset;- }- }- return "custom";- }, [config.charucoBoardXSquares, config.charucoBoardYSquares]);-const handleClearError = useCallback((): void => {clearError();setLocalError(null);}, [clearError]);- const handlePresetChange = useCallback(- (preset: BoardPreset): void => {- if (preset === "custom") return;- const presetConfig = BOARD_PRESETS[preset];- updateCalibrationConfig({- charucoBoardXSquares: presetConfig.xSquares,- charucoBoardYSquares: presetConfig.ySquares,- });- },- [updateCalibrationConfig],- );-const handleSelectDirectory = async (): Promise<void> => {if (!api) return;try {@@ -163,34 +117,25 @@ export const CalibrationSubsection: React.FC = () => {: theme.palette.grey[600];return (- <Accordion defaultExpanded={false} disableGutters>- <AccordionSummary- expandIcon={<ExpandMoreIcon />}+ <CollapsibleSidebarSection+ icon={<SquareFootIcon sx={{color: "inherit"}}/>}+ title="Capture Volume Calibration"+ summaryContent={<Chip+ label={statusLabel}+ size="small"sx={{- minHeight: 40,- "& .MuiAccordionSummary-content": {- alignItems: "center",- gap: 1,- my: 0.5,- },+ ml: "auto",+ height: 20,+ fontSize: 11,+ fontWeight: 600,+ backgroundColor: statusColor,+ color: theme.palette.getContrastText(statusColor),}}- >- <SquareFootIcon fontSize="small" sx={{color: theme.palette.text.secondary}} />- <Typography variant="subtitle2">Capture Volume Calibration</Typography>- <Chip- label={statusLabel}- size="small"- sx={{- ml: "auto",- height: 20,- fontSize: 11,- fontWeight: 600,- backgroundColor: statusColor,- color: theme.palette.getContrastText(statusColor),- }}- />- </AccordionSummary>- <AccordionDetails sx={{p: 2}}>+ />}+ defaultExpanded={false}+ >+ <Box sx={{p: 2}}>+<Stack spacing={2}>{displayError && (<Alert severity="error" onClose={handleClearError}>@@ -216,7 +161,7 @@ export const CalibrationSubsection: React.FC = () => {<Buttonvariant="contained"color="primary"- startIcon={<PlayArrowIcon />}+ startIcon={<PlayArrowIcon/>}onClick={dispatchStartCalibrationRecording}disabled={!canStartRecording || isLoading}fullWidth@@ -227,7 +172,7 @@ export const CalibrationSubsection: React.FC = () => {<Buttonvariant="contained"color="error"- startIcon={<StopIcon />}+ startIcon={<StopIcon/>}onClick={dispatchStopCalibrationRecording}disabled={isLoading}fullWidth@@ -251,7 +196,7 @@ export const CalibrationSubsection: React.FC = () => {{isUsingManualPath && (<Tooltip title="Clear manual path (revert to default)"><IconButton onClick={clearManualRecordingPath} edge="end" size="small">- <ClearIcon fontSize="small" />+ <ClearIcon fontSize="small"/></IconButton></Tooltip>)}@@ -263,13 +208,13 @@ export const CalibrationSubsection: React.FC = () => {size="small"disabled={!calibrationRecordingPath || isLoading}>- <RefreshIcon fontSize="small" />+ <RefreshIcon fontSize="small"/></IconButton></span></Tooltip><Tooltip title="Select directory"><IconButton onClick={handleSelectDirectory} edge="end">- <FolderOpenIcon />+ <FolderOpenIcon/></IconButton></Tooltip></InputAdornment>@@ -299,64 +244,9 @@ export const CalibrationSubsection: React.FC = () => {isRefreshing={false}/>- {/* Board Size Configuration */}- <Stack direction="row" spacing={2}>- <FormControl size="small" sx={{minWidth: 140}}>- <InputLabel id="board-preset-label">Preset</InputLabel>- <Select- labelId="board-preset-label"- value={currentPreset}- label="Preset"- onChange={(e) => handlePresetChange(e.target.value as BoardPreset)}- disabled={isLoading}- >- <MenuItem value="5x3">5Γ3</MenuItem>- <MenuItem value="7x5">7Γ5</MenuItem>- <MenuItem value="custom">Custom</MenuItem>- </Select>- </FormControl>- <TextField- label="X Squares"- type="number"- value={config.charucoBoardXSquares}- onChange={(e) => {- const v = parseInt(e.target.value, 10);- if (!isNaN(v) && v > 0) updateCalibrationConfig({charucoBoardXSquares: v});- }}- disabled={isLoading}- size="small"- sx={{flex: 1}}- inputProps={{min: 2, max: 20}}- />- <TextField- label="Y Squares"- type="number"- value={config.charucoBoardYSquares}- onChange={(e) => {- const v = parseInt(e.target.value, 10);- if (!isNaN(v) && v > 0) updateCalibrationConfig({charucoBoardYSquares: v});- }}- disabled={isLoading}- size="small"- sx={{flex: 1}}- inputProps={{min: 2, max: 20}}- />- </Stack>-- <TextField- label="Square Length (mm)"- type="number"- value={config.charucoSquareLength}- onChange={(e) =>- updateCalibrationConfig({charucoSquareLength: parseFloat(e.target.value) || 0})- }- disabled={isLoading}- size="small"- fullWidth- inputProps={{min: 1, step: 0.1}}- />+ <CharucoBoardConfigSection />- <CalibrationSolverSection />+ <CalibrationSolverSection/>{isRecording && (<Box sx={{width: "100%"}}>@@ -386,7 +276,8 @@ export const CalibrationSubsection: React.FC = () => {</Stack>- </AccordionDetails>- </Accordion>- );+ </Box>+ </CollapsibleSidebarSection>+ )+ ;};diff --git a/freemocap-ui/src/components/control-panels/calibration-control-panel/CharucoBoardConfigSection.tsx b/freemocap-ui/src/components/control-panels/calibration-control-panel/CharucoBoardConfigSection.tsxnew file mode 100644index 00000000..e8efe161--- /dev/null+++ b/freemocap-ui/src/components/control-panels/calibration-control-panel/CharucoBoardConfigSection.tsx@@ -0,0 +1,119 @@+import React, {useCallback, useMemo} from "react";+import {+ FormControl,+ InputLabel,+ MenuItem,+ Select,+ Stack,+ TextField,+ Typography,+ useTheme,+} from "@mui/material";+import {useCalibration} from "@/hooks/useCalibration";++type BoardPreset = "5x3" | "7x5" | "custom";++interface BoardPresetConfig {+ squares_x: number;+ squares_y: number;+}++const BOARD_PRESETS: Record<Exclude<BoardPreset, "custom">, BoardPresetConfig> = {+ "5x3": {squares_x: 5, squares_y: 3},+ "7x5": {squares_x: 7, squares_y: 5},+};++export const CharucoBoardConfigSection: React.FC = () => {+ const theme = useTheme();+ const {config, updateCalibrationConfig, isLoading} = useCalibration();+ const board = config.charucoBoard;++ const currentPreset = useMemo<BoardPreset>(() => {+ for (const [preset, presetConfig] of Object.entries(BOARD_PRESETS)) {+ if (presetConfig.squares_x === board.squares_x && presetConfig.squares_y === board.squares_y) {+ return preset as BoardPreset;+ }+ }+ return "custom";+ }, [board.squares_x, board.squares_y]);++ const handlePresetChange = useCallback(+ (preset: BoardPreset): void => {+ if (preset === "custom") return;+ const presetConfig = BOARD_PRESETS[preset];+ updateCalibrationConfig({+ charucoBoard: {...board, ...presetConfig},+ });+ },+ [board, updateCalibrationConfig],+ );++ return (+ <Stack spacing={2} sx={{p:2}}>+ <Typography variant="subtitle2" sx={{color: theme.palette.text.secondary, fontWeight: 600}}>+ Charuco Board+ </Typography>++ {/* Preset */}+ <FormControl size="small" sx={{minWidth: 140}}>+ <InputLabel id="board-preset-label">Preset</InputLabel>+ <Select+ labelId="board-preset-label"+ value={currentPreset}+ label="Preset"+ onChange={(e) => handlePresetChange(e.target.value as BoardPreset)}+ disabled={isLoading}+ >+ <MenuItem value="5x3">5Γ3</MenuItem>+ <MenuItem value="7x5">7Γ5</MenuItem>+ <MenuItem value="custom">Custom</MenuItem>+ </Select>+ </FormControl>++ {/* X / Y Squares */}+ <Stack direction="row" spacing={2}>+ <TextField+ label="X Squares"+ type="number"+ value={board.squares_x}+ onChange={(e) => {+ const v = parseInt(e.target.value, 10);+ if (!isNaN(v) && v > 0) updateCalibrationConfig({charucoBoard: {...board, squares_x: v}});+ }}+ disabled={isLoading}+ size="small"+ sx={{flex: 1}}+ inputProps={{min: 2, max: 20}}+ />+ <TextField+ label="Y Squares"+ type="number"+ value={board.squares_y}+ onChange={(e) => {+ const v = parseInt(e.target.value, 10);+ if (!isNaN(v) && v > 0) updateCalibrationConfig({charucoBoard: {...board, squares_y: v}});+ }}+ disabled={isLoading}+ size="small"+ sx={{flex: 1}}+ inputProps={{min: 2, max: 20}}+ />+ </Stack>++ {/* Square Length */}+ <TextField+ label="Square Length (mm)"+ type="number"+ value={board.square_length_mm}+ onChange={(e) => {+ const v = parseFloat(e.target.value);+ if (!isNaN(v) && v > 0) updateCalibrationConfig({charucoBoard: {...board, square_length_mm: v}});+ }}+ disabled={isLoading}+ size="small"+ fullWidth+ inputProps={{min: 1, step: 0.1}}+ />+ </Stack>+ );+};diff --git a/freemocap-ui/src/components/control-panels/post-processing-panel/MocapSubsection.tsx b/freemocap-ui/src/components/control-panels/mocap-control-panel/MocapPanel.tsxsimilarity index 93%rename from freemocap-ui/src/components/control-panels/post-processing-panel/MocapSubsection.tsxrename to freemocap-ui/src/components/control-panels/mocap-control-panel/MocapPanel.tsxindex 3bedc7a2..c083f46f 100644--- a/freemocap-ui/src/components/control-panels/post-processing-panel/MocapSubsection.tsx+++ b/freemocap-ui/src/components/control-panels/mocap-control-panel/MocapPanel.tsx@@ -30,8 +30,10 @@ import {useElectronIPC} from "@/services";import {CalibrationTomlPicker} from "@/components/common/CalibrationTomlPicker";import {RealtimePipelineConfigTree} from "@/components/control-panels/realtime-panel/RealtimePipelineConfigTree";import {useServer} from "@/services/server/ServerContextProvider";+import SquareFootIcon from "@mui/icons-material/SquareFoot";+import {CollapsibleSidebarSection} from "@/components/common/CollapsibleSidebarSection";-export const MocapSubsection: React.FC = () => {+export const MocapPanel: React.FC = () => {const theme = useTheme();const {setOverlayVisibility} = useServer();const [localError, setLocalError] = useState<string | null>(null);@@ -191,34 +193,25 @@ export const MocapSubsection: React.FC = () => {: theme.palette.grey[600];return (- <Accordion defaultExpanded={false} disableGutters>- <AccordionSummary- expandIcon={<ExpandMoreIcon />}+ <CollapsibleSidebarSection+ icon={<DirectionsRunIcon sx={{color: "inherit"}}/>}+ title="Motion Capture"+ summaryContent={<Chip+ label={statusLabel}+ size="small"sx={{- minHeight: 40,- "& .MuiAccordionSummary-content": {- alignItems: "center",- gap: 1,- my: 0.5,- },+ ml: "auto",+ height: 20,+ fontSize: 11,+ fontWeight: 600,+ backgroundColor: statusColor,+ color: theme.palette.getContrastText(statusColor),}}- >- <DirectionsRunIcon fontSize="small" sx={{color: theme.palette.text.secondary}} />- <Typography variant="subtitle2">Motion Capture</Typography>- <Chip- label={statusLabel}- size="small"- sx={{- ml: "auto",- height: 20,- fontSize: 11,- fontWeight: 600,- backgroundColor: statusColor,- color: theme.palette.getContrastText(statusColor),- }}- />- </AccordionSummary>- <AccordionDetails sx={{p: 2}}>+ />}+ defaultExpanded={false}+ >++ <Box sx={{p: 2}}><Stack spacing={2}>{/* Process button at TOP per requirements */}<Button@@ -411,7 +404,7 @@ export const MocapSubsection: React.FC = () => {onRigidBodyToggle={setRigidBodyEnabled}/></Stack>- </AccordionDetails>- </Accordion>+ </Box>+ </CollapsibleSidebarSection>);};diff --git a/freemocap-ui/src/components/control-panels/post-processing-panel/PostProcessingPanel.tsx b/freemocap-ui/src/components/control-panels/post-processing-panel/PostProcessingPanel.tsxdeleted file mode 100644index 75992882..00000000--- a/freemocap-ui/src/components/control-panels/post-processing-panel/PostProcessingPanel.tsx+++ /dev/null@@ -1,21 +0,0 @@-import React from "react";-import {Box} from "@mui/material";-import BuildIcon from "@mui/icons-material/Build";-import {CollapsibleSidebarSection} from "@/components/common/CollapsibleSidebarSection";-import {CalibrationSubsection} from "@/components/control-panels/post-processing-panel/CalibrationSubsection";-import {MocapSubsection} from "@/components/control-panels/post-processing-panel/MocapSubsection";--export const PostProcessingPanel: React.FC = () => {- return (- <CollapsibleSidebarSection- icon={<BuildIcon sx={{color: "inherit"}} />}- title="Post Processing"- defaultExpanded={false}- >- <Box sx={{p: 1}}>- <CalibrationSubsection />- <MocapSubsection />- </Box>- </CollapsibleSidebarSection>- );-};diff --git a/freemocap-ui/src/components/tabbed-bottom-panel/TabbedBottomLeftPanel.tsx b/freemocap-ui/src/components/tabbed-bottom-panel/TabbedBottomLeftPanel.tsxindex d75c165f..654de4f1 100644--- a/freemocap-ui/src/components/tabbed-bottom-panel/TabbedBottomLeftPanel.tsx+++ b/freemocap-ui/src/components/tabbed-bottom-panel/TabbedBottomLeftPanel.tsx@@ -1,30 +1,12 @@-import {useState} from 'react';-import Box from '@mui/material/Box';-import Tabs from '@mui/material/Tabs';-import Tab from '@mui/material/Tab';import FramerateViewerPanel from '@/components/framerate-viewer/FrameRateViewer';import PipelineProgressPanel from '@/components/pipeline-progress/PipelineProgressPanel';+import {TabbedContent} from '@/components/ui-components/TabbedContent';export default function TabbedBottomLeftPanel() {- const [tab, setTab] = useState(0);-return (- <Box sx={{height: '100%', display: 'flex', flexDirection: 'column'}}>- <Tabs- value={tab}- onChange={(_, v) => setTab(v)}- sx={{minHeight: 28, '& .MuiTab-root': {minHeight: 28, py: 0, fontSize: '0.75rem'}}}- >- <Tab label="Framerate"/>- <Tab label="Pipelines"/>- </Tabs>- {/* Keep both mounted so framerate charts don't reset */}- <Box sx={{flex: 1, overflow: 'hidden', display: tab === 0 ? 'block' : 'none'}}>- <FramerateViewerPanel/>- </Box>- <Box sx={{flex: 1, overflow: 'hidden', display: tab === 1 ? 'block' : 'none'}}>- <PipelineProgressPanel/>- </Box>- </Box>+ <TabbedContent tabs={[+ {label: 'Framerate', content: <FramerateViewerPanel/>},+ {label: 'Pipelines', content: <PipelineProgressPanel/>},+ ]}/>);}diff --git a/freemocap-ui/src/components/ui-components/PageTabButtons.tsx b/freemocap-ui/src/components/ui-components/PageTabButtons.tsxindex 5498a710..dde42dfc 100644--- a/freemocap-ui/src/components/ui-components/PageTabButtons.tsx+++ b/freemocap-ui/src/components/ui-components/PageTabButtons.tsx@@ -1,88 +1,42 @@-import {useAppDispatch} from "@/store";-import {useTheme} from "@mui/material/styles";-import {useTranslation} from "react-i18next";-import {Box, Button} from "@mui/material";-import VideocamIcon from "@mui/icons-material/Videocam";-import SlideshowIcon from '@mui/icons-material/Slideshow';-import {useNavigate} from "react-router-dom";+import {useLocation, useNavigate} from "react-router-dom";+import {StreamingViewPage} from "@/pages/StreamingViewPage";+import PlaybackPage from "@/pages/PlaybackPage";+import {TabbedContent} from "@/components/ui-components/TabbedContent";+import {useCallback, useMemo} from "react";+import Box from "@mui/material/Box";++const PAGE_TABS = [+ {path: '/streaming', label: 'Streaming'},+ {path: '/playback', label: 'Playback'},+] as const;export const PageTabButtons = () => {- const theme = useTheme();+ const location = useLocation();const navigate = useNavigate();- const {t} = useTranslation();+ const isTabRoute = PAGE_TABS.some(t => location.pathname === t.path);++ const activeTab = useMemo(() => {+ const idx = PAGE_TABS.findIndex(t => location.pathname === t.path);+ return idx >= 0 ? idx : 0;+ }, [location.pathname]);++ const handleTabChange = useCallback((index: number) => {+ navigate(PAGE_TABS[index].path);+ }, [navigate]);++ const tabs = useMemo(() => [+ {label: PAGE_TABS[0].label, content: <StreamingViewPage/>},+ {label: PAGE_TABS[1].label, content: <PlaybackPage/>},+ ], []);return (- <Box sx={{- display: 'flex',- gap: 0.5,- px: 0.75,- py: 0.75,- borderBottom: theme.palette.mode === 'dark'- ? '1px solid rgba(255,255,255,0.08)'- : '1px solid rgba(0,0,0,0.08)',- }}>- <Button- variant={location.pathname === '/cameras' ? 'contained' : 'outlined'}- size="small"- startIcon={<VideocamIcon sx={{fontSize: 16}}/>}- onClick={() => navigate('/cameras')}- fullWidth- sx={{- textTransform: 'none',- fontWeight: 600,- fontSize: '0.8rem',- py: 0.75,- ...(location.pathname === '/cameras' ? {- backgroundColor: theme.palette.success.main,- color: '#fff',- '&:hover': {backgroundColor: theme.palette.success.dark},- } : {- borderColor: theme.palette.divider,- color: theme.palette.text.secondary,- '&:hover': {- borderColor: theme.palette.success.main,- color: theme.palette.success.main,- backgroundColor: theme.palette.mode === 'dark'- ? 'rgba(76,175,80,0.08)'- : 'rgba(76,175,80,0.04)',- },- }),- }}- >- Streaming- </Button>- <Button- variant={location.pathname === '/playback' ? 'contained' : 'outlined'}- size="small"- startIcon={<SlideshowIcon sx={{fontSize: 16}}/>}- onClick={() => navigate('/playback')}- fullWidth- sx={{- textTransform: 'none',- fontWeight: 600,- fontSize: '0.8rem',- py: 0.75,- ...(location.pathname === '/playback' ? {- backgroundColor: theme.palette.info.main,- color: '#fff',- '&:hover': {backgroundColor: theme.palette.info.dark},- } : {- borderColor: theme.palette.divider,- color: theme.palette.text.secondary,- '&:hover': {- borderColor: theme.palette.info.main,- color: theme.palette.info.main,- backgroundColor: theme.palette.mode === 'dark'- ? 'rgba(41,182,246,0.08)'- : 'rgba(41,182,246,0.04)',- },- }),- }}- >- {t('videoPlayback')}- </Button>+ <Box sx={{display: isTabRoute ? 'flex' : 'none', flexDirection: 'column', height: '100%'}}>+ <TabbedContent+ tabs={tabs}+ activeTab={activeTab}+ onTabChange={handleTabChange}+ /></Box>-- )-}+ );+};diff --git a/freemocap-ui/src/components/ui-components/SettingsOverlay.tsx b/freemocap-ui/src/components/ui-components/SettingsOverlay.tsxindex 06aece49..4e3007d0 100644--- a/freemocap-ui/src/components/ui-components/SettingsOverlay.tsx+++ b/freemocap-ui/src/components/ui-components/SettingsOverlay.tsx@@ -20,7 +20,7 @@ import SplitscreenIcon from '@mui/icons-material/Splitscreen';import ViewAgendaIcon from '@mui/icons-material/ViewAgenda';import {useServer} from '@/services/server/ServerContextProvider';import {useTranslation} from 'react-i18next';-import type {CameraSettings, LayoutDirection} from '@/pages/ViewportPage';+import type {CameraSettings, LayoutDirection} from '@/pages/StreamingViewPage';interface SettingsOverlayProps {settings: CameraSettings;diff --git a/freemocap-ui/src/components/ui-components/TabbedContent.tsx b/freemocap-ui/src/components/ui-components/TabbedContent.tsxnew file mode 100644index 00000000..93a738d0--- /dev/null+++ b/freemocap-ui/src/components/ui-components/TabbedContent.tsx@@ -0,0 +1,56 @@+import React, {useState} from 'react';+import Box from '@mui/material/Box';+import Tabs from '@mui/material/Tabs';+import Tab from '@mui/material/Tab';+import type {SxProps, Theme} from '@mui/material/styles';++export interface TabDef {+ label: string;+ content: React.ReactNode;+}++interface TabbedContentProps {+ tabs: TabDef[];+ activeTab?: number;+ onTabChange?: (index: number) => void;+ tabsSx?: SxProps<Theme>;+}++/**+ * Generic tabbed content container.+ * All tab panels stay mounted β only visibility is toggled (display block/none).+ * Can be controlled (activeTab + onTabChange) or uncontrolled (internal state).+ */+export function TabbedContent({tabs, activeTab, onTabChange, tabsSx}: TabbedContentProps) {+ const [internalTab, setInternalTab] = useState(0);+ const controlled = activeTab !== undefined;+ const currentTab = controlled ? activeTab : internalTab;++ const handleChange = (_: React.SyntheticEvent, value: number) => {+ if (onTabChange) onTabChange(value);+ if (!controlled) setInternalTab(value);+ };++ return (+ <Box sx={{height: '100%', display: 'flex', flexDirection: 'column'}}>+ <Tabs+ value={currentTab}+ onChange={handleChange}+ sx={{+ minHeight: 28,+ '& .MuiTab-root': {minHeight: 28, py: 0, fontSize: '0.75rem'},+ ...tabsSx as any,+ }}+ >+ {tabs.map((t, i) => (+ <Tab key={i} label={t.label}/>+ ))}+ </Tabs>+ {tabs.map((t, i) => (+ <Box key={i} sx={{flex: 1, overflow: 'hidden', display: currentTab === i ? 'block' : 'none'}}>+ {t.content}+ </Box>+ ))}+ </Box>+ );+}diff --git a/freemocap-ui/src/layout/BasePanelLayout.tsx b/freemocap-ui/src/layout/BasePanelLayout.tsxindex fb2eb74b..e89773f7 100644--- a/freemocap-ui/src/layout/BasePanelLayout.tsx+++ b/freemocap-ui/src/layout/BasePanelLayout.tsx@@ -8,8 +8,10 @@ import {Box} from "@mui/material";import {useMenuActions} from "@/hooks/useMenuActions";import {useKeyboardShortcuts} from "@/hooks/useKeyboardShortcuts";import {RecordingCompleteDialog} from "@/components/control-panels/recording-info-panel/RecordingCompleteDialog";+import {PageTabButtons} from "@/components/ui-components/PageTabButtons";-export const BasePanelLayout = ({children}: { children: React.ReactNode }) => {++export const BasePanelLayout = ({children}: { children?: React.ReactNode }) => {const theme = useTheme();const leftPanelRef = useRef<ImperativePanelHandle>(null);const [isCollapsed, setIsCollapsed] = useState(false);@@ -73,6 +75,7 @@ export const BasePanelLayout = ({children}: { children: React.ReactNode }) => {{/* Main/Central Content Panel */}<Panel defaultSize={76} minSize={10}>+ <PageTabButtons/>{children}<RecordingCompleteDialog /></Panel>diff --git a/freemocap-ui/src/layout/content/BaseContentRouter.tsx b/freemocap-ui/src/layout/content/BaseContentRouter.tsxindex e1139f68..75f01c22 100644--- a/freemocap-ui/src/layout/content/BaseContentRouter.tsx+++ b/freemocap-ui/src/layout/content/BaseContentRouter.tsx@@ -1,15 +1,14 @@import React from 'react';import {Navigate, Route, Routes} from 'react-router-dom';-import {ViewportPage} from "@/pages/ViewportPage";-import PlaybackPage from "@/pages/PlaybackPage";import WelcomePage from "@/pages/WelcomePage";export const BaseContentRouter: React.FC = () => {return (<Routes>- <Route path="/" element={<WelcomePage />} />- <Route path="/playback" element={<PlaybackPage/>}/>- <Route path="/viewport" element={<ViewportPage />} />+ <Route path="/" element={<WelcomePage/>}/>+ {/* /streaming and /playback are handled by PageTabButtons (keep-mounted tabs) */}+ <Route path="/streaming" element={null}/>+ <Route path="/playback" element={null}/><Route path="*" element={<Navigate to="/" replace/>}/></Routes>);diff --git a/freemocap-ui/src/layout/content/SidePanelContent.tsx b/freemocap-ui/src/layout/content/SidePanelContent.tsxindex 5088d93f..3a8f661a 100644--- a/freemocap-ui/src/layout/content/SidePanelContent.tsx+++ b/freemocap-ui/src/layout/content/SidePanelContent.tsx@@ -23,9 +23,10 @@ import {CameraConfigTreeView} from '@/components/control-panels/camera-config-panel/camera-config-tree-view/CameraConfigTreeView';import {RecordingInfoPanel} from "@/components/control-panels/recording-info-panel/RecordingInfoPanel";-import {PostProcessingPanel} from "@/components/control-panels/post-processing-panel/PostProcessingPanel";import {RealtimePipelinePanel} from "@/components/control-panels/realtime-panel/RealtimePipelinePanel";import {PageTabButtons} from "@/components/ui-components/PageTabButtons";+import {MocapPanel} from "@/components/control-panels/mocap-control-panel/MocapPanel";+import {CalibrationPanel} from "@/components/control-panels/calibration-control-panel/CalibrationPanel";const STORAGE_KEY = 'freemocap-sidebar-section-order';@@ -33,7 +34,8 @@ const DEFAULT_SECTION_ORDER = ['cameras','recording','realtime',- 'postprocessing',+ 'calibration',+ 'mocap',] as const;type SectionId = (typeof DEFAULT_SECTION_ORDER)[number];@@ -42,7 +44,8 @@ const SECTION_COMPONENTS: Record<SectionId, React.FC> = {realtime: RealtimePipelinePanel,cameras: CameraConfigTreeView,recording: RecordingInfoPanel,- postprocessing: PostProcessingPanel+ calibration: CalibrationPanel,+ mocap: MocapPanel,};function loadSectionOrder(): SectionId[] {@@ -236,7 +239,6 @@ export const SidePanelContent = () => {</ListItem></List><ServerConnectionStatus/>- <PageTabButtons/>{/* Sidebar Sections β drag-reorderable */}<DndContextdiff --git a/freemocap-ui/src/pages/PlaybackPage.tsx b/freemocap-ui/src/pages/PlaybackPage.tsxindex d770eb24..56e50cdf 100644--- a/freemocap-ui/src/pages/PlaybackPage.tsx+++ b/freemocap-ui/src/pages/PlaybackPage.tsx@@ -15,7 +15,7 @@ import {RecordingBrowser} from '@/components/playback/RecordingBrowser';import {useElectronIPC} from '@/services';import {useTranslation} from 'react-i18next';import {useLocation} from 'react-router-dom';-import type {CameraSettings} from '@/pages/ViewportPage';+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";diff --git a/freemocap-ui/src/pages/ViewportPage.tsx b/freemocap-ui/src/pages/StreamingViewPage.tsxsimilarity index 99%rename from freemocap-ui/src/pages/ViewportPage.tsxrename to freemocap-ui/src/pages/StreamingViewPage.tsxindex 5e1a2359..c5ccfed7 100644--- a/freemocap-ui/src/pages/ViewportPage.tsx+++ b/freemocap-ui/src/pages/StreamingViewPage.tsx@@ -18,7 +18,7 @@ export interface CameraSettings {layoutDirection: LayoutDirection;}-export const ViewportPage = () => {+export const StreamingViewPage = () => {const theme = useTheme();const [resetKey, setResetKey] = useState<number>(0);const [settings, setSettings] = useState<CameraSettings>({diff --git a/freemocap-ui/src/store/slices/calibration/calibration-slice.ts b/freemocap-ui/src/store/slices/calibration/calibration-slice.tsindex d31829c7..2122057b 100644--- a/freemocap-ui/src/store/slices/calibration/calibration-slice.ts+++ b/freemocap-ui/src/store/slices/calibration/calibration-slice.ts@@ -10,10 +10,14 @@ import {export type CalibrationSolverMethod = 'anipose' | 'pyceres';+export interface CharucoBoardConfig {+ squares_x: number;+ squares_y: number;+ square_length_mm: number;+}+export interface CalibrationConfig {- charucoBoardXSquares: number;- charucoBoardYSquares: number;- charucoSquareLength: number;+ charucoBoard: CharucoBoardConfig;minSharedViewsPerCamera: number;autoStopOnMinViewCount: boolean;solverMethod: CalibrationSolverMethod;@@ -46,9 +50,7 @@ export interface CalibrationState {const initialState: CalibrationState = {config: {- charucoBoardXSquares: 5,- charucoBoardYSquares: 3,- charucoSquareLength: 54,+ charucoBoard: { squares_x: 5, squares_y: 3, square_length_mm: 54 },minSharedViewsPerCamera: 200,autoStopOnMinViewCount: true,solverMethod: 'anipose',diff --git a/freemocap/api/websocket/websocket_server.py b/freemocap/api/websocket/websocket_server.pyindex 12069fc3..984325c5 100644--- a/freemocap/api/websocket/websocket_server.py+++ b/freemocap/api/websocket/websocket_server.py@@ -145,13 +145,13 @@ class WebsocketServer:continuetry:- packets = 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=self.last_sent_frame_number)except IndexError:logger.warning("Ring buffer overwrite β resetting to latest frame")self.last_sent_frame_number = -1continue- for packet in packets.values():+ for packet in packets:if packet.frontend_payload is not None:async with self._send_lock:await self.websocket.send_json(packet.frontend_payload.model_dump())@@ -181,6 +181,12 @@ class WebsocketServer:framerate_source="Display")self._display_framerate_trackers[packet.camera_group_id].update(time.perf_counter_ns())++ # Send posthoc pipeline progress updates+ for update_message in progress_updates:+ logger.trace(update_message.model_dump_json(indent=2))+ await self.websocket.send_json(update_message.model_dump())+# Send framerate updates from our local trackers (throttled to ~4Hz)now = time.monotonic()if now - self._last_framerate_send_time >= 0.25:diff --git a/freemocap/app/freemocap_application.py b/freemocap/app/freemocap_application.pyindex 33abee2f..6a581b16 100644--- a/freemocap/app/freemocap_application.py+++ b/freemocap/app/freemocap_application.py@@ -21,6 +21,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 PipelineProgressMessagelogger = logging.getLogger(__name__)@@ -54,6 +55,25 @@ class FreemocapApplication:@propertydef should_continue(self) -> bool:return not self.global_kill_flag.value+ # ------------------------------------------------------------------+ # Recording orchestration+ # ------------------------------------------------------------------++ async def start_recording_all(self, recording_info: RecordingInfo) -> None:+ await self.camera_group_manager.start_recording_all_groups(+ recording_info=recording_info,+ )++ async def stop_recording_all(self) -> RecordingInfo | None:+ recording_infos = await self.camera_group_manager.stop_recording_all_groups()+ if len(recording_infos) == 0:+ logger.warning("No recordings were stopped.")+ return None+ if len(recording_infos) > 1:+ raise NotImplementedError(+ "Stopping multiple recordings at once is not supported yet."+ )+ return recording_infos[0][0]# ------------------------------------------------------------------# Realtime pipeline operations@@ -104,25 +124,6 @@ class FreemocapApplication:)return pipeline- # ------------------------------------------------------------------- # Recording orchestration- # -------------------------------------------------------------------- async def start_recording_all(self, recording_info: RecordingInfo) -> None:- await self.camera_group_manager.start_recording_all_groups(- recording_info=recording_info,- )-- async def stop_recording_all(self) -> RecordingInfo | None:- recording_infos = await self.camera_group_manager.stop_recording_all_groups()- if len(recording_infos) == 0:- logger.warning("No recordings were stopped.")- return None- if len(recording_infos) > 1:- raise NotImplementedError(- "Stopping multiple recordings at once is not supported yet."- )- return recording_infos[0][0]# ------------------------------------------------------------------# Frontend payloads@@ -131,7 +132,7 @@ class FreemocapApplication:def get_latest_frontend_payloads(self,if_newer_than: FrameNumberInt,- ) -> dict[str, FrontendImagePacket]:+ ) ->tuple[list[FrontendImagePacket], list[PipelineProgressMessage]]:self.posthoc_pipeline_manager.evict_completed()realtime_pipelines = self.realtime_pipeline_manager.pipelines@@ -139,23 +140,27 @@ class FreemocapApplication:if not active_pipelines:# Camera-only path- result = {}+ results: list[FrontendImagePacket] = []for cg_id, payload in self.camera_group_manager.get_latest_frontend_payloads(if_newer_than=if_newer_than).items():frame_number, mf_timestamp, image_bytes = payload # unpack the known tuple shape- result[cg_id] = FrontendImagePacket(+ results.append(FrontendImagePacket(image_bytes=image_bytes,multiframe_timestamp=mf_timestamp,frontend_payload=FrontendPayload(camera_group_id=cg_id,frame_number=frame_number),- )- return result+ ))+ return results, []# Pipeline path β delegate to manager, which also returns FrontendImagePacket- return self.realtime_pipeline_manager.get_latest_frontend_payloads(+ 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+# ------------------------------------------------------------------# Lifecycle# ------------------------------------------------------------------diff --git a/freemocap/core/pipeline/posthoc/posthoc_aggregation_node.py b/freemocap/core/pipeline/posthoc/posthoc_aggregation_node.pyindex a6486263..9655151f 100644--- a/freemocap/core/pipeline/posthoc/posthoc_aggregation_node.py+++ b/freemocap/core/pipeline/posthoc/posthoc_aggregation_node.py@@ -30,12 +30,13 @@ from skellycam.core.types.type_overloads import TopicSubscriptionQueuefrom freemocap.core.pipeline.abcs.aggregator_node_abc import AggregatorNodefrom freemocap.core.pipeline.abcs.pipeline_ipc import PipelineIPCfrom freemocap.core.pipeline.posthoc.video_group_helper import VideoMetadata-from freemocap.core.types.type_overloads import PipelineIdString, FrameNumberInt, VideoIdString+from freemocap.core.types.type_overloads import PipelineIdString, FrameNumberInt, VideoIdString, TopicPublicationQueuefrom freemocap.pubsub.pubsub_manager import PubSubTopicManagerfrom freemocap.pubsub.pubsub_topics import (VideoNodeOutputMessage,VideoNodeOutputTopic,- PosthocProgressMessage,+ AggregatorNodeProgressTopic,+ AggregatorNodeProgressMessage, PipelineProgressMessage,)from freemocap.utilities.wait_functions import wait_1ms@@ -46,19 +47,19 @@ PosthocAggregationNodeTaskFn = Callable[..., None]@dataclassclass PosthocAggregationNode(AggregatorNode):+ progress_subscription: TopicSubscriptionQueue@classmethoddef create(- cls,- *,- aggregation_task_fn: PosthocAggregationNodeTaskFn,- video_metadata: dict[VideoIdString, VideoMetadata],- pipeline_id: PipelineIdString,- recording_info: RecordingInfo,- worker_registry: WorkerRegistry,- ipc: PipelineIPC,- pubsub: PubSubTopicManager,- progress_pub: Optional[multiprocessing.Queue] = None,+ cls,+ *,+ aggregation_task_fn: PosthocAggregationNodeTaskFn,+ video_metadata: dict[VideoIdString, VideoMetadata],+ pipeline_id: PipelineIdString,+ recording_info: RecordingInfo,+ worker_registry: WorkerRegistry,+ ipc: PipelineIPC,+ pubsub: PubSubTopicManager,) -> "PosthocAggregationNode":shutdown_self_flag, worker = cls._create_worker(target=cls._run,@@ -71,37 +72,35 @@ class PosthocAggregationNode(AggregatorNode):recording_info=recording_info,video_metadata=video_metadata,ipc=ipc,+ aggregator_progress_pub=pubsub.get_publication_queue(+ AggregatorNodeProgressTopic+ ),video_node_output_subscription=pubsub.get_subscription(VideoNodeOutputTopic,),- progress_pub=progress_pub,),+)return cls(shutdown_self_flag=shutdown_self_flag,+ progress_subscription=pubsub.get_subscription(+ AggregatorNodeProgressTopic,),worker=worker,)@staticmethoddef _run(- *,- aggregation_task_fn: PosthocAggregationNodeTaskFn,- pipeline_id: PipelineIdString,- recording_info: RecordingInfo,- video_metadata: dict[VideoIdString, VideoMetadata],- ipc: PipelineIPC,- shutdown_self_flag: multiprocessing.Value,- video_node_output_subscription: TopicSubscriptionQueue,- progress_pub: Optional[multiprocessing.Queue] = None,+ *,+ aggregation_task_fn: PosthocAggregationNodeTaskFn,+ pipeline_id: PipelineIdString,+ recording_info: RecordingInfo,+ video_metadata: dict[VideoIdString, VideoMetadata],+ ipc: PipelineIPC,+ shutdown_self_flag: multiprocessing.Value,+ video_node_output_subscription: TopicSubscriptionQueue,+ aggregator_progress_pub: TopicPublicationQueue,) -> None:- def _emit_progress(phase: str, progress_fraction: float, detail: str = "") -> None:- if progress_pub is not None:- progress_pub.put(PosthocProgressMessage(- pipeline_id=pipeline_id,- phase=phase,- progress_fraction=progress_fraction,- detail=detail,- ))+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:@@ -115,12 +114,14 @@ class PosthocAggregationNode(AggregatorNode):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)logger.debug(f"PosthocAggregationNode [{pipeline_id}] starting β "f"expecting {len(frame_numbers)} frames Γ {len(video_ids)} videos "f"= {total_expected} outputs")- _emit_progress("collecting_frames", 0.0, f"Collecting {total_expected} observations from {len(video_ids)} videos")video_outputs_by_frame: dict[FrameNumberInt, dict[VideoIdString, VideoNodeOutputMessage | None]] = {frame_number: {vid: None for vid in video_ids}@@ -153,8 +154,8 @@ class PosthocAggregationNode(AggregatorNode):received_count += 1if all(- isinstance(v, VideoNodeOutputMessage)- for v in video_outputs_by_frame[msg.frame_number].values()+ isinstance(v, VideoNodeOutputMessage)+ for v in video_outputs_by_frame[msg.frame_number].values()):got_all_by_frame[msg.frame_number] = True@@ -170,7 +171,6 @@ class PosthocAggregationNode(AggregatorNode):)logger.info(f"PosthocAggregationNode [{pipeline_id}] β all frames collected")- _emit_progress("all_frames_collected", 1.0, f"All {total_expected} observations collected")observations_by_frame: list[dict[VideoIdString, object]] = []for frame_number in frame_numbers:@@ -184,25 +184,38 @@ class PosthocAggregationNode(AggregatorNode):observations[vid_id] = output_msg.observationobservations_by_frame.append(observations)+ progress_message.running_aggregation_task = True+ aggregator_progress_pub.put(progress_message)+aggregation_task_fn(frame_observations=observations_by_frame,recording_info=recording_info,video_metadata=video_metadata,- report_progress=lambda detail, fraction: _emit_progress("processing", fraction, detail),+)+ progress_message.running_aggregation_task = False+ aggregator_progress_pub.put(progress_message)logger.info(f"PosthocAggregationNode [{pipeline_id}] β task completed")- _emit_progress("complete", 1.0, "Pipeline complete")except Exception as e:logger.error(f"Exception in PosthocAggregationNode [{pipeline_id}]: {e}",exc_info=True,)- _emit_progress("failed", 0.0, str(e))+ progress_message.error = True+ aggregator_progress_pub.put(progress_message)ipc.shutdown_pipeline()raisefinally:+ progress_message.complete = True+ aggregator_progress_pub.put(progress_message)logger.debug(f"PosthocAggregationNode [{pipeline_id}] exiting")++ def get_progress_messages(self) -> list[PipelineProgressMessage]:+ messages: list[AggregatorNodeProgressMessage] = []+ while not self.progress_subscription.empty():+ messages.append(self.progress_subscription.get())+ return messagesdiff --git a/freemocap/core/pipeline/posthoc/posthoc_pipeline.py b/freemocap/core/pipeline/posthoc/posthoc_pipeline.pyindex a3256f3a..755dad81 100644--- a/freemocap/core/pipeline/posthoc/posthoc_pipeline.py+++ b/freemocap/core/pipeline/posthoc/posthoc_pipeline.py@@ -28,6 +28,7 @@ from freemocap.core.pipeline.posthoc.video_group_helper import VideoGroupHelperfrom freemocap.core.pipeline.posthoc.video_node import VideoNodefrom freemocap.core.types.type_overloads import PipelineIdString, VideoIdStringfrom freemocap.pubsub.pubsub_manager import PubSubTopicManager+from freemocap.pubsub.pubsub_topics import PipelineProgressMessagelogger = logging.getLogger(__name__)@@ -70,7 +71,6 @@ class PosthocPipeline(PipelineABC):worker_registry: WorkerRegistry,global_kill_flag: multiprocessing.Value,save_annotated_video: bool = True,- progress_pub: Optional[multiprocessing.Queue] = None,) -> "PosthocPipeline":"""Create a posthoc pipeline.@@ -105,8 +105,6 @@ class PosthocPipeline(PipelineABC):video_nodes: dict[VideoIdString, VideoNode] = {}for video_id, video_helper in video_group.videos.items():- vm = video_group.video_metadata_by_id[video_id]- total_frame_count = vm.end_frame - vm.start_framevideo_nodes[video_id] = VideoNode.create(video_id=video_id,video_path=video_helper.video_path,@@ -117,8 +115,6 @@ class PosthocPipeline(PipelineABC):recording_path=recording_path,save_annotated_video=save_annotated_video,pipeline_id=pipeline_id,- total_frame_count=total_frame_count,- progress_pub=progress_pub,)aggregation_node = PosthocAggregationNode.create(@@ -129,7 +125,6 @@ class PosthocPipeline(PipelineABC):worker_registry=worker_registry,ipc=ipc,pubsub=pubsub,- progress_pub=progress_pub,)video_group.close()@@ -175,3 +170,10 @@ class PosthocPipeline(PipelineABC):if self.aggregation_node.is_alive:self.aggregation_node.shutdown()logger.debug(f"PosthocPipeline [{self.id}] shut down")++ def get_progress_messages(self) -> list[PipelineProgressMessage]:+ progress_messages: list[PipelineProgressMessage] = []+ for node in list(self.video_nodes.values()):+ progress_messages.append(node.get_progress_messages())+ progress_messages.append(self.aggregation_node.get_progress_messages())+ return progress_messagesdiff --git a/freemocap/core/pipeline/posthoc/posthoc_pipeline_manager.py b/freemocap/core/pipeline/posthoc/posthoc_pipeline_manager.pyindex ee245809..f83e9dde 100644--- a/freemocap/core/pipeline/posthoc/posthoc_pipeline_manager.py+++ b/freemocap/core/pipeline/posthoc/posthoc_pipeline_manager.py@@ -23,6 +23,7 @@ from freemocap.core.tasks.calibration.posthoc_calibration_task import run_posthofrom 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 PipelineProgressMessagelogger = logging.getLogger(__name__)@@ -41,7 +42,6 @@ class PosthocPipelineManager(PipelineManagerABC):worker_registry: WorkerRegistrylock: multiprocessing.Lock = field(default_factory=multiprocessing.Lock)pipelines: dict[PipelineIdString, PosthocPipeline] = field(default_factory=dict)- shared_progress_queue: multiprocessing.Queue = field(default_factory=multiprocessing.Queue)# ------------------------------------------------------------------# Lazy cleanup@@ -96,7 +96,6 @@ class PosthocPipelineManager(PipelineManagerABC):aggregation_task_fn=calibration_aggregation_task_fn,worker_registry=self.worker_registry,global_kill_flag=self.global_kill_flag,- progress_pub=self.shared_progress_queue,)pipeline.start()with self.lock:@@ -125,7 +124,6 @@ class PosthocPipelineManager(PipelineManagerABC):aggregation_task_fn=mocap_task_fn,worker_registry=self.worker_registry,global_kill_flag=self.global_kill_flag,- progress_pub=self.shared_progress_queue,)if start_pipeline:pipeline.start()@@ -154,3 +152,11 @@ class PosthocPipelineManager(PipelineManagerABC):pipeline.shutdown()self.pipelines.clear()logger.info("PosthocPipelineManager: all pipelines shut down")++ def get_progress_updates(self) -> list[PipelineProgressMessage]:+ progress_messages: list[PipelineProgressMessage] = []++ for pipeline in self.pipelines.values():+ progress_messages.extend(pipeline.get_progress_messages())++ return progress_messagesdiff --git a/freemocap/core/pipeline/posthoc/video_node.py b/freemocap/core/pipeline/posthoc/video_node.pyindex a476983d..d8be2974 100644--- a/freemocap/core/pipeline/posthoc/video_node.py+++ b/freemocap/core/pipeline/posthoc/video_node.py@@ -13,7 +13,6 @@ import loggingimport multiprocessingfrom dataclasses import dataclassfrom pathlib import Path-from typing import Optionalimport cv2from skellycam.core.ipc.process_management.worker_registry import WorkerRegistry@@ -22,9 +21,11 @@ from skellytracker.trackers.base_tracker.helpers import create_detector_from_confrom 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 freemocap.core.types.type_overloads import VideoIdString, TopicPublicationQueue, PipelineIdString, \+ TopicSubscriptionQueuefrom freemocap.pubsub.pubsub_manager import PubSubTopicManager-from freemocap.pubsub.pubsub_topics import VideoNodeOutputTopic, VideoNodeOutputMessage, PosthocProgressMessage+from freemocap.pubsub.pubsub_topics import VideoNodeOutputTopic, VideoNodeOutputMessage, VideoNodeProgressTopic, \+ VideoNodeProgressMessage, PipelineProgressMessagelogger = logging.getLogger(__name__)@@ -35,6 +36,7 @@ ANNOTATED_VIDEOS_FOLDER_NAME = "annotated_videos"class VideoNode(SourceNode):video_id: VideoIdStringvideo_path: Path+ progress_subscription: TopicSubscriptionQueue@classmethoddef create(@@ -49,8 +51,6 @@ class VideoNode(SourceNode):recording_path: Path,save_annotated_video: bool = True,pipeline_id: PipelineIdString | None = None,- total_frame_count: int = 0,- progress_pub: Optional[multiprocessing.Queue] = None,) -> "VideoNode":shutdown_self_flag, worker = cls._create_worker(target=cls._run,@@ -65,11 +65,12 @@ class VideoNode(SourceNode):video_output_pub=pubsub.get_publication_queue(VideoNodeOutputTopic,),+ video_progress_pub = pubsub.get_publication_queue(+ VideoNodeProgressTopic+ ),recording_path=recording_path,save_annotated_video=save_annotated_video,pipeline_id=pipeline_id,- total_frame_count=total_frame_count,- progress_pub=progress_pub,),)return cls(@@ -77,6 +78,7 @@ class VideoNode(SourceNode):video_path=video_path,shutdown_self_flag=shutdown_self_flag,worker=worker,+ progress_subscription=pubsub.get_publication_queue(VideoNodeOutputTopic))@staticmethod@@ -125,17 +127,21 @@ class VideoNode(SourceNode):detector_config: BaseDetectorConfig,ipc: PipelineIPC,video_output_pub: TopicPublicationQueue,+ video_progress_pub: TopicPublicationQueue,shutdown_self_flag: multiprocessing.Value,recording_path: Path,save_annotated_video: bool,- pipeline_id: PipelineIdString | None = None,- total_frame_count: int = 0,- progress_pub: Optional[multiprocessing.Queue] = None,+ pipeline_id: PipelineIdString,) -> None: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)# Set up annotation pipeline if requestedannotator = None@@ -143,6 +149,8 @@ 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(@@ -177,10 +185,10 @@ class VideoNode(SourceNode):f"VideoNode started for {video_path.stem}"f"{' (with annotation)' if save_annotated_video else ''}")+frame_number: int = 0- _PROGRESS_THRESHOLD = 0.05- last_reported_fraction: float = -1.0try:+success, image = video_reader.read()while success and not shutdown_self_flag.value and ipc.should_continue:observation = detector.detect(@@ -195,16 +203,8 @@ class VideoNode(SourceNode):),)- if progress_pub is not None and pipeline_id is not None and total_frame_count > 0:- fraction = frame_number / total_frame_count- if fraction - last_reported_fraction >= _PROGRESS_THRESHOLD:- progress_pub.put(PosthocProgressMessage(- pipeline_id=pipeline_id,- phase="detecting_frames",- progress_fraction=min(fraction, 1.0),- detail=f"{video_path.stem}: frame {frame_number}/{total_frame_count}",- ))- last_reported_fraction = fraction++# Annotate and write frame if enabledif annotator is not None and video_writer is not None:@@ -232,6 +232,7 @@ class VideoNode(SourceNode):success, image = video_reader.read()frame_number += 1+ video_progress_pub.put(progress_message.increment())logger.info(f"VideoNode for {video_path.stem} finished reading "@@ -242,10 +243,14 @@ class VideoNode(SourceNode):logger.exception(f"Exception in VideoNode for {video_path.stem}: {e}")+ progress_message.error = True+ video_progress_pub.put(progress_message)ipc.shutdown_pipeline()raisefinally:video_reader.release()+ progress_message.complete = True+ video_progress_pub.put(progress_message)if video_writer is not None:video_writer.release()if base_reader is not None:@@ -254,3 +259,9 @@ class VideoNode(SourceNode):if prev_annotated_path is not None and prev_annotated_path.exists():prev_annotated_path.unlink()logger.debug(f"VideoNode for {video_path.stem} exiting")++ def get_progress_messages(self) -> list[PipelineProgressMessage]:+ messages: list[VideoNodeProgressMessage] = []+ while not self.progress_subscription.empty():+ messages.append(self.progress_subscription.get())+ return messagesdiff --git a/freemocap/core/pipeline/realtime/realtime_pipeline_manager.py b/freemocap/core/pipeline/realtime/realtime_pipeline_manager.pyindex faac6a8f..89353780 100644--- a/freemocap/core/pipeline/realtime/realtime_pipeline_manager.py+++ b/freemocap/core/pipeline/realtime/realtime_pipeline_manager.py@@ -106,13 +106,13 @@ class RealtimePipelineManager(PipelineManagerABC):def get_latest_frontend_payloads(self,if_newer_than: FrameNumberInt,- ) -> dict[PipelineIdString, FrontendImagePacket]:- latest: dict[PipelineIdString, FrontendImagePacket] = {}+ ) -> list[FrontendImagePacket]:+ latest: list[FrontendImagePacket] = []with self.lock:for pipeline_id, pipeline in self.pipelines.items():packet = pipeline.get_latest_frontend_payload(if_newer_than=if_newer_than)if packet is not None:- latest[pipeline_id] = packet+ latest.append(packet)return latest# ------------------------------------------------------------------diff --git a/freemocap/core/tasks/calibration/posthoc_calibration_task.py b/freemocap/core/tasks/calibration/posthoc_calibration_task.pyindex 41b109c3..501c0aac 100644--- a/freemocap/core/tasks/calibration/posthoc_calibration_task.py+++ b/freemocap/core/tasks/calibration/posthoc_calibration_task.py@@ -34,7 +34,8 @@ from freemocap.core.tasks.calibration.shared.calibration_paths import get_last_sfrom freemocap.core.tasks.calibration.shared.calibration_save import save_calibration_copiesfrom freemocap.core.tasks.calibration.shared.groundplane_alignment import GroundPlaneResult, groundplane_metadatafrom freemocap.core.tasks.mocap.mocap_helpers.charuco_model_from_observations import charuco_model_from_observations-from freemocap.core.types.type_overloads import VideoIdString+from freemocap.core.types.type_overloads import VideoIdString, TopicPublicationQueue+from freemocap.pubsub.pubsub_topics import AggregatorNodeProgressMessagefrom freemocap.utilities.toml_mixin import numpy_to_pythonfrom scripts.compare_calibrations import compute_calibration_health@@ -222,7 +223,6 @@ def run_posthoc_calibration_task(recording_info: RecordingInfo,video_metadata: dict[VideoIdString, VideoMetadata],task_config: PosthocCalibrationPipelineConfig,- report_progress: Callable[[str, float], None] | None = None,) -> None:"""Run posthoc calibration on collected charuco observations.@@ -230,6 +230,7 @@ def run_posthoc_calibration_task(task_config.solver_method. Both paths produce a CalibrationResultthat is saved via the same anipose-compatible TOML format."""+video_ids = list(video_metadata.keys())# ---- Validate all observations are CharucoObservation ----@@ -246,20 +247,14 @@ def run_posthoc_calibration_task(charuco_observations_by_frame.append(frame_charuco)views_per_camera = {vid_id: len(charuco_observations_by_frame) for vid_id in video_ids}logger.debug(f"Received (video id: charuco observation count): {views_per_camera}")- if report_progress is not None:- report_progress("Validating observations", 0.05)# ---- Create shared board definition ----board = _create_board(task_config=task_config)- if report_progress is not None:- report_progress("Board created", 0.10)# ---- Convert to shared observation format (used by pyceres and health check) ----all_observations = _convert_all_observations(charuco_observations_by_frame=charuco_observations_by_frame,)- if report_progress is not None:- report_progress("Observations converted", 0.20)# Save observations so comparison tools can run board reconstruction testsobservations_json_path = Path(recording_info.full_recording_path) / "output_data"/"charuco_observations.json"@@ -271,8 +266,6 @@ def run_posthoc_calibration_task(# ---- Route to solver ----logger.info(f"Using calibration solver: {task_config.solver_method.value}")- if report_progress is not None:- report_progress(f"Running solver: {task_config.solver_method.value}", 0.25)ground_plane: GroundPlaneResult | None = Nonematch task_config.solver_method:@@ -294,8 +287,6 @@ def run_posthoc_calibration_task(case _:raise ValueError(f"Unknown solver method: {task_config.solver_method}")- if report_progress is not None:- report_progress("Solver complete", 0.80)# ---- Save calibration result (unified for both paths) ----_save_result(@@ -304,8 +295,6 @@ def run_posthoc_calibration_task(solver_method=task_config.solver_method.value,ground_plane=ground_plane,)- if report_progress is not None:- report_progress("Calibration saved", 0.90)# ---- Log calibration health (including board reconstruction accuracy) ----health = compute_calibration_health(@@ -314,8 +303,6 @@ def run_posthoc_calibration_task(all_observations=all_observations,)logger.info(f"\n{health.summary}")- if report_progress is not None:- report_progress("Health check complete", 0.95)# ---- Build charuco board model from observations ----observation_recorders_by_video: dict[VideoIdString, BaseRecorder] = {@@ -331,8 +318,6 @@ def run_posthoc_calibration_task(output_data_folder=Path(recording_info.full_recording_path) / "output_data",)- if report_progress is not None:- report_progress("Calibration complete", 1.0)logger.info(f"Posthoc calibration complete! Output saved to {recording_info.full_recording_path}")diff --git a/freemocap/pubsub/pubsub_topics.py b/freemocap/pubsub/pubsub_topics.pyindex fe78f8d0..78133136 100644--- a/freemocap/pubsub/pubsub_topics.py+++ b/freemocap/pubsub/pubsub_topics.py@@ -5,9 +5,9 @@ Each Message + Topic pair defines a typed channel. Topics auto-registervia __init_subclass__ so the PubSubTopicManager discovers them at startup."""import logging-from typing import TYPE_CHECKING+from typing import TYPE_CHECKING, Self-from pydantic import Field, model_validator+from pydantic import Field, model_validator, ConfigDictfrom 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@@ -130,12 +130,40 @@ class AggregationNodeOutputMessage(TopicMessageABC):# Posthoc progress reporting# ----------------------------------------------------------------------------class PosthocProgressMessage(TopicMessageABC):- """Progress report from a posthoc pipeline."""+class PipelineProgressMessage(TopicMessageABC):pipeline_id: PipelineIdString- phase: str # "collecting_frames", "processing", "complete", "failed"- progress_fraction: float = Field(ge=0.0, le=1.0)- detail: str = ""+ frame_count: int = Field(ge=0)+ last_processed: FrameNumberInt = Field(ge=-1, default=-1)+ working: bool = False+ complete: bool = False+ error:bool = False+ model_config = ConfigDict(+ arbitrary_types_allowed=True,+ frozen=False+ )++ 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++++class VideoNodeProgressMessage(PipelineProgressMessage):+ video_id: VideoIdString+++class AggregatorNodeProgressMessage(PipelineProgressMessage):+ running_aggregation_task: bool = Field(default=False)# ---------------------------------------------------------------------------@@ -147,4 +175,5 @@ PipelineConfigUpdateTopic = create_topic(PipelineConfigUpdateMessage)CameraNodeOutputTopic = create_topic(CameraNodeOutputMessage)VideoNodeOutputTopic = create_topic(VideoNodeOutputMessage)AggregationNodeOutputTopic = create_topic(AggregationNodeOutputMessage)-PosthocProgressTopic = create_topic(PosthocProgressMessage)+VideoNodeProgressTopic = create_topic(VideoNodeProgressMessage)+AggregatorNodeProgressTopic = create_topic(AggregatorNodeProgressMessage)