Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
video_fps = cap.get(cv2.CAP_PROP_FPS) # for video capture
print(video_fps)
times = []
data_buffer = []
# data for plotting
filtered_data = []
fft_of_interest = []
freqs_of_interest = []
bpm = 0
#plotting
app = QtGui.QApplication([])
win = pg.GraphicsWindow(title="plotting")
p1 = win.addPlot(title="FFT")
p2 = win.addPlot(title ="Signal")
win.resize(1200,600)
def update():
p1.clear()
p1.plot(np.column_stack((freqs_of_interest,fft_of_interest)), pen = 'g')
p2.clear()
p2.plot(filtered_data[20:],pen='g')
app.processEvents()
timer = QtCore.QTimer()
timer.timeout.connect(update)
def main():
db = Data_Buffer()
app = QtGui.QApplication(sys.argv)
gui = GUI(data_buffer=db)
sys.exit(app.exec_())
def processRequests(self):
try:
RemoteEventHandler.processRequests(self)
except ClosedError:
from ..Qt import QtGui, QtCore
QtGui.QApplication.instance().quit()
self.timer.stop()
#raise SystemExit
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
def create_plot(name):
p6 = win.addPlot(title=name)
p6.setYRange(-1.5, 1.5)
blue_curve = p6.plot(pen='g')
orng_curve = p6.plot(pen='r')
#green_curve = p6.plot(pen='g')
#red_curve = p6.plot(pen='r')
return p6, blue_curve, orng_curve
#QtGui.QApplication.setGraphicsSystem('raster')
app = QtGui.QApplication([])
#mw = QtGui.QMainWindow()
#mw.resize(800,800)
win = pg.GraphicsWindow(title="RLBot Live Plotting")
win.resize(500, 300)
win.setWindowTitle('RLBot Live Plotting')
# Enable antialiasing for prettier plots
pg.setConfigOptions(antialias=True)
# Open shared memory rotating buffer
expected_reward_blue_0 = live_data_util.RotatingBuffer(0)
expected_reward_orange_0 = live_data_util.RotatingBuffer(1)
real_reward_blue_0 = live_data_util.RotatingBuffer(10)
real_reward_orange_0 = live_data_util.RotatingBuffer(11)
def update():
global realPlot, real_blue, real_orange, expectedPlot, expected_blue, expected_orange
expected_blue.setData(expected_reward_blue_0.get_current_buffer())
expected_orange.setData(expected_reward_orange_0.get_current_buffer())
real_blue.setData(real_reward_blue_0.get_current_buffer())
real_orange.setData(real_reward_orange_0.get_current_buffer())
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(50)
## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
import sys
## Make sure pyqtgraph is importable
p = os.path.dirname(os.path.abspath(__file__))
p = os.path.join(p, '..', '..')
sys.path.insert(0, p)
from pyqtgraph.Qt import QtCore, QtGui
from .DockArea import *
from .Dock import *
app = QtGui.QApplication([])
win = QtGui.QMainWindow()
area = DockArea()
win.setCentralWidget(area)
win.resize(800,800)
from .Dock import Dock
d1 = Dock("Dock1", size=(200,200))
d2 = Dock("Dock2", size=(100,100))
d3 = Dock("Dock3", size=(1,1))
d4 = Dock("Dock4", size=(50,50))
d5 = Dock("Dock5", size=(100,100))
d6 = Dock("Dock6", size=(300,300))
area.addDock(d1, 'left')
area.addDock(d2, 'right')
area.addDock(d3, 'bottom')
area.addDock(d4, 'right')
area.addDock(d5, 'left', d1)
plot_data[0:-1] = plot_data[1:]
plot_data[-1] = float(ping)
plot.setData(plot_data)
p1.setYRange(0, max(plot_data)+1, padding=0)
# plot.setPos(plot_idx, 0)
QtGui.QApplication.instance().processEvents()
plot_idx += 1
# if plot_idx >= plot_data.shape[0]:
# tmp = plot_data
# plot_data = np.empty(plot_data.shape[0]*2)
# plot_data[:tmp.shape[0]] = tmp
time.sleep(1)
QtGui.QApplication.instance().processEvents()
from widgets import (QuadrotorWin, InfoWin, ParamsWin,
TabWidget, CurveModifyWin, Checkbox,
ThreadQDialog, PropertyLabel, AnalysisGraphWin,
HelpWin)
__version__ = '1.1.0b'
pyqtSignal = QtCore.pyqtSignal
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
resource_package = __name__
def get_source_name(file_path_name):
return pkg_resources.resource_filename(resource_package, file_path_name)
basepath = os.path.dirname(__file__)
def show_curve_property_diag(id, parent):
def func(event):
print('curve was double clicked')
This example demonstrates the SpinBox widget, which is an extension of
QDoubleSpinBox providing some advanced features:
* SI-prefixed units
* Non-linear stepping modes
* Bounded/unbounded values
"""
import initExample ## Add path to library (just for examples; you do not need this)
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np
app = QtGui.QApplication([])
spins = [
("Floating-point spin box, min=0, no maximum.",
pg.SpinBox(value=5.0, bounds=[0, None])),
("Integer spin box, dec stepping<br>(1-9, 10-90, 100-900, etc), decimals=4",
pg.SpinBox(value=10, int=True, dec=True, minStep=1, step=1, decimals=4)),
("Float with SI-prefixed units<br>(n, u, m, k, M, etc)",
pg.SpinBox(value=0.9, suffix='V', siPrefix=True)),
("Float with SI-prefixed units,<br>dec step=0.1, minStep=0.1",
pg.SpinBox(value=1.0, suffix='V', siPrefix=True, dec=True, step=0.1, minStep=0.1)),
("Float with SI-prefixed units,<br>dec step=0.5, minStep=0.01",
pg.SpinBox(value=1.0, suffix='V', siPrefix=True, dec=True, step=0.5, minStep=0.01)),
("Float with SI-prefixed units,<br>dec step=1.0, minStep=0.001",
pg.SpinBox(value=1.0, suffix='V', siPrefix=True, dec=True, step=1.0, minStep=0.001)),
]
plot.addCurve(x, y, "dummy")
plot.addCurve(x + 100, -x * x, "To set Active")
print("Active curve = ", plot.getActiveCurve())
print("X Limits) = ", plot.getGraphXLimits())
print("Y Limits = ", plot.getGraphYLimits())
print("All curves = ", plot.getAllCurves())
#plot.removeCurve("dummy")
plot.setActiveCurve("To set Active")
print("All curves = ", plot.getAllCurves())
plot.insertXMarker(50., draggable=True)
#plot.resetZoom()
return plot
if __name__ == "__main__":
import numpy
app = QtGui.QApplication([])
w = main()
w.getWidgetHandle().show()
#w.invertYAxis(True)
w.replot()
#w.invertYAxis(True)
data = numpy.arange(1000.*1000)
data.shape = 10000,100
#plot.replot()
#w.invertYAxis(True)
#w.replot()
#w.widget.show()
w.addImage(data, legend="image 0", xScale=(25, 1.0) , yScale=(-1000, 1.0),
selectable=True)
#w.removeImage("image 0")
#w.invertYAxis(True)
w.replot()