Вставить PyQtGraph в графический интерфейс Qt Designer - PullRequest
1 голос
/ 29 марта 2019

У меня есть график QtGraph, и я хочу показать его в QLabel, Qwidget или Graphicsview в графическом интерфейсе, который я создал в Qt Designer, но я не могу найти прямой способ показать этот график. Я транслирую видео с камеры, и я мог бы легко показать его в своем графическом интерфейсе, но я борюсь с этим.

Проблема в показе.

#These are the libraries which have been used in the app.
import sys
import numpy as np
import cv2
import pyqtgraph as pg
import datetime

from PyQt5 import QtCore
from PyQt5.QtWidgets import QApplication , QMainWindow
from PyQt5.uic import loadUi
from PyQt5 import QtGui

#this is the main class for this app and get the visual GUI from QtDesigner
class VideoStream(QMainWindow):

    def __init__(self):
        super(VideoStream , self).__init__()
        loadUi('VideoStream.ui',self)
        self.image= None
        #self.l_values is the place that we collect the intensity values for each frame
        self.l_values = []
        #This is a button to set the geometry of our mask for the specific zone of lightness
        self.Apply_Button.clicked.connect(self.Geometry)
        #this  button save the maximum values of the specific zone in a text file
        #self.Save_Button.clicked.connect(self.save_data)
        self.startButton.clicked.connect(self.start_webcam)
        self.stopButton.clicked.connect(self.stop_webcam)
        #these two variables are the height and width of our camera. 
        #With different cameras this part should be changed.
        self.cameraHeight=480
        self.cameraWidth=640

    #This function shows the stream in the GUI we created by qtdesigner     
    def displayImage(self,img,window=1):
        qformat=QtGui.QImage.Format_Grayscale8
        outImage=QtGui.QImage(img, img.shape[1],img.shape[0],qformat)
        self.imgLabel.setPixmap(QtGui.QPixmap.fromImage(outImage))
        self.imgLabel.setScaledContents(True)

    #for the seperate canvas you should click on the move button in that window once
    def displayHist(self,img, window=1):
        self.avr = int(np.average(self.image)*25)
        self.avrage=np.array([self.avr])
        if self.l<=self.bufferSize:
            self.plt.setRange(xRange=[max(self.l- 100, 0), self.l])    
            self.data[self.l:self.l+self.n] = self.avrage
            self.curve.setData(self.data)
            print(self.l)
            self.l = (self.l+self.n) 
            if self.l%100==0:
                if self.l>=100:
                    print("y  ",self.k,np.max(self.data[self.l-100:self.l]))
                    self.k=self.k+1
                elif self.l==0:
                    print("- ",self.k,np.max(self.data[-(100-self.l):]))
                else:
                    print("n  ",self.k,max(np.max(self.data[-(100-self.l):]),np.max(self.data[:self.l])))
                    self.k=self.k+1
            self.line.setValue(self.l)
        if self.l>self.bufferSize:
            self.plt.setRange(xRange=[max(self.bufferSize- 100, 0), self.bufferSize])
            for j in range(self.bufferSize-1):
                self.data[j]=self.data[j+1]
            self.data[-1]=self.avrage
            self.curve.setData(self.data)
            self.l = (self.l+self.n)
            self.line.setValue(self.bufferSize)

    #this is the place that I don't have any idea what to do
...