This repository provides a comprehensive set of tools to analyze, process, and visualize joint angle differences between two videos (e.g., student vs. teacher movements). The project leverages keypoint extraction, dynamic time warping, and skeleton visualization to highlight areas of significant movement differences. This README.md is made by chatGPT. 😊
models, bin, tables and output, check from: https://drive.google.com/drive/folders/1PSy92vllcudy35nP8EFolWO0oyZj5Ktp?usp=sharing
- Python 3.8.5
- Opencv-python >=4.5
- NumPy >=1.20
- Matplotlib >=3.3
- OpenPose (Python API, manually compiled)
- scikit-learn >=0.24
- fastdtw >=0.3.4
-
Keypoint Extraction:
- Extracts keypoints from videos using OpenPose.
- Handles missing frames by applying interpolation for smoother results.
-
Angle Difference Calculation:
- Computes joint angle differences between two sets of keypoints.
- Supports frame alignment using truncation or interpolation.
-
Dynamic Time Warping (DTW):
- Measures the similarity between two temporal sequences of joint angles.
- Provides insights into movement synchronization.
-
Heatmap Visualization:
- Generates heatmaps to visualize angle differences across frames and joints.
-
Skeleton Visualization:
- Draws skeletons on video frames.
- Highlights joints with significant angle differences.
-
High-Difference Joint Detection:
- Identifies joints with significant movement differences using a customizable threshold.
Using the script 000_preprocess_videos.py, resample student and teacher videos to ensure the same frame count, FPS, and resolution.
The script 001_save_keypoints_and_offset.py extracts keypoints from the videos and computes joint angle differences.
With 002_angle_diff_analysis.py, analyze the computed angle differences by:
- Clustering frames based on movement patterns.
- Detecting frames with high average angle differences.
- Saving high-difference joint information.
Use 003_heatmap_angle.py to generate heatmaps of angle differences for intuitive visualization of movement discrepancies.
Finally, with 004_visualize_diff.py, create a video overlaying skeletons on student and teacher videos, highlighting joints with significant angle differences.
-
Clone this repository:
git clone https://github.com/chika19qian/OpenPose_DanceComparing.git cd MyOpenPose -
Install dependencies:
pip install -r requirements.txt
Note: The
requirements.txtfile has not been fully tested, and some dependencies may need manual installation or adjustment. -
Set up OpenPose: OpenPose is required for keypoint extraction, but it cannot be installed via pip. You need to compile OpenPose manually and ensure the
pyopenposelibrary is accessible in your environment. Place the compiledpyopenposefiles in theOpenPose_DanceComparing/directory.- Refer to the OpenPose documentation for compilation instructions.
- Make sure to include the
pyopenposelibrary in your Python environment.
-
Create a
modelsdirectory and download the OpenPose models:mkdir models # Add OpenPose model files here
python 000_preprocess_videos.pyEnsure that the student and teacher videos are in the examples/ directory.
python 001_save_keypoints_and_offset.pyThe keypoints and angle differences will be saved in the table/ directory.
Run each script step-by-step:
-
Analyze Angle Differences:
python 002_angle_diff_analysis.py
Outputs include:
- Frame-wise average angle differences:
output/lip_frame_average_difference.png - Joint-wise average angle differences:
output/lip_joint_average_difference.png - Clustering of frames:
output/lip_frame_clustering.png - DTW results: Printed DTW distance for angle synchronization analysis.
- Frame-wise average angle differences:
-
Generate Heatmaps:
python 003_heatmap_angle.py
-
Create Highlighted Video:
python 004_visualize_diff.py
The output will be saved in the output/ directory.
.
├── bin/ # OpenPose compiled binaries and pyopenpose
├── examples/ # Original student and teacher videos
├── models/ # OpenPose model files
├── myenv/ # Optional virtual environment directory
├── output/ # Generated visualizations and videos
├── table/ # Keypoints and angle difference data
├── videos/ # Processed videos
├── .gitignore
├── 000_preprocess_videos.py
├── 001_save_keypoints_and_offset.py
├── 002_angle_diff_analysis.py
├── 003_heatmap_angle.py
├── 004_visualize_diff.py
├── pyopenpose.cp38-win_amd64.pyd # OpenPose Python library
├── requirements.txt
└── README.md
-
Skeleton Visualization: ![Skeleton Video]
Contributions are welcome! Feel free to submit issues or pull requests for improvements.



