2
這個問題之前貶爲一式二份,請注意:轉換OpenCV的3(IplImage結構),以PyQt5的QImage/QPixmap的Python中
- 使用OpenCV的版本3(不是版本2)
- 使用Python 3(不是C++)
- 使用PyQt的5(未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
我不知道如何調試這個了。沒有錯誤回溯被打印到控制檯。任何幫助表示讚賞。提前致謝。