22from typing import Sequence
33from json import JSONDecodeError
44
5+ from rich .console import Console
6+ from rich .progress import (
7+ Progress ,
8+ TextColumn ,
9+ BarColumn ,
10+ MofNCompleteColumn ,
11+ TimeRemainingColumn
12+ )
513from jsonschema import ValidationError
614from geocompy .data import Coordinate , Angle
715import numpy as np
@@ -175,18 +183,33 @@ def run_annotate(
175183
176184 fov_w , fov_h = meta ["fov" ]
177185 center = Coordinate (* meta ["center" ])
186+ console = Console ()
187+ progress = Progress (
188+ TextColumn ("[progress.description]{task.description}" ),
189+ BarColumn (),
190+ MofNCompleteColumn (),
191+ TimeRemainingColumn (),
192+ console = console
193+ )
194+ progress .start ()
195+ task_images = progress .add_task (
196+ "Preprocessing images" ,
197+ total = len (meta ["images" ])
198+ )
178199
179200 for data in meta ["images" ]:
180201 pos = Coordinate (* data ["position" ])
181202 vec = Coordinate (* data ["vector" ])
182203 path = images .get (data ["filename" ])
183204 if path is None :
184205 echo_yellow (f"Could not find '{ data ['filename' ]} '" )
206+ progress .update (task_images , advance = 1 )
185207 continue
186208
187209 img = cv .imread (str (path ))
188210 if img is None :
189211 echo_yellow (f"Could not load '{ data ['filename' ]} '" )
212+ progress .update (task_images , advance = 1 )
190213 continue
191214
192215 hz , v , _ = vec .to_polar ()
@@ -251,6 +274,11 @@ def run_annotate(
251274 apply_rotation (pos - center , np .linalg .inv (offset_rot ))
252275 )
253276
277+ progress .update (task_images , advance = 1 )
278+
279+ progress .stop ()
280+ console .print ("Merging images... " , end = "" )
281+
254282 blender = cv .detail .Blender .createDefault (cv .detail .BLENDER_MULTI_BAND )
255283 blender .prepare (
256284 corners ,
@@ -274,6 +302,9 @@ def run_annotate(
274302 None , None
275303 ) # type: ignore[call-overload]
276304
305+ console .print ("Done" )
306+ console .print ("Annotating points... " , end = "" )
307+
277308 # Top left image center point for reference
278309 origin_x , origin_y , _ , _ = cv .detail .resultRoi (
279310 corners ,
@@ -346,6 +377,8 @@ def run_annotate(
346377 bottomLeftOrigin = False
347378 )
348379
380+ console .print ("Done" )
381+ console .print ("Saving final image... " , end = "" )
349382 # For some reason the blending function returns the image as int16 instead
350383 # uint8, and it might contain negative values. These need to be clipped,
351384 # otherwise the type conversion will result in color artifacts due to the
@@ -356,6 +389,9 @@ def run_annotate(
356389 result .astype (np .uint8 )
357390 )
358391
392+ console .print ("Done" )
393+ console .print ("Panorama complete" , style = "green" )
394+
359395
360396_MARKER_MAP = {
361397 "cross" : cv .MARKER_CROSS ,
0 commit comments