Free Motion Capture for Everyone πβ¨
TypeScript
super basic update of readme to run refactored GUI (#336)
jonmatthisb73e63cef05a
diff --git a/OLD_README.md b/OLD_README.mddeleted file mode 100644index 83541bc8..00000000--- a/OLD_README.md+++ /dev/null@@ -1,356 +0,0 @@--https://user-images.githubusercontent.com/15314521/124694557-8069ea00-deaf-11eb-9328-3be27a4b1ea4.mp4--# This is all very much a work in progress! More to come!-## (As of May 2022) We're currently working on building a proper API with documentation, but for now enjoy this pile of not-quite-spaghetti-but-definitely-lasagna-flavored code and sloppy ReadMe π--___________________________________-___--[](https://github.com/freemocap/freemocap/actions/workflows/python-testing.yml)--## Prerequisites --**Required**-* Windows only for now (sorry! Mac and Linux support coming very soon!π )-* A Python 3.7 environment -- * We recommend installing Anaconda from here (https://www.anaconda.com/products/individual#Downloads) to create your Python environment.--* Two or more USB webcams attached to viable USB ports- * ~~USB hubs typically don't work~~ I think they do now?- * Note that two cameras is the **minimum** required for 3d reconstruction. However, with just two views, many points will be occluded/not visible to both cameras. For better performance, use three (or four or more?) cameras-* Each camera must get a clean unobstructed view of a Charuco board at some (See below).-____-____-# Installation-Open an Anaconda-enabled command prompt or powershell window and perform the following steps:--1) Create a Python3.7 Anaconda environment-```-conda create -n freemocap-env python=3.7-```--2) Activate that newly created environment-```-conda activate freemocap-env-```-3) Install freemocap from PyPi using `pip`-```-pip install freemocap==0.0.54 #pin version at pre-alpha, to match the workflow described in this document-```-That should be it!-___-___-# Basic Usage---- ## HOW TO CREATE A *NEW* `FreeMoCap` RECORDING SESSION--tl;dr- **Activate the the freemocap Python environment** and run the following lines of code (either in a script or in a console)--```python-import freemocap-freemocap.RunMe()-```--But COOL KIDS will install Blender ([blender.org](https://blender.org) and generate an awesome `.blend` file animation by setting `useBlender=True`:--```python-import freemocap-freemocap.RunMe(useBlender=True)-```-----This two-line script is a copy of the `freemocap_runme_script.py` file, which can be run by entering the following command into a command prompt or powershell:-```-(freemoocap-env)$ python freemocap_runme_script.py-```--## In a bit more detail--- ### 1) In an Anaconda enabled Command Prompt, PowerShell, or Windows Terminal window-- You will know if it's `Anaconda Enabled` because you will see a little `(base)` to the left of each line, which denotes that your `(base)` environment is currently active.-- We recommend Windows Terminal so you can enjoy all the [Rich](https://github.com/willmcgugan/rich)β¨ formatted text output, but you'll need to do a bit of work to connect it to Anaconda (e.g. [these instructions](https://dev.to/azure/easily-add-anaconda-prompt-in-windows-terminal-to-make-life-better-3p6j) )- - If that seems intimidating (or just too much work), just press the `Windows` key, type `Anaconda Prompt` and run everything from there.-- ### 2) Activate your freemocap environment- - e.g. if your freemocap environment is named `freemocap-env`, type:- ```- (base)$ conda activate freemocap-env- ```- - If successful, the `(base)` to the left of each line will change to `(freemocap-env)`, indicating that your freemocap environment is now active (type `conda info --envs` or `conda info -e` for a list of all available environments)--### 3) Activate an `ipython` console- - Activate an instance of an `ipython` console by typing `ipython` into the command window and pressing 'Enter'-```-(freemocap-env)$ ipython-```-### 4) Within the `ipython` console, import the `freemocap` package--```Python-[1]: import freemocap-```--### 5) Execute the `freemocap.RunMe()` command (with default parameters, see [#runme-input-parameters](#runme-input-parameters) for more info)--```python-[2]: freemocap.RunMe() #<-this is where the magic happens!-```--### 6) Follow instructions in the Command window and pop-up GUI windows!----β¨πβ¨---.------___--## HOW TO REPROCESS A PREVIOUSLY RECORDED `FreeMoCap` RECORDING SESSION--You can re-start the processing pipeline from any of the following processing stages (defined below)by specifying the `SessionID` desired `stage` in the call to `freemocap.RunMe()`--So to process the session named `sesh_2021-11-21_19_42_07` starting from stage 3 (aka, skipping the `1- recording` and `2- synchronization` stages), run:-```python-import freemocap-freemocap.RunMe(sessionID="sesh_2021-11-21_19_42_07", stage=3)-```--Note - if you leave `sessionID` unspecified but set `stage` to a number higher than 1, it will attempt to use the last recorded session (but this can be buggy atm)--___--## [Processing stages](#processing-stages) --- - **Stage 1 - Record Videos**- - Record raw videos from attached USB webcams and timestamps for each frame- - Raw Videos saved to `FreeMoCap_Data/[Session Folder]/RawVideos`-- - **Stage 2 - Synchronize Videos**- - Use recorded timestamps to re-save raw videos as synchronized videos (same start and end and same number of frames). Videos saved to- - Synchronized Videos saved to `FreeMoCap_Data/[Session Folder]/SynchedVideos`--- - **Stage 3 - Calibrate Capture Volume**- - Use [Anipose](https://anipose.org)'s [Charuco-based](https://docs.opencv.org/3.4/df/d4a/tutorial_charuco_detection.html) calibration method to determine the location of each camera during a recording session and calibrate the capture volume- - Calibration info saved to `[sessionID]_calibration.toml` and `[sessionID]_calibration.pickle`---- **Stage 4 - Track 2D points in videos and Reconstruct 3D** <-This is where the magic happens β¨- - Apply user specified tracking algorithms to Synchronized videos (currently supporting MediaPipe, OpenPose, and DeepLabCut) to generate 2D data- - Save to `FreeMoCap_Data/[Session Folder]/DataArrays/` folder (e.g. `mediaPipeData_2d.npy`)- - Combine 2d data from each camera with calibration data from Stage 3 to reconstruct the 3d trajectory of each tracked point- - Save to `/DataArrays` folder (e.g. `openPoseSkel_3d.npy`)- - NOTE - you might think it would make sense to separate the 2d tracking and 3d reconstruction into different stages, but the way the code is currently set up it's cleaner to combine them into the same processing stage Β―\\\_(γ)_/Β―--- **Stage 5 - Use Blender to generate output data files (optional, requires [Blender](https://blender.org) installed. set `freemocap.RunMe(useBlender=True)` to use)**- - Hijack a user-installed version of [Blender](https://blender.org) to format raw mocap data into a `.blend` file including the raw data as keyframed emtpies with a (sloppy, inexpertly) rigged and meshed armatured based on the [Rigify](https://docs.blender.org/manual/en/2.81/addons/rigging/rigify.html) Human Metarig- - Save `.blend` file to `[Session_Folder]/[Session_ID]/[Session_ID].blend`- - You can double click that `.blend` file to open it in Blender.- - For instructions on how to navigate a Blender Scene, try this [YouTube Tutorial](https://www.youtube.com/watch?v=nIoXOplUvAw)---- **Stage 6 - Save Skeleton Animation!**- - Create a [Matplotlib](https://matplotlib.org) based output animation video.- - Saves Animation video to: `[Session Folder]/[SessionID]_animVid.mp4`- - Note - This part takes for-EVER π--____-____-## `freemocap.RunMe()` Specify recording session paramters-___-The `freemocap.RunMe()` function takes a number of parameters that can be used to alter it's default behavior in important ways. Here are the default parameters along with a followed by a brief description of each one.---### RunMe - Default parameters-```python-#in `freemocap/fmc_runme.py`-def RunMe(sessionID=None,- stage=1,- useOpenPose=False,- runOpenPose = True,- useMediaPipe=True,- runMediaPipe=True,- useDLC=False,- dlcConfigPath=None,- debug=False,- setDataPath = False,- userDataPath = None,- recordVid = True,- showAnimation = True,- reconstructionConfidenceThreshold = .7,- charucoSquareSize = 36, #mm- calVideoFrameLength = .5,- startFrame = 0,- useBlender = False,- resetBlenderExe = False,- get_synced_unix_timestamps = True,- good_clean_frame_number = 0,- bundle_adjust_3d_points=False,- use_saved_calibration = False,- ):-```--### [RunMe input parameters](#runme-input-parameters)-- `sessionID`- - Type - (str)- - [Default] - None.- - Indentifying string to use for this session.- - If creating a new session, default behavior is to autogerate SessionID is based on date and time that the session was recorded- - If re-processing a previously recorded session, this value specifies which session to reprocess (must be the name of a folder within the `FreeMoCap_Data` folder)- --- `stage`- - [Type] - Int- - [Default] - 1- - Which processing stage to start from. Processing stages are deined in more detail in [#processing-stages](#processing-stages)-- ```- stage 1 - Record Raw Videos- stage 2 - Synchronize Videos- stage 3 - Camera Calibration- stage 4 - 2d Tracking and 3d Calibration- stage 5 - Create output files (using Blender)- stage 6 - Create output animation (Matplotlib)- ```-- `useMediaPipe`- - [Type] - BOOL- - [Default] - False,- - Whether or not to use the MediaPipe tracking method in `stage=4`--- `runMediaPipe`- - [Type] - BOOL- - [Default] - False,- - Whether or not to RUN the MediaPipe tracking method in `stage=4` (will use previously processed data. This can save a lot of time when re-processing long videos)--- `useOpenPose`- - [Type] - BOOL- - [Default] - False,- - Whether or not to use the OpenPose tracking method in `stage=4`--- `runOpenPose`- - [Type] - BOOL- - [Default] - False,- - Whether or not to RUN the OpenPose tracking method in `stage=4` (will use previously processed data. This can save a lot of time when re-processing long videos)--- `useDeepLabCut`- - [Type] - BOOL- - [Default] - False,- - Whether or not to use the DeepLabCut model/project specified at `dlcConfigPath` to track objects in `stage=4`---- `setDataPath`- - [Type] - BOOL- - [Default] - False,- - Trigger the GUI that prompts user to specify location of `FreeMoCap_Data`--- `userDataPath`- - [Type] - BOOL- - [Default] - False,- - path to the location of `FreeMoCap_Data`--- `recordVid`- - [Type] - BOOL- - [Default] - False,- - wehether to save the matplotlib animation to an `.mp4` file--- `showAnimation`- - [Type] - BOOL- - [Default] - False,- - wehether to save the matplotlib animation to an `.mp4` file--- `reconstructionConfidenceThreshold`- - [Type] - float in range(0,1),- - [Default] - .7- - Threshold 'confidence' value to include a point in the 3d reconstruction step--- `charucoSquareSize`- - [Type] = int- - [Default] = 36,- - The size of a side of a black square in the Charuco board used in this calibration. The default value of 36 is approximately appropriate for a print out on an 8 in bu 10 in paper (US Letter, approx A4)--- `calVideoLength`- - [Type] = int, float in range (0,1), or [int, int]- - [Default] = .5,- - What portion of the videos to use in the Anipose calibration step in `stage=3`. `-1` uses the whole recording, a number between 0 and 1 defines a proprotion of the video to use, and a tuple of two numbers defines the start and end frame---- `startFrame`- - [Type] = int- - [Default] = 0,- - what frame of the video to start the animation in `stage=6`--- `useBlender`- - [Type] = BOOL- - [Default] = True,- - Whether to use Blender to create output `.blend`, `.fbx`,`.usd`,and `.gltf` files--- `resetBlenderExe`- - [Type] = BOOL- - [Default] = False,- - Whether to launch GUI to set Blender .exe path (usually something like `C:/Program Files/Blender Foundation/2.95/`)--- `get_synced_unix_timestamps`- - [Type] = BOOL- - [Default] = True,- - Whether to save camera timestamps in `Unix Epoch Time` in addition to the default 'counting up from zero' timestamps. Very helpful for synchronizing FreeMoCap with other softwares--- `good_clean_frame_number`- - [Type] = int- - [Default] = 0,- - A frame where the subject is standing in something like a T-pose or an A-pose, which will be used to scale the armature created via the `useBlender=True` option. If set to default (`0`) the software will attempt to locate this frame automatically by looking for a frame where all markers are visible with high `confidence` values (but this is buggy)--- `bundle_adjust_3d_points` [EXPERIMENTAL as of May 2022]- - [Type] = BOOL- - [Default] = False,- - When set to `True`, the system will run a bundle adjust optimization of all recorded 3d points produced in `stage=4` using `aniposelib`'s `optim_points` method. This takes a rather long time, but can signicantly clean up the resulting recordings. However,it may also "over smooth" the data. We're in the process of testing this method out now--- `use_saved_calibration`- - [Type] = BOOL- - [Default] = False,- - Choose whether to use a calibration file from a previous session. When `False`, FreeMoCap will automatically save out calibration data whenever stage 3 is successfully completed. Only one saved calibration file is stored, so running another session will overwrite the currently saved calibration file. When `True` , FreeMoCap will instead load in the saved calibration data, which allows users to create recordings without needing to show the cameras the Charuco board.---____-____-## Charuco Board Information-___- * Our calibration method relies on [Anipose](https://anipose.org)'s [Charuco-based](https://docs.opencv.org/3.4/df/d4a/tutorial_charuco_detection.html) calibration method to determine the location of each camera during a recording session. This information is later used to create the 3d reconstruction of the tracked points-- * IMPORTANT The Charuco board shown to the camera MUST be generated with the `cv2.aruco.DICT_4X4_250` dictionary!-- * Ah high resoultion `png` of this Charuco board is in this repository at `/charuco_board_image_highRes.png`-*- * To generate your own board, use the following python commands (or equivalent). DO NOT CHANGE THE PARAMETERS OR THE CALIBRATION WILL NOT WORK:- ``` python- import cv2-- aruco_dict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_4X4_250) #note `cv2.aruco` can be installed via `pip install opencv-contrib-python`-- board = cv2.aruco.CharucoBoard_create(7, 5, 1, .8, aruco_dict)-- charuco_board_image = board.draw((2000,2000)) #`2000` is the resolution of the resulting image. Increase this number if printing a large board (bigger is better! Esp for large spaces!-- cv2.imwrite('charuco_board_image.png',charuco_board_image)-- ```--# **Optional**--Both [Deeplabcut](https://deeplabcut.org) and [OpenPose](https://github.com/CMU-Perceptual-Computing-Lab/openpose) are technically supported, but both are rather under-tested at the moment.--* To use DeepLabCut, install with set `freemocap.RunMe(useDLC=True)`- * Installation instructions for DeepLabCut may be found on their github - https://github.com/DeepLabCut/DeepLabCut--* If you would like to use OpenPose for body tracking, install Cuda and the Windows Portable Demo of OpenPose and set `freemocap.RunMe(useOpenPose=True)`.- * Install CUDA: https://developer.nvidia.com/cuda-downloads-- * Install OpenPose (Windows Portable Demo): https://github.com/CMU-Perceptual-Computing-Lab/openpose/releases/tag/v1.6.0-----Follow the GitHub Repository and/or Join the Discord (https://discord.gg/HX7MTprYsK) for updates!--# Stay Tuned for more soon!---β¨πβ¨diff --git a/README.md b/README.mdindex 28425138..619a1884 100644--- a/README.md+++ b/README.md@@ -43,124 +43,47 @@https://user-images.githubusercontent.com/15314521/192062522-2a8d9305-f181-4869-a4b9-1aa068e094c9.mp4-___-# How to use the `pre-alpha` code---We're in the process of switching over to the `alpha` phase of this project (`v0.1.0` and on) , which use full refactor code written with help from a professional experienced software architect.--Until the new code stabilizes, you may have more luck using the `pre-alpha` code (e.g. `v0.0.54`)---## INSTALLATION-Note: This will install the latest/last version from the `pre-alpha` phase of this project, frozen at release tag `v0.0.54` [here](https://github.com/freemocap/freemocap/releases/tag/v0.0.54)+> NOTE - these are super bare-bones install instructions just to show the new entry point - these instructions will be overhauled very soon (written 2023-03-14)-Open an Anaconda-enabled command prompt or powershell window and enter the following commands:+Open an [Anaconda-enabled command prompt](https://www.anaconda.org) (or equivalent) and enter the following commands:-1) Create a Python3.7 Anaconda environment+1) Create a `Python3.8+` environment```bash-conda create -n freemocap-env python=3.7+conda create -n freemocap-env python=3.9```2) Activate that newly created environment```bashconda activate freemocap-env```-3) Install freemocap (version `0.0.54`) from PyPi using `pip`-```bash-pip install freemocap==0.0.54-```--BUG FIX - Update `mediapipe` with: `pip install mediapipe --upgrade`--That should be it!-___-## How to create a *NEW* `freemocap` recording session--tl;dr- **Activate the freemocap Python environment** and run the following lines of code (either in a script or in a console)--```python-import freemocap-freemocap.RunMe()-```--But COOL KIDS will install Blender ([blender.org](https://blender.org) and generate an awesome `.blend` file animation by setting `useBlender=True`:--```python-import freemocap-freemocap.RunMe(useBlender=True)-```--:point_right: **For additional, more detailed instructions (including methods to re-process recorded sessions), [refer to the `OLD_README.md` document](https://github.com/freemocap/freemocap/blob/main/OLD_README.md))** :point_left:--___--# HOW TO RUN THE `alpha` GUI--NOTES-- no promises here, friends. Work in progress lol :joy:-- Personally, I run the gui through PyCharm, but its easier to write instructions on how to run from an anaconda prompt--## Pre-requisites:-1. Install Anaconda- - https://anaconda.org-2. Install git- - https://git-scm.com/book/en/v2/Getting-Started-Installing-Git (just use the defaults)-3. (OPTIONAL) Install Blender - https://blender.org--## Installation instructions--1. Open anaconda enabled terminal--2. Create a `python=3.9` environment+3) Clone the repository (pip install coming very soon!)```bash-conda create -n freemocap-gui python=3.9-```--3. Activate that environment:-```-conda activate freemocap-gui-```--4. Clone the repository (i.e. download the code from github. It'll show up in the current working directory of your terminal session)-```git clone https://github.com/freemocap/freemocap```-5. Navigate into that newly cloned/downloaded `freemocap` folder with:-```+4) Navigate into the newly cloned/downloaded `freemocap` folder+```bashcd freemocap```-6. Install the dependencies listed in the `requirements.txt` file:-```-pip install -r requirements.txt+5) Install the package via the `pyproject.toml` file+```bash+pip install -e .```-7. Run the GUI by running the `src/gui/main/main.py` file by entering this command into the terminal:+6) Launch the GUI (via the `freemocap.__main__.py` entry point)```bash-python old_src/gui/main/main.py+python -m freemocap```-8. Hopefully a GUI popped up! There are no docs on usage yet, so just click and see what you can figure out :joy:--## Current limitations+A GUI should pop up!-At the moment, the `alpha GUI`'s method for connecting to the cameras is very innefficient and will experience framerate drops with more than ~3 cameras (even with a powerful PC). We're working on a fix, and should have it handled soon! In the mean time, you can still use the GUI to process videos recorded with other methods (workflow described in the next section!)-__-# Create 3D skeleton animations from externally recorded (and synchronized) videos :sparkles:--You can use `alpha GUI` to process videos that were recorded and synchronized from any source!--Simply synchronize your videos in whatever way you wish, convert them to `.mp4` format, and place them all in a single folder.--Then, *import* that folder via the `Import Videos` button in the GUI and follow the standard processing steps--For details, see this guide - https://freemocap.readthedocs.io/en/latest/how_to_guides/how_to_process_previously_recorded_videos/-___-## Documentation and Knowledge Base+## Documentation and Knowledge Base (NOTE - no docs exist for the version of the GUI on the `main` branch yet - these docs refer to the `Alpha` releaseDocumentation for this software is currently pretty thin... but we're woking on it!diff --git a/requirements.txt b/requirements.txtindex 8a19d19c..e8af6182 100644--- a/requirements.txt+++ b/requirements.txt@@ -1,34 +1,6 @@-ipython==8.2.0-numpy>=1.19-pydantic==1.9.0-uvicorn==0.16.0-fastapi==0.71.0-gunicorn==20.1.0-requests==2.27.1-pyudev==0.22.0-python-multipart==0.0.5-websockets==10.1-sqlalchemy==1.4.31-singleton-decorator==1.0.0-orjson==3.6.7-aiomultiprocess==0.9.0-pre-commit==2.17.0-pandas==1.4.2-pyqtgraph==0.12.4-pyqt6==6.3.1-pyopengl==3.1.6-mediapipe==0.8.11-setuptools==58.0.4-aniposelib==0.4.3-protobuf==3.19.0-pytest==7.1.2-taskipy==1.10.2-pytest-cov==3.0.0-pyinstaller==5.2-pyinstaller-hooks-contrib==2022.8-black[d]==22.6.0-mkdocs-material==8.3.9-qtconsole==5.3.0-qtpy==2.0.1-rich==12.6.0+skellycam==2023.2.1076+skelly_viewer==2023.3.1017+mediapipe==0.9.1.0opencv-contrib-python==4.6.0.66+toml==0.10.2+aniposelib==0.4.3\ No newline at end of file