假设我正在使用opencv从网络摄像头拍摄图像。在
_, img = self.cap.read() # numpy.ndarray (480, 640, 3)
然后我使用img
创建一个QImage
qimg:
但错误的说法是:
TypeError: 'data' is an unknown keyword argument
但是在this文档中,构造函数应该有一个名为data
的参数。在
我正在使用水蟒环境来运行这个项目。在
opencv version = 3.1.4
pyqt version = 5.9.2
numpy version = 1.15.0
我怀疑它用
TypeError: 'data' is an unknown keyword argument
出错,因为这是它遇到的第一个参数。在链接类引用用于PyQt4,对于PyQt5,它链接到位于https://doc.qt.io/qt-5/qimage.html的
C++
文档,但相似之处很明显。在根据https://www.programcreek.com/python/example/106694/PyQt5.QtGui.QImage中的示例,您可以尝试
(没有数据=,宽度=等)
他们所表示的是数据是必需的参数,而不是关键字被称为data,下面的方法将numpy/opencv图像转换为QImage:
或者您可以使用qimage2ndarray库
当使用索引裁剪图像时,只修改},解决方案是制作一个副本
^{pr2}$shape
,而不是{相关问题 更多 >
编程相关推荐