still updating the 3d video

This commit is contained in:
2025-07-08 15:26:33 +03:00
parent 2532bf6219
commit a565cd67e1
14 changed files with 1180 additions and 150 deletions

View File

@@ -1,40 +1,30 @@
# Enhanced 3D Video Animation Feature
# Professional Google Earth-Style 3D Video Animation
## Overview
The Enhanced 3D Video Animation feature generates professional, Google Earth-style video animations from GPS route data with spectacular space entry sequences. This upgraded system creates cinematic flythrough experiences starting from space and descending to follow the route with dynamic camera movement, realistic perspective, and advanced visual effects.
The Professional Google Earth-Style 3D Video Animation feature generates cinematic, high-quality video animations from GPS route data with realistic space entry sequences. This system creates authentic Google Earth-style visuals with professional terrain rendering, atmospheric effects, and spectacular space-to-Earth transitions.
## Core Enhancements
## Major Visual Enhancements
### Space Entry Sequence (NEW!)
- **Spectacular Entry from Space**: 3-second cinematic descent from 50km altitude
- **Smooth Space-to-Earth Transition**: Seamless transition from space view to aerial following
- **Earth Curvature Effects**: Realistic Earth curvature visible at high altitudes
- **Atmospheric Layers**: Progressive atmospheric effects during descent
- **Route Identification**: Route becomes visible and highlighted during descent
### Realistic Google Earth Visuals
- **Authentic Earth Sphere Rendering**: Realistic planetary view from space with proper curvature
- **Professional Terrain Textures**: Multi-layer terrain with forests, mountains, plains, deserts, and water bodies
- **Geographic Feature Simulation**: Coastlines, rivers, and landmasses with fractal-like detail
- **Atmospheric Scattering**: Realistic atmospheric effects and color gradients
- **Cloud Layer Rendering**: Dynamic cloud formations with proper shadows
### Advanced Camera System
- **Improved Aerial Perspective**: Camera height optimized for 1000-3000m range
- **Dynamic Camera Following**: Intelligent camera positioning that follows the route
- **Speed-Adaptive Look-Ahead**: Camera direction adjusts based on vehicle speed
- **Smooth Camera Transitions**: Fluid camera movements with momentum
- **Enhanced Perspective Offset**: Camera positioned for optimal aerial viewing angles
- **Dynamic Height & Tilt**: Camera height and angle adapt to terrain and speed
### Enhanced Space Entry Sequence
- **Spectacular Space View**: Authentic space background with star fields and Earth sphere
- **Realistic Atmospheric Entry**: Progressive transition through atmospheric layers
- **Earth's Terminator Line**: Day/night boundary visible at high altitudes
- **Professional UI**: Google Earth-style information panels and progress indicators
- **Cinematic Descent**: Smooth altitude progression from 50km to route level
### Google Earth-Style Perspective
- **True 3D Projection**: Proper field-of-view perspective projection
- **Depth-Aware Rendering**: Objects rendered in correct Z-order
- **Enhanced Aerial Views**: Optimized 1000-3000m altitude for perfect aerial perspective
- **Realistic Elevation**: Enhanced terrain with multi-layered elevation simulation
- **Atmospheric Perspective**: Distance fog and haze effects for depth
- **Terrain Grid**: Perspective grid for enhanced depth perception
### Enhanced Visual Effects
- **Space-to-Earth Transition**: Spectacular entry sequence with space background
- **Multi-Layer Terrain**: Realistic terrain with varied colors and textures
- **Gradient Backgrounds**: Dynamic space-to-sky-to-terrain transitions
- **Enhanced Route Visualization**: Depth-based thickness and opacity
- **Advanced Markers**: Multi-layer current position with shadows and glows
- **Direction Indicators**: Speed-based directional arrows
### Advanced Terrain System
- **Multi-Octave Terrain Generation**: Realistic landscape using multiple noise layers
- **Geographic Coordinate Influence**: Terrain varies based on actual GPS coordinates
- **Atmospheric Perspective**: Distance-based color shifts and haze effects
- **Cloud Shadow Mapping**: Realistic shadow patterns on terrain
- **Enhanced Color Palette**: Professional color schemes for different terrain types
### Professional UI Elements
- **Information Panel**: Speed, bearing, altitude, time, and progress with gradients
@@ -48,11 +38,14 @@ The Enhanced 3D Video Animation feature generates professional, Google Earth-sty
- **Frame Rate**: 30 FPS (smooth motion)
- **Format**: MP4 video (universal compatibility)
- **Compression**: MP4V codec optimized for quality
- **Space Entry**: 3-second descent from 50km altitude
- **Visual Quality**: Professional Google Earth-style rendering
- **Space Entry**: 3-second descent from 50km altitude with realistic visuals
- **Camera Height**: 1000-3000m (dynamic aerial perspective)
- **View Distance**: 3000m ahead (enhanced for aerial views)
- **Field of View**: 75° (optimized for aerial perspective)
- **Tilt Angle**: 65-73° (dynamic for terrain following)
- **Terrain Detail**: Multi-layer realistic terrain with 6+ terrain types
- **Color Depth**: Professional color palette with atmospheric effects
- **Entry Altitude Range**: 50km → 2km (space to aerial transition)
## Advanced Animation Features
@@ -226,14 +219,18 @@ Metadata Addition → File Output
1. **Space View (0-1 seconds)**: Starts from 50km altitude with black space background and Earth curvature
2. **Atmospheric Entry (1-2 seconds)**: Gradual transition showing atmospheric layers and blue sky emergence
3. **Route Approach (2-3 seconds)**: Descent to 2km altitude with route becoming visible and highlighted
4. **Aerial Following (3+ seconds)**: Seamless transition to dynamic camera following at optimal aerial height
4. **Transition Bridge (3-3.5 seconds)**: Smooth bridge frame announcing route start
5. **Aerial Following (3.5+ seconds)**: Seamless transition to dynamic camera following at optimal aerial height
### Technical Implementation
- **Altitude Range**: 50,000m → 2,000m → 1,000-3,000m (dynamic)
- **Descent Curve**: Cubic ease-out for natural deceleration
- **Camera Transition**: Smooth movement from center overview to route start
- **Transition Bridge**: Dedicated frame for smooth space-to-route handoff
- **Visual Effects**: Earth curvature, atmospheric glow, space-to-sky gradient
- **Route Visibility**: Progressive highlighting during descent approach
- **Error Handling**: Robust fallback frames ensure generation continues
- **Variable Safety**: Protected against undefined position markers
### Enhanced Aerial Perspective
- **Optimal Height Range**: 1000-3000 meters for perfect aerial views

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
gAAAAABobLgWZWKYF0nkSynV8d6s9J_G4GWuCbRofa_raK783ueF0ES9WXnIX02OcwMWWgpV1Ps4DJxDBTXtAQfjWHR0WrIN-FfcnViS1PEFFNDUtsN_PSSTND2vLOQEMRtUYYKG_UDZ
gAAAAABobPcZPB2ZDJEqHef1TANu1yOi8sYRts1-zpn_zcMBH3ydy0TWJp_G1YWt_G7dpvK29qN2UtnLkhi6-_EXq9AWcy1xHgF6FL5jl27RhdBF3-zNDSFOcDDnSVVbgvMjG88tOBMa

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 907 KiB

