예제 #1
0
    def display(self, image):
        image8 = image.astype(np.uint8)
        height, width, colors = image8.shape

        image = QImage(image8.data, width, height, 3 * width,
                       QImage.Format_RGB888)

        self.image_active = QPixmap.fromImage(image.rgbSwapped())
        self.rescale_active_image()
예제 #2
0
def cv_to_qpixmap(cvimg):
    qformat = QImage.Format_Indexed8
    if len(cvimg.shape) == 3:
        if cvimg.shape[2] == 4:
            qformat = QImage.Format_RGBA8888
        else:
            qformat = QImage.Format_RGB888
    qimg = QImage(cvimg.data, cvimg.shape[1], cvimg.shape[0], cvimg.strides[0],
                  qformat)
    qimg = qimg.rgbSwapped()

    return QPixmap.fromImage(qimg)
예제 #3
0
파일: main.py 프로젝트: tuanken92/py_qt
    def display_image(self, image):
        ''' Display a image on lable'''
        size = image.shape
        step = image.size / size[0]
        qformat = QImage.Format_Indexed8

        if len(size) == 3:
            if size[2] == 4:
                qformat = QImage.Format_RGBA8888
            else:
                qformat = QImage.Format_RGB888

        img = QImage(image, size[1], size[0], step, qformat)
        img = img.rgbSwapped()

        self.ui.lbImg.setPixmap(QPixmap.fromImage(img))
예제 #4
0
    def display_webcam_feed(self):
        '''
        Displays the frame in the QLabel instance.
        '''
        frame_format = None
        if 3 <= len(self.processed_webcam_frame.shape) <= 4:
            if len(self.processed_webcam_frame.shape) == 4:
                frame_format = QImage.Format_RGBA8888
            if len(self.processed_webcam_frame.shape) == 3:
                frame_format = QImage.Format_RGB888
        if len(self.processed_webcam_frame.shape) == 2:
            frame_format = QImage.Format_Grayscale8

        output_webcam_frame = QImage(self.processed_webcam_frame,
                                     self.processed_webcam_frame.shape[1],
                                     self.processed_webcam_frame.shape[0],
                                     self.processed_webcam_frame.strides[0],
                                     frame_format)
        output_webcam_frame = output_webcam_frame.rgbSwapped()
        self.webcamFeedLabel.setPixmap(QPixmap.fromImage(output_webcam_frame))
        self.webcamFeedLabel.setScaledContents(True)