Skip to content

Commit

Permalink
Merge pull request #1808 from pierotofy/airsrt
Browse files Browse the repository at this point in the history
Fix RST parsing for DJI air 2
  • Loading branch information
pierotofy authored Oct 21, 2024
2 parents e3a11fd + 5de1ff0 commit 12e5b63
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions opendm/video/srtparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def parse(self):
# <font size="36">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] </font>
# </font>

# DJI Mavic Mini
# 1
Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 12e5b63

Please sign in to comment.