Skip to content

Commit d04b447

Browse files
committed
[panorama] simplified progress reporting
1 parent bc2b0a8 commit d04b447

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/instrumentman/panorama/process.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
TextColumn,
1515
BarColumn,
1616
MofNCompleteColumn,
17-
TimeRemainingColumn
17+
TimeRemainingColumn,
18+
TimeElapsedColumn
1819
)
1920
from jsonschema import ValidationError
2021
from geocompy.data import Coordinate, Angle
@@ -217,8 +218,8 @@ def run_annotate(
217218
BarColumn(),
218219
MofNCompleteColumn(),
219220
TimeRemainingColumn(),
220-
console=console,
221-
transient=True
221+
TimeElapsedColumn(),
222+
console=console
222223
) as progress:
223224
warper: cv.PyRotationWarper | None = None
224225
for data in progress.track(
@@ -312,24 +313,23 @@ def run_annotate(
312313
images_warped.append(image_warped)
313314
masks_warped.append(mask_warped)
314315

315-
console.print("Preprocessed images")
316-
317-
with Progress(transient=True, console=console) as progress:
318-
progress.add_task(description="Finding seams", total=None)
316+
task_seams = progress.add_task(description="Finding seams", total=None)
319317
finder = cv.detail.SeamFinder.createDefault(seam_mode)
320318
seams = finder.find(
321319
images_warped, # type: ignore[arg-type]
322320
corners,
323321
masks_warped # type: ignore[arg-type]
324322
)
325323

326-
console.print("Identified seams")
324+
if scale is None:
325+
scale = 1000
327326

328-
if scale is None:
329-
scale = 1000
327+
progress.update(task_seams, completed=len(seams), total=len(seams))
330328

331-
with Progress(transient=True, console=console) as progress:
332-
progress.add_task(description="Merging images", total=None)
329+
task_merge = progress.add_task(
330+
description="Merging images",
331+
total=None
332+
)
333333
compensator = cv.detail.ExposureCompensator.createDefault(
334334
compenstation_mode
335335
)
@@ -385,9 +385,13 @@ def run_annotate(
385385
None, None
386386
) # type: ignore[call-overload]
387387

388-
console.print("Merged images")
389-
if len(points) > 0:
390-
with Progress(transient=True, console=console) as progress:
388+
progress.update(
389+
task_merge,
390+
completed=len(images_warped),
391+
total=len(images_warped)
392+
)
393+
394+
if len(points) > 0:
391395
# Top left image center point for reference
392396
origin_x, origin_y, _, _ = cv.detail.resultRoi(
393397
corners,
@@ -472,10 +476,7 @@ def run_annotate(
472476
bottomLeftOrigin=False
473477
)
474478

475-
console.print("Annotated points")
476-
477-
with Progress(transient=True, console=console) as progress:
478-
progress.add_task("Saving final image", total=None)
479+
task_save = progress.add_task("Saving final image", total=None)
479480
# For some reason the blending function returns the image as int16
480481
# instead uint8, and it might contain negative values. These need to be
481482
# clipped, otherwise the type conversion will result in color artifacts
@@ -485,9 +486,7 @@ def run_annotate(
485486
str(output),
486487
result.astype(np.uint8)
487488
)
488-
489-
console.print("Saved final image")
490-
console.print("Panorama complete", style="green")
489+
progress.update(task_save, completed=1, total=1)
491490

492491

493492
_MARKER_MAP = {

0 commit comments

Comments
 (0)