Free Motion Capture for Everyone πβ¨
TypeScript
kinda workin?
jonmatthis2199d8946136
diff --git a/bin/build_installer/__init__.py b/bin/build_installer/__init__.pydeleted file mode 100644index e69de29b..00000000diff --git a/bin/build_installer/run_pyinstaller.py b/bin/build_installer/run_pyinstaller.pydeleted file mode 100644index 571a3f59..00000000--- a/bin/build_installer/run_pyinstaller.py+++ /dev/null@@ -1,28 +0,0 @@-import logging-import os-from pathlib import Path--import PyInstaller.__main__--logger = logging.getLogger(__name__)--os.environ['PYINSTALLER_NO_CONDA'] = '1'--SPEC_FILE_PATH = str(Path(__file__).parent / 'freemocap.spec')-if not Path(SPEC_FILE_PATH).exists():- raise FileNotFoundError(f"Spec file not found at {SPEC_FILE_PATH}")---def run_pyinstaller():- print(f"Running PyInstaller with spec file {SPEC_FILE_PATH}...")-- installer_parameters = [- # SPEC_FILE_PATH,- '--log-level', 'INFO'- ]-- PyInstaller.__main__.run(installer_parameters)---if __name__ == "__main__":- run_pyinstaller()diff --git a/bin/builds/install_packages b/bin/builds/install_packagesdeleted file mode 100755index daaf15b2..00000000--- a/bin/builds/install_packages+++ /dev/null@@ -1,27 +0,0 @@-#!/usr/bin/env bash-# Automating package installation and cleanup!-# Sourced from minideb:-# https://github.com/bitnami/minideb/blob/59c31e40dd1c79930aaa6f95ba0e7744d68d8366/mkimage-set -e-set -u-export DEBIAN_FRONTEND=noninteractive-n=0-max=2-until [ $n -gt $max ]; do- set +e- (- apt-get update -qq &&- apt-get install -y --no-install-recommends "$@"- )- CODE=$?- set -e- if [ $CODE -eq 0 ]; then- break- fi- if [ $n -eq $max ]; then- exit $CODE- fi- echo "apt failed, retrying"- n=$(($n + 1))-done-rm -r /var/lib/apt/lists /var/cache/apt/archivesdiff --git a/bin/installer.sh b/bin/installer.shdeleted file mode 100755index cea156c7..00000000--- a/bin/installer.sh+++ /dev/null@@ -1 +0,0 @@-pyinstaller --name="freemocap" --windowed --onefile .\freemocap\__main__.pydiff --git a/bin/linux/build.sh b/bin/linux/build.shdeleted file mode 100755index 4336b0e6..00000000--- a/bin/linux/build.sh+++ /dev/null@@ -1,6 +0,0 @@-#!/usr/bin/env bash-#-# Run tests meant to calculate_center_of_mass in CI--# https://github.com/moby/moby/issues/39003#issuecomment-852915070 - use buildkit inline cache with --build-arg (in docker-compose file)-COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose builddiff --git a/bin/linux/run_uvicorn_server.sh b/bin/linux/run_uvicorn_server.shdeleted file mode 100755index 939a3b18..00000000--- a/bin/linux/run_uvicorn_server.sh+++ /dev/null@@ -1,8 +0,0 @@-#!/usr/bin/env bash-#-# Start the webserver---uvicorn --factory src.api.app_factory:create_app --port 8080 --host 0.0.0.0 --workers 8 --ws websockets --reload--diff --git a/bin/linux/run_web_server.sh b/bin/linux/run_web_server.shdeleted file mode 100755index 0022ef0d..00000000--- a/bin/linux/run_web_server.sh+++ /dev/null@@ -1,8 +0,0 @@-#!/usr/bin/env bash-#-# Start the webserver--# shellcheck disable=SC2086-gunicorn -b 0.0.0.0:8080 --timeout 0 -w 1 -k uvicorn.workers.UvicornWorker 'old_src.api.app_factory:create_app()'-#hypercorn 'old_src.api.app_factory:create_app()' --bind 0.0.0.0:8080 --websocket-ping-interval 1000-#uvicorn --factory old_src.api.app_factory:create_app --port 8080 --host 0.0.0.0 --workers 4diff --git a/bin/linux/shell.sh b/bin/linux/shell.shdeleted file mode 100755index db942981..00000000--- a/bin/linux/shell.sh+++ /dev/null@@ -1,5 +0,0 @@-#!/usr/bin/env bash-#-# Run docker container in bash shell session.--docker-compose run --rm --service-ports app bashdiff --git a/bin/linux/test.sh b/bin/linux/test.shdeleted file mode 100755index a2587e22..00000000--- a/bin/linux/test.sh+++ /dev/null@@ -1,5 +0,0 @@-#!/usr/bin/env bash-#-# Run unit tests.--docker-compose run --rm app python -m pytest -p no:warnings ./diff --git a/bin/linux/up.sh b/bin/linux/up.shdeleted file mode 100755index ab0278b9..00000000--- a/bin/linux/up.sh+++ /dev/null@@ -1,5 +0,0 @@-#!/usr/bin/env bash-#-# Start docker services.--docker-compose up "$@"diff --git a/bin/windows/install-windows-pyapp.ps1 b/bin/windows/install-windows-pyapp.ps1deleted file mode 100644index 34af78e2..00000000--- a/bin/windows/install-windows-pyapp.ps1+++ /dev/null@@ -1,52 +0,0 @@-# Check system information-systeminfo || Write-Host "Unable to fetch system information"--# Ensure Python 3.11 is installed and added to your PATH.-Write-Host "Ensure Python 3.11 is installed and added to your PATH."--# Upgrade pip and install dependencies-python -m pip install --upgrade pip-pip install -e .--# Freeze dependencies to requirements.txt-pip freeze > requirements.txt--# Remove opencv-python dependency-(Get-Content requirements.txt) -notmatch 'opencv-python' | Set-Content requirements.txt--# Download PyApp-Invoke-WebRequest -Uri "https://github.com/ofek/pyapp/releases/download/v0.22.0/source.zip" -OutFile "pyapp.zip"--# Unzip PyApp-Expand-Archive -Path "pyapp.zip" -DestinationPath "."--# List directory contents-Get-ChildItem -Path "."--# Set environment variables for PyApp-$env:PYAPP_PROJECT_NAME = "freemocap"-$env:PYAPP_PROJECT_VERSION = "v1.4.7"-$env:PYAPP_PYTHON_VERSION = "3.11"-$env:PYAPP_PROJECT_DEPENDENCY_FILE = (Resolve-Path "requirements.txt").Path-$env:PYAPP_EXEC_SCRIPT = (Resolve-Path "freemocap\__main__.py").Path-$env:PYAPP_PIP_EXTRA_ARGS = "--no-deps"-$env:PYAPP_EXPOSE_ALL_COMMANDS = "true"--# Build and install PyApp (requires Rust and Cargo)-# Install Rust from https://rustup.rs/ if not installed-cd pyapp-v0.22.0-cargo build --release-cargo install pyapp --force --root (Get-Location).Path-cd ..--# Rename the executable-Rename-Item -Path ".\bin\pyapp.exe" -NewName "freemocap_app.exe"--# Install Rcedit with Chocolatey-# Ensure Chocolatey is installed on your system-choco install rcedit -y--# Set executable icon-rcedit "freemocap_app.exe" --set-icon "freemocap/assets/logo/freemocap_skelly_logo.ico"--Write-Host "freemocap_app.exe has been created with the specified icon."\ No newline at end of filediff --git a/bin/windows/installChocolatey.cmd b/bin/windows/installChocolatey.cmddeleted file mode 100644index b86d667d..00000000--- a/bin/windows/installChocolatey.cmd+++ /dev/null@@ -1,8 +0,0 @@-@echo off--SET DIR=%~dp0%--::download install.ps1-%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "((new-object net.webclient).DownloadFile('https://community.chocolatey.org/install.ps1','%DIR%install.ps1'))"-::run installer-%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%DIR%install.ps1' %*"\ No newline at end of filediff --git a/bin/windows/run_web_server.cmd b/bin/windows/run_web_server.cmddeleted file mode 100644index b06cbf92..00000000--- a/bin/windows/run_web_server.cmd+++ /dev/null@@ -1 +0,0 @@-uvicorn --factory src.api.app_factory:create_app --port 8080 --host 0.0.0.0 --workers 4 --ws websockets --reload\ No newline at end of filediff --git a/freemocap-ui/electron/main/api.ts b/freemocap-ui/electron/main/api.tsindex 4079c2a1..95dff16e 100644--- a/freemocap-ui/electron/main/api.ts+++ b/freemocap-ui/electron/main/api.ts@@ -181,6 +181,18 @@ export const api = t.router({return result.canceled ? null : result.filePaths[0];}),+ selectTomlFile: t.procedure+ .mutation(async () => {+ const result = await dialog.showOpenDialog({+ properties: ['openFile'],+ filters: [+ { name: 'TOML Files', extensions: ['toml'] },+ { name: 'All Files', extensions: ['*'] },+ ],+ });+ return result.canceled ? null : result.filePaths[0];+ }),+validateCalibrationDirectory: t.procedure.input(z.object({ directoryPath: z.string() }))@@ -245,8 +257,8 @@ export const api = t.router({const result = {exists: false,canRecord: false,- canProcess: false,- cameraCalibrationTomlPath: null as string | null,+ canCalibrate: false,+ cameraMocapTomlPath: null as string | null,hasSynchronizedVideos: false,hasVideos: false,errorMessage: null as string | null,@@ -282,9 +294,9 @@ export const api = t.router({const entries = fs.readdirSync(input.directoryPath);result.canRecord = !result.hasVideos;- result.cameraCalibrationTomlPath = findCameraCalibrationToml(input.directoryPath);+ result.cameraMocapTomlPath = findCameraCalibrationToml(input.directoryPath);- result.canProcess = result.hasVideos && result.cameraCalibrationTomlPath !== null;+ result.canCalibrate = result.hasVideos && result.cameraMocapTomlPath !== null;return result;diff --git a/freemocap-ui/src/components/calibration-control-panel/CalibrationControlPanel.tsx b/freemocap-ui/src/components/calibration-control-panel/CalibrationControlPanel.tsxindex dc296868..5b37236f 100644--- a/freemocap-ui/src/components/calibration-control-panel/CalibrationControlPanel.tsx+++ b/freemocap-ui/src/components/calibration-control-panel/CalibrationControlPanel.tsx@@ -5,6 +5,7 @@ import {Button,Checkbox,Chip,+ CircularProgress,FormControl,FormControlLabel,IconButton,@@ -24,10 +25,12 @@ 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 InfoIcon from "@mui/icons-material/Info";-import CloseIcon from "@mui/icons-material/Close";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/calibration-control-panel/CalibrationSolverSection";@@ -47,6 +50,7 @@ const BOARD_PRESETS: Record<Exclude<BoardPreset, "custom">, BoardPresetConfig> =export const CalibrationControlPanel: React.FC = () => {const theme = useTheme();const [localError, setLocalError] = useState<string | null>(null);+ const [isRefreshing, setIsRefreshing] = useState(false);const {api} = useElectronIPC();const {@@ -166,6 +170,18 @@ export const CalibrationControlPanel: React.FC = () => {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(() => {@@ -173,59 +189,63 @@ export const CalibrationControlPanel: React.FC = () => {return "Using default recording directory";}, [isUsingManualPath]);- // Derive status for collapsed summary- const statusLabel = isRecording- ? `Recording ${recordingProgress.toFixed(0)}%`- : isLoading- ? "Processing..."- : directoryInfo?.cameraCalibrationTomlPath- ? "Calibrated"- : "Idle";+ // βββ 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 statusColor = isRecording- ? theme.palette.error.main- : isLoading- ? theme.palette.warning.main- : directoryInfo?.cameraCalibrationTomlPath- ? theme.palette.success.main- : theme.palette.grey[600];+ 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]);- // Primary control: compact start/stop recording toggle in the header- const headerRecordButton = 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"}>+ /** Refresh button β lives in the header row */+ const refreshButton = (+ <Tooltip title={calibrationRecordingPath ? "Re-check calibration folder" : "No path set"}><span><IconButtonsize="small"onClick={(e: React.MouseEvent) => {e.stopPropagation();- dispatchStartCalibrationRecording();+ handleRefresh();}}- disabled={!canStartRecording || isLoading}+ disabled={!calibrationRecordingPath || isLoading || isRefreshing}sx={{+ p: 0.5,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)",@@ -233,12 +253,93 @@ export const CalibrationControlPanel: React.FC = () => {},}}>- <FiberManualRecordIcon fontSize="small" />+ {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 (<CollapsibleSidebarSectionicon={<SquareFootIcon sx={{color: "inherit"}} />}@@ -256,7 +357,7 @@ export const CalibrationControlPanel: React.FC = () => {}}/>}- primaryControl={headerRecordButton}+ primaryControl={headerControls}defaultExpanded={false}><Box sx={{p: 2, bgcolor: "background.paper"}}>@@ -337,6 +438,21 @@ export const CalibrationControlPanel: React.FC = () => {</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"><IconButtononClick={handleSelectDirectory}@@ -351,170 +467,18 @@ export const CalibrationControlPanel: React.FC = () => {/>{/* Directory Status Info */}- {directoryInfo && (- <Box- sx={{- p: 1.5,- borderRadius: 1,- border: `2px solid ${theme.palette.divider}`,- }}- >- <Stack spacing={1}>- <Box- sx={{- display: "flex",- alignItems: "center",- gap: 1,- }}- >- <InfoIcon fontSize="small" color="info" />- <Typography variant="caption" fontWeight="medium">- Calibration Folder Status- </Typography>- </Box>-- <Box- sx={{- display: "flex",- gap: 1,- flexWrap: "wrap",- }}- >- <Chip- label={- directoryInfo.exists- ? "Directory exists"- : "Directory will be created"- }- size="small"- color={directoryInfo.exists ? "success" : "default"}- icon={- directoryInfo.exists ? (- <CheckCircleIcon />- ) : (- <CloseIcon />- )- }- variant={directoryInfo.exists ? "filled" : "outlined"}- sx={- !directoryInfo.exists- ? {- borderColor: theme.palette.grey[400],- "& .MuiChip-icon": {- color: theme.palette.grey[600],- },- }- : {}- }- />- <Chip- label="Has videos"- size="small"- color={directoryInfo.hasVideos ? "success" : "default"}- icon={- directoryInfo.hasVideos ? (- <CheckCircleIcon />- ) : (- <CloseIcon />- )- }- variant={directoryInfo.hasVideos ? "filled" : "outlined"}- sx={- !directoryInfo.hasVideos- ? {- borderColor: theme.palette.grey[400],- "& .MuiChip-icon": {- color: theme.palette.grey[600],- },- }- : {}- }- />- <Chip- label="Has synchronized_videos"- size="small"- color={- directoryInfo.hasSynchronizedVideos- ? "success"- : "default"- }- icon={- directoryInfo.hasSynchronizedVideos ? (- <CheckCircleIcon />- ) : (- <CloseIcon />- )- }- variant={- directoryInfo.hasSynchronizedVideos- ? "filled"- : "outlined"- }- sx={- !directoryInfo.hasSynchronizedVideos- ? {- borderColor: theme.palette.grey[400],- "& .MuiChip-icon": {- color: theme.palette.grey[600],- },- }- : {}- }- />- <Chip- label="Has calibration TOML"- size="small"- color={- directoryInfo.cameraCalibrationTomlPath- ? "success"- : "default"- }- icon={- directoryInfo.cameraCalibrationTomlPath ? (- <CheckCircleIcon />- ) : (- <CloseIcon />- )- }- variant={- directoryInfo.cameraCalibrationTomlPath- ? "filled"- : "outlined"- }- sx={- !directoryInfo.cameraCalibrationTomlPath- ? {- borderColor: theme.palette.grey[400],- "& .MuiChip-icon": {- color: theme.palette.grey[600],- },- }- : {}- }- />- </Box>-- {directoryInfo.cameraCalibrationTomlPath && (- <Box sx={{mt: 1}}>- <Typography variant="caption" color="text.secondary">- Found calibration file:- </Typography>- <Typography- variant="caption"- sx={{- fontFamily: "monospace",- display: "block",- color: "success.main",- wordBreak: "break-all",- }}- >- {directoryInfo.cameraCalibrationTomlPath}- </Typography>- </Box>- )}- </Stack>- </Box>- )}+ <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}+ />{/* Board Size Configuration */}<Stack direction="row" spacing={2}>diff --git a/freemocap-ui/src/components/common/DirectoryStatusPanel.tsx b/freemocap-ui/src/components/common/DirectoryStatusPanel.tsxnew file mode 100644index 00000000..824acfca--- /dev/null+++ b/freemocap-ui/src/components/common/DirectoryStatusPanel.tsx@@ -0,0 +1,170 @@+import React from "react";+import {+ Box,+ Chip,+ CircularProgress,+ IconButton,+ Stack,+ Tooltip,+ Typography,+ useTheme,+} from "@mui/material";+import CheckCircleIcon from "@mui/icons-material/CheckCircle";+import CloseIcon from "@mui/icons-material/Close";+import InfoIcon from "@mui/icons-material/Info";+import RefreshIcon from "@mui/icons-material/Refresh";++/**+ * Minimal directoryβinfo shape shared by both calibration and mocap hooks.+ * Extend as needed β the component only reads what it renders.+ */+export interface DirectoryStatus {+ exists: boolean;+ hasVideos: boolean;+ hasSynchronizedVideos: boolean;+ errorMessage?: string | null;+ /** Path to a relevant TOML / output file, if one exists. */+ tomlPath?: string | null;+}++export interface DirectoryStatusPanelProps {+ /** Section heading shown next to the info icon. */+ title: string;+ /** Label for the TOML chip, e.g. "Has calibration TOML" */+ tomlLabel: string;+ /** The directoryInfo object from the relevant hook. `null` hides the panel. */+ directoryInfo: DirectoryStatus | null;+ /** Called when the user clicks the refresh button. */+ onRefresh?: () => void;+ /** Disables the refresh button. */+ refreshDisabled?: boolean;+ /** Shows a spinner on the refresh button. */+ isRefreshing?: boolean;+ /** Visual accent for the border: "ok" | "bad" | "none". Defaults to "none". */+ status?: "ok" | "bad" | "none";+}++/** Reusable chip for a boolean check. */+const StatusChip: React.FC<{+ label: string;+ ok: boolean;+}> = ({label, ok}) => {+ const theme = useTheme();+ return (+ <Chip+ label={label}+ size="small"+ color={ok ? "success" : "default"}+ icon={ok ? <CheckCircleIcon /> : <CloseIcon />}+ variant={ok ? "filled" : "outlined"}+ sx={+ !ok+ ? {+ borderColor: theme.palette.grey[400],+ "& .MuiChip-icon": {color: theme.palette.grey[600]},+ }+ : {}+ }+ />+ );+};++/**+ * Shows directory existence, video availability, sync status and TOML+ * presence as a row of status chips with an optional refresh button.+ *+ * Designed to drop into both CalibrationControlPanel and MocapTaskTreeItem,+ * replacing the ~140 lines of duplicated chip JSX in each.+ */+export const DirectoryStatusPanel: React.FC<DirectoryStatusPanelProps> = ({+ title,+ tomlLabel,+ directoryInfo,+ onRefresh,+ refreshDisabled = false,+ isRefreshing = false,+ status = "none",+}) => {+ const theme = useTheme();++ if (!directoryInfo) return null;++ const borderColor =+ status === "ok"+ ? "#00e5ff44"+ : status === "bad"+ ? `${theme.palette.error.main}44`+ : theme.palette.divider;++ return (+ <Box sx={{p: 1.5, borderRadius: 1, border: `2px solid ${borderColor}`}}>+ <Stack spacing={1}>+ {/* Header row */}+ <Box+ sx={{+ display: "flex",+ alignItems: "center",+ justifyContent: "space-between",+ }}+ >+ <Box sx={{display: "flex", alignItems: "center", gap: 1}}>+ <InfoIcon fontSize="small" color="info" />+ <Typography variant="caption" fontWeight="medium">+ {title}+ </Typography>+ </Box>++ {onRefresh && (+ <Tooltip title="Re-check folder">+ <span>+ <IconButton+ size="small"+ onClick={onRefresh}+ disabled={refreshDisabled}+ sx={{p: 0.25}}+ >+ {isRefreshing ? (+ <CircularProgress size={14} color="inherit" />+ ) : (+ <RefreshIcon sx={{fontSize: 14}} />+ )}+ </IconButton>+ </span>+ </Tooltip>+ )}+ </Box>++ {/* Status chips */}+ <Box sx={{display: "flex", gap: 1, flexWrap: "wrap"}}>+ <StatusChip+ label={directoryInfo.exists ? "Directory exists" : "Directory will be created"}+ ok={directoryInfo.exists}+ />+ <StatusChip label="Has videos" ok={directoryInfo.hasVideos} />+ <StatusChip label="Has synchronized_videos" ok={directoryInfo.hasSynchronizedVideos} />+ <StatusChip label={tomlLabel} ok={!!directoryInfo.tomlPath} />+ </Box>++ {/* TOML path display */}+ {directoryInfo.tomlPath && (+ <Box sx={{mt: 1}}>+ <Typography variant="caption" color="text.secondary">+ Found calibration file:+ </Typography>+ <Typography+ variant="caption"+ sx={{+ fontFamily: "monospace",+ display: "block",+ color: "success.main",+ wordBreak: "break-all",+ }}+ >+ {directoryInfo.tomlPath}+ </Typography>+ </Box>+ )}+ </Stack>+ </Box>+ );+};diff --git a/freemocap-ui/src/components/mocap-control-panel/MocapTaskTreeItem.tsx b/freemocap-ui/src/components/mocap-control-panel/MocapTaskTreeItem.tsxindex 7fe7203b..6656fc45 100644--- a/freemocap-ui/src/components/mocap-control-panel/MocapTaskTreeItem.tsx+++ b/freemocap-ui/src/components/mocap-control-panel/MocapTaskTreeItem.tsx@@ -1,9 +1,10 @@-import React, {useCallback, useMemo, useState} from "react";+import React, {useCallback, useEffect, useMemo, useState} from "react";import {Alert,Box,Button,Chip,+ CircularProgress,IconButton,InputAdornment,Stack,@@ -17,19 +18,24 @@ 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 InfoIcon from "@mui/icons-material/Info";-import CloseIcon from "@mui/icons-material/Close";import FiberManualRecordIcon from "@mui/icons-material/FiberManualRecord";+import CheckCircleIcon from "@mui/icons-material/CheckCircle";+import WarningAmberIcon from "@mui/icons-material/WarningAmber";+import CancelIcon from "@mui/icons-material/Cancel";+import RefreshIcon from "@mui/icons-material/Refresh";+import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile";import {CollapsibleSidebarSection} from "@/components/common/CollapsibleSidebarSection";+import {DirectoryStatusPanel} from "@/components/common/DirectoryStatusPanel";import {useMocap} from "@/hooks/useMocap";import {useElectronIPC} from "@/services";import {MediapipeConfigPanel} from "@/components/mocap-control-panel/MediapipeConfigPanel";import {SkeletonFilterConfigPanel} from "@/components/mocap-control-panel/SkeletonFilterConfigPanel";+import {useCalibration} from "@/hooks/useCalibration";export const MocapTaskTreeItem: React.FC = () => {const theme = useTheme();const [localError, setLocalError] = useState<string | null>(null);+ const [isRefreshing, setIsRefreshing] = useState(false);const {api, isElectron} = useElectronIPC();const {@@ -47,9 +53,26 @@ export const MocapTaskTreeItem: React.FC = () => {setManualRecordingPath,clearManualRecordingPath,dispatchProcessMocapRecording,+ validateDirectory,+ calibrationTomlPath,+ setCalibrationTomlPath,+ clearCalibrationTomlPath,clearError,} = useMocap();++ // Get the most recent calibration recording path from calibration state+ const {+ calibrationRecordingPath: mostRecentCalibrationPath,+ directoryInfo: calibrationDirectoryInfo,+ } = useCalibration();++ useEffect(() => {+ if (mocapRecordingPath) {+ validateDirectory(mocapRecordingPath);+ }+ }, [mocapRecordingPath, validateDirectory]);+const handleClearError = useCallback((): void => {clearError();setLocalError(null);@@ -96,6 +119,32 @@ export const MocapTaskTreeItem: React.FC = () => {clearManualRecordingPath();}, [clearManualRecordingPath]);+ const handleRefresh = useCallback(async (): Promise<void> => {+ if (!mocapRecordingPath) return;+ setIsRefreshing(true);+ try {+ await validateDirectory(mocapRecordingPath);+ } finally {+ setTimeout(() => setIsRefreshing(false), 400);+ }+ }, [mocapRecordingPath, validateDirectory]);++ const handleSelectCalibrationToml = async (): Promise<void> => {+ if (!isElectron || !api) {+ console.warn("Electron API not available");+ return;+ }+ try {+ const result: string | null = await api.fileSystem.selectTomlFile.mutate();+ if (result) {+ setCalibrationTomlPath(result);+ }+ } catch (err) {+ console.error("Failed to select TOML file:", err);+ setLocalError("Failed to select TOML file");+ }+ };+const displayError = error || localError || directoryInfo?.errorMessage;const pathHelperText = useMemo(() => {@@ -103,21 +152,98 @@ export const MocapTaskTreeItem: React.FC = () => {return "Using default recording directory";}, [isUsingManualPath]);+ // βββ Effective calibration path (considers all sources) ββββββββββββββββββββ+ const effectiveCalibrationTomlPath = useMemo(() => {+ if (calibrationTomlPath) return calibrationTomlPath;+ if (directoryInfo?.cameraMocapTomlPath) return directoryInfo.cameraMocapTomlPath;+ if (calibrationDirectoryInfo?.cameraCalibrationTomlPath) return calibrationDirectoryInfo.cameraCalibrationTomlPath;+ return null;+ }, [calibrationTomlPath, directoryInfo?.cameraMocapTomlPath, calibrationDirectoryInfo?.cameraCalibrationTomlPath]);++ // βββ Mocap status derivation ββββββββββββββββββββββββββββββββββββββββββββββ+ const mocapStatus: "ok" | "none" | "bad" = useMemo(() => {+ if (effectiveCalibrationTomlPath) return "ok";+ if (!mocapRecordingPath || !directoryInfo) return "none";+ return "bad";+ }, [effectiveCalibrationTomlPath, mocapRecordingPath, directoryInfo]);++ const mocapStatusIcon = useMemo(() => {+ if (mocapStatus === "ok") {+ return (+ <Tooltip title="Calibration file found β ready to process">+ <CheckCircleIcon fontSize="small" sx={{color: "#00e5ff"}} />+ </Tooltip>+ );+ }+ if (mocapStatus === "bad") {+ return (+ <Tooltip title="No calibration file found at this path">+ <CancelIcon fontSize="small" sx={{color: theme.palette.error.main}} />+ </Tooltip>+ );+ }+ return (+ <Tooltip title="No mocap directory selected">+ <WarningAmberIcon fontSize="small" sx={{color: theme.palette.warning.main}} />+ </Tooltip>+ );+ }, [mocapStatus, theme]);++ const refreshButton = (+ <Tooltip title={mocapRecordingPath ? "Re-check mocap folder" : "No path set"}>+ <span>+ <IconButton+ size="small"+ onClick={(e: React.MouseEvent) => {+ e.stopPropagation();+ handleRefresh();+ }}+ disabled={!mocapRecordingPath || 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 summaryconst statusLabel = isRecording? `Recording ${recordingProgress.toFixed(0)}%`: isLoading? "Processing..."- : "Idle";+ : effectiveCalibrationTomlPath+ ? "Ready"+ : "Idle";const statusColor = isRecording? theme.palette.error.main: isLoading? theme.palette.warning.main- : theme.palette.grey[600];+ : effectiveCalibrationTomlPath+ ? theme.palette.success.main+ : theme.palette.grey[600];- // Primary control: compact start/stop recording toggle in the header- const headerRecordButton = isRecording ? (+ // Primary controls: status icon + refresh + record start/stop+ const headerControls = (+ <Box sx={{display: "flex", alignItems: "center", gap: 0.75}}>+ {mocapStatusIcon}+ {refreshButton}+ {isRecording ? (<Tooltip title="Stop mocap recording"><IconButtonsize="small"@@ -163,6 +289,8 @@ export const MocapTaskTreeItem: React.FC = () => {</IconButton></span></Tooltip>+ )}+ </Box>);return (@@ -182,7 +310,7 @@ export const MocapTaskTreeItem: React.FC = () => {}}/>}- primaryControl={headerRecordButton}+ primaryControl={headerControls}defaultExpanded={false}><Box sx={{p: 2, bgcolor: "background.paper"}}>@@ -257,170 +385,71 @@ export const MocapTaskTreeItem: React.FC = () => {/>{/* Directory Status Info */}- {directoryInfo && (- <Box- sx={{- p: 1.5,- borderRadius: 1,- border: `2px solid ${theme.palette.divider}`,- }}- >- <Stack spacing={1}>- <Box- sx={{- display: "flex",- alignItems: "center",- gap: 1,- }}- >- <InfoIcon fontSize="small" color="info" />- <Typography variant="caption" fontWeight="medium">- Mocap Folder Status- </Typography>- </Box>+ <DirectoryStatusPanel+ title="Mocap Folder Status"+ tomlLabel="Has calibration TOML"+ directoryInfo={directoryInfo ? {+ ...directoryInfo,+ tomlPath: directoryInfo.cameraMocapTomlPath,+ } : null}+ status={mocapStatus}+ onRefresh={handleRefresh}+ refreshDisabled={!mocapRecordingPath || isLoading || isRefreshing}+ isRefreshing={isRefreshing}+ />- <Box+ {/* Calibration TOML Override */}+ <Box sx={{p: 1.5, borderRadius: 1, border: `1px solid ${theme.palette.divider}`}}>+ <Stack spacing={1}>+ <Box sx={{display: "flex", alignItems: "center", gap: 1}}>+ <InsertDriveFileIcon fontSize="small" color="info" />+ <Typography variant="caption" fontWeight="medium">+ Calibration TOML+ </Typography>+ </Box>+ <Typography variant="caption" color="text.secondary">+ {calibrationTomlPath+ ? "Using specified calibration file"+ : effectiveCalibrationTomlPath+ ? "Using auto-detected calibration"+ : "No calibration file found"}+ </Typography>+ {effectiveCalibrationTomlPath && (+ <Typography+ variant="caption"sx={{- display: "flex",- gap: 1,- flexWrap: "wrap",+ fontFamily: "monospace",+ display: "block",+ color: "success.main",+ wordBreak: "break-all",}}>- <Chip- label={- directoryInfo.exists- ? "Directory exists"- : "Directory will be created"- }- size="small"- color={directoryInfo.exists ? "success" : "default"}- icon={- directoryInfo.exists ? (- <CheckCircleIcon />- ) : (- <CloseIcon />- )- }- variant={directoryInfo.exists ? "filled" : "outlined"}- sx={- !directoryInfo.exists- ? {- borderColor: theme.palette.grey[400],- "& .MuiChip-icon": {- color: theme.palette.grey[600],- },- }- : {}- }- />- <Chip- label="Has videos"- size="small"- color={directoryInfo.hasVideos ? "success" : "default"}- icon={- directoryInfo.hasVideos ? (- <CheckCircleIcon />- ) : (- <CloseIcon />- )- }- variant={directoryInfo.hasVideos ? "filled" : "outlined"}- sx={- !directoryInfo.hasVideos- ? {- borderColor: theme.palette.grey[400],- "& .MuiChip-icon": {- color: theme.palette.grey[600],- },- }- : {}- }- />- <Chip- label="Has synchronized_videos"- size="small"- color={- directoryInfo.hasSynchronizedVideos- ? "success"- : "default"- }- icon={- directoryInfo.hasSynchronizedVideos ? (- <CheckCircleIcon />- ) : (- <CloseIcon />- )- }- variant={- directoryInfo.hasSynchronizedVideos- ? "filled"- : "outlined"- }- sx={- !directoryInfo.hasSynchronizedVideos- ? {- borderColor: theme.palette.grey[400],- "& .MuiChip-icon": {- color: theme.palette.grey[600],- },- }- : {}- }- />- <Chip- label="Has calibration TOML"- size="small"- color={- directoryInfo.cameraMocapTomlPath- ? "success"- : "default"- }- icon={- directoryInfo.cameraMocapTomlPath ? (- <CheckCircleIcon />- ) : (- <CloseIcon />- )- }- variant={- directoryInfo.cameraMocapTomlPath- ? "filled"- : "outlined"- }- sx={- !directoryInfo.cameraMocapTomlPath- ? {- borderColor: theme.palette.grey[400],- "& .MuiChip-icon": {- color: theme.palette.grey[600],- },- }- : {}- }- />- </Box>-- {directoryInfo.cameraMocapTomlPath && (- <Box sx={{mt: 1}}>- <Typography variant="caption" color="text.secondary">- Found calibration file:- </Typography>- <Typography- variant="caption"- sx={{- fontFamily: "monospace",- display: "block",- color: "success.main",- wordBreak: "break-all",- }}- >- {directoryInfo.cameraMocapTomlPath}- </Typography>- </Box>- )}+ {effectiveCalibrationTomlPath}+ </Typography>+ )}+ <Stack direction="row" spacing={1}>+ <Button+ variant={calibrationTomlPath ? "outlined" : "contained"}+ size="small"+ onClick={clearCalibrationTomlPath}+ disabled={!calibrationTomlPath}+ sx={{flex: 1}}+ >+ Use Most Recent+ </Button>+ <Button+ variant={calibrationTomlPath ? "contained" : "outlined"}+ size="small"+ startIcon={<InsertDriveFileIcon />}+ onClick={handleSelectCalibrationToml}+ disabled={!isElectron}+ sx={{flex: 1}}+ >+ Select TOML+ </Button></Stack>- </Box>- )}+ </Stack>+ </Box>{/* Recording Progress */}{isRecording && (diff --git a/freemocap-ui/src/hooks/useMocap.ts b/freemocap-ui/src/hooks/useMocap.tsindex 0233834a..2bc94723 100644--- a/freemocap-ui/src/hooks/useMocap.ts+++ b/freemocap-ui/src/hooks/useMocap.ts@@ -12,6 +12,8 @@ import {mocapErrorCleared,manualMocapRecordingPathChanged,manualMocapRecordingPathCleared,+ calibrationTomlPathChanged,+ calibrationTomlPathCleared,selectMocap,selectMocapDetectorConfig,selectSkeletonFilterConfig,@@ -20,6 +22,7 @@ import {selectCanProcessMocapRecording,selectCanStartMocapRecording,selectIsUsingManualMocapPath,+ selectCalibrationTomlPath,startMocapRecording,stopMocapRecording,processMocapRecording,@@ -37,6 +40,7 @@ export function useMocap() {const mocapRecordingPath = useAppSelector(selectMocapRecordingPath);const directoryInfo = useAppSelector(selectMocapDirectoryInfo);const isUsingManualPath = useAppSelector(selectIsUsingManualMocapPath);+ const calibrationTomlPath = useAppSelector(selectCalibrationTomlPath);const updateDetectorConfig = useCallback((updates: Partial<MediapipeDetectorConfig>) => {@@ -111,6 +115,17 @@ export function useMocap() {dispatch(processMocapRecording());}, [dispatch]);+ const setCalibrationTomlPath = useCallback(+ (path: string) => {+ dispatch(calibrationTomlPathChanged(path));+ },+ [dispatch]+ );++ const clearCalibrationTomlPath = useCallback(() => {+ dispatch(calibrationTomlPathCleared());+ }, [dispatch]);+const clearError = useCallback(() => {dispatch(mocapErrorCleared());}, [dispatch]);@@ -129,6 +144,7 @@ export function useMocap() {isUsingManualPath,canStartRecording,canProcessMocapRecording,+ calibrationTomlPath,// ActionsupdateDetectorConfig,replaceDetectorConfig,@@ -139,6 +155,9 @@ export function useMocap() {dispatchStartMocapRecording,dispatchStopMocapRecording,dispatchProcessMocapRecording,+ validateDirectory,+ setCalibrationTomlPath,+ clearCalibrationTomlPath,clearError,};}diff --git a/freemocap-ui/src/store/slices/calibration/calibration-slice.ts b/freemocap-ui/src/store/slices/calibration/calibration-slice.tsindex 65124964..b4036af2 100644--- a/freemocap-ui/src/store/slices/calibration/calibration-slice.ts+++ b/freemocap-ui/src/store/slices/calibration/calibration-slice.ts@@ -50,7 +50,7 @@ const initialState: CalibrationState = {liveTrackCharuco: true,charucoBoardXSquares: 5,charucoBoardYSquares: 3,- charucoSquareLength: 1,+ charucoSquareLength: 54,minSharedViewsPerCamera: 200,autoStopOnMinViewCount: true,solverMethod: 'anipose',diff --git a/freemocap-ui/src/store/slices/mocap/mocap-slice.ts b/freemocap-ui/src/store/slices/mocap/mocap-slice.tsindex 3309db49..0b5d4cb6 100644--- a/freemocap-ui/src/store/slices/mocap/mocap-slice.ts+++ b/freemocap-ui/src/store/slices/mocap/mocap-slice.ts@@ -142,6 +142,8 @@ export interface MocapState {lastMocapRecordingPath: string | null;manualMocapRecordingPath: string | null;directoryInfo: MocapDirectoryInfo | null;+ /** User-specified calibration TOML path override. null = use most recent (default). */+ calibrationTomlPath: string | null;}// ==================== Initial State ====================@@ -158,6 +160,7 @@ const initialState: MocapState = {lastMocapRecordingPath: null,manualMocapRecordingPath: null,directoryInfo: null,+ calibrationTomlPath: null,};// ==================== Slice ====================@@ -206,6 +209,14 @@ export const mocapSlice = createSlice({state.directoryInfo = action.payload;},+ calibrationTomlPathChanged: (state, action: PayloadAction<string>) => {+ state.calibrationTomlPath = action.payload;+ },++ calibrationTomlPathCleared: (state) => {+ state.calibrationTomlPath = null;+ },+resetMocapState: () => initialState,},@@ -274,6 +285,7 @@ export const selectMocapIsRecording = (state: RootState) => state.mocap.isRecordexport const selectMocapProgress = (state: RootState) => state.mocap.recordingProgress;export const selectMocapError = (state: RootState) => state.mocap.error;export const selectMocapDirectoryInfo = (state: RootState) => state.mocap.directoryInfo;+export const selectCalibrationTomlPath = (state: RootState) => state.mocap.calibrationTomlPath;export const selectMocapRecordingPath = createSelector([@@ -331,6 +343,8 @@ export const {manualMocapRecordingPathChanged,manualMocapRecordingPathCleared,mocapDirectoryInfoUpdated,+ calibrationTomlPathChanged,+ calibrationTomlPathCleared,resetMocapState} = mocapSlice.actions;diff --git a/freemocap-ui/src/store/slices/mocap/mocap-thunks.ts b/freemocap-ui/src/store/slices/mocap/mocap-thunks.tsindex e1bbb27d..6598b3d2 100644--- a/freemocap-ui/src/store/slices/mocap/mocap-thunks.ts+++ b/freemocap-ui/src/store/slices/mocap/mocap-thunks.ts@@ -20,9 +20,15 @@ export const startMocapRecording = createAsyncThunk<return rejectWithValue('Recording directory is not set');}+ const calibrationTomlPath = state.mocap.calibrationTomlPath;+ const configWithCalibration = {+ ...mocapTaskConfig,+ calibrationTomlPath: calibrationTomlPath,+ };+console.log('π¬ Starting mocap recording with:', {mocapRecordingDirectory,- mocapTaskConfig,+ mocapTaskConfig: configWithCalibration,});const response = await fetch(serverUrls.endpoints.mocapStartRecording, {@@ -30,7 +36,7 @@ export const startMocapRecording = createAsyncThunk<headers: { 'Content-Type': 'application/json' },body: JSON.stringify({mocapRecordingDirectory,- mocapTaskConfig,+ mocapTaskConfig: configWithCalibration,}),});@@ -62,13 +68,18 @@ export const stopMocapRecording = createAsyncThunk<const mocapTaskConfig = state.mocap.config;- console.log(`π¬ Stoping mocap recording and starting mocap with: ${JSON.stringify(mocapTaskConfig, null, 2)}`);+ const calibrationTomlPath = state.mocap.calibrationTomlPath;+ const configWithCalibration = {+ ...mocapTaskConfig,+ calibrationTomlPath: calibrationTomlPath,+ };+ console.log(`π¬ Stopping mocap recording and starting mocap with: ${JSON.stringify(configWithCalibration, null, 2)}`);const response = await fetch(serverUrls.endpoints.mocapStopRecording, {method: 'POST',headers: { 'Content-Type': 'application/json' },- body: JSON.stringify({mocapTaskConfig}),+ body: JSON.stringify({mocapTaskConfig: configWithCalibration}),});if (!response.ok) {@@ -108,12 +119,18 @@ export const processMocapRecording = createAsyncThunk<mocapTaskConfig,});+ const calibrationTomlPath = state.mocap.calibrationTomlPath;+ const configWithCalibration = {+ ...mocapTaskConfig,+ calibrationTomlPath: calibrationTomlPath,+ };+const response = await fetch(serverUrls.endpoints.processMocapRecording, {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({mocapRecordingDirectory,- mocapTaskConfig,+ mocapTaskConfig: configWithCalibration,}),});diff --git a/freemocap/core/calibration/calibration_task.py b/freemocap/core/calibration/calibration_task.pyindex 753bb0cf..40a51ea3 100644--- a/freemocap/core/calibration/calibration_task.py+++ b/freemocap/core/calibration/calibration_task.py@@ -50,8 +50,8 @@ def _create_board(task_config: CalibrationPipelineConfig) -> CharucoBoardDefinitreturn CharucoBoardDefinition(squares_x=task_config.charuco_board_x_squares,squares_y=task_config.charuco_board_y_squares,- square_length_mm=task_config.charuco_square_length,- marker_length_mm=task_config.charuco_square_length * 0.8,+ square_length_mm=task_config.detector_config.square_length,+ marker_length_mm=task_config.detector_config.marker_length,)diff --git a/freemocap/core/mocap/posthoc_mocap_task.py b/freemocap/core/mocap/posthoc_mocap_task.pyindex fcd4bc57..2fab5952 100644--- a/freemocap/core/mocap/posthoc_mocap_task.py+++ b/freemocap/core/mocap/posthoc_mocap_task.py@@ -68,12 +68,21 @@ def run_post_mocap_aggregation_task(observation_recorders[vid_id].add_observation(observation=obs)# ---- Get calibration path ----- calibration_toml_path = get_last_successful_calibration_toml_path()- if calibration_toml_path is None:- raise RuntimeError(- "No calibration file found β cannot run mocap without calibration. "- "Run a calibration pipeline first."- )+ if task_config.calibration_toml_path:+ calibration_toml_path = Path(task_config.calibration_toml_path)+ if not calibration_toml_path.exists():+ raise RuntimeError(+ f"Specified calibration TOML not found: {calibration_toml_path}"+ )+ logger.info(f"Using user-specified calibration TOML: {calibration_toml_path}")+ else:+ calibration_toml_path = get_last_successful_calibration_toml_path()+ if calibration_toml_path is None:+ raise RuntimeError(+ "No calibration file found β cannot run mocap without calibration. "+ "Run a calibration pipeline first."+ )+ logger.info(f"Using most recent calibration TOML: {calibration_toml_path}")# ---- Run skeleton triangulation ----if report_progress is not None:diff --git a/freemocap/core/pipeline/pipeline_configs.py b/freemocap/core/pipeline/pipeline_configs.pyindex 9c650403..d41d3cd2 100644--- a/freemocap/core/pipeline/pipeline_configs.py+++ b/freemocap/core/pipeline/pipeline_configs.py@@ -89,7 +89,7 @@ class CalibrationPipelineConfig(BaseModel):)charuco_board_x_squares: int = Field(gt=0, default=7, alias="charucoBoardXSquares")charuco_board_y_squares: int = Field(gt=0, default=5, alias="charucoBoardYSquares")- charuco_square_length: float = Field(gt=0, default=58, alias="charucoSquareLength")+ # charuco_square_length: float = Field(gt=0, default=1, alias="charucoSquareLength")solver_method: CalibrationSolverMethod = Field(default=CalibrationSolverMethod.ANIPOSE,@@ -114,7 +114,7 @@ class CalibrationPipelineConfig(BaseModel):return CharucoDetectorConfig(squares_x=self.charuco_board_x_squares,squares_y=self.charuco_board_y_squares,- square_length=self.charuco_square_length,+ # square_length=self.charuco_square_length,)@@ -146,8 +146,15 @@ DetectorConfig = Annotated[class MocapPipelineConfig(BaseModel):+ model_config = ConfigDict(populate_by_name=True)+detector_config: DetectorConfig = Field(default_factory=LegacyMediapipeDetectorConfig)realtime_filter_config: RealtimeFilterConfig = Field(default_factory=RealtimeFilterConfig)+ calibration_toml_path: str | None = Field(+ default=None,+ alias="calibrationTomlPath",+ description="Optional override for calibration TOML file. If None, uses the most recent successful calibration.",+ )@classmethoddef default_realtime(cls) -> "MocapPipelineConfig":