#!/usr/bin/env python3 """ Test the enhanced Google Earth-style video generation """ import sys import os sys.path.append('/home/pi/Desktop/traccar_animation') from py_scripts.video_3d_generator import create_space_entry_frame, create_3d_frame import numpy as np import cv2 def test_enhanced_visuals(): """Test the enhanced Google Earth-style visuals""" print("Testing enhanced Google Earth-style video generation...") # Test parameters start_pos = { 'latitude': 45.7749, 'longitude': -122.4194, 'speed': 0, 'deviceTime': '2025-07-08 12:00:00' } positions = [start_pos] center_lat = 45.7749 center_lon = -122.4194 min_lat = 45.7700 max_lat = 45.7800 min_lon = -122.4250 max_lon = -122.4150 width = 1920 height = 1080 # Test space entry frames at different altitudes test_frames = [0, 30, 60, 89] # Beginning, middle, end of space entry for frame_idx in test_frames: print(f"Testing space entry frame {frame_idx}/90...") try: frame = create_space_entry_frame( start_pos, center_lat, center_lon, min_lat, max_lat, min_lon, max_lon, width, height, frame_idx, 90 ) # Verify frame quality if frame is None: print(f"❌ Frame {frame_idx} is None") return False if frame.shape != (height, width, 3): print(f"❌ Frame {frame_idx} wrong shape: {frame.shape}") return False # Check for visual diversity (not just black/empty) unique_colors = len(np.unique(frame.reshape(-1, frame.shape[2]), axis=0)) if unique_colors < 100: # Should have many colors for realistic visuals print(f"❌ Frame {frame_idx} too few colors: {unique_colors}") return False print(f"✅ Space entry frame {frame_idx} - Colors: {unique_colors}, Range: {np.min(frame)}-{np.max(frame)}") except Exception as e: print(f"❌ Space entry frame {frame_idx} failed: {e}") return False # Test route following frame print("Testing enhanced route following frame...") try: route_frame = create_3d_frame( start_pos, positions, 0, center_lat, center_lon, min_lat, max_lat, min_lon, max_lon, width, height ) if route_frame is None: print("❌ Route frame is None") return False unique_colors = len(np.unique(route_frame.reshape(-1, route_frame.shape[2]), axis=0)) if unique_colors < 100: print(f"❌ Route frame too few colors: {unique_colors}") return False print(f"✅ Route frame - Colors: {unique_colors}, Range: {np.min(route_frame)}-{np.max(route_frame)}") except Exception as e: print(f"❌ Route frame failed: {e}") return False print("✅ All enhanced visual tests passed!") print("🌍 Google Earth-style backgrounds are working properly") print("🚀 Space entry sequence has realistic visuals") print("🎬 High-quality terrain and atmospheric effects generated") return True if __name__ == "__main__": success = test_enhanced_visuals() if success: print("\n🎉 Enhanced Google Earth-style video generation is ready!") sys.exit(0) else: print("\n❌ Enhanced video generation test failed") sys.exit(1)