diff --git a/pose_detector_window.py b/pose_detector_window.py index 2975637..b282d79 100644 --- a/pose_detector_window.py +++ b/pose_detector_window.py @@ -666,10 +666,12 @@ def main(): ) # Essential arguments - parser.add_argument('--input', '-i', required=True, - help='Input source (path to video file or URL)') - parser.add_argument('--output', '-o', required=True, - help='Output JSON file to save pose data') + parser.add_argument('--input', '-i', required=False, + help='Input source (path to video file, URL, or camera index like "0" for webcam)') + parser.add_argument('--camera', '-c', action='store_true', + help='Use default webcam (camera 0) as input source') + parser.add_argument('--output', '-o', required=False, + help='Output JSON file to save pose data (optional for camera mode)') parser.add_argument('--model', type=str, default='n', choices=['n', 's', 'm', 'l', 'x'], help='YOLOv11 model size (n=nano, s=small, m=medium, l=large, x=xlarge)') parser.add_argument('--device', type=str, default='auto', @@ -693,6 +695,19 @@ def main(): args = parser.parse_args() + # Handle camera/input source logic + if args.camera: + input_source = 0 # Default webcam + print("📷 Using default webcam (camera 0)") + elif args.input: + input_source = args.input + else: + parser.error("Either --input/-i or --camera/-c must be specified") + + # Output is optional for camera mode + if not args.output and not args.camera: + parser.error("--output/-o is required when not using camera mode") + # Validate filter window size if args.filter_window % 2 == 0: args.filter_window += 1 @@ -701,8 +716,8 @@ def main(): print("\n" + "="*50) print("📹 JD-Clone YOLOv11 Pose Detector") print("="*50) - print(f"• Input: {args.input}") - print(f"• Output: {args.output}") + print(f"• Input: {input_source if not args.camera else 'Webcam (camera 0)'}") + print(f"• Output: {args.output if args.output else 'None (preview only)'}") print(f"• Model: YOLOv11-{args.model}") print(f"• Device: {args.device}") print(f"• Preview: {'Disabled' if args.no_preview else 'Enabled'}") @@ -714,7 +729,7 @@ def main(): # Run pose detection try: run_pose_detection( - input_source=args.input, + input_source=input_source, output_file=args.output, normalize=not args.no_normalize, detection_threshold=args.detection_threshold,