diff --git a/lerobot/scripts/control_robot.py b/lerobot/scripts/control_robot.py index 3daea98d..a1988638 100644 --- a/lerobot/scripts/control_robot.py +++ b/lerobot/scripts/control_robot.py @@ -134,6 +134,13 @@ python lerobot/scripts/control_robot.py \ ``` """ +import cv2 + +# Make sure that the UI gets initialized before PyAV (av) gets imported by torchvision +# This solves the hanging issue with cv2.imshow on Ubuntu +cv2.namedWindow("i") +cv2.destroyAllWindows() + import logging import os import time diff --git a/lerobot/scripts/control_sim_robot.py b/lerobot/scripts/control_sim_robot.py index 5347822c..245bd7b7 100644 --- a/lerobot/scripts/control_sim_robot.py +++ b/lerobot/scripts/control_sim_robot.py @@ -88,6 +88,12 @@ import time from pathlib import Path import cv2 + +# Make sure that the UI gets initialized before PyAV (av) gets imported by torchvision +# This solves the hanging issue with cv2.imshow on Ubuntu +cv2.namedWindow("i") +cv2.destroyAllWindows() + import gymnasium as gym import numpy as np import torch