From 823458306bc35df760a49ea276403cf8abdc4ca9 Mon Sep 17 00:00:00 2001 From: Marina Moreira <67443181+marinagmoreira@users.noreply.github.com> Date: Sun, 30 Jun 2024 15:09:25 -0700 Subject: [PATCH] making hugin work with different versions (#798) --- .../sparse_mapping/tools/generate_hugin.py | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/localization/sparse_mapping/tools/generate_hugin.py b/localization/sparse_mapping/tools/generate_hugin.py index 6966b0d51b..3d2bd83dc9 100755 --- a/localization/sparse_mapping/tools/generate_hugin.py +++ b/localization/sparse_mapping/tools/generate_hugin.py @@ -112,7 +112,14 @@ def main(): if args.input_hugin is not None: # read the pto file into the Panorama object - p.ReadPTOFile(args.input_hugin) + # Accomodate hugin changing API + try: + # Attempt the first method + ifs = ifstream(args.input_hugin) + p.readData(ifs) + except AttributeError: + # Fallback to the second method if the first method fails + p.ReadPTOFile(args.input_hugin) # don't need anymore del ifs @@ -132,9 +139,14 @@ def main(): p.addImage(srcImage) # write the modified panorama to that stream - p.WritePTOFile(output_hugin) - # done with it - del ofs + # Accomodate hugin changing API + try: + # Attempt the first method + ofs = ofstream(output_hugin) + p.writeData(ofs) + except AttributeError: + # Fallback to the second method if the first method fails + p.WritePTOFile(output_hugin) if __name__ == "__main__":