我尝试将 cv2 与 PyQt4 小部件一起使用,但一直收到此错误:
(python3:3974): GLib-GObject-WARNING **: 12:41:27.117: 无法注册现有类型“GdkDisplayManager”
(python3:3974): GLib-CRITICAL **: 12:41:27.118: g_once_init_leave: 断言‘result != 0’失败
(python3:3974): GLib-GObject-CRITICAL **: 12:41:27.118: g_object_new_with_properties: 断言‘G_TYPE_IS_OBJECT (object_type)’失败
我确信我的 cv2 代码运行良好
import cv2
def takePicture():
cap = cv2.VideoCapture(1)
while(True):
ret, frame= cap.read()
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
但是当我将按钮连接到它时,出现了上面的错误:
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
take_picture_button = QtGui.QPushButton('Take picture')
from takePicture import takePicture
take_picture_button.clicked.connect(takePicture)
take_picture_button.show()
- Ubuntu 18.04
- python3.6.7
- PyQt4?
- 简历2?