Skip to content

Commit

Permalink
try grabbing the first frame multiple times giving the decoder some t…
Browse files Browse the repository at this point in the history
…ime to become ready (fix #90)
  • Loading branch information
M4GNV5 committed Jun 6, 2021
1 parent 0d0a591 commit 0b478a0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion djitellopy/tello.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,15 @@ def __init__(self, tello, address):
if not self.cap.isOpened():
self.cap.open(address)

self.grabbed, self.frame = self.cap.read()
# Try grabbing a frame multiple times
# According to issue #90 the decoder might need some time
# https://github.com/damiafuentes/DJITelloPy/issues/90#issuecomment-855458905
for _ in range(20):
self.grabbed, self.frame = self.cap.read()
if self.frame is not None:
break
time.sleep(0.05)

if not self.grabbed or self.frame is None:
raise Exception('Failed to grab first frame from video stream')

Expand Down

0 comments on commit 0b478a0

Please sign in to comment.