Skip to content

Commit

Permalink
Timestamp Camera images between grab and decode (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
gemblerz authored May 31, 2023
1 parent 786ee82 commit 4b2d9a0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/waggle/data/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,22 @@ def __exit__(self, exc_type, exc_val, exc_tb):
self.capture.release()

def snapshot(self):
timestamp = get_timestamp()
ok, data = self.capture.read()
ok = self.capture.grab()
if not ok:
raise RuntimeError("failed to take snapshot")
timestamp = get_timestamp()
ok, data = self.capture.retrieve()
if not ok:
raise RuntimeError("failed to retrieve the taken snapshot")
return ImageSample(data=data, timestamp=timestamp, format=self.format)

def stream(self):
while True:
ok = self.capture.grab()
if not ok:
break
timestamp = get_timestamp()
ok, data = self.capture.read()
ok, data = self.capture.retrieve()
if not ok:
break
yield ImageSample(data=data, timestamp=timestamp, format=self.format)
Expand Down

0 comments on commit 4b2d9a0

Please sign in to comment.