From 5de1ff0258bc22ec42d48d01226cb9082d3c21e5 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Mon, 21 Oct 2024 12:30:48 -0400 Subject: [PATCH] Fix RST parsing for DJI air 2 --- opendm/video/srtparser.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/opendm/video/srtparser.py b/opendm/video/srtparser.py index 8dba167da..cfe871211 100644 --- a/opendm/video/srtparser.py +++ b/opendm/video/srtparser.py @@ -120,6 +120,7 @@ def parse(self): # SrtCnt : 1, DiffTime : 16ms # 2023-01-06 18:56:48,380,821 # [iso : 3200] [shutter : 1/60.0] [fnum : 280] [ev : 0] [ct : 3925] [color_md : default] [focal_len : 240] [latitude: 0.000000] [longitude: 0.000000] [altitude: 0.000000] + # # DJI Mavic Mini # 1 @@ -164,9 +165,10 @@ def parse(self): end = None for line in f: + # Remove html tags, spaces + line = re.sub('<[^<]+?>', '', line).strip() - # Check if line is empty - if not line.strip(): + if not line: if start is not None: self.data.append({ "start": start, @@ -193,9 +195,6 @@ def parse(self): continue - # Remove html tags - line = re.sub('<[^<]+?>', '', line) - # Search this "00:00:00,000 --> 00:00:00,016" match = re.search("(\d{2}:\d{2}:\d{2},\d+) --> (\d{2}:\d{2}:\d{2},\d+)", line) if match: @@ -225,14 +224,14 @@ def parse(self): ("GPS \([\d\.\-]+,? ([\d\.\-]+),? [\d\.\-]+\)", lambda v: float(v) if v != 0 else None), ("RTK \([-+]?\d+\.\d+, (-?\d+\.\d+), -?\d+\)", lambda v: float(v) if v != 0 else None), ], line) - + longitude = match_single([ ("longitude: ([\d\.\-]+)", lambda v: float(v) if v != 0 else None), ("longtitude : ([\d\.\-]+)", lambda v: float(v) if v != 0 else None), ("GPS \(([\d\.\-]+),? [\d\.\-]+,? [\d\.\-]+\)", lambda v: float(v) if v != 0 else None), ("RTK \((-?\d+\.\d+), [-+]?\d+\.\d+, -?\d+\)", lambda v: float(v) if v != 0 else None), ], line) - + altitude = match_single([ ("altitude: ([\d\.\-]+)", lambda v: float(v) if v != 0 else None), ("GPS \([\d\.\-]+,? [\d\.\-]+,? ([\d\.\-]+)\)", lambda v: float(v) if v != 0 else None),