久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='K1LjF'></bdo><ul id='K1LjF'></ul>

    <legend id='K1LjF'><style id='K1LjF'><dir id='K1LjF'><q id='K1LjF'></q></dir></style></legend>
    <i id='K1LjF'><tr id='K1LjF'><dt id='K1LjF'><q id='K1LjF'><span id='K1LjF'><b id='K1LjF'><form id='K1LjF'><ins id='K1LjF'></ins><ul id='K1LjF'></ul><sub id='K1LjF'></sub></form><legend id='K1LjF'></legend><bdo id='K1LjF'><pre id='K1LjF'><center id='K1LjF'></center></pre></bdo></b><th id='K1LjF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='K1LjF'><tfoot id='K1LjF'></tfoot><dl id='K1LjF'><fieldset id='K1LjF'></fieldset></dl></div>

      1. <small id='K1LjF'></small><noframes id='K1LjF'>

        <tfoot id='K1LjF'></tfoot>

        如何使用 opencv 向 PYQT 顯示圖像

        How to show image to PYQT with opencv(如何使用 opencv 向 PYQT 顯示圖像)

          1. <i id='LX3ku'><tr id='LX3ku'><dt id='LX3ku'><q id='LX3ku'><span id='LX3ku'><b id='LX3ku'><form id='LX3ku'><ins id='LX3ku'></ins><ul id='LX3ku'></ul><sub id='LX3ku'></sub></form><legend id='LX3ku'></legend><bdo id='LX3ku'><pre id='LX3ku'><center id='LX3ku'></center></pre></bdo></b><th id='LX3ku'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='LX3ku'><tfoot id='LX3ku'></tfoot><dl id='LX3ku'><fieldset id='LX3ku'></fieldset></dl></div>
              <bdo id='LX3ku'></bdo><ul id='LX3ku'></ul>
            • <tfoot id='LX3ku'></tfoot>

              <small id='LX3ku'></small><noframes id='LX3ku'>

              • <legend id='LX3ku'><style id='LX3ku'><dir id='LX3ku'><q id='LX3ku'></q></dir></style></legend>

                  <tbody id='LX3ku'></tbody>
                1. 本文介紹了如何使用 opencv 向 PYQT 顯示圖像的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  您好,我是 python 和 opencv 的新手

                  我想問,如何在 qlabel (pyqt) 中顯示我的圖像,我想將 qlabel 轉(zhuǎn)換為灰度.

                  I want to ask, how to show my image in qlabel (pyqt) and i want to convert qlabel to grayscale.

                  import sys
                  from PyQt5.uic import loadUi
                  from PyQt5.QtWidgets import QMainWindow, QApplication, QFileDialog
                  import cv2
                  from PyQt5 import QtCore, QtGui, QtWidgets
                  from PyQt5.QtGui import *
                  from PyQt5.QtCore import *
                  
                  class UIProgram(QMainWindow):
                  def __init__(self):
                      super(UIProgram,self).__init__()
                      loadUi("Backpro2.ui",self)
                      #self.image=None
                      self.trainLoadImgBtn.clicked.connect(self.loadClicked)
                      self.image = QImage()
                  @pyqtSlot()
                  def loadClicked(self):
                      fname,filter=QFileDialog.getOpenFileName(self,'Open File','D:\',"Image Files(*.jpg)")
                      if fname:
                          self.loadImage(fname)
                      else:
                          print('invalid image')
                  
                  def loadImage(self,fname):
                      self.image=cv2.imread(fname,cv2.IMREAD_COLOR)
                      self.displayImage()
                  
                  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[0],QtGui.QImage.Format_RGB888)
                  
                          img = img.rgbSwapped()
                          self.trainOpenImg.setPixmap(QPixmap.fromImage(img))
                          self.trainOpenImgn.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
                  
                  
                  
                  if __name__ == "__main__":
                  
                  app=QApplication(sys.argv)
                  window=UIProgram()
                  window.setWindowTitle('Test')
                  window.show()
                  sys.exit(app.exec_())
                  

                  當(dāng)我點擊加載圖片按鈕時它崩潰了,圖片無法在 qlabel 中顯示還有這個錯誤

                  it crashed when i click load image button, the image can't show in qlabel and this error

                  進程以退出代碼 -1073740791 (0xC0000409) 結(jié)束

                  Process finished with exit code -1073740791 (0xC0000409)

                  推薦答案

                  有2個錯誤:

                  • 您必須將 bytesPerLine 傳遞給 QImage
                  • 設(shè)置對齊方式時,trainOpenImg 中有n"個更多.
                  • You have to pass the bytesPerLine to the QImage
                  • You have an "n" of more in trainOpenImg when you set the alignment.
                  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 或終端中運行它,因為它們會為您提供更多信息,例如在這種情況下,錯誤消息是:

                  On the other hand IDEs have problems handling certain types of errors and only launch a code, so in those cases it is advisable to run it in the CMD or terminal as they give you more information, for example in this case the error message was :

                  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 arguments
                  Aborted (core dumped)
                  

                  這篇關(guān)于如何使用 opencv 向 PYQT 顯示圖像的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動時,yaxis 刻度標(biāo)簽應(yīng)該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)

                      <tfoot id='RrfBV'></tfoot>

                        • <bdo id='RrfBV'></bdo><ul id='RrfBV'></ul>
                        • <small id='RrfBV'></small><noframes id='RrfBV'>

                              <tbody id='RrfBV'></tbody>
                          • <legend id='RrfBV'><style id='RrfBV'><dir id='RrfBV'><q id='RrfBV'></q></dir></style></legend>
                            <i id='RrfBV'><tr id='RrfBV'><dt id='RrfBV'><q id='RrfBV'><span id='RrfBV'><b id='RrfBV'><form id='RrfBV'><ins id='RrfBV'></ins><ul id='RrfBV'></ul><sub id='RrfBV'></sub></form><legend id='RrfBV'></legend><bdo id='RrfBV'><pre id='RrfBV'><center id='RrfBV'></center></pre></bdo></b><th id='RrfBV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RrfBV'><tfoot id='RrfBV'></tfoot><dl id='RrfBV'><fieldset id='RrfBV'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 免费xxxx大片国产在线 | 久久久久久久久久久久一区二区 | 久久国产精品偷 | 久久久久久综合 | 日韩中文字幕 | 国产精品国产三级国产a | 国产激情免费视频 | 国产一区日韩在线 | 国产成人精品一区二区三区在线 | 91亚洲欧美 | 国产伦一区二区三区四区 | 欧美日韩在线电影 | www狠狠爱com | 国产一区二区三区在线观看免费 | 欧美一级大片免费看 | 国产视频不卡一区 | 日韩中文字幕第一页 | 在线中文一区 | 一区二区精品 | 免费在线观看黄网站 | 青青草视频免费观看 | 日韩a v在线免费观看 | 91视频观看 | 成人国产精品色哟哟 | 婷婷综合在线 | 99热电影| 精品无码久久久久久国产 | www.日韩av.com | 精品久久久久一区二区国产 | 日本午夜精品 | 欧美一区二区三区 | 欧美成人精品一区二区男人看 | 91精品国产一区二区三区 | 亚洲国产aⅴ成人精品无吗 欧美激情欧美激情在线五月 | 成人午夜性成交 | 久久久国产一区二区 | 欧美一区不卡 | 黄视频网站在线 | 欧美白人做受xxxx视频 | 精品国产乱码久久久久久闺蜜 | 免费欧美|