You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
The text was updated successfully, but these errors were encountered:
apply the above workaround after the window is shown
run the Klampt GUI in single-threaded mode
For example:
import cv2
from PyQt5.QtCore import QLibraryInfo
import os
cap = cv2.VideoCapture(0)
if not cap.isOpened():
print("Cannot open camera")
exit()
ret, frame = cap.read()
# if frame is read correctly ret is True
if not ret:
print("Can't receive frame (stream end?). Exiting ...")
exit()
# Display the resulting frame
cv2.imshow('frame', frame)
#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.vis import GLPluginInterface
from klampt import WorldModel
import time
def capture():
ret, frame = cap.read()
# if frame is read correctly ret is True
if not ret:
print("Can't receive frame (stream end?). Exiting ...")
vis.show(False)
return
# Display the resulting frame
cv2.imshow('frame', frame)
w = WorldModel()
w.readFile("../../data/athlete_plane.xml")
vis.add("world",w)
#can only run single-threaded mode
vis.loop(callback=capture)
#vis.show()
#while vis.shown():
# capture()
# time.sleep(0.01)
vis.kill()
cap.release()
If you are using the opencv-python library on Linux, there will be a problem with PyQt5. The workaround is as follows:
The text was updated successfully, but these errors were encountered: