Klampt icon indicating copy to clipboard operation
Klampt copied to clipboard

OpenCV and PyQt5 incompatibility workaround

Open krishauser opened this issue 9 months ago • 1 comments

If you are using the opencv-python library on Linux, there will be a problem with PyQt5. The workaround is as follows:

import cv2
from PyQt5.QtCore import QLibraryInfo
import os

#hack needed to get opencv to work with PyQt5
os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = QLibraryInfo.location(QLibraryInfo.PluginsPath)

from klampt import vis
from klampt import WorldModel
import time

w = WorldModel()
w.readFile("../../data/athlete_plane.xml")
vis.add("world",w)
vis.show()
while vis.shown():
    time.sleep(0.1)
vis.kill()

krishauser avatar May 08 '24 22:05 krishauser