107
test_enhanced_video.py Normal file
View File

@@ -0,0 +1,107 @@
#!/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)

115
test_transition.py Normal file
View File

@@ -0,0 +1,115 @@
#!/usr/bin/env python3
"""
Test script to verify the transition from space entry to route following works correctly
"""
import sys
import os
sys.path.append('/home/pi/Desktop/traccar_animation')
from py_scripts.video_3d_generator import create_3d_frame, draw_3d_route
import numpy as np
def test_route_transition():
"""Test the transition from space entry to route following"""
print("Testing route transition...")
# Sample route positions
positions = [
{'latitude': 45.7749, 'longitude': -122.4194, 'speed': 0, 'deviceTime': '2025-07-08 12:00:00'},
{'latitude': 45.7750, 'longitude': -122.4195, 'speed': 20, 'deviceTime': '2025-07-08 12:01:00'},
{'latitude': 45.7751, 'longitude': -122.4196, 'speed': 30, 'deviceTime': '2025-07-08 12:02:00'},
{'latitude': 45.7752, 'longitude': -122.4197, 'speed': 40, 'deviceTime': '2025-07-08 12:03:00'},
{'latitude': 45.7753, 'longitude': -122.4198, 'speed': 50, 'deviceTime': '2025-07-08 12:04:00'},
]
# Test parameters
center_lat = 45.7751
center_lon = -122.4196
min_lat = 45.7740
max_lat = 45.7760
min_lon = -122.4210
max_lon = -122.4180
width = 1920
height = 1080
# Test the first few frames (transition period)
for frame_index in range(len(positions)):
print(f"Testing route frame {frame_index}...")
try:
current_pos = positions[frame_index]
frame = create_3d_frame(
current_pos, positions, frame_index,
center_lat, center_lon, min_lat, max_lat, min_lon, max_lon,
width, height
)
# Check frame integrity
if frame is None:
print(f"ERROR: Route frame {frame_index} is None")
return False
if frame.shape != (height, width, 3):
print(f"ERROR: Route frame {frame_index} has wrong shape: {frame.shape}")
return False
# Check for valid pixel values
if np.any(frame < 0) or np.any(frame > 255):
print(f"ERROR: Route frame {frame_index} has invalid pixel values")
return False
print(f"Route frame {frame_index} OK - Shape: {frame.shape}, Min: {np.min(frame)}, Max: {np.max(frame)}")
except Exception as e:
print(f"ERROR: Route frame {frame_index} failed: {e}")
import traceback
traceback.print_exc()
return False
print("All route transition frames generated successfully!")
return True
def test_draw_3d_route():
"""Test the draw_3d_route function with various scenarios"""
print("Testing draw_3d_route function...")
# Create test frame
frame = np.zeros((1080, 1920, 3), dtype=np.uint8)
# Test scenarios
test_cases = [
# Empty route
([], 0, "Empty route"),
# Single point - no past points
([(960, 540, False)], 0, "Single future point"),
# Single point - current point
([(960, 540, True)], 0, "Single current point"),
# Multiple points - beginning of route
([(960, 540, True), (970, 550, False), (980, 560, False)], 0, "Beginning of route"),
# Multiple points - middle of route
([(950, 530, True), (960, 540, True), (970, 550, False), (980, 560, False)], 1, "Middle of route"),
]
for route_points_3d, frame_index, description in test_cases:
print(f"Testing: {description}")
try:
test_frame = frame.copy()
draw_3d_route(test_frame, route_points_3d, frame_index)
print(f"{description} - OK")
except Exception as e:
print(f"{description} - Failed: {e}")
return False
print("All draw_3d_route tests passed!")
return True
if __name__ == "__main__":
route_success = test_route_transition()
draw_success = test_draw_3d_route()
if route_success and draw_success:
print("✅ All transition tests PASSED")
sys.exit(0)
else:
print("❌ Some transition tests FAILED")
sys.exit(1)

