Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with CoG Velocity Calculation: Units and Near-Zero Results #5846

Open
Vincent-Crawl opened this issue Feb 1, 2025 · 1 comment
Open
Assignees
Labels
os:windows MediaPipe issues on Windows platform:python MediaPipe Python issues stat:awaiting response Waiting for user response

Comments

@Vincent-Crawl
Copy link

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

Yes

OS Platform and Distribution

Windows 10 Home Basic 64 - bit

MediaPipe Tasks SDK version

0.10.20

Task name (e.g. Image classification, Gesture recognition etc.)

Pose Estimation

Programming Language and version (e.g. C++, Python, Java)

Python

Describe the actual behavior

The calculated CoG velocity is consistently near zero, even though the CoG position changes visibly in the video. This suggests a unit conversion issue or a problem with the calculation method.

Describe the expected behaviour

The CoG velocity should reflect the actual movement speed of the body's center of gravity, expressed in meters per second (m/s).

Standalone code/steps you may have used to try to get what you need

import cv2 import mediapipe as mp import numpy as np from scipy.signal import savgol_filter # ... (MediaPipe initialization and video capture) CoG_positions = [] while cap.isOpened(): # ... (MediaPipe pose processing) if results.pose_landmarks: landmarks = results.pose_landmarks.landmark CoG_x_pixel, CoG_y_pixel, CoG_z_pixel = calculate_body_center(landmarks) # Your CoG calculation function CoG_positions.append([CoG_x_pixel, CoG_y_pixel, CoG_z_pixel]) # ... (after the loop) CoG_positions = np.array(CoG_positions) # Velocity calculation (this is where I suspect the problem lies) CoG_velocities = np.diff(CoG_positions, axis=0) * fps # ... (smoothing and plotting)

Other info / Complete Logs

Here's an example of CoG position and velocity values:

Frame 1: CoG Position (x, y, z) = (0.3437, 0.7112, -0.0171)
Frame 1: CoG Velocity (x, y, z) = (0.0823, -0.3564, -0.1760) (These values are likely incorrect due to units.)
I suspect the issue is that the MediaPipe 3D coordinates are not in meters.  Could you please clarify the units and how to convert them to meters for velocity calculation?  Are there best practices for calculating CoG velocity with MediaPipe?
@kuaashish kuaashish assigned kuaashish and unassigned kalyan2789g Feb 3, 2025
@kuaashish kuaashish added os:windows MediaPipe issues on Windows platform:python MediaPipe Python issues labels Feb 3, 2025
@kuaashish
Copy link
Collaborator

Hi @Vincent-Crawl,

Please provide the complete standalone code to help us understand and reproduce the issue if needed. Alternatively, you can share the documentation you are following along with details of the support you require from us.

Thank you!!

@kuaashish kuaashish added the stat:awaiting response Waiting for user response label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:windows MediaPipe issues on Windows platform:python MediaPipe Python issues stat:awaiting response Waiting for user response
Projects
None yet
Development

No branches or pull requests

3 participants