Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Python qt5 QLabel setPixmap display Problem
Forum Updated to NodeBB v4.3 + New Features

Python qt5 QLabel setPixmap display Problem

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 588 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • msyasakM Offline
    msyasakM Offline
    msyasak
    wrote on last edited by
    #1

    Hi to all,

    I have to try display a rgb image (1030x360x3) inside Qlabel object of QT5 with python3.

    The image type is numpy array. And, I tried make display a frame with following code parts.

    disp_frame = QtGui.QImage(frame.data, 1030, 360, QtGui.QImage.Format_RGB888).rgbSwapped()
    self.qt_label.setPixmap(QtGui.QPixmap.fromImage(disp_frame))
    
    • The problem is displayed image that showed like as following (above) picture. The above image is displayed in Qtlabel and the below one is opencv showed image (as desired). Is there any way to correctly fix the image.

    qt_ques.png

    • Another example image displayed as following picture.
      qt_ques2.png

    Designed Qlabel Parameters are:
    qt_ques3.png

    eyllanescE 1 Reply Last reply
    0
    • msyasakM msyasak

      Hi to all,

      I have to try display a rgb image (1030x360x3) inside Qlabel object of QT5 with python3.

      The image type is numpy array. And, I tried make display a frame with following code parts.

      disp_frame = QtGui.QImage(frame.data, 1030, 360, QtGui.QImage.Format_RGB888).rgbSwapped()
      self.qt_label.setPixmap(QtGui.QPixmap.fromImage(disp_frame))
      
      • The problem is displayed image that showed like as following (above) picture. The above image is displayed in Qtlabel and the below one is opencv showed image (as desired). Is there any way to correctly fix the image.

      qt_ques.png

      • Another example image displayed as following picture.
        qt_ques2.png

      Designed Qlabel Parameters are:
      qt_ques3.png

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by eyllanesc
      #2

      @msyasak See https://stackoverflow.com/a/55468544/6622587:

      frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
      h, w, ch = frame.shape
      bytesPerLine = ch * w
      disp_frame = QtGui.QImage(frame.data, w, h, bytesPerLine, QtGui.QImage.Format_RGB888)
      

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      msyasakM 1 Reply Last reply
      1
      • eyllanescE eyllanesc

        @msyasak See https://stackoverflow.com/a/55468544/6622587:

        frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
        h, w, ch = frame.shape
        bytesPerLine = ch * w
        disp_frame = QtGui.QImage(frame.data, w, h, bytesPerLine, QtGui.QImage.Format_RGB888)
        
        msyasakM Offline
        msyasakM Offline
        msyasak
        wrote on last edited by
        #3

        @eyllanesc Thank you for your helping. That solved the display problem.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved