My program scans for circles in a given video. With a QSlider I can change the value of my WaitKey while the program is running. Every number works fine except when I change the slider value to 0. The video doesn't wait for any keystroke (as far as I know WaitKey(0) means to wait for any keystroke). The program acts like the value is still at 1. The parameter is called "globals.Speed".
# class that does the interface stuff
class MyWindow(QMainWindow):
def __init__(self):
super(MyWindow, self).__init__()
self.resize(1300, 800)
self.setWindowTitle("MainWindow")
self.initUI()
def initUI(self):
[...]
# QSlider to change WaitKey value
self.horizontalSliderSpeed = QtWidgets.QSlider(self)
self.horizontalSliderSpeed.setGeometry(QtCore.QRect(20, 300, 160, 22))
self.horizontalSliderSpeed.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSliderSpeed.setMinimum(0)
self.horizontalSliderSpeed.setMaximum(2000)
self.horizontalSliderSpeed.setValue(globals.Speed)
self.horizontalSliderSpeed.valueChanged.connect(lambda: self.changedValue(4))
self.horizontalSliderSpeedLabel = QtWidgets.QLabel(self)
self.horizontalSliderSpeedLabel.setFont(font)
self.horizontalSliderSpeedLabel.setText(f"Speed: {globals.Speed}")
self.horizontalSliderSpeedLabel.move(200, 300)
[...]
def changedValue(self, a):
[...]
if a == 4:
globals.Speed = self.horizontalSliderSpeed.value()
self.horizontalSliderSpeedLabel.setText(f"Speed: {globals.Speed}")
[...]
# class that processes the video
class Child_Clocked(QThread):
def run(self):
cap = cv2.VideoCapture(globals.VideoFile)
while globals.While_Run:
try:
cv2.waitKey(globals.Speed)
ret, frame = cap.read()
[...]