#!/usr/bin/env python3 """ Test script to verify streaming implementation components """ import sys from pathlib import Path def test_imports(): """Test that all modules can be imported""" print("Testing imports...") try: from vr180_streaming import VR180StreamingProcessor, StreamingConfig print("✅ Main imports successful") except ImportError as e: print(f"❌ Failed to import main modules: {e}") return False try: from vr180_streaming.frame_reader import StreamingFrameReader from vr180_streaming.frame_writer import StreamingFrameWriter from vr180_streaming.stereo_manager import StereoConsistencyManager from vr180_streaming.sam2_streaming import SAM2StreamingProcessor from vr180_streaming.detector import PersonDetector print("✅ Component imports successful") except ImportError as e: print(f"❌ Failed to import components: {e}") return False return True def test_config(): """Test configuration loading""" print("\nTesting configuration...") try: from vr180_streaming.config import StreamingConfig # Test creating config config = StreamingConfig() print("✅ Config creation successful") # Test config validation errors = config.validate() print(f" Config errors: {len(errors)} (expected, no paths set)") return True except Exception as e: print(f"❌ Config test failed: {e}") return False def test_dependencies(): """Test required dependencies""" print("\nTesting dependencies...") deps_ok = True # Test PyTorch try: import torch print(f"✅ PyTorch {torch.__version__}") if torch.cuda.is_available(): print(f" CUDA available: {torch.cuda.get_device_name(0)}") else: print(" ⚠️ CUDA not available") except ImportError: print("❌ PyTorch not installed") deps_ok = False # Test OpenCV try: import cv2 print(f"✅ OpenCV {cv2.__version__}") except ImportError: print("❌ OpenCV not installed") deps_ok = False # Test Ultralytics try: from ultralytics import YOLO print("✅ Ultralytics YOLO available") except ImportError: print("❌ Ultralytics not installed") deps_ok = False # Test other deps try: import yaml import numpy as np import psutil print("✅ Other dependencies available") except ImportError as e: print(f"❌ Missing dependency: {e}") deps_ok = False return deps_ok def test_frame_reader(): """Test frame reader with a dummy video""" print("\nTesting StreamingFrameReader...") try: from vr180_streaming.frame_reader import StreamingFrameReader # Would need an actual video file to test print("⚠️ Skipping reader test (no test video)") return True except Exception as e: print(f"❌ Frame reader test failed: {e}") return False def main(): """Run all tests""" print("🧪 VR180 Streaming Implementation Test") print("=" * 40) all_ok = True # Run tests all_ok &= test_imports() all_ok &= test_config() all_ok &= test_dependencies() all_ok &= test_frame_reader() print("\n" + "=" * 40) if all_ok: print("✅ All tests passed!") print("\nNext steps:") print("1. Install SAM2: cd segment-anything-2 && pip install -e .") print("2. Download checkpoints: cd checkpoints && ./download_ckpts.sh") print("3. Create config: python -m vr180_streaming --generate-config my_config.yaml") print("4. Run processing: python -m vr180_streaming my_config.yaml") else: print("❌ Some tests failed") print("\nPlease run: pip install -r requirements.txt") return 0 if all_ok else 1 if __name__ == "__main__": sys.exit(main())