在将这个问题视为重复之前,请注意:
- 使用OpenCV版本3(不是版本2)
- 使用Python 3(而不是C++)
- 使用PyQt5(而不是PyQt4)
目标:尝试在PyQt5 GUI窗口中流式传输OpenCV网络摄像头视频帧。
# For testing, I'm simply reading in a single image instead of a video frame
frame = cv2.imread('Koala.jpg',0) # this is a numpy.ndarray object
height, width = frame.shape
my_image = QImage(frame.tostring(), width, height, QImage.Format_RGB888)
# By here, things seem okay. print(mimage) basically says <QImage object at 0x32243>
# my_image.rgbSwapped() # This line crashes program
pixmap = QPixmap.fromImage(mimage) # This line crashes program as well
我不确定如何再调试了。没有任何错误回溯被打印到控制台。非常感谢您的帮助。