-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstitch_frames.py
More file actions
50 lines (38 loc) · 1.49 KB
/
stitch_frames.py
File metadata and controls
50 lines (38 loc) · 1.49 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
#!/usr/bin/env python3
"""
Stitch consecutive satellite frames into a single panoramic strip.
Thin CLI entry point — delegates to declass.stitch for frame ordering,
rotation detection, overlap computation, and VRT-based stitching.
Usage:
python3 stitch_frames.py frame1.tif frame2.tif [frame3.tif ...] -o output.tif
python3 stitch_frames.py frame1.tif frame2.tif -o output.tif --preserve-order
"""
import argparse
import os
import sys
import tempfile
from preprocess.stitch import stitch_frames
def main():
parser = argparse.ArgumentParser(description="Stitch consecutive satellite frames")
parser.add_argument("frames", nargs="+", help="Input TIF frames")
parser.add_argument("-o", "--output", required=True, help="Output TIF path")
parser.add_argument("--preserve-order", action="store_true",
help="Use input order instead of auto-detecting frame sequence")
args = parser.parse_args()
if len(args.frames) < 2:
print("Need at least 2 frames to stitch")
sys.exit(1)
for f in args.frames:
if not os.path.exists(f):
print(f"ERROR: File not found: {f}")
sys.exit(1)
output_dir = tempfile.mkdtemp(prefix="stitch_")
print(f"Stitching {len(args.frames)} frames...")
print(f" Working dir: {output_dir}")
result = stitch_frames(
args.frames, args.output, output_dir,
preserve_order=args.preserve_order,
)
print(f"Done: {result}")
if __name__ == "__main__":
main()