Utils
detect_image_output(workflow_output)
¶
Detect the first available image output field in workflow output.
Source code in inference/core/interfaces/webrtc_worker/utils.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
get_cv2_rotation_code(rotation)
¶
Get OpenCV rotation code to correct a given rotation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rotation
|
int
|
Rotation angle in degrees from metadata |
required |
Returns:
| Type | Description |
|---|---|
Optional[int]
|
cv2 rotation constant or None if no correction needed |
Source code in inference/core/interfaces/webrtc_worker/utils.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
get_video_fps(filepath)
¶
Detect video FPS from container metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Path to the video file |
required |
Returns:
| Type | Description |
|---|---|
Optional[float]
|
FPS as float, or None if detection fails |
Source code in inference/core/interfaces/webrtc_worker/utils.py
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 | |
get_video_rotation(filepath)
¶
Detect video rotation from metadata (displaymatrix or rotate tag).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Path to the video file |
required |
Returns:
| Type | Description |
|---|---|
int
|
Rotation in degrees (-90, 0, 90, 180, 270) or 0 if not found. |
int
|
Negative values indicate counter-clockwise rotation. |
Source code in inference/core/interfaces/webrtc_worker/utils.py
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 | |
parse_video_file_chunk(message)
¶
Parse video file chunk message.
Returns: (chunk_index, total_chunks, payload)
Source code in inference/core/interfaces/webrtc_worker/utils.py
196 197 198 199 200 201 202 203 204 | |
rotate_video_frame(frame, rotation_code)
¶
Apply rotation to a video frame using OpenCV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
VideoFrame
|
Input VideoFrame |
required |
rotation_code
|
int
|
cv2 rotation constant (ROTATE_90_CLOCKWISE, etc.) |
required |
Returns:
| Type | Description |
|---|---|
VideoFrame
|
Rotated VideoFrame |
Source code in inference/core/interfaces/webrtc_worker/utils.py
382 383 384 385 386 387 388 389 390 391 392 393 394 | |