Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Addressing Issue: Temporary failure in name resolution (#84)
Browse files Browse the repository at this point in the history
* chore(examples): made gazer example draw the gaze point on the video.
* added timeout for tests
  • Loading branch information
edavalosanaya authored Feb 7, 2023
1 parent 7c127f6 commit 14c7a79
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
19 changes: 16 additions & 3 deletions examples/streamgazertsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


async def stream_rtsp():
async with connect_to_glasses.with_hostname(os.environ["G3_HOSTNAME"]) as g3:
async with connect_to_glasses.with_hostname(os.environ["G3_HOSTNAME"], using_zeroconf=True) as g3:
async with g3.stream_rtsp(scene_camera=True, gaze=True) as streams:
async with streams.gaze.decode() as gaze_stream, streams.scene_camera.decode() as scene_stream:
for i in range(200):
Expand All @@ -26,18 +26,31 @@ async def stream_rtsp():
gaze, gaze_timestamp = await gaze_stream.get()
while gaze_timestamp is None:
gaze, gaze_timestamp = await gaze_stream.get()
cv2.imshow("Video", frame.to_ndarray(format="bgr24")) # type: ignore
cv2.waitKey(1) # type: ignore

logging.info(f"Frame timestamp: {frame_timestamp}")
logging.info(f"Gaze timestamp: {gaze_timestamp}")
frame = frame.to_ndarray(format="bgr24")

# If given gaze data
if "gaze2d" in gaze:
gaze2d = gaze["gaze2d"]
logging.info(f"Gaze2d: {gaze2d[0]:9.4f},{gaze2d[1]:9.4f}")

# Convert rational (x,y) to pixel location (x,y)
h, w = frame.shape[:2]
fix = (int(gaze2d[0] * w), int(gaze2d[1] * h))

# Draw gaze
frame = cv2.circle(frame, fix, 10, (0, 0, 255), 3)

elif i % 50 == 0:
logging.info(
"No gaze data received. Have you tried putting on the glasses?"
)

cv2.imshow("Video", frame) # type: ignore
cv2.waitKey(1) # type: ignore


def main():
asyncio.run(stream_rtsp())
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ skip_gitignore = true
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]

# Timeout
faulthandler_timeout=30
1 change: 1 addition & 0 deletions src/g3pylib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from types import TracebackType
from typing import Any, AsyncIterator, Coroutine, Generator, Optional, Tuple, Type, cast


import g3pylib.websocket
from g3pylib._utils import APIComponent
from g3pylib.calibrate import Calibrate
Expand Down

0 comments on commit 14c7a79

Please sign in to comment.