-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.py
More file actions
85 lines (72 loc) · 3.17 KB
/
main.py
File metadata and controls
85 lines (72 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
#!/usr/bin/env python3
"""
Main entry point for the fast volleyball tracking inference system.
"""
import argparse
import os
import sys
def main():
parser = argparse.ArgumentParser(description="Fast Volleyball Tracking Inference")
parser.add_argument("--mode", type=str, choices=["track", "pose", "analyze"],
default="track", help="Processing mode")
parser.add_argument("--video_path", type=str, help="Path to input video file")
parser.add_argument("--track_file", type=str, help="Path to track JSON file (for pose mode)")
parser.add_argument("--model_path", type=str, default="models/vballNetV1.onnx",
help="Path to ONNX model file")
parser.add_argument("--output_dir", type=str, default="output",
help="Directory to save output files")
parser.add_argument("--visualize", action="store_true",
help="Enable visualization on display using cv2")
args = parser.parse_args()
if args.mode == "track":
# Ball tracking mode
if not args.video_path:
print("Error: --video_path is required for tracking mode")
return 1
# Import and run ball tracking
try:
from src.inference_onnx import main as track_main
# We would need to pass the args to the tracking module
print("Ball tracking mode selected")
print(f"Video: {args.video_path}")
print(f"Model: {args.model_path}")
print(f"Visualize: {args.visualize}")
# In a full implementation, we would call track_main with appropriate arguments
except ImportError as e:
print(f"Error importing tracking module: {e}")
return 1
elif args.mode == "pose":
# Pose detection mode
if not args.track_file or not args.video_path:
print("Error: --track_file and --video_path are required for pose mode")
return 1
# Import and run pose detection
try:
from src.pose_detector import add_pose_to_track_json
print("Pose detection mode selected")
print(f"Track file: {args.track_file}")
print(f"Video: {args.video_path}")
print(f"Visualize: {args.visualize}")
add_pose_to_track_json(
track_file=args.track_file,
video_path=args.video_path,
output_dir=args.output_dir,
visualize=args.visualize
)
except ImportError as e:
print(f"Error importing pose detection module: {e}")
return 1
except Exception as e:
print(f"Error during pose detection: {e}")
return 1
elif args.mode == "analyze":
# Analysis mode
print("Analysis mode selected")
print("This mode is not yet implemented")
else:
print("Hello from fast-volleyball-tracking-inference!")
print("Use --mode to specify the processing mode")
print("Available modes: track, pose, analyze")
return 0
if __name__ == "__main__":
sys.exit(main())