### Navigate to Demo and Start IPython Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Change directory to the Pose2Sim demo folder and start an IPython session to run the pipeline. ```bash cd ipython ``` -------------------------------- ### Install uv and Create Environment (Windows) Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Installs uv and creates a Python virtual environment for Pose2Sim on Windows. Ensure you have PowerShell. ```powershell # Install uv powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # Create uv environment uv venv "$env:USERPROFILE\.venv\pose2sim" --python 3.13 # or 3.11, or 3.12 # Activate the uv environment & "$env:USERPROFILE\.venv\pose2sim\Scripts\Activate.ps1" ``` -------------------------------- ### Install Pose2Sim from Source (Developers) Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Installs the bleeding-edge version of Pose2Sim from its GitHub repository for development purposes. Requires git. ```cmd git clone --depth 1 https://github.com/perfanalytics/pose2sim.git cd pose2sim uv pip install -e . ``` -------------------------------- ### Install ONNX Runtime GPU Support Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Installs the ONNX Runtime with GPU acceleration. This replaces the CPU-only version. ```cmd uv pip uninstall onnxruntime uv pip install onnxruntime-gpu ``` -------------------------------- ### Install uv and Create Environment (Linux/MacOS) Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Installs uv and creates a Python virtual environment for Pose2Sim on Linux or MacOS. Ensure you have curl. ```bash # Install uv curl -LsSf https://astral.sh/uv/install.sh | sh # Create uv environment uv venv ~/.venv/pose2sim --python 3.13 # or 3.11, or 3.12 # Activate the uv environment source ~/.venv/pose2sim/bin/activate ``` -------------------------------- ### Find Pose2Sim Installation Path Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Use this command to locate the installation directory of the pose2sim package, which is needed to find the demo folder. ```bash uv pip show pose2sim # to find ``` -------------------------------- ### Install Latest Stable Pose2Sim Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Installs the latest stable version of Pose2Sim using uv pip. Ensure your environment is activated. ```cmd uv pip install pose2sim --upgrade ``` -------------------------------- ### Install PyTorch with CUDA Support Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Installs PyTorch, Torchvision, and Torchaudio with specific CUDA support. Check compatibility with your GPU and driver. ```cmd uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 ``` -------------------------------- ### Verify GPU and ONNX Runtime Setup Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Verifies that PyTorch can detect the GPU and that ONNX Runtime recognizes the CUDA execution provider. ```python import torch; import onnxruntime as ort print(torch.cuda.is_available(), ort.get_available_providers()) # Should print "True ['CUDAExecutionProvider', ...]" ``` -------------------------------- ### Configure Custom Pose Models with RTMLib Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Example configurations for using custom detection and pose models with RTMLib. These settings can be local paths or URLs and specify model types and input sizes. ```python # Equivalent to mode='balanced', with body_with_feet pose model mode = """{'det_class':'YOLOX', 'det_model':'https://huggingface.co/datasets/DavidPagnon/rtmlib_models/resolve/main/mmpose/rtmposev1/onnx_sdk/yolox_m_8xb8-300e_humanart-c2c7a14a.onnx', 'det_input_size':[640, 640], 'pose_class':'RTMPose', 'pose_model':'https://huggingface.co/datasets/DavidPagnon/rtmlib_models/resolve/main/mmpose/rtmposev1/onnx_sdk/rtmpose-m_simcc-body7_pt-body7-halpe26_700e-256x192-4d3e73dd_20230605.onnx', 'pose_input_size':[192,256]}""" # With one-stage RTMO model # Requires pose_model = 'Body'. Marker augmentation won't work, Kimatic analysis will mode = """{'pose_class':'RTMO', 'pose_model':'https://huggingface.co/datasets/DavidPagnon/rtmlib_models/resolve/main/mmpose/rtmo/onnx_sdk/rtmo-m_16xb16-600e_body7-640x640-39e78cc4_20231211.onnx', 'pose_input_size':[640, 640]}""" # With animal pose estimation: # Marker augmentation won't work, and you will need to create your owOpenSim skeleton for kinematic analysis. mode = """{'pose_class':'RTMPose', 'pose_model':'https://huggingface.co/datasets/DavidPagnon/rtmlib_models/resolve/main/mmpose/rtmposev1/onnx_sdk/rtmpose-m_simcc-ap10k_pt-aic-coco_210e-256x256-7a041aa1_20230206.onnx', 'pose_input_size':[256,256]}""" # Same approach for hand or face pose estimation, check the RTMLib domentation for more information. ``` -------------------------------- ### Run OpenSim Scale and IK Tools via Python API Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Execute OpenSim scaling and inverse kinematics tools programmatically using the Python API. Ensure the setup file path is absolute and adjust parameters like time_range and output_motion_file as needed. ```python import opensim opensim.ScaleTool(".xml").run() opensim.InverseKinematicsTool(".xml").run() ``` -------------------------------- ### Pose Estimation with Updated Config Dictionary Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Override default configuration by passing an updated dictionary to `poseEstimation`. This example shows how to set the `whole_body` pose model and enable overwriting. ```python import toml config_dict = toml.load("/Config.toml") config_dict.get("project").update({"project_dir":""}) config_dict.get("pose").update({"pose_model": "whole_body","overwrite_pose": True}) Pose2Sim.poseEstimation(config_dict) ``` ```python # Or even simpler, just pass the updated parameters config_dict = {"project": {"project_dir": ""}, "pose": {"pose_model": "whole_body", "overwrite_pose": True}} Pose2Sim.poseEstimation(config_dict) ``` -------------------------------- ### Run OpenPose Demo for Pose Estimation Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Launch the OpenPose demo from your OpenPose directory to process videos and write pose estimations to JSON files. Recommended model is BODY_25B. ```cmd bin\OpenPoseDemo.exe --model_pose BODY_25B --video \videos\cam01.mp4 --write_json \pose\pose_cam01_json ``` -------------------------------- ### Run Batch Analysis with Pose2Sim Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Initiate batch processing by navigating to the batch demo directory and executing Pose2Sim. This allows for running numerous analyses with varying parameters. ```python cd ipython from Pose2Sim import Pose2Sim Pose2Sim.runAll() ``` -------------------------------- ### Run Multi-Person Analysis with Pose2Sim Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Execute multi-person analysis by navigating to the demo directory and running Pose2Sim. Ensure 'multi_person = true' is set in Config.toml. ```python cd ipython from Pose2Sim import Pose2Sim Pose2Sim.runAll() ``` -------------------------------- ### Run Full Pose2Sim Pipeline Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Execute the complete Pose2Sim pipeline by calling its static methods in sequence. This processes video data into 3D joint angles. ```python from Pose2Sim import Pose2Sim Pose2Sim.calibration() Pose2Sim.poseEstimation() Pose2Sim.synchronization() Pose2Sim.personAssociation() Pose2Sim.triangulation() Pose2Sim.filtering() Pose2Sim.markerAugmentation() Pose2Sim.kinematics() ``` -------------------------------- ### Run Camera Synchronization Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Execute the camera synchronization process using the Pose2Sim library. This command initiates the algorithm to find the optimal time offset for correlating camera views based on vertical speed of keypoints. ```python from Pose2Sim import Pose2Sim Pose2Sim.synchronization() ``` -------------------------------- ### Perform Calibration in Pose2Sim Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Use this snippet to initiate the calibration process. Ensure `calibration_type` is set to `calculate` in your configuration. ```python Pose2Sim.calibration() ``` -------------------------------- ### Run Pose2Sim Filtering Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Initiates the filtering process in Pose2Sim. Ensure your environment is activated before running. ```python from Pose2Sim import Pose2Sim Pose2Sim.filtering() ``` -------------------------------- ### Run RTMPose 2D Pose Estimation Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Execute the default RTMPose pose estimation using the Pose2Sim library. This command processes videos and saves results in the 'pose' folder in OpenPose format. ```python from Pose2Sim import Pose2Sim Pose2Sim.poseEstimation() ``` -------------------------------- ### Run MediaPipe BlazePose with Output Options Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Execute BlazePose using the provided Python script to save detected coordinates in OpenPose (json) or DeepLabCut (h5 or csv) format. Use '-h' for parameter explanations. ```cmd Blazepose_runsave -i input_file -dJs ``` -------------------------------- ### Compress Video and Decrease Resolution with ffmpeg Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Use this command to compress videos and decrease their resolution, significantly reducing storage use with minimal impact on accuracy. Adjust CRF for compression and use the scale filter for resolution. ```cmd ffmpeg -i original_vid.MP4 \ -vcodec libx264 -crf 30 -preset fast \ -vf "scale='min(1280,iw)':'min(720,ih)':force_original_aspect_ratio=decrease" \ -movflags +faststart \ lighter_vid.mp4 ``` -------------------------------- ### Visualize Custom Pose Model Hierarchy Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Visualize your skeleton's hierarchy by setting pose_model to CUSTOM in Config.toml and using this Python script. It requires the toml and anytree libraries. ```python config_path = r'path_to_Config.toml' import toml, anytree config = toml.load(config_path) pose_model = config.get('pose').get('pose_model') model = anytree.importer.DictImporter().import_(config.get('pose').get(pose_model)) for pre, _, node in anytree.RenderTree(model): print(f'{pre}{node.name} id={node.id}') ``` -------------------------------- ### Convert DeepLabCut H5 to JSON Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Use this script to translate DeepLabCut's h5 2D coordinates to JSON files. Ensure camera folder names match the calibration file and end with '_json'. ```cmd DLC_to_OpenPose -i input_h5_file ``` -------------------------------- ### Run All Pose2Sim Stages Concurrently Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Execute all processing stages of Pose2Sim with a single function call. Optional arguments allow enabling or disabling specific stages. ```python from Pose2Sim import Pose2Sim Pose2Sim.runAll() # or: # Pose2Sim.runAll(do_calibration=True, do_poseEstimation=True, do_synchronization=True, do_personAssociation=True, do_triangulation=True, do_filtering=True, do_markerAugmentation=True, do_kinematics=True) ``` -------------------------------- ### Calibrate Cameras using Pose2Sim Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Calibrate cameras by calculating intrinsic and extrinsic parameters. This Python script can convert existing calibration files or compute them from scratch. Ensure your environment is activated and you are in your project folder. ```python from Pose2Sim import Pose2Sim Pose2Sim.calibration() ``` -------------------------------- ### Run Keypoint Triangulation Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Performs robust triangulation of 2D keypoints to 3D coordinates. This function is crucial for reconstructing the 3D pose of individuals from multiple camera perspectives. ```python from Pose2Sim import Pose2Sim Pose2Sim.triangulation() ``` -------------------------------- ### Run Person Association Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Initiates the person association process. This is used when multiple people are present in the scene and need to be tracked across different camera views. ```python from Pose2Sim import Pose2Sim Pose2Sim.personAssociation() ``` -------------------------------- ### Convert AlphaPose JSON to OpenPose Format Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Use this script to translate single JSON files generated by AlphaPose into OpenPose frame-by-frame files. Ensure the input JSON file path is correctly specified. ```cmd AlphaPose_to_OpenPose -i input_alphapose_json_file ``` -------------------------------- ### Perform OpenSim Kinematics Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Automatically scale an OpenSim skeletal model and compute 3D joint angles using inverse kinematics. This function can be significantly faster if `use_simple_model` is set to true in Config.toml. Filtering can be enabled with `filter_ik`. ```python from Pose2Sim import Pose2Sim Pose2Sim.kinematics() ``` -------------------------------- ### Augment Markers with Stanford LSTM Model Source: https://github.com/perfanalytics/pose2sim/blob/main/README.md Use this function to estimate the position of virtual markers using the Stanford LSTM model. Ensure participant height is correct in Config.toml and that missing values are interpolated. This method provides more stable but less precise output. ```python from Pose2Sim import Pose2Sim Pose2Sim.markerAugmentation() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.