栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何使用opencv将图像显示到PYQT

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何使用opencv将图像显示到PYQT

它有2个错误:

  • 您必须将传递
    bytesPerLine
    给QImage
  • trainOpenImg
    设置对齐方式时,您会输入更多的“ n” 。

def displayImage(self):    qformat =QImage.Format_Indexed8    if len(self.image.shape)==3:        if self.image.shape[2] ==4: qformat=QImage.Format_RGBA8888        else: qformat=QImage.Format_RGB888        img = QtGui.QImage(self.image.data, self.image.shape[1], self.image.shape[0],  self.image.strides[0], # <--- +++ qformat)        img = img.rgbSwapped()        self.trainOpenImg.setPixmap(QPixmap.fromImage(img))        self.trainOpenImg.setAlignment(QtCore.Qt.AlignCenter)

另一方面,IDE在处理某些类型的错误时遇到问题,只能启动代码,因此,在这种情况下,建议在CMD或终端中运行它,因为它们会为您提供更多信息,例如,在这种情况下,错误消息为:

Traceback (most recent call last):  File "test.py", line 20, in loadClicked    self.loadImage(fname)  File "test.py", line 26, in loadImage    self.displayImage()  File "test.py", line 36, in displayImage    img=QtGui.QImage(self.image.data,self.image.shape[1],self.image[0],QtGui.QImage.Format_RGB888)TypeError: arguments did not match any overloaded call:  QImage(): too many arguments  QImage(QSize, QImage.Format): argument 1 has unexpected type 'memoryview'  QImage(int, int, QImage.Format): argument 1 has unexpected type 'memoryview'  QImage(bytes, int, int, QImage.Format): argument 3 has unexpected type 'numpy.ndarray'  QImage(sip.voidptr, int, int, QImage.Format): argument 3 has unexpected type 'numpy.ndarray'  QImage(bytes, int, int, int, QImage.Format): argument 3 has unexpected type 'numpy.ndarray'  QImage(sip.voidptr, int, int, int, QImage.Format): argument 3 has unexpected type 'numpy.ndarray'  QImage(List[str]): argument 1 has unexpected type 'memoryview'  QImage(str, format: str = None): argument 1 has unexpected type 'memoryview'  QImage(QImage): argument 1 has unexpected type 'memoryview'  QImage(Any): too many argumentsAborted (core dumped)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/625240.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号