API Reference¶
Complete API documentation for all public classes and functions.
ClimbingAnalysis¶
Complete analysis result with summary and detailed history.
Attributes:
| Name | Type | Description |
|---|---|---|
summary |
ClimbingSummary
|
Aggregated statistics |
history |
Dict[str, list]
|
Frame-by-frame metric history |
video_path |
str | None
|
Path to analyzed video |
video_quality |
VideoQualityReport | None
|
Video quality report (if validation was run) |
tracking_quality |
TrackingQualityReport | None
|
Pose tracking quality report (if validation was run) |
Source code in src/climb_sensei/models.py
from_dict(d)
classmethod
¶
Create ClimbingAnalysis from dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
Dict
|
Dictionary with summary, history, and video_path |
required |
Returns:
| Type | Description |
|---|---|
ClimbingAnalysis
|
ClimbingAnalysis instance |
Source code in src/climb_sensei/models.py
to_dict()
¶
Convert to dictionary for serialization.
Returns:
| Type | Description |
|---|---|
Dict
|
Dictionary with summary, history, video_path, and quality reports |
Source code in src/climb_sensei/models.py
options: show_source: true heading_level: 3
Video Quality¶
VideoQualityChecker¶
Validates video quality for climbing analysis.
Source code in src/climb_sensei/video_quality.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
__init__(deep_check=False)
¶
Initialize quality checker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deep_check
|
bool
|
If True, perform frame-by-frame analysis (slower) |
False
|
check_video(video_path)
¶
Perform comprehensive video quality check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_path
|
str
|
Path to video file |
required |
Returns:
| Type | Description |
|---|---|
VideoQualityReport
|
VideoQualityReport with detailed assessment |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If video file doesn't exist |
ValueError
|
If file cannot be opened as video |
Source code in src/climb_sensei/video_quality.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
options: show_source: true heading_level: 3
VideoQualityReport¶
Comprehensive video quality assessment report.
Attributes:
| Name | Type | Description |
|---|---|---|
is_valid |
bool
|
Overall validity for climbing analysis |
file_path |
str
|
Path to video file |
file_size_mb |
float
|
File size in megabytes |
width |
int
|
Video width in pixels |
height |
int
|
Video height in pixels |
fps |
float
|
Frames per second |
frame_count |
int
|
Total number of frames |
duration_seconds |
float
|
Video duration in seconds |
codec |
str
|
Video codec (fourcc code) |
format_compatible |
bool
|
Whether format is supported |
resolution_quality |
str
|
Resolution quality assessment |
fps_quality |
str
|
Frame rate quality assessment |
duration_quality |
str
|
Duration quality assessment |
lighting_quality |
Optional[str]
|
Lighting conditions assessment |
stability_quality |
Optional[str]
|
Camera stability assessment |
issues |
List[str]
|
List of detected issues |
warnings |
List[str]
|
List of warnings |
recommendations |
List[str]
|
List of recommendations |
Source code in src/climb_sensei/video_quality.py
options: show_source: true heading_level: 3
check_video_quality¶
Convenience function to check video quality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_path
|
str
|
Path to video file |
required |
deep_check
|
bool
|
Whether to perform deep frame analysis |
False
|
Returns:
| Type | Description |
|---|---|
VideoQualityReport
|
VideoQualityReport |
Source code in src/climb_sensei/video_quality.py
options: show_source: true heading_level: 3
Tracking Quality¶
TrackingQualityAnalyzer¶
Analyze pose tracking quality in climbing videos.
This analyzer runs pose detection on a video and evaluates: - Detection rate: How often poses are detected - Landmark confidence: Average confidence scores - Visibility: Percentage of landmarks visible - Smoothness: Consistency of tracking (low jitter) - Tracking loss: Number of times tracking is lost
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_detection_rate
|
float
|
Minimum acceptable detection rate (0-100) |
70.0
|
min_avg_confidence
|
float
|
Minimum acceptable average confidence (0-1) |
0.5
|
min_visibility
|
float
|
Minimum acceptable visibility percentage (0-100) |
60.0
|
min_smoothness
|
float
|
Minimum acceptable smoothness score (0-1) |
0.6
|
max_tracking_losses
|
int
|
Maximum acceptable tracking loss events |
5
|
sample_rate
|
int
|
Analyze every Nth frame (1 = every frame) |
1
|
pose_detection_confidence
|
float
|
Confidence threshold for pose detection |
0.5
|
pose_tracking_confidence
|
float
|
Confidence threshold for pose tracking |
0.5
|
Source code in src/climb_sensei/tracking_quality.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
analyze_from_landmarks(landmarks_sequence, file_path='landmarks_sequence')
¶
Analyze tracking quality from pre-extracted landmark sequence.
This is more efficient than analyze_video() when landmarks are already available (e.g., during analyze_climb processing).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
landmarks_sequence
|
List[Optional[List[Tuple[float, float]]]]
|
List of landmark lists, one per frame. Each frame is either None (no detection) or a list of (x, y) tuples. Use None for frames where pose was not detected. |
required |
file_path
|
str
|
Optional identifier for the source (for reporting) |
'landmarks_sequence'
|
Returns:
| Type | Description |
|---|---|
TrackingQualityReport
|
TrackingQualityReport with analysis results |
Example
landmarks_seq = [ ... [(0.5, 0.5), (0.6, 0.4), ...], # Frame 0 ... [(0.5, 0.5), (0.6, 0.4), ...], # Frame 1 ... None, # Frame 2 - no detection ... [(0.5, 0.5), (0.6, 0.4), ...], # Frame 3 ... ] analyzer = TrackingQualityAnalyzer() report = analyzer.analyze_from_landmarks(landmarks_seq)
Source code in src/climb_sensei/tracking_quality.py
analyze_video(video_path)
¶
Analyze tracking quality for a video.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_path
|
str
|
Path to video file |
required |
Returns:
| Type | Description |
|---|---|
TrackingQualityReport
|
TrackingQualityReport with analysis results |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If video file doesn't exist |
ValueError
|
If video cannot be opened |
Source code in src/climb_sensei/tracking_quality.py
options: show_source: true heading_level: 3
TrackingQualityReport¶
Report of pose tracking quality analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
file_path |
str
|
Path to analyzed video file |
total_frames |
int
|
Total number of frames analyzed |
frames_with_pose |
int
|
Number of frames where pose was detected |
detection_rate |
float
|
Percentage of frames with pose detected (0-100) |
avg_landmark_confidence |
float
|
Average confidence across all landmarks (0-1) |
min_landmark_confidence |
float
|
Minimum average confidence in any frame (0-1) |
avg_visibility_score |
float
|
Average percentage of visible landmarks (0-100) |
tracking_smoothness |
float
|
Smoothness score based on landmark jitter (0-1, higher=smoother) |
tracking_loss_events |
int
|
Number of times tracking was lost then regained |
is_trackable |
bool
|
Whether video has sufficient tracking quality |
issues |
List[str]
|
List of critical tracking issues |
warnings |
List[str]
|
List of tracking quality warnings |
quality_level |
str
|
Overall tracking quality ('poor', 'acceptable', 'good', 'excellent') |
frame_confidences |
List[float]
|
Per-frame average confidence scores |
frame_visibility |
List[float]
|
Per-frame visibility percentages |
Source code in src/climb_sensei/tracking_quality.py
options: show_source: true heading_level: 3
analyze_tracking_quality¶
Convenience function to analyze tracking quality from video.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_path
|
str
|
Path to video file |
required |
sample_rate
|
int
|
Analyze every Nth frame (1 = every frame) |
1
|
min_detection_rate
|
float
|
Minimum acceptable detection rate percentage |
70.0
|
Returns:
| Type | Description |
|---|---|
TrackingQualityReport
|
TrackingQualityReport with analysis results |
Example
report = analyze_tracking_quality('climbing.mp4') if report.is_trackable: ... print(f"Detection rate: {report.detection_rate}%") ... else: ... print("Tracking issues:", report.issues)
Source code in src/climb_sensei/tracking_quality.py
options: show_source: true heading_level: 3
analyze_tracking_from_landmarks¶
Convenience function to analyze tracking quality from landmarks.
More efficient than analyze_tracking_quality() when landmarks are already available from pose detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
landmarks_sequence
|
List[Optional[List[Tuple[float, float]]]]
|
List of landmark lists, one per frame. Each frame is either None (no detection) or list of (x, y) tuples. |
required |
sample_rate
|
int
|
Analyze every Nth frame (1 = every frame) |
1
|
min_detection_rate
|
float
|
Minimum acceptable detection rate percentage |
70.0
|
file_path
|
str
|
Optional identifier for the source |
'landmarks_sequence'
|
Returns:
| Type | Description |
|---|---|
TrackingQualityReport
|
TrackingQualityReport with analysis results |
Example
During analysis¶
landmarks_history = [] for frame in video: ... landmarks = detect_pose(frame) ... landmarks_history.append(landmarks)
Analyze tracking quality¶
report = analyze_tracking_from_landmarks(landmarks_history) print(f"Smoothness: {report.tracking_smoothness:.3f}")
Source code in src/climb_sensei/tracking_quality.py
options: show_source: true heading_level: 3
PoseEngine¶
Pose estimation engine using MediaPipe PoseLandmarker.
This class wraps MediaPipe's PoseLandmarker to detect human pose landmarks in images. It provides a clean interface for processing individual frames and extracting landmark coordinates.
Attributes:
| Name | Type | Description |
|---|---|---|
min_detection_confidence |
Minimum confidence value ([0.0, 1.0]) for pose detection to be considered successful. |
|
min_tracking_confidence |
Minimum confidence value ([0.0, 1.0]) for pose tracking to be considered successful. |
|
landmarker |
MediaPipe PoseLandmarker instance. |
Source code in src/climb_sensei/pose_engine.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
__enter__()
¶
__exit__(exc_type, exc_val, exc_tb)
¶
__init__(min_detection_confidence=_DEFAULT_POSE.min_detection_confidence, min_tracking_confidence=_DEFAULT_POSE.min_tracking_confidence, model_path=None)
¶
Initialize the pose engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_detection_confidence
|
float
|
Minimum confidence for detection (0.0-1.0). |
min_detection_confidence
|
min_tracking_confidence
|
float
|
Minimum confidence for tracking (0.0-1.0). |
min_tracking_confidence
|
model_path
|
Optional[str]
|
Optional path to the pose model file. If None, downloads the default model automatically. |
None
|
Source code in src/climb_sensei/pose_engine.py
close()
¶
extract_landmarks(results=None)
¶
Extract landmark coordinates from pose detection results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
Any
|
MediaPipe pose detection results object. If None, uses the last processed results. |
None
|
Returns:
| Type | Description |
|---|---|
List[Dict[str, float]]
|
List of dictionaries containing x, y, z coordinates and |
List[Dict[str, float]]
|
visibility for each landmark. Coordinates are normalized |
List[Dict[str, float]]
|
to [0.0, 1.0] range. |
Source code in src/climb_sensei/pose_engine.py
process(image)
¶
Process an image and detect pose landmarks with temporal smoothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
Input image in BGR format (OpenCV convention). |
required |
Returns:
| Type | Description |
|---|---|
Optional[Any]
|
MediaPipe pose detection results object containing landmarks, |
Optional[Any]
|
or None if no pose was detected. |
Source code in src/climb_sensei/pose_engine.py
options: show_source: true heading_level: 3
VideoReader¶
Read video frames from a file or camera source.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path to video file or camera index. |
|
cap |
OpenCV VideoCapture object. |
|
fps |
Frames per second of the video. |
|
frame_count |
Total number of frames in the video. |
|
width |
Width of video frames in pixels. |
|
height |
Height of video frames in pixels. |
Source code in src/climb_sensei/video_io.py
__enter__()
¶
__exit__(exc_type, exc_val, exc_tb)
¶
__init__(path)
¶
Initialize the video reader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | int
|
Path to video file or camera index (0 for default camera). |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the video source cannot be opened. |
Source code in src/climb_sensei/video_io.py
__iter__()
¶
Iterate over video frames.
Yields:
| Type | Description |
|---|---|
ndarray
|
Each frame as a numpy array (BGR format). |
Example
with VideoReader("video.mp4") as reader: ... for frame in reader: ... process(frame)
Source code in src/climb_sensei/video_io.py
__len__()
¶
read()
¶
Read the next frame from the video.
Returns:
| Type | Description |
|---|---|
bool
|
A tuple of (success, frame) where success is True if frame was read |
Optional[ndarray]
|
successfully, and frame is the image data as a numpy array. |
Source code in src/climb_sensei/video_io.py
options: show_source: true heading_level: 3
VideoWriter¶
Write video frames to a file.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Output file path. |
|
fourcc |
FourCC codec code. |
|
fps |
Frames per second for output video. |
|
width |
Width of output frames in pixels. |
|
height |
Height of output frames in pixels. |
|
writer |
OpenCV VideoWriter object. |
Source code in src/climb_sensei/video_io.py
__enter__()
¶
__exit__(exc_type, exc_val, exc_tb)
¶
__init__(path, fps, width, height, fourcc='avc1')
¶
Initialize the video writer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Output file path. |
required |
fps
|
int
|
Frames per second for the output video. |
required |
width
|
int
|
Width of output frames in pixels. |
required |
height
|
int
|
Height of output frames in pixels. |
required |
fourcc
|
str
|
FourCC codec code (default: "avc1" for H.264, browser-compatible). |
'avc1'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the video writer cannot be initialized. |
Source code in src/climb_sensei/video_io.py
release()
¶
write(frame)
¶
Write a frame to the video file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
ndarray
|
Image data as a numpy array (BGR format). |
required |
options: show_source: true heading_level: 3
Biomechanics Functions¶
calculate_joint_angle¶
Calculate the angle at point B formed by three points A-B-C.
This function calculates the interior angle at the middle point (B) using the law of cosines. The angle is measured in degrees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point_a
|
Tuple[float, float]
|
Coordinates (x, y) of the first point. |
required |
point_b
|
Tuple[float, float]
|
Coordinates (x, y) of the vertex point (angle point). |
required |
point_c
|
Tuple[float, float]
|
Coordinates (x, y) of the third point. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angle in degrees at point B (range: 0-180). |
Example
Calculate elbow angle¶
shoulder = (0.5, 0.3) elbow = (0.6, 0.5) wrist = (0.7, 0.6) angle = calculate_joint_angle(shoulder, elbow, wrist)
Source code in src/climb_sensei/biomechanics.py
options: show_source: true heading_level: 4
calculate_reach_distance¶
Calculate Euclidean distance between two points.
This function calculates the straight-line distance between two points in 2D space. Useful for measuring reach distances between body landmarks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point_a
|
Tuple[float, float]
|
Coordinates (x, y) of the first point. |
required |
point_b
|
Tuple[float, float]
|
Coordinates (x, y) of the second point. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Euclidean distance between the two points. |
Example
Calculate reach from hip to hand¶
hip = (0.5, 0.5) hand = (0.7, 0.3) distance = calculate_reach_distance(hip, hand)
Source code in src/climb_sensei/biomechanics.py
options: show_source: true heading_level: 4
calculate_center_of_mass¶
Calculate the weighted center of mass for a set of points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list[Tuple[float, float]]
|
List of (x, y) coordinate tuples. |
required |
weights
|
list[float] | None
|
Optional list of weights for each point. If None, all points are weighted equally. |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Coordinates (x, y) of the center of mass. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If points list is empty or weights length doesn't match. |
Example
Calculate body center of mass¶
landmarks = [(0.5, 0.3), (0.5, 0.5), (0.5, 0.7)] center = calculate_center_of_mass(landmarks)
Source code in src/climb_sensei/biomechanics.py
options: show_source: true heading_level: 4
calculate_limb_angles¶
Calculate joint angles for all major limbs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
landmarks
|
list[dict[str, float]]
|
List of landmark dictionaries with x, y, z coordinates |
required |
landmark_indices
|
type[LandmarkIndex]
|
LandmarkIndex class with landmark indices |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary with joint angles: |
dict[str, float]
|
|
dict[str, float]
|
|
dict[str, float]
|
|
dict[str, float]
|
|
dict[str, float]
|
|
dict[str, float]
|
|
dict[str, float]
|
|
dict[str, float]
|
|
Source code in src/climb_sensei/biomechanics.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
options: show_source: true heading_level: 4
calculate_total_distance_traveled¶
Calculate total distance traveled along a path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
list[Tuple[float, float]]
|
List of (x, y) positions in chronological order |
required |
Returns:
| Type | Description |
|---|---|
float
|
Total distance traveled (sum of all segments) |
Source code in src/climb_sensei/biomechanics.py
options: show_source: true heading_level: 4
Visualization Functions¶
draw_pose_landmarks¶
Draw pose landmarks and connections on an image with color-coded body parts.
This function draws the detected pose landmarks as circles and connects them with lines. By default, uses color-coding for different body parts (similar to MediaPipe's built-in visualization).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
Input image in BGR format (will not be modified). |
required |
results
|
Any
|
MediaPipe pose detection results object. |
required |
landmark_color
|
Optional[Tuple[int, int, int]]
|
BGR color tuple for landmarks. If None and use_color_coding=True, uses automatic color-coding by body part. |
None
|
connection_color
|
Optional[Tuple[int, int, int]]
|
BGR color tuple for connections. If None, uses white. |
None
|
thickness
|
int
|
Line thickness in pixels (default: 2). |
line_thickness
|
circle_radius
|
int
|
Landmark circle radius in pixels (default: 5). |
circle_radius
|
connections
|
Optional[FrozenSet[Tuple[int, int]]]
|
Optional set of (start_idx, end_idx) tuples defining which landmarks to connect. If None, uses default full pose connections. |
None
|
landmarks_to_draw
|
Optional[FrozenSet[int]]
|
Optional set of landmark indices to draw. If None, draws all. |
None
|
use_color_coding
|
bool
|
If True, uses color-coded landmarks by body part (default: True). |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
New image with landmarks drawn (BGR format). |
Example
from climb_sensei.config import CLIMBING_CONNECTIONS, CLIMBING_LANDMARKS with PoseEngine() as engine: ... results = engine.process(frame) ... if results: ... # Draw only climbing-relevant landmarks (no head) with color-coding ... annotated_frame = draw_pose_landmarks( ... frame, results, ... connections=CLIMBING_CONNECTIONS, ... landmarks_to_draw=CLIMBING_LANDMARKS ... )
Source code in src/climb_sensei/viz.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
options: show_source: true heading_level: 4
draw_metrics_overlay¶
Draw climbing metrics overlay on image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
Input image in BGR format (will not be modified). |
required |
current_metrics
|
Optional[dict]
|
Dictionary of current frame metrics. |
None
|
cumulative_metrics
|
Optional[dict]
|
Dictionary of cumulative/average metrics. |
None
|
font_scale
|
float
|
Font scale factor (default: 0.6). |
font_scale
|
thickness
|
int
|
Text thickness in pixels (default: 2). |
font_thickness
|
bg_alpha
|
float
|
Background transparency (0.0-1.0, default: 0.7). |
metrics_overlay_bg_alpha
|
Returns:
| Type | Description |
|---|---|
ndarray
|
New image with metrics overlay drawn (BGR format). |
Source code in src/climb_sensei/viz.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
options: show_source: true heading_level: 4
create_metrics_dashboard¶
Create a dashboard with multiple metric plots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history
|
Dict[str, List[float]]
|
Dictionary with metric histories from ClimbingAnalyzer.get_history() |
required |
current_frame
|
int
|
Current frame index |
required |
fps
|
float
|
Frames per second (for time axis) |
30.0
|
plot_width
|
int
|
Width of each plot |
plot_width
|
plot_height
|
int
|
Height of each plot |
plot_height
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Dashboard image as numpy array (BGR format) |
Source code in src/climb_sensei/metrics_viz.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
options: show_source: true heading_level: 4
compose_frame_with_dashboard¶
Compose video frame side-by-side with metrics dashboard (no overlay).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
ndarray
|
Input video frame |
required |
dashboard
|
ndarray
|
Metrics dashboard image |
required |
position
|
str
|
Where to place dashboard ("right" or "left") |
'right'
|
spacing
|
int
|
Pixels of spacing between frame and dashboard |
0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Composite frame with video and dashboard side-by-side |
Source code in src/climb_sensei/metrics_viz.py
options: show_source: true heading_level: 4
overlay_metrics_on_frame¶
Overlay metrics dashboard on video frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
ndarray
|
Input video frame (BGR) |
required |
dashboard
|
ndarray
|
Dashboard image from create_metrics_dashboard |
required |
position
|
str
|
Where to place dashboard ("right", "left", "bottom") |
'right'
|
alpha
|
float
|
Opacity of dashboard (0.0 = transparent, 1.0 = opaque) |
0.9
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Frame with dashboard overlaid |
Source code in src/climb_sensei/metrics_viz.py
options: show_source: true heading_level: 4
Configuration¶
Configuration for pose visualization and analysis.
This module defines application-wide configuration including: - Pose landmarks and connections for climbing analysis - Model configuration (confidence thresholds, etc.) - Metrics calculation parameters - Visualization styling (colors, dimensions, etc.)
LandmarkIndex
¶
Bases: IntEnum
MediaPipe Pose landmark indices.
Centralized definition of landmark indices for consistency across modules.
Source code in src/climb_sensei/config.py
MetricsConfig
dataclass
¶
Immutable metrics calculation configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
lock_off_threshold_degrees |
float
|
Elbow angle threshold for lock-off detection |
rest_velocity_threshold |
float
|
Max velocity for rest position detection |
rest_body_angle_threshold |
float
|
Max body angle for rest position (degrees) |
efficient_economy_ratio |
float
|
Threshold for efficient movement economy |
fatigue_window_size |
int
|
Number of frames for fatigue analysis |
com_body_weight |
float
|
Weight factor for center of mass calculation |
Source code in src/climb_sensei/config.py
PoseConfig
dataclass
¶
Immutable pose detection and tracking configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
min_detection_confidence |
float
|
Minimum confidence for pose detection (0.0-1.0) |
min_tracking_confidence |
float
|
Minimum confidence for pose tracking (0.0-1.0) |
timestamp_increment_ms |
int
|
Milliseconds per frame for temporal smoothing |
Source code in src/climb_sensei/config.py
__post_init__()
¶
Validate configuration values.
Source code in src/climb_sensei/config.py
VisualizationConfig
dataclass
¶
Visualization styling configuration (immutable).
Source code in src/climb_sensei/config.py
get_landmark_name(index)
¶
Get the human-readable name for a landmark index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Landmark index (0-32). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Human-readable landmark name. |
Source code in src/climb_sensei/config.py
options: show_source: true heading_level: 3