-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulator.py
More file actions
63 lines (49 loc) · 1.77 KB
/
Copy pathsimulator.py
File metadata and controls
63 lines (49 loc) · 1.77 KB
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
import numpy as np
import cv2
def generate_frame(size=256, num_stars=50, sat_pos=None):
"""
Generate one synthetic telescope frame.
Args:
size: image width/height in pixels
num_stars: number of background stars to scatter
sat_pos: (x, y) pixel position of the satellite,
or None to generate a star-only frame
Returns:
np.uint8 array of shape (size, size)
"""
img = np.zeros((size, size), dtype=np.uint8)
# Background stars – random single bright pixels
for _ in range(num_stars):
x, y = np.random.randint(0, size, 2)
img[y, x] = 255
# Satellite – slightly larger 3×3 blob so it stands out
if sat_pos is not None:
x, y = sat_pos
x = int(np.clip(x, 1, size - 4))
y = int(np.clip(y, 1, size - 4))
img[y:y+3, x:x+3] = 255
# Telescope optics blur
img = cv2.GaussianBlur(img, (5, 5), 0)
# Sensor noise (~5 % intensity)
noise = np.random.normal(0, 13, img.shape)
img = np.clip(img + noise, 0, 255).astype(np.uint8)
return img
def generate_video(num_frames=50, size=256, num_stars=50,
start_pos=(50, 50), velocity=(1, 1)):
"""
Generate a sequence of frames with a satellite moving at constant velocity.
Returns:
list of np.uint8 arrays
"""
frames = []
sx, sy = start_pos
vx, vy = velocity
for i in range(num_frames):
pos = (int(sx + i * vx), int(sy + i * vy))
frame = generate_frame(size=size, num_stars=num_stars, sat_pos=pos)
frames.append(frame)
return frames
# Quick smoke-test when run directly
if __name__ == "__main__":
frames = generate_video(num_frames=10)
print(f"Generated {len(frames)} frames, shape: {frames[0].shape}")