mirror of
https://github.com/yakhyo/uniface.git
synced 2026-05-15 12:57:55 +00:00
* feat: Add BYTETrack for face/person tracking * docs: Update documentation * ref: Update tools folder file naming and imports * docs: Update jupyter notebook examples * ref: Rename the file and remove duplicate codes * docs: Update README.md * chore: Update description in mkdocs, add keywords for face tracking * docs: Add announcement section * feat: Remove expand bbox for tracking and update docs
30 lines
812 B
Python
30 lines
812 B
Python
# Copyright 2025-2026 Yakhyokhuja Valikhujaev
|
|
# Author: Yakhyokhuja Valikhujaev
|
|
# GitHub: https://github.com/yakhyo
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
IMAGE_EXTENSIONS = {'.jpg', '.jpeg', '.png', '.bmp', '.webp', '.tiff'}
|
|
VIDEO_EXTENSIONS = {'.mp4', '.avi', '.mov', '.mkv', '.webm', '.flv'}
|
|
|
|
|
|
def get_source_type(source: str) -> str:
|
|
"""Determine if source is image, video, or camera.
|
|
|
|
Args:
|
|
source: File path or camera ID string (e.g. ``"0"``).
|
|
|
|
Returns:
|
|
One of ``"image"``, ``"video"``, ``"camera"``, or ``"unknown"``.
|
|
"""
|
|
if source.isdigit():
|
|
return 'camera'
|
|
suffix = Path(source).suffix.lower()
|
|
if suffix in IMAGE_EXTENSIONS:
|
|
return 'image'
|
|
if suffix in VIDEO_EXTENSIONS:
|
|
return 'video'
|
|
return 'unknown'
|