Spaces:
Running
Running
File size: 3,466 Bytes
06417df 63ea6ab 06417df 63ea6ab c15d55f 63ea6ab 06417df c15d55f 63ea6ab 06417df 63ea6ab 06417df 63ea6ab c15d55f 63ea6ab 06417df 63ea6ab 06417df 63ea6ab c15d55f 63ea6ab 06417df 63ea6ab f4c30f7 63ea6ab f4c30f7 63ea6ab f4c30f7 06417df f4c30f7 |
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 86 87 |
#!/usr/bin/env python3
"""
Command-line interface for lane detection
Usage: python cli.py <input_video> <output_video> [method] [enhanced] [segmented]
"""
import sys
import os
from lane_detection import process_video
def main():
if len(sys.argv) < 3 or len(sys.argv) > 6:
print("Usage: python cli.py <input_video> <output_video> [method] [enhanced] [segmented]")
print("\nArguments:")
print(" input_video: Path to input video file")
print(" output_video: Path to output video file")
print(" method: 'basic_standard', 'basic_segmented', 'advanced', 'yolop', 'ufld', or 'scnn' (default: advanced)")
print(" enhanced: 'true' or 'false' for enhanced thresholding (default: true, advanced only)")
print(" segmented: 'true' or 'false' for segmented lines (default: false, basic only)")
print("\nExamples:")
print(" python cli.py road_video.mp4 output_result.mp4")
print(" python cli.py road_video.mp4 output_result.mp4 yolop")
print(" python cli.py road_video.mp4 output_result.mp4 ufld")
print(" python cli.py road_video.mp4 output_result.mp4 scnn")
print(" python cli.py road_video.mp4 output_result.mp4 basic_standard")
print(" python cli.py road_video.mp4 output_result.mp4 basic_segmented")
print(" python cli.py road_video.mp4 output_result.mp4 advanced true false")
sys.exit(1)
input_path = sys.argv[1]
output_path = sys.argv[2]
method = sys.argv[3] if len(sys.argv) >= 4 else "advanced"
enhanced = sys.argv[4].lower() == "true" if len(sys.argv) >= 5 else True
segmented = sys.argv[5].lower() == "true" if len(sys.argv) >= 6 else False
# Validate method
valid_methods = ["basic_standard", "basic_segmented", "advanced", "yolop", "ufld", "scnn"]
if method not in valid_methods:
print(f"Error: Invalid method '{method}'. Use one of: {', '.join(valid_methods)}")
sys.exit(1)
# Check if input file exists
if not os.path.exists(input_path):
print(f"Error: Input file '{input_path}' not found!")
sys.exit(1)
print(f"Processing video: {input_path}")
print(f"Output will be saved to: {output_path}")
print(f"Method: {method}")
if method == "advanced":
print(f"Enhanced thresholding: {'enabled' if enhanced else 'disabled'}")
if method in ["basic_standard", "basic_segmented"]:
print(f"Segmented lines: {'enabled' if segmented else 'disabled'}")
print("\nProcessing...")
try:
success = process_video(input_path, output_path, method, enhanced, segmented)
if success:
print("\n✓ Video processing completed successfully!")
print(f"✓ Result saved to: {output_path}")
if os.path.exists(output_path):
size = os.path.getsize(output_path)
print(f"✓ File size: {size:,} bytes")
else:
print("\n✗ Video processing failed!")
sys.exit(1)
except Exception as e:
print(f"\n✗ Error during processing: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\nOperation cancelled by user.")
sys.exit(0)
except Exception as e:
print(f"\n✗ Unexpected error: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
|