75
test_video_generator.py Normal file
View File

@@ -0,0 +1,75 @@
#!/usr/bin/env python3
"""
Test script to verify the enhanced 3D video generator works without overflow errors
"""
import sys
import os
sys.path.append('/home/pi/Desktop/traccar_animation')
from py_scripts.video_3d_generator import create_space_entry_frame
import numpy as np
def test_space_entry_frame():
"""Test the space entry frame generation"""
print("Testing space entry frame generation...")
# Sample position data
start_pos = {
'latitude': 45.7749,
'longitude': -122.4194,
'speed': 50,
'deviceTime': '2025-07-08 12:00:00'
}
# Test parameters
center_lat = 45.7749
center_lon = -122.4194
min_lat = 45.7000
max_lat = 45.8500
min_lon = -122.5000
max_lon = -122.3500
width = 1920
height = 1080
# Test multiple frames to ensure no overflow
for frame_index in range(0, 90, 10): # Test every 10th frame
print(f"Testing frame {frame_index}/90...")
try:
frame = create_space_entry_frame(
start_pos, center_lat, center_lon,
min_lat, max_lat, min_lon, max_lon,
width, height, frame_index, 90
)
# Check frame integrity
if frame is None:
print(f"ERROR: Frame {frame_index} is None")
return False
if frame.shape != (height, width, 3):
print(f"ERROR: Frame {frame_index} has wrong shape: {frame.shape}")
return False
# Check for valid pixel values
if np.any(frame < 0) or np.any(frame > 255):
print(f"ERROR: Frame {frame_index} has invalid pixel values")
return False
print(f"Frame {frame_index} OK - Shape: {frame.shape}, Min: {np.min(frame)}, Max: {np.max(frame)}")
except Exception as e:
print(f"ERROR: Frame {frame_index} failed: {e}")
return False
print("All space entry frames generated successfully!")
return True
if __name__ == "__main__":
success = test_space_entry_frame()
if success:
print("✅ Space entry frame generation test PASSED")
sys.exit(0)
else:
print("❌ Space entry frame generation test FAILED")
sys.exit(1)