Free Motion Capture for Everyone πβ¨
TypeScript
comit paperbase layout and begin deconstruction of the fmc_runme algorithm
Endurance Idehencf8482f44b4b
diff --git a/docker-compose.yml b/docker-compose.ymlindex b0c505eb..81e5f95a 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -11,3 +11,11 @@ services:- "./bin/run_uvicorn_server.sh"volumes:- .:/workspace++ db:+ image: postgres:14-alpine+ ports:+ - "5432:5432"+ environment:+ POSTGRES_USER: postgres+ POSTGRES_PASSWORD: passworddiff --git a/freemocap-ui/README.md b/freemocap-ui/README.mdindex 49fc5387..cabf3743 100644--- a/freemocap-ui/README.md+++ b/freemocap-ui/README.md@@ -46,4 +46,5 @@ To learn React, check out the [React documentation](https://reactjs.org/).## Relevant links-- https://web.dev/how-to-use-local-https/\ No newline at end of file+- https://web.dev/how-to-use-local-https/+- https://stackoverflow.com/questions/27420581/get-maximum-video-resolution-with-getusermedia\ No newline at end of filediff --git a/freemocap-ui/package.json b/freemocap-ui/package.jsonindex 498688c0..9aa05ee4 100644--- a/freemocap-ui/package.json+++ b/freemocap-ui/package.json@@ -2,6 +2,9 @@"name": "freemocap-ui","version": "0.1.0","private": true,+ "engines": {+ "node": "=16.13.2"+ },"dependencies": {"@emotion/react": "^11.7.1","@emotion/styled": "^11.6.0",@@ -21,6 +24,8 @@"react": "^17.0.2","react-dom": "^17.0.2","react-redux": "^7.2.6",+ "react-router": "^6.2.1",+ "react-router-dom": "^6.2.1","react-scripts": "5.0.0","react-webcam": "^6.0.0","typescript": "~4.1.5"diff --git a/freemocap-ui/src/components/webcam/webcam-capture.tsx b/freemocap-ui/src/components/webcam/webcam-capture.tsxnew file mode 100644index 00000000..a1d2725f--- /dev/null+++ b/freemocap-ui/src/components/webcam/webcam-capture.tsx@@ -0,0 +1,32 @@+import React from "react";+import Webcam from "react-webcam";++export const WebcamCapture = () => {+ const [deviceId, setDeviceId] = React.useState<any>({});+ const [devices, setDevices] = React.useState<any>([]);++ const handleDevices = React.useCallback(mediaDevices =>+ // @ts-ignore+ setDevices(mediaDevices.filter(({ kind }) => kind === "videoinput")),+ [setDevices]+ );++ React.useEffect(+ () => {+ navigator.mediaDevices.enumerateDevices().then(handleDevices);+ },+ [handleDevices]+ );++ return (+ <>+ {devices.map((device, key) => (+ <div>+ <Webcam audio={false} videoConstraints={{ deviceId: device.deviceId }} />+ {device.label || `Device ${key + 1}`}+ </div>++ ))}+ </>+ );+};\ No newline at end of filediff --git a/freemocap-ui/src/components/webcam/webcam.tsx b/freemocap-ui/src/components/webcam/webcam.tsxnew file mode 100644index 00000000..786182cc--- /dev/null+++ b/freemocap-ui/src/components/webcam/webcam.tsx@@ -0,0 +1,6 @@++import { default as Webcam } from 'react-webcam';++export const SomeWebcam = () => {+ return <Webcam />+}\ No newline at end of filediff --git a/freemocap-ui/src/layout/Navigator.tsx b/freemocap-ui/src/layout/Navigator.tsxindex aeeb9f07..1d68f622 100644--- a/freemocap-ui/src/layout/Navigator.tsx+++ b/freemocap-ui/src/layout/Navigator.tsx@@ -1,6 +1,6 @@import * as React from 'react';import Divider from '@mui/material/Divider';-import Drawer, { DrawerProps } from '@mui/material/Drawer';+import Drawer, {DrawerProps} from '@mui/material/Drawer';import List from '@mui/material/List';import Box from '@mui/material/Box';import ListItem from '@mui/material/ListItem';@@ -9,14 +9,7 @@ import ListItemIcon from '@mui/material/ListItemIcon';import ListItemText from '@mui/material/ListItemText';import HomeIcon from '@mui/icons-material/Home';import PeopleIcon from '@mui/icons-material/People';-import DnsRoundedIcon from '@mui/icons-material/DnsRounded';-import PermMediaOutlinedIcon from '@mui/icons-material/PhotoSizeSelectActual';-import PublicIcon from '@mui/icons-material/Public';-import SettingsEthernetIcon from '@mui/icons-material/SettingsEthernet';-import SettingsInputComponentIcon from '@mui/icons-material/SettingsInputComponent';-import TimerIcon from '@mui/icons-material/Timer';-import SettingsIcon from '@mui/icons-material/Settings';-import PhonelinkSetupIcon from '@mui/icons-material/PhonelinkSetup';+import {useNavigate} from "react-router";const categories = [{@@ -62,35 +55,37 @@ const itemCategory = {px: 3,};-export const Navigator = function(props: DrawerProps) {- const { ...other } = props;-+export const Navigator = function (props: DrawerProps) {+ const {...other} = props;+ const navigate = useNavigate();return (<Drawer variant="permanent" {...other}><List disablePadding>- <ListItem sx={{ ...item, ...itemCategory, fontSize: 22, color: '#fff' }}>+ <ListItem sx={{...item, ...itemCategory, fontSize: 22, color: '#fff'}}>FreeMoCap</ListItem>- <ListItem sx={{ ...item, ...itemCategory }}>+ <ListItem sx={{...item, ...itemCategory}}><ListItemIcon><HomeIcon /></ListItemIcon><ListItemText>Overview</ListItemText></ListItem>- {categories.map(({ id, children }) => (- <Box key={id} sx={{ bgcolor: '#101F33' }}>- <ListItem sx={{ py: 2, px: 3 }}>- <ListItemText sx={{ color: '#fff' }}>{id}</ListItemText>+ {categories.map(({id, children}) => (+ <Box key={id} sx={{bgcolor: '#101F33'}}>+ <ListItem sx={{py: 2, px: 3}}>+ <ListItemText sx={{color: '#fff'}}>{id}</ListItemText></ListItem>- {children.map(({ id: childId, icon, active }) => (+ {children.map(({id: childId, icon, active}) => (<ListItem disablePadding key={childId}>- <ListItemButton selected={active} sx={item}>+ <ListItemButton selected={active} sx={item} onClick={() => {+ navigate("/show_cameras")+ }}><ListItemIcon>{icon}</ListItemIcon><ListItemText>{childId}</ListItemText></ListItemButton></ListItem>))}- <Divider sx={{ mt: 2 }} />+ <Divider sx={{mt: 2}} /></Box>))}</List>diff --git a/freemocap-ui/src/layout/Paperbase.tsx b/freemocap-ui/src/layout/Paperbase.tsxindex 8045f7d6..2e8fd6a9 100644--- a/freemocap-ui/src/layout/Paperbase.tsx+++ b/freemocap-ui/src/layout/Paperbase.tsx@@ -1,11 +1,11 @@import * as React from 'react';-import { createTheme, ThemeProvider } from '@mui/material/styles';+import {createTheme, ThemeProvider} from '@mui/material/styles';import useMediaQuery from '@mui/material/useMediaQuery';import Box from '@mui/material/Box';-import { Navigator } from './Navigator';+import {Navigator} from './Navigator';import {Copyright} from "./Copyright";-import {EmptyContent} from "./EmptyContent";-+import {BaseContent} from "./content/BaseContent";+import {BrowserRouter} from 'react-router-dom';let theme = createTheme({palette: {@@ -152,7 +152,7 @@ theme = {const drawerWidth = 256;-export const Paperbase = function() {+export const Paperbase = function () {const [mobileOpen, setMobileOpen] = React.useState(false);const isSmUp = useMediaQuery(theme.breakpoints.up('sm'));@@ -162,33 +162,35 @@ export const Paperbase = function() {return (<ThemeProvider theme={theme}>- <Box sx={{ display: 'flex', minHeight: '100vh' }}>- <Box- component="nav"- sx={{ width: { sm: drawerWidth }, flexShrink: { sm: 0 } }}- >- {isSmUp ? null : (+ <BrowserRouter>+ <Box sx={{display: 'flex', minHeight: '100vh'}}>+ <Box+ component="nav"+ sx={{width: {sm: drawerWidth}, flexShrink: {sm: 0}}}+ >+ {isSmUp ? null : (+ <Navigator+ PaperProps={{style: {width: drawerWidth}}}+ variant="temporary"+ open={mobileOpen}+ onClose={handleDrawerToggle}+ />+ )}<Navigator- PaperProps={{ style: { width: drawerWidth } }}- variant="temporary"- open={mobileOpen}- onClose={handleDrawerToggle}+ PaperProps={{style: {width: drawerWidth}}}+ sx={{display: {sm: 'block', xs: 'none'}}}/>- )}- <Navigator- PaperProps={{ style: { width: drawerWidth } }}- sx={{ display: { sm: 'block', xs: 'none' } }}- />- </Box>- <Box sx={{ flex: 1, display: 'flex', flexDirection: 'column' }}>- <Box component="main" sx={{ flex: 1, bgcolor: '#eaeff1' }}>- <EmptyContent /></Box>- <Box component="footer" sx={{ p: 2, bgcolor: '#eaeff1' }}>- <Copyright />+ <Box sx={{flex: 1, display: 'flex', flexDirection: 'column'}}>+ <Box component="main" sx={{flex: 1, bgcolor: '#eaeff1'}}>+ <BaseContent />+ </Box>+ <Box component="footer" sx={{p: 2, bgcolor: '#eaeff1'}}>+ <Copyright />+ </Box></Box></Box>- </Box>+ </BrowserRouter></ThemeProvider>);}\ No newline at end of filediff --git a/freemocap-ui/src/layout/EmptyContent.tsx b/freemocap-ui/src/layout/content/BaseContent.tsxsimilarity index 56%rename from freemocap-ui/src/layout/EmptyContent.tsxrename to freemocap-ui/src/layout/content/BaseContent.tsxindex 23de9125..c42b1272 100644--- a/freemocap-ui/src/layout/EmptyContent.tsx+++ b/freemocap-ui/src/layout/content/BaseContent.tsx@@ -1,15 +1,14 @@import React from 'react';-import {Paper} from "@mui/material";-import {Header} from "./Header";+import {Header} from "../Header";import Box from "@mui/material/Box";+import {Router} from "../routing/router";-export const EmptyContent = () => {+export const BaseContent = () => {return (<React.Fragment><Header title={"Something"} onDrawerToggle={() => {}} /><Box sx={{ py: 6, px: 4, flex: 1, bgcolor: '#eaeff1' }}>- <Paper sx={{ maxWidth: 936, margin: 'auto', overflow: 'hidden' }}>- </Paper>+ <Router /></Box></React.Fragment>)diff --git a/freemocap-ui/src/layout/content/BasePaper.tsx b/freemocap-ui/src/layout/content/BasePaper.tsxnew file mode 100644index 00000000..c4e4e04a--- /dev/null+++ b/freemocap-ui/src/layout/content/BasePaper.tsx@@ -0,0 +1,11 @@+import {Paper} from "@mui/material";+import React from "react";++export const BasePaper = (props) => {+ const { children, ...rest} = props;+ return (+ <Paper sx={{ maxWidth: 936, margin: 'auto', overflow: 'hidden', ...rest }}>+ {props.children}+ </Paper>+ )+}\ No newline at end of filediff --git a/freemocap-ui/src/layout/Content.tsx b/freemocap-ui/src/layout/content/Content.tsxsimilarity index 100%rename from freemocap-ui/src/layout/Content.tsxrename to freemocap-ui/src/layout/content/Content.tsxdiff --git a/freemocap-ui/src/layout/routing/router.tsx b/freemocap-ui/src/layout/routing/router.tsxnew file mode 100644index 00000000..9f7a150e--- /dev/null+++ b/freemocap-ui/src/layout/routing/router.tsx@@ -0,0 +1,12 @@+import React from 'react';+import {Route, Routes} from "react-router-dom";+import {ShowCameras} from "../../views/ShowCameras";++export const Router = () => {+ return (+ <Routes>+ <Route path={'/'} element={<React.Fragment />} />+ <Route path={'/show_cameras'} element={<ShowCameras />} />+ </Routes>+ )+}\ No newline at end of filediff --git a/freemocap-ui/src/views/ShowCameras.tsx b/freemocap-ui/src/views/ShowCameras.tsxnew file mode 100644index 00000000..04333de9--- /dev/null+++ b/freemocap-ui/src/views/ShowCameras.tsx@@ -0,0 +1,7 @@+import {WebcamCapture} from "../components/webcam/webcam-capture";++export const ShowCameras = () => {+ return (+ <WebcamCapture/>+ )+}\ No newline at end of filediff --git a/freemocap-ui/src/views/UserConfig.tsx b/freemocap-ui/src/views/UserConfig.tsxnew file mode 100644index 00000000..3cefead9--- /dev/null+++ b/freemocap-ui/src/views/UserConfig.tsx@@ -0,0 +1,10 @@++interface Props {+ recordingSessionLocation: string;+}++export const UserConfig = (+ props: Props+) => {+ return null;+}\ No newline at end of filediff --git a/freemocap-ui/tsconfig.json b/freemocap-ui/tsconfig.jsonindex a273b0cf..41929ff7 100644--- a/freemocap-ui/tsconfig.json+++ b/freemocap-ui/tsconfig.json@@ -18,7 +18,8 @@"resolveJsonModule": true,"isolatedModules": true,"noEmit": true,- "jsx": "react-jsx"+ "jsx": "react-jsx",+ "noImplicitAny": false},"include": ["src"diff --git a/freemocap/dto/run_me_options.py b/freemocap/dto/run_me_options.pynew file mode 100644index 00000000..8c0c9bed--- /dev/null+++ b/freemocap/dto/run_me_options.py@@ -0,0 +1,25 @@+from pydantic import BaseModel+++class RunMeOptions(BaseModel):+ sessionID: str+ stage: int+ useOpenPose: bool = False+ runOpenPose: bool = True+ useMediaPipe: bool = True+ runMediaPipe: bool = True+ useDLC: bool = False+ dlcConfigPath: str+ debug: bool = False+ setDataPath: bool = False+ userDataPath: str = None+ recordVid: bool = True+ showAnimation: bool = True+ reconstructionConfidenceThreshold: float = .7+ # mm -+ # the size of the squares when printed on 8.5x11" paper based on parameters in ReadMe.md+ charucoSquareSize: int = 36+ calVideoFrameLength: float = .5+ startFrame: int = 0+ useBlender: bool = False+ resetBlenderExe: bool = Falsediff --git a/freemocap/fmc_runme.py b/freemocap/fmc_runme.pyindex b17b07c5..bbf30134 100644--- a/freemocap/fmc_runme.py+++ b/freemocap/fmc_runme.py@@ -42,6 +42,7 @@ from freemocap import (thisStage = 0 #global+# TODO: Replace the below functions with the RunMe options.def RunMe(sessionID=None,stage=1,useOpenPose=False,diff --git a/src/api/routes/__init__.py b/src/api/routes/__init__.pyindex caacecd2..7a73bf20 100644--- a/src/api/routes/__init__.py+++ b/src/api/routes/__init__.py@@ -1,3 +1,3 @@-from src.api.routes.health_check_route import healthcheck_router+from src.api.routes.health.health_check_route import healthcheck_routerenabled_routers = [healthcheck_router]diff --git a/src/api/routes/health/__init__.py b/src/api/routes/health/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/src/api/routes/health_check_route.py b/src/api/routes/health/health_check_route.pysimilarity index 100%rename from src/api/routes/health_check_route.pyrename to src/api/routes/health/health_check_route.py