@@ -948,7 +948,7 @@ def py_calibration(selection, exp):
948948
949949def write_targets (targets : TargetArray , short_file_base : str , frame : int ) -> bool :
950950 """Write targets to a file."""
951- output_path = _prepare_output_path (f" { short_file_base } . { frame :04d } _targets" )
951+ output_path = _prepare_output_path (_target_filename ( short_file_base , frame ) )
952952 num_targets = len (targets )
953953 success = False
954954 if num_targets == 0 :
@@ -1012,7 +1012,7 @@ def _sum_grey_value(target):
10121012
10131013def read_targets (short_file_base : str , frame : int ) -> TargetArray :
10141014 """Read targets from a file."""
1015- filename = f" { short_file_base } . { frame :04d } _targets"
1015+ filename = _target_filename ( short_file_base , frame )
10161016 print (f" Reading targets from: filename: { filename } " )
10171017
10181018 if not os .path .exists (filename ):
@@ -1043,6 +1043,13 @@ def read_targets(short_file_base: str, frame: int) -> TargetArray:
10431043 return targs
10441044
10451045
1046+ def _target_filename (short_file_base : str , frame : int ) -> str :
1047+ """Resolve a target filename from either a plain base or a legacy %d pattern."""
1048+ if "%d" in short_file_base :
1049+ return re .sub (r"%0?\d*d" , str (frame ), short_file_base ) + "_targets"
1050+ return f"{ short_file_base } .{ frame :04d} _targets"
1051+
1052+
10461053def extract_cam_ids (file_bases : list [str ]) -> list [int ]:
10471054 """
10481055 Given a list of file base strings, extract the camera identification number from each.
0 commit comments