""" Create a simple test video with lane-like features for testing """ import cv2 import numpy as np import os def create_test_video(output_path, duration_sec=5, fps=30): """ Create a test video with simulated road and lanes """ width, height = 640, 480 fourcc = cv2.VideoWriter_fourcc(*'mp4v') out = cv2.VideoWriter(output_path, fourcc, fps, (width, height)) total_frames = duration_sec * fps for frame_idx in range(total_frames): # Create dark gray background (asphalt) frame = np.ones((height, width, 3), dtype=np.uint8) * 50 # Add some texture/noise for realism noise = np.random.randint(0, 20, (height, width, 3), dtype=np.uint8) frame = cv2.add(frame, noise) # Draw road perspective trapezoid road_points = np.array([ [int(width * 0.1), height], [int(width * 0.4), int(height * 0.5)], [int(width * 0.6), int(height * 0.5)], [int(width * 0.9), height] ], dtype=np.int32) cv2.fillPoly(frame, [road_points], (60, 60, 60)) # Calculate lane positions with slight animation offset = int(10 * np.sin(frame_idx / 10)) # Left lane left_bottom = (int(width * 0.3) + offset, height) left_top = (int(width * 0.45) + offset, int(height * 0.6)) cv2.line(frame, left_bottom, left_top, (255, 255, 255), 3) # Right lane right_bottom = (int(width * 0.7) + offset, height) right_top = (int(width * 0.55) + offset, int(height * 0.6)) cv2.line(frame, right_bottom, right_top, (255, 255, 255), 3) # Add dashed center line for y in range(height, int(height * 0.6), -30): if (y // 30) % 2 == 0: x_start = int(width * 0.5) + offset x_end = int(width * 0.5) + offset cv2.line(frame, (x_start, y), (x_end, y - 20), (255, 255, 0), 2) # Write frame out.write(frame) out.release() print(f"✓ Test video created: {output_path}") print(f" Duration: {duration_sec}s, FPS: {fps}, Frames: {total_frames}") if __name__ == "__main__": # Create test video in /tmp output_path = "/tmp/test_road_video.mp4" create_test_video(output_path, duration_sec=3, fps=30)