Skip to content

Commit 8a05fad

Browse files
committed
[panorama] added overlap option to measurement
1 parent e5ddfd2 commit 8a05fad

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/instrumentman/panorama/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
type=Choice(("x1", "x2", "x4", "x8"), case_sensitive=False),
3737
default="x1"
3838
)
39+
@option(
40+
"--overlap",
41+
help="Minimum horizontal and vertical overlap between images (percentage)",
42+
type=(IntRange(5, 95), IntRange(5, 95)),
43+
default=(30, 30)
44+
)
3945
def cli_measure(**kwargs: Any) -> None:
4046
"""
4147
Take pictures with the instrument camera for later panormaic stitching

src/instrumentman/panorama/measure.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def run_panorama(
1515
tps: GeoCom,
1616
file: TextIO,
1717
zoom: Zoom,
18+
overlap: tuple[int, int],
1819
logger: Logger
1920
) -> None:
20-
2121
pause("Aim the instrument at the starting corner, then press any key...")
2222
resp_start = tps.tmc.get_angle()
2323
if resp_start.error != GeoComCode.OK or resp_start.params is None:
@@ -50,12 +50,14 @@ def run_panorama(
5050
exit(1)
5151

5252
fov_hz, fov_v = resp_fov.params
53+
reduced_fov_hz = float(fov_hz) * (1 - overlap[0] / 100)
54+
reduced_fov_v = float(fov_hz) * (1 - overlap[1] / 100)
5355

5456
delta_hz = to_hz.relative_to(from_hz)
5557
delta_v = to_v.relative_to(from_v)
5658

57-
cols = math.ceil(abs(float(delta_hz)) / float(fov_hz)) + 1
58-
rows = math.ceil(abs(float(delta_v)) / float(fov_v)) + 1
59+
cols = math.ceil(abs(float(delta_hz)) / reduced_fov_hz) + 1
60+
rows = math.ceil(abs(float(delta_v)) / reduced_fov_v) + 1
5961

6062
print(
6163
"image",
@@ -123,7 +125,8 @@ def main(
123125
timeout: int = 15,
124126
retry: int = 1,
125127
sync_after_timeout: bool = False,
126-
zoom: str = "x1"
128+
zoom: str = "x1",
129+
overlap: tuple[int, int] = (30, 30)
127130
) -> None:
128131
logger = getLogger("iman.panorama.measure")
129132
with open_serial(
@@ -135,4 +138,4 @@ def main(
135138
logger=logger.getChild("com")
136139
) as com:
137140
tps = GeoCom(com, logger.getChild("instrument"))
138-
run_panorama(tps, metadata, Zoom[zoom.upper()], logger)
141+
run_panorama(tps, metadata, Zoom[zoom.upper()], overlap, logger)

0 commit comments

Comments
 (0)