Skip to main content

A set of computer vision tools for analyzing your climbing videos.

Project description

Climbing Analysis Toolbox

A set of computer vision tools for analyzing your climbing videos.

Getting Started

# (Optional) Create an virtual env
python -m venv PATH_TO_YOUR_VENV
source PATH_TO_YOUR_VENV
# Install prerequisites
python -m pip install -r requirements.txt

Catalogue

  1. Warping Video for Scene Matching goto
  2. Drawing Trajectories for Body Movements goto

1️⃣ Warping Video for Scene Matching

Sometimes, to analyze our sequences for a climb, we typically have multiple sessions. During those sessions, we might have the camera placed at different locations, thus pointing from different angles towards the climb we are projecting. This tool helps you transform videos so that they match a reference image that corresponds to the whole picture of your climb. Reasons for doing this are:

  1. It is better for using tools that involve 2D/3D pose estimation
  2. It is easier to see how your body moves with respect to similar angles. Note that, right now, it is impossible to seamlessly match a video to the scene of a base image if their camera angles and positions differ by a large amount; some area might be off from base scene.

To warp a video to match a reference scene, we extract the features between two frames, and then a homography matrix is extracted for the image transformation. By default, we use a per-frame homography matrix, but that also means we have to compute $H$ for each frame of the input video if the input video is moving. If the camera of your input video is not moving, we can reduce the processing time by only comparing the first frame of the video and the base scene. This reduces the computation time for the matcher we are using, so only image transformation is involved for the entire warping process. We call the first scenario dynamic and the second scenario fixed, as you can set with the type option.

# Warp a video with moving camera (per-frame homography matrix for the transformation)
python examples/scripts/warp_video.py \
--src_video_path "examples/videos/warp-dynamic-input.mp4" \
--ref_img "examples/videos/warp-dynamic-ref.jpg"
# by default the type of warping is `dynamic`
cruxes = Cruxes()
cruxes.warp_video(
    reference_image, target_video, 
    warp_type="dynamic",
    overlay_text=False # Whether to overlay filename on top of the video or not
)
🎬 Example Resulting Video Your browser does not support the video tag.
# Warp a video with fixed camera (first-frame homography matrix for the transformation)
python examples/scripts/warp_video.py \
--src_video_path "examples/videos/warp-fixed-input.mp4" \
--ref_img "examples/videos/warp-fixed-ref.jpg" \
--type "fixed"
cruxes = Cruxes()
cruxes.warp_video(
    reference_image, target_video, 
    warp_type="fixed",
    overlay_text=False
)
🎬 Example Resulting Video Your browser does not support the video tag.

If you can't see the example resulting video, go to the example/videos/ folder.


2️⃣ Drawing Trajectories for Body Movements

It is recommended to apply this script to a video with fixed camera position, i.e., camera is not being moved.

There is a couple of settings you can adjust inside the script for extract_pose_and_draw_trajectory():

Argument Description
track_point Points of interest on the estimated pose you want to track. A velocity vector arrow will be drawn to indicate how fast each point is moving with respect to its 3D position
overlay_trajectory Whether to overlay a half-transparent mask on top of the original video. Note that if this is set to True, the velocity vector arrow that corresponds to each track point will be removed.
draw_pose Whether to draw pose skeleton or not
kalman_settings Whether to apply Kalman filter to smooth out the trajectory (not the pose itself)
trajectory_png_path Whether to generate a .png file for the trajectory with black background

Then, run the command as follows:

python examples/scripts/body_trajectory.py \
--video_path "examples/videos/body-trajectory-input.mp4"
cruxes = Cruxes()
cruxes.body_trajectory(
    target_video_path,
    track_point=[
        "hip_mid",
        # "upper_body_center",
        # "head",
        "left_hand",
        "right_hand",
        # "left_foot",
        # "right_foot",
    ],
    overlay_trajectory=False,
    draw_pose=True,
    kalman_settings=[  # Kalman filter settings: [use_kalman : bool, kalman_gain : float]
        True,  # Set this to false if you don't want to apply Kalman filter
        1e0,  # >=1e0 for higher noise, <=1e-1 for lower noise
    ],
    trajectory_png_path=None,
)

The generated video will then be located inside of the output folder.

🎬 Example Resulting Video Your browser does not support the video tag.

If you can't see the example resulting video, go to the example/videos/ folder.

To-do

  • Migrate to PyPI for easier installation and use.
  • Add a server backend to allow API request for specific functionality.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cruxes-0.0.2.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cruxes-0.0.2-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file cruxes-0.0.2.tar.gz.

File metadata

  • Download URL: cruxes-0.0.2.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for cruxes-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a1c58af0ab8eda48aca9959215044c372cf91e3a09c52f109eecc2a51b597d7c
MD5 9ea24ebbafb2024239f86cc7007a906c
BLAKE2b-256 285cd3ea1cbb6718e6cb783f2a19d4cee83339e087b5dca673b56bbd8bc57e45

See more details on using hashes here.

File details

Details for the file cruxes-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: cruxes-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for cruxes-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 84e7ee251f98afc08c1f6ec716a55e4031f6efeb213107da4941edde1b1e3b31
MD5 76ba42aec4915c8fe2715ab015dd8945
BLAKE2b-256 b567927b1119a0e51230cd52b39df1e81204150b6c513d50ca5ccd269f4dc7d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page