diff --git a/src/televuer/televuer.py b/src/televuer/televuer.py index 3689088..371fb8c 100644 --- a/src/televuer/televuer.py +++ b/src/televuer/televuer.py @@ -346,37 +346,36 @@ class TeleVuer: to="bgChildren", ) while True: - session.upsert( - [ - ImageBackground( - self.img2display[:, :self.img_width], - aspect=self.aspect_ratio, - height=1, - distanceToCamera=1, - # The underlying rendering engine supported a layer binary bitmask for both objects and the camera. - # Below we set the two image planes, left and right, to layers=1 and layers=2. - # Note that these two masks are associated with left eye’s camera and the right eye’s camera. - layers=1, - format="jpeg", - quality=50, - key="background-left", - interpolate=True, - ), - ImageBackground( - self.img2display[:, self.img_width:], - aspect=self.aspect_ratio, - height=1, - distanceToCamera=1, - layers=2, - format="jpeg", - quality=50, - key="background-right", - interpolate=True, - ), - ], - to="bgChildren", - ) - # 'jpeg' encoding should give you about 30fps with a 16ms wait in-between. + try: + session.upsert( + [ + ImageBackground( + self.img2display[:, :self.img_width], + aspect=self.aspect_ratio, + height=1, + distanceToCamera=1, + layers=1, + format="jpeg", + quality=50, + key="background-left", + interpolate=True, + ), + ImageBackground( + self.img2display[:, self.img_width:], + aspect=self.aspect_ratio, + height=1, + distanceToCamera=1, + layers=2, + format="jpeg", + quality=50, + key="background-right", + interpolate=True, + ), + ], + to="bgChildren", + ) + except Exception: + pass # Session dropped; coroutine stays alive for reconnect await asyncio.sleep(1.0 / self.display_fps) async def main_image_monocular_zmq(self, session): @@ -393,7 +392,7 @@ class TeleVuer: else: session.upsert( MotionControllers( - stream=True, + stream=True, key="motionControllers", left=True, right=True, @@ -402,21 +401,24 @@ class TeleVuer: ) while True: - session.upsert( - [ - ImageBackground( - self.img2display, - aspect=self.aspect_ratio, - height=1, - distanceToCamera=1, - format="jpeg", - quality=50, - key="background-mono", - interpolate=True, - ), - ], - to="bgChildren", - ) + try: + session.upsert( + [ + ImageBackground( + self.img2display, + aspect=self.aspect_ratio, + height=1, + distanceToCamera=1, + format="jpeg", + quality=50, + key="background-mono", + interpolate=True, + ), + ], + to="bgChildren", + ) + except Exception: + pass # Session dropped; coroutine stays alive for reconnect await asyncio.sleep(1.0 / self.display_fps) async def main_image_binocular_webrtc(self, session): @@ -515,37 +517,36 @@ class TeleVuer: to="bgChildren", ) while True: - session.upsert( - [ - ImageBackground( - self.img2display[:, :self.img_width], - aspect=self.aspect_ratio, - height=0.75, - distanceToCamera=2, - # The underlying rendering engine supported a layer binary bitmask for both objects and the camera. - # Below we set the two image planes, left and right, to layers=1 and layers=2. - # Note that these two masks are associated with left eye’s camera and the right eye’s camera. - layers=1, - format="jpeg", - quality=50, - key="background-left", - interpolate=True, - ), - ImageBackground( - self.img2display[:, self.img_width:], - aspect=self.aspect_ratio, - height=0.75, - distanceToCamera=2, - layers=2, - format="jpeg", - quality=50, - key="background-right", - interpolate=True, - ), - ], - to="bgChildren", - ) - # 'jpeg' encoding should give you about 30fps with a 16ms wait in-between. + try: + session.upsert( + [ + ImageBackground( + self.img2display[:, :self.img_width], + aspect=self.aspect_ratio, + height=0.75, + distanceToCamera=2, + layers=1, + format="jpeg", + quality=50, + key="background-left", + interpolate=True, + ), + ImageBackground( + self.img2display[:, self.img_width:], + aspect=self.aspect_ratio, + height=0.75, + distanceToCamera=2, + layers=2, + format="jpeg", + quality=50, + key="background-right", + interpolate=True, + ), + ], + to="bgChildren", + ) + except Exception: + pass await asyncio.sleep(1.0 / self.display_fps) async def main_image_monocular_zmq_ego(self, session): @@ -571,21 +572,24 @@ class TeleVuer: ) while True: - session.upsert( - [ - ImageBackground( - self.img2display, - aspect=self.aspect_ratio, - height=0.75, - distanceToCamera=2, - format="jpeg", - quality=50, - key="background-mono", - interpolate=True, - ), - ], - to="bgChildren", - ) + try: + session.upsert( + [ + ImageBackground( + self.img2display, + aspect=self.aspect_ratio, + height=0.75, + distanceToCamera=2, + format="jpeg", + quality=50, + key="background-mono", + interpolate=True, + ), + ], + to="bgChildren", + ) + except Exception: + pass await asyncio.sleep(1.0 / self.display_fps) async def main_image_binocular_webrtc_ego(self, session):