我正在从PyQt切换到PySide。
使用PyQt,我使用在SO上找到的代码将QImage
转换为Numpy.Array
:
def convertQImageToMat(incomingImage):
''' Converts a QImage into an opencv MAT format '''
incomingImage = incomingImage.convertToFormat(4)
width = incomingImage.width()
height = incomingImage.height()
ptr = incomingImage.bits()
ptr.setsize(incomingImage.byteCount())
arr = np.array(ptr).reshape(height, width, 4) # Copies the data
return arr
但是ptr.setsize(incomingImage.byteCount())
不适用于PySide,因为这是PyQt的^{
我的问题是:如何使用PySide将QImage转换为Numpy.Array
。
编辑:
Version Info
> Windows 7 (64Bit)
> Python 2.7
> PySide Version 1.2.1
> Qt Version 4.8.5
目前没有回答
相关问题 更多 >
编程相关推荐