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

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

      <tfoot id='yx24E'></tfoot>

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

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

      <legend id='yx24E'><style id='yx24E'><dir id='yx24E'><q id='yx24E'></q></dir></style></legend>
    2. `QImage` 構造函數有未知關鍵字 `data`

      `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)

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

          <tbody id='Ss0Hs'></tbody>
        • <legend id='Ss0Hs'><style id='Ss0Hs'><dir id='Ss0Hs'><q id='Ss0Hs'></q></dir></style></legend>

            <tfoot id='Ss0Hs'></tfoot>
                <bdo id='Ss0Hs'></bdo><ul id='Ss0Hs'></ul>

              • <i id='Ss0Hs'><tr id='Ss0Hs'><dt id='Ss0Hs'><q id='Ss0Hs'><span id='Ss0Hs'><b id='Ss0Hs'><form id='Ss0Hs'><ins id='Ss0Hs'></ins><ul id='Ss0Hs'></ul><sub id='Ss0Hs'></sub></form><legend id='Ss0Hs'></legend><bdo id='Ss0Hs'><pre id='Ss0Hs'><center id='Ss0Hs'></center></pre></bdo></b><th id='Ss0Hs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Ss0Hs'><tfoot id='Ss0Hs'></tfoot><dl id='Ss0Hs'><fieldset id='Ss0Hs'></fieldset></dl></div>
                本文介紹了`QImage` 構造函數有未知關鍵字 `data`的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                假設我正在使用 opencv 從網絡攝像頭拍攝圖像.

                Suppose I am taking an image from the webcam using opencv.

                _, img = self.cap.read()  # numpy.ndarray (480, 640, 3)
                

                然后我使用 img 創建一個 QImage qimg:

                Then I create a QImage qimg using img:

                qimg = QImage(
                    data=img,
                    width=img.shape[1],
                    height=img.shape[0],
                    bytesPerLine=img.strides[0],
                    format=QImage.Format_Indexed8)
                

                但它給出了一個錯誤提示:

                But it gives an error saying that:

                TypeError: 'data' 是一個未知的關鍵字參數

                TypeError: 'data' is an unknown keyword argument

                但是在 this 文檔中說,構造函數應該有一個名為數據.

                But said in this documentation, the constructor should have an argument named data.

                我正在使用 anaconda 環境來運行這個項目.

                I am using anaconda environment to run this project.

                opencv 版本 = 3.1.4

                opencv version = 3.1.4

                pyqt 版本 = 5.9.2

                pyqt version = 5.9.2

                numpy 版本 = 1.15.0

                numpy version = 1.15.0

                推薦答案

                他們的意思是需要data作為參數,而不是關鍵字叫data,下面的方法做了一個numpy/opencv的轉換圖像到 QImage:

                What they are indicating is that the data is required as a parameter, not that the keyword is called data, the following method makes the conversion of a numpy/opencv image to QImage:

                from PyQt5.QtGui import QImage, qRgb
                import numpy as np
                import cv2
                
                gray_color_table = [qRgb(i, i, i) for i in range(256)]
                
                def NumpyToQImage(im):
                    qim = QImage()
                    if im is None:
                        return qim
                    if im.dtype == np.uint8:
                        if len(im.shape) == 2:
                            qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_Indexed8)
                            qim.setColorTable(gray_color_table)
                        elif len(im.shape) == 3:
                            if im.shape[2] == 3:
                                qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_RGB888)
                            elif im.shape[2] == 4:
                                qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_ARGB32)
                    return qim
                
                img = cv2.imread('/path/of/image')
                qimg = NumpyToQImage(img)
                assert(not qimg.isNull())
                

                或者您可以使用 qimage2ndarray 庫

                當使用索引裁剪圖片時只修改shape而不修改data,解決方法是復制一份

                When using the indexes to crop the image is only modifying the shape but not the data, the solution is to make a copy

                img = cv2.imread('/path/of/image')
                img = np.copy(img[200:500, 300:500, :]) # copy image
                qimg = NumpyToQImage(img)
                assert(not qimg.isNull())
                

                這篇關于`QImage` 構造函數有未知關鍵字 `data`的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                How to bind a function to an Action from Qt menubar?(如何將函數綁定到 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 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                Erasing pen on a canvas(在畫布上擦筆)
                  <tbody id='UphZ6'></tbody>

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

                  • <tfoot id='UphZ6'></tfoot>
                    • <bdo id='UphZ6'></bdo><ul id='UphZ6'></ul>

                      <legend id='UphZ6'><style id='UphZ6'><dir id='UphZ6'><q id='UphZ6'></q></dir></style></legend>

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

                        1. 主站蜘蛛池模板: 国产日韩欧美中文字幕 | www国产成人免费观看视频 | 亚洲精品91| 国产视频精品区 | 精品在线免费观看视频 | 免费看啪啪网站 | 性色在线 | 毛片a级毛片免费播放100 | 亚洲精品免费看 | 一区二区三区国产好的精 | 午夜专区| 国产在线a | 欧美片网站免费 | 久久精品国产一区二区三区 | 久久久久久免费精品一区二区三区 | 欧美精品综合 | 黄色大片网 | 国产一区二区在线视频 | 色资源在线 | 午夜午夜精品一区二区三区文 | 欧美日韩国产在线观看 | 我想看一级黄色毛片 | 欧美高清视频一区 | 日本一二三区高清 | 巨大黑人极品videos精品 | 亚洲精选久久 | 日本黄色大片免费看 | 国产一区二区三区四区三区四 | 成人免费网站 | 午夜一区二区三区在线观看 | 亚洲综合一区二区三区 | 一区二区三区四区国产 | 91豆花视频 | 亚洲国产一区二区三区四区 | 一区二区视频在线观看 | 国产在线一区二区三区 | 日本午夜一区 | 欧美激情久久久 | 中文字幕在线精品 | 日韩1区 | 精品一区二区三